Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2020-09-05 18:36:53 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-09-05 18:49:14 +0300
commit13305fb5138a6d1df1ac1edd5bd7da5d1a0b54dd (patch)
tree0100cf8f81bde1d054f9c32aac8e6acd8c4a10e8 /source/blender/gpu/intern
parentb100b77fda0667d78cac0f219e0f6208d6b8f854 (diff)
Cleanup: GPUFrameBuffer: Use Texture class instead of gl calls
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.cc39
1 files changed, 7 insertions, 32 deletions
diff --git a/source/blender/gpu/intern/gpu_framebuffer.cc b/source/blender/gpu/intern/gpu_framebuffer.cc
index 742fdc6d8b3..6d95e539446 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.cc
+++ b/source/blender/gpu/intern/gpu_framebuffer.cc
@@ -139,34 +139,20 @@ void FrameBuffer::recursive_downsample(int max_lvl,
/* Bind to make sure the frame-buffer is up to date. */
this->bind(true);
- if (width_ == 1 && height_ == 1) {
- return;
- }
- /* HACK: Make the frame-buffer appear not bound to avoid assert in GPU_texture_bind. */
- ctx->active_fb = NULL;
-
- int levels = floor(log2(max_ii(width_, height_)));
- max_lvl = min_ii(max_lvl, levels);
+ /* FIXME(fclem): This assumes all mips are defined which may not be the case. */
+ max_lvl = min_ii(max_lvl, floor(log2(max_ii(width_, height_))));
- int current_dim[2] = {width_, height_};
- int mip_lvl;
- for (mip_lvl = 1; mip_lvl < max_lvl + 1; mip_lvl++) {
- /* calculate next viewport size */
- current_dim[0] = max_ii(current_dim[0] / 2, 1);
- current_dim[1] = max_ii(current_dim[1] / 2, 1);
+ for (int mip_lvl = 1; mip_lvl <= max_lvl; mip_lvl++) {
/* Replace attached mip-level for each attachment. */
for (int att = 0; att < ARRAY_SIZE(attachments_); att++) {
- GPUTexture *tex = attachments_[att].tex;
+ Texture *tex = reinterpret_cast<Texture *>(attachments_[att].tex);
if (tex != NULL) {
/* Some Intel HDXXX have issue with rendering to a mipmap that is below
* the texture GL_TEXTURE_MAX_LEVEL. So even if it not correct, in this case
* we allow GL_TEXTURE_MAX_LEVEL to be one level lower. In practice it does work! */
- int map_lvl = (GPU_mip_render_workaround()) ? mip_lvl : (mip_lvl - 1);
+ int mip_max = (GPU_mip_render_workaround()) ? mip_lvl : (mip_lvl - 1);
/* Restrict fetches only to previous level. */
- GPU_texture_bind(tex, 0);
- glTexParameteri(GPU_texture_target(tex), GL_TEXTURE_BASE_LEVEL, mip_lvl - 1);
- glTexParameteri(GPU_texture_target(tex), GL_TEXTURE_MAX_LEVEL, map_lvl);
- GPU_texture_unbind(tex);
+ tex->mip_range_set(mip_lvl - 1, mip_max);
/* Bind next level. */
attachments_[att].mip = mip_lvl;
}
@@ -174,25 +160,14 @@ void FrameBuffer::recursive_downsample(int max_lvl,
/* Update the internal attachments and viewport size. */
dirty_attachments_ = true;
this->bind(true);
- /* HACK: Make the frame-buffer appear not bound to avoid assert in GPU_texture_bind. */
- ctx->active_fb = NULL;
callback(userData, mip_lvl);
-
- /* This is the last mipmap level. Exit loop without incrementing mip_lvl. */
- if (current_dim[0] == 1 && current_dim[1] == 1) {
- break;
- }
}
for (int att = 0; att < ARRAY_SIZE(attachments_); att++) {
if (attachments_[att].tex != NULL) {
/* Reset mipmap level range. */
- GPUTexture *tex = attachments_[att].tex;
- GPU_texture_bind(tex, 0);
- glTexParameteri(GPU_texture_target(tex), GL_TEXTURE_BASE_LEVEL, 0);
- glTexParameteri(GPU_texture_target(tex), GL_TEXTURE_MAX_LEVEL, mip_lvl);
- GPU_texture_unbind(tex);
+ reinterpret_cast<Texture *>(attachments_[att].tex)->mip_range_set(0, max_lvl);
/* Reset base level. NOTE: might not be the one bound at the start of this function. */
attachments_[att].mip = 0;
}