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-08-29 16:17:13 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-08-30 14:11:03 +0300
commit8527d84d3588563123bfad7ccbdeeff62ee90bdb (patch)
tree51ccbaa3c129c62a54af5aed43b55b9c89b901e6 /source/blender/gpu/intern/gpu_framebuffer.cc
parent4f395c84fe9f05b59b81be36b464521bcf92331e (diff)
GPUState: Move Scissor and Viewport state to framebuffer
This way it is way clearer what each viewport state is. There is no more save and reset. The scissor test is also saved per framebuffer. The only rule to remember is that the viewport state (size and origin) is reset for both the viewport and scissor when a texture is attached or detached from an attachment slot.
Diffstat (limited to 'source/blender/gpu/intern/gpu_framebuffer.cc')
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.cc33
1 files changed, 19 insertions, 14 deletions
diff --git a/source/blender/gpu/intern/gpu_framebuffer.cc b/source/blender/gpu/intern/gpu_framebuffer.cc
index 600dd129aef..f4b8a4040d4 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.cc
+++ b/source/blender/gpu/intern/gpu_framebuffer.cc
@@ -55,6 +55,7 @@ FrameBuffer::FrameBuffer(const char *name)
}
/* Force config on first use. */
dirty_attachments_ = true;
+ dirty_state_ = true;
for (int i = 0; i < ARRAY_SIZE(attachments_); i++) {
attachments_[i].tex = NULL;
@@ -341,21 +342,30 @@ void GPU_framebuffer_config_array(GPUFrameBuffer *gpu_fb,
}
}
-/* ---------- Framebuffer Operations ----------- */
+/* ---------- Viewport & Scissor Region ----------- */
-#define CHECK_FRAMEBUFFER_IS_BOUND(_fb) \
- BLI_assert(GPU_framebuffer_bound(_fb)); \
- UNUSED_VARS_NDEBUG(_fb); \
- ((void)0)
+/* Viewport and scissor size is stored per framebuffer.
+ * It is only reset to its original dimensions explicitely OR when binding the framebuffer after
+ * modifiying its attachments. */
+void GPU_framebuffer_viewport_set(GPUFrameBuffer *gpu_fb, int x, int y, int width, int height)
+{
+ int viewport_rect[4] = {x, y, width, height};
+ reinterpret_cast<FrameBuffer *>(gpu_fb)->viewport_set(viewport_rect);
+}
-/* Needs to be done after binding. */
-void GPU_framebuffer_viewport_set(GPUFrameBuffer *gpu_fb, int x, int y, int w, int h)
+void GPU_framebuffer_viewport_get(GPUFrameBuffer *gpu_fb, int r_viewport[4])
{
- CHECK_FRAMEBUFFER_IS_BOUND(gpu_fb);
+ reinterpret_cast<FrameBuffer *>(gpu_fb)->viewport_get(r_viewport);
+}
- GPU_viewport(x, y, w, h);
+/* Reset to its attachement(s) size. */
+void GPU_framebuffer_viewport_reset(GPUFrameBuffer *gpu_fb)
+{
+ reinterpret_cast<FrameBuffer *>(gpu_fb)->viewport_reset();
}
+/* ---------- Framebuffer Operations ----------- */
+
void GPU_framebuffer_clear(GPUFrameBuffer *gpu_fb,
eGPUFrameBufferBits buffers,
const float clear_col[4],
@@ -582,19 +592,14 @@ GPUOffScreen *GPU_offscreen_create(
return NULL;
}
- int viewport[4];
- GPU_viewport_size_get_i(viewport);
-
GPUFrameBuffer *fb = gpu_offscreen_fb_get(ofs);
/* check validity at the very end! */
if (!GPU_framebuffer_check_valid(fb, err_out)) {
GPU_offscreen_free(ofs);
- GPU_viewport(UNPACK4(viewport));
return NULL;
}
GPU_framebuffer_restore();
- GPU_viewport(UNPACK4(viewport));
return ofs;
}