[Bf-blender-cvs] [50b43ff6d49] blender2.8: GPU: frame buffer stack
Jacques Lucke
noreply at git.blender.org
Tue Nov 6 15:24:47 CET 2018
Commit: 50b43ff6d49cb101884e26f2c04aa9c19512b6cc
Author: Jacques Lucke
Date: Tue Nov 6 15:24:13 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB50b43ff6d49cb101884e26f2c04aa9c19512b6cc
GPU: frame buffer stack
Reviewers: fclem
Differential Revision: https://developer.blender.org/D3903
===================================================================
M source/blender/gpu/intern/gpu_framebuffer.c
===================================================================
diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c
index db5ab55c0a0..f92899f91a0 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@ -416,6 +416,31 @@ static void gpu_framebuffer_update_attachments(GPUFrameBuffer *fb)
glDrawBuffer(GL_NONE);
}
+
+#define FRAMEBUFFER_STACK_DEPTH 16
+
+static struct {
+ GPUFrameBuffer *framebuffers[FRAMEBUFFER_STACK_DEPTH];
+ uint top;
+} FrameBufferStack = { 0 };
+
+static void gpuPushFrameBuffer(GPUFrameBuffer *fbo)
+{
+ BLI_assert(FrameBufferStack.top < FRAMEBUFFER_STACK_DEPTH);
+ FrameBufferStack.framebuffers[FrameBufferStack.top] = fbo;
+ FrameBufferStack.top++;
+}
+
+static GPUFrameBuffer *gpuPopFrameBuffer(void)
+{
+ BLI_assert(FrameBufferStack.top > 0);
+ FrameBufferStack.top--;
+ return FrameBufferStack.framebuffers[FrameBufferStack.top];
+}
+
+#undef FRAMEBUFFER_STACK_DEPTH
+
+
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
{
if (fb->object == 0)
@@ -753,6 +778,8 @@ void GPU_offscreen_bind(GPUOffScreen *ofs, bool save)
{
if (save) {
gpuPushAttrib(GPU_SCISSOR_BIT | GPU_VIEWPORT_BIT);
+ GPUFrameBuffer *fb = GPU_framebuffer_active_get();
+ gpuPushFrameBuffer(fb);
}
glDisable(GL_SCISSOR_TEST);
GPU_framebuffer_bind(ofs->fb);
@@ -760,9 +787,18 @@ void GPU_offscreen_bind(GPUOffScreen *ofs, bool save)
void GPU_offscreen_unbind(GPUOffScreen *UNUSED(ofs), bool restore)
{
- GPU_framebuffer_restore();
+ GPUFrameBuffer *fb = NULL;
+
if (restore) {
gpuPopAttrib();
+ fb = gpuPopFrameBuffer();
+ }
+
+ if (fb) {
+ GPU_framebuffer_bind(fb);
+ }
+ else {
+ GPU_framebuffer_restore();
}
}
More information about the Bf-blender-cvs
mailing list