From 39efb58446eb7af0f3ab10f8316ba81f465cdc17 Mon Sep 17 00:00:00 2001 From: mano-wii Date: Thu, 6 Dec 2018 11:47:37 -0200 Subject: GPU Framebuffer: simplify gpu_framebuffer_update_attachments_and_fill_empty_slots func --- source/blender/gpu/intern/gpu_framebuffer.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'source') diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c index d5762700b0f..8714c72686c 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.c +++ b/source/blender/gpu/intern/gpu_framebuffer.c @@ -424,7 +424,6 @@ static void gpu_framebuffer_update_attachments(GPUFrameBuffer *fb) static void gpu_framebuffer_update_attachments_and_fill_empty_slots(GPUFrameBuffer *fb) { GLenum gl_attachments[GPU_FB_MAX_COLOR_ATTACHMENT]; - bool fill_empty_slot = false; int dummy_tex = 0; BLI_assert(GPU_framebuffer_active_get() == fb); @@ -435,11 +434,10 @@ static void gpu_framebuffer_update_attachments_and_fill_empty_slots(GPUFrameBuff if (type >= GPU_FB_COLOR_ATTACHMENT0) { int slot = type - GPU_FB_COLOR_ATTACHMENT0; - if (tex != NULL || fill_empty_slot) { + if (tex != NULL || (dummy_tex != 0)) { gl_attachments[slot] = convert_attachment_type_to_gl(type); - if (!fill_empty_slot) { - fill_empty_slot = true; + if (dummy_tex == 0) { dummy_tex = GPU_texture_opengl_bindcode(tex); } } @@ -448,22 +446,23 @@ static void gpu_framebuffer_update_attachments_and_fill_empty_slots(GPUFrameBuff } } else { - fill_empty_slot = false; dummy_tex = 0; } - if ((fill_empty_slot && tex == NULL) || GPU_FB_ATTACHEMENT_IS_DIRTY(fb->dirty_flag, type)) { + if ((dummy_tex != 0) && tex == NULL) { + /* Fill empty slot */ + glFramebufferTexture(GL_FRAMEBUFFER, convert_attachment_type_to_gl(type), dummy_tex, 0); + } + else if (GPU_FB_ATTACHEMENT_IS_DIRTY(fb->dirty_flag, type)) { if (tex != NULL) { gpu_framebuffer_attachment_attach(&fb->attachments[type], type); fb->multisample = (GPU_texture_samples(tex) > 0); fb->width = GPU_texture_width(tex); fb->height = GPU_texture_height(tex); - - fill_empty_slot = dummy_tex != 0; } else { - glFramebufferTexture(GL_FRAMEBUFFER, convert_attachment_type_to_gl(type), dummy_tex, 0); + gpu_framebuffer_attachment_detach(&fb->attachments[type], type); } } } -- cgit v1.2.3