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:
authorJacques Lucke <mail@jlucke.com>2018-11-06 17:24:13 +0300
committerJacques Lucke <mail@jlucke.com>2018-11-06 17:24:13 +0300
commit50b43ff6d49cb101884e26f2c04aa9c19512b6cc (patch)
treede453d7542695e26b63277ab8d3ce44dcdc977cf /source/blender/gpu/intern
parentddc64b9dd45eb157c061685ce352ee57f85145e9 (diff)
GPU: frame buffer stack
Reviewers: fclem Differential Revision: https://developer.blender.org/D3903
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.c38
1 files changed, 37 insertions, 1 deletions
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();
}
}