diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-07-30 14:56:22 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-07-30 15:18:55 +0300 |
commit | 0f97718c10e8c2a441f58a51eb923b1dfa3698d4 (patch) | |
tree | 54fd9db7f510e1d9c2cad423503c4cd4aadb65db /source/blender/draw/intern | |
parent | d65df10216b8de09b8a1cfc695030649511337a0 (diff) |
DRW: Add option to only resolve framebuffer colors without depth test
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r-- | source/blender/draw/intern/DRW_render.h | 13 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 49 |
2 files changed, 46 insertions, 16 deletions
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index cd2db3cfd0a..d2c44cfef2a 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -120,7 +120,16 @@ typedef char DRWViewportEmptyList; if (dfbl->multisample_fb != NULL) { \ DRW_stats_query_start("Multisample Resolve"); \ GPU_framebuffer_bind(dfbl->default_fb); \ - DRW_multisamples_resolve(dtxl->multisample_depth, dtxl->multisample_color); \ + DRW_multisamples_resolve(dtxl->multisample_depth, dtxl->multisample_color, true); \ + DRW_stats_query_end(); \ + } \ +} + +#define MULTISAMPLE_SYNC_DISABLE_NO_DEPTH(dfbl, dtxl) { \ + if (dfbl->multisample_fb != NULL) { \ + DRW_stats_query_start("Multisample Resolve"); \ + GPU_framebuffer_bind(dfbl->default_fb); \ + DRW_multisamples_resolve(dtxl->multisample_depth, dtxl->multisample_color, false); \ DRW_stats_query_end(); \ } \ } @@ -228,7 +237,7 @@ void DRW_uniformbuffer_free(struct GPUUniformBuffer *ubo); void DRW_transform_to_display(struct GPUTexture *tex); void DRW_transform_none(struct GPUTexture *tex); void DRW_multisamples_resolve( - struct GPUTexture *src_depth, struct GPUTexture *src_color); + struct GPUTexture *src_depth, struct GPUTexture *src_color, bool use_depth); /* Shaders */ struct GPUShader *DRW_shader_create( diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 0a15fb3a114..87239e7d93e 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -317,10 +317,14 @@ void DRW_transform_none(GPUTexture *tex) /* Use manual multisample resolve pass. * Much quicker than blitting back and forth. * Assume destination fb is bound*/ -void DRW_multisamples_resolve(GPUTexture *src_depth, GPUTexture *src_color) +void DRW_multisamples_resolve(GPUTexture *src_depth, GPUTexture *src_color, bool use_depth) { - drw_state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_PREMUL | - DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL); + DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_PREMUL; + + if (use_depth) { + state |= DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL; + } + drw_state_set(state); int samples = GPU_texture_samples(src_depth); @@ -330,22 +334,39 @@ void DRW_multisamples_resolve(GPUTexture *src_depth, GPUTexture *src_color) GPUBatch *geom = DRW_cache_fullscreen_quad_get(); int builtin; - switch (samples) { - case 2: builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_2; break; - case 4: builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_4; break; - case 8: builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_8; break; - case 16: builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_16; break; - default: - BLI_assert(0); - builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_2; - break; + if (use_depth) { + switch (samples) { + case 2: builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_2_DEPTH_TEST; break; + case 4: builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_4_DEPTH_TEST; break; + case 8: builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_8_DEPTH_TEST; break; + case 16: builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_16_DEPTH_TEST; break; + default: + BLI_assert("Mulisample count unsupported by blit shader."); + builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_2_DEPTH_TEST; + break; + } + } + else { + switch (samples) { + case 2: builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_2; break; + case 4: builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_4; break; + case 8: builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_8; break; + case 16: builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_16; break; + default: + BLI_assert("Mulisample count unsupported by blit shader."); + builtin = GPU_SHADER_2D_IMAGE_MULTISAMPLE_2; + break; + } } GPU_batch_program_set_builtin(geom, builtin); - GPU_texture_bind(src_depth, 0); + if (use_depth) { + GPU_texture_bind(src_depth, 0); + GPU_batch_uniform_1i(geom, "depthMulti", 0); + } + GPU_texture_bind(src_color, 1); - GPU_batch_uniform_1i(geom, "depthMulti", 0); GPU_batch_uniform_1i(geom, "colorMulti", 1); float mat[4][4]; |