diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-08-17 00:20:59 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-08-18 22:30:10 +0300 |
commit | d10f000322914edf83ace36ee2abb2479c2b533b (patch) | |
tree | b33d453cf2e1c5364cea88998103a7008ab31763 /source/blender/gpu/intern/gpu_framebuffer.cc | |
parent | f30df15edc0b5bfce98809cfa8c2ca96cfe03e97 (diff) |
GPUState: Remove gpuPushAttr/gpuPopAttr
And use manual save/restore mechanism.
The stack method is not used so much to be considered useful.
Diffstat (limited to 'source/blender/gpu/intern/gpu_framebuffer.cc')
-rw-r--r-- | source/blender/gpu/intern/gpu_framebuffer.cc | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/source/blender/gpu/intern/gpu_framebuffer.cc b/source/blender/gpu/intern/gpu_framebuffer.cc index 627f417e0c3..4c7f13a58eb 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.cc +++ b/source/blender/gpu/intern/gpu_framebuffer.cc @@ -901,6 +901,13 @@ struct GPUOffScreen { GPUTexture *color; GPUTexture *depth; + + /** Saved state of the previously bound framebuffer. */ + /* TODO(fclem) This is quite hacky and a proper fix would be to + * put these states directly inside the GPUFrambuffer. + * But we don't have a GPUFramebuffer for the default framebuffer yet. */ + int saved_viewport[4]; + int saved_scissor[4]; }; /* Returns the correct framebuffer for the current context. */ @@ -964,21 +971,19 @@ GPUOffScreen *GPU_offscreen_create( return NULL; } - gpuPushAttr(GPU_VIEWPORT_BIT); + 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); - gpuPopAttr(); + GPU_viewport(UNPACK4(viewport)); return NULL; } - GPU_framebuffer_restore(); - - gpuPopAttr(); - + GPU_viewport(UNPACK4(viewport)); return ofs; } @@ -1002,7 +1007,9 @@ void GPU_offscreen_free(GPUOffScreen *ofs) void GPU_offscreen_bind(GPUOffScreen *ofs, bool save) { if (save) { - gpuPushAttr((eGPUAttrMask)(GPU_SCISSOR_BIT | GPU_VIEWPORT_BIT)); + GPU_scissor_get(ofs->saved_scissor); + GPU_viewport_size_get_i(ofs->saved_viewport); + GPUFrameBuffer *fb = GPU_framebuffer_active_get(); gpuPushFrameBuffer(fb); } @@ -1013,12 +1020,13 @@ void GPU_offscreen_bind(GPUOffScreen *ofs, bool save) GPU_shader_set_framebuffer_srgb_target(false); } -void GPU_offscreen_unbind(GPUOffScreen *UNUSED(ofs), bool restore) +void GPU_offscreen_unbind(GPUOffScreen *ofs, bool restore) { GPUFrameBuffer *fb = NULL; if (restore) { - gpuPopAttr(); + GPU_scissor(UNPACK4(ofs->saved_scissor)); + GPU_viewport(UNPACK4(ofs->saved_viewport)); fb = gpuPopFrameBuffer(); } |