Commit: e5796233c7039967b033452afc5d5a10e6cb5b3f
Author: Clément Foucault
Date:   Tue Aug 18 21:21:58 2020 +0200
Branches: master
https://developer.blender.org/rBe5796233c7039967b033452afc5d5a10e6cb5b3f

GPUState: Use GPU_viewport to set viewport state in GPU_framebuffer

also fix a small issue in GPU_texture_clear.

===================================================================

M       source/blender/gpu/intern/gpu_framebuffer.cc
M       source/blender/gpu/intern/gpu_texture.cc

===================================================================

diff --git a/source/blender/gpu/intern/gpu_framebuffer.cc 
b/source/blender/gpu/intern/gpu_framebuffer.cc
index a94212969b9..da8ab80b347 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.cc
+++ b/source/blender/gpu/intern/gpu_framebuffer.cc
@@ -552,7 +552,7 @@ void GPU_framebuffer_bind(GPUFrameBuffer *fb)
   }
 #endif
 
-  glViewport(0, 0, fb->width, fb->height);
+  GPU_viewport(0, 0, fb->width, fb->height);
 }
 
 /* Workaround for binding a srgb framebuffer without doing the srgb transform. 
*/
@@ -611,7 +611,7 @@ void GPU_framebuffer_viewport_set(GPUFrameBuffer *fb, int 
x, int y, int w, int h
 {
   CHECK_FRAMEBUFFER_IS_BOUND(fb);
 
-  glViewport(x, y, w, h);
+  GPU_viewport(x, y, w, h);
 }
 
 void GPU_framebuffer_clear(GPUFrameBuffer *fb,
@@ -866,7 +866,7 @@ void GPU_framebuffer_recursive_downsample(GPUFrameBuffer 
*fb,
 
     BLI_assert(GL_FRAMEBUFFER_COMPLETE == 
glCheckFramebufferStatus(GL_FRAMEBUFFER));
 
-    glViewport(0, 0, current_dim[0], current_dim[1]);
+    GPU_viewport(0, 0, current_dim[0], current_dim[1]);
     callback(userData, i);
 
     if (current_dim[0] == 1 && current_dim[1] == 1) {
diff --git a/source/blender/gpu/intern/gpu_texture.cc 
b/source/blender/gpu/intern/gpu_texture.cc
index a0a230f2980..91990dac83f 100644
--- a/source/blender/gpu/intern/gpu_texture.cc
+++ b/source/blender/gpu/intern/gpu_texture.cc
@@ -1611,6 +1611,9 @@ void GPU_texture_clear(GPUTexture *tex, eGPUDataFormat 
gpu_data_format, const vo
     /* This means that this function can only be used in one context for each 
texture. */
     BLI_assert(tex->copy_fb_ctx == GPU_context_active_get());
 
+    int viewport[4];
+    GPU_viewport_size_get_i(viewport);
+
     glBindFramebuffer(GL_FRAMEBUFFER, tex->copy_fb);
     glViewport(0, 0, tex->w, tex->h);
 
@@ -1675,6 +1678,8 @@ void GPU_texture_clear(GPUTexture *tex, eGPUDataFormat 
gpu_data_format, const vo
       glClear(GL_COLOR_BUFFER_BIT);
     }
 
+    glViewport(UNPACK4(viewport));
+
     if (prev_fb) {
       GPU_framebuffer_bind(prev_fb);
     }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to