Commit: db21312bfb310db2c935d2e45897ea167ff12d77 Author: Clément Foucault Date: Fri Dec 13 19:28:37 2019 +0100 Branches: greasepencil-refactor https://developer.blender.org/rBdb21312bfb310db2c935d2e45897ea167ff12d77
GPU: Framebuffer: Add GPU_framebuffer_multi_clear This is to clear individual targets using a different color. =================================================================== M source/blender/gpu/GPU_framebuffer.h M source/blender/gpu/intern/gpu_framebuffer.c =================================================================== diff --git a/source/blender/gpu/GPU_framebuffer.h b/source/blender/gpu/GPU_framebuffer.h index 7d0f8b0bcbf..213cbe30794 100644 --- a/source/blender/gpu/GPU_framebuffer.h +++ b/source/blender/gpu/GPU_framebuffer.h @@ -173,6 +173,8 @@ void GPU_framebuffer_clear(GPUFrameBuffer *fb, #define GPU_framebuffer_clear_color_depth_stencil(fb, col, depth, stencil) \ GPU_framebuffer_clear(fb, GPU_COLOR_BIT | GPU_DEPTH_BIT | GPU_STENCIL_BIT, col, depth, stencil) +void GPU_framebuffer_multi_clear(GPUFrameBuffer *fb, const float (*clear_cols)[4]); + void GPU_framebuffer_read_depth(GPUFrameBuffer *fb, int x, int y, int w, int h, float *data); void GPU_framebuffer_read_color( GPUFrameBuffer *fb, int x, int y, int w, int h, int channels, int slot, float *data); diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c index a531c22365c..9da842f6409 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.c +++ b/source/blender/gpu/intern/gpu_framebuffer.c @@ -612,6 +612,19 @@ void GPU_framebuffer_clear(GPUFrameBuffer *fb, glClear(mask); } +/* Clear all textures bound to this framebuffer with a different color. */ +void GPU_framebuffer_multi_clear(GPUFrameBuffer *fb, const float (*clear_cols)[4]) +{ + CHECK_FRAMEBUFFER_IS_BOUND(fb); + + GPUAttachmentType type = GPU_FB_COLOR_ATTACHMENT0; + for (int i = 0; type < GPU_FB_MAX_ATTACHEMENT; i++, type++) { + if (fb->attachments[type].tex != NULL) { + glClearBufferfv(GL_COLOR, i, clear_cols[i]); + } + } +} + void GPU_framebuffer_read_depth(GPUFrameBuffer *fb, int x, int y, int w, int h, float *data) { CHECK_FRAMEBUFFER_IS_BOUND(fb); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs