diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-09-12 07:10:11 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-09-12 16:29:54 +0300 |
commit | 136bdb561b4ce05788e7b654c7e734cc35664b91 (patch) | |
tree | 7b1dd88c0e36f02498a66f107b99252f6f1c76d5 /source/blender/draw/engines | |
parent | a442da62dc6ea14c43a7aba04a600c9ba7cd7f1b (diff) |
GPU: Add Image Load Store extension support
This wraps the functionality used to speedup EEVEE volumetrics.
This touches the rendering code of EEVEE as it should fix a mis-usage of
the GL barrier. The barrier changed type and location, removing an
unused barrier.
Diffstat (limited to 'source/blender/draw/engines')
3 files changed, 13 insertions, 21 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index 8216d2545ac..e731ed071b2 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -84,9 +84,7 @@ extern struct DrawEngineType draw_engine_eevee_type; #define EEVEE_PROBE_MAX min_ii(MAX_PROBE, GPU_max_texture_layers() / 6) #define EEVEE_VELOCITY_TILE_SIZE 32 -#define USE_VOLUME_OPTI \ - (GLEW_ARB_shader_image_load_store && GLEW_ARB_shading_language_420pack && \ - !GPU_crappy_amd_driver()) +#define USE_VOLUME_OPTI (GPU_shader_image_load_store_support()) #define SWAP_DOUBLE_BUFFERS() \ { \ diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c index 69b916244b5..93701887b51 100644 --- a/source/blender/draw/engines/eevee/eevee_volumes.c +++ b/source/blender/draw/engines/eevee/eevee_volumes.c @@ -601,6 +601,10 @@ void EEVEE_volumes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo); DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo); DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined); + if (USE_VOLUME_OPTI) { + DRW_shgroup_uniform_image_ref(grp, "finalScattering_img", &txl->volume_scatter_history); + DRW_shgroup_uniform_image_ref(grp, "finalTransmittance_img", &txl->volume_transmit_history); + } DRW_shgroup_call_procedural_triangles( grp, NULL, USE_VOLUME_OPTI ? 1 : common_data->vol_tex_size[2]); @@ -610,6 +614,7 @@ void EEVEE_volumes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) DRW_shgroup_uniform_texture_ref(grp, "inScattering", &txl->volume_scatter); DRW_shgroup_uniform_texture_ref(grp, "inTransmittance", &txl->volume_transmit); DRW_shgroup_uniform_texture_ref(grp, "inSceneDepth", &e_data.depth_src); + DRW_shgroup_uniform_block(grp, "light_block", sldata->light_ubo); DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo); DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo); DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined); @@ -714,15 +719,7 @@ void EEVEE_volumes_compute(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) DRW_draw_pass(psl->volumetric_scatter_ps); if (USE_VOLUME_OPTI) { - int tex_scatter = GPU_texture_opengl_bindcode(txl->volume_scatter_history); - int tex_transmit = GPU_texture_opengl_bindcode(txl->volume_transmit_history); - /* TODO(fclem) Encapsulate these GL calls into DRWManager. */ - glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT); - /* Subtlety here! we need to tell the GL that the texture is layered (GL_TRUE) - * in order to bind the full 3D texture and not just a 2D slice. */ - glBindImageTexture(0, tex_scatter, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_R11F_G11F_B10F); - glBindImageTexture(1, tex_transmit, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_R11F_G11F_B10F); - + /* Avoid feedback loop assert. */ GPU_framebuffer_bind(fbl->volumetric_fb); } else { @@ -731,13 +728,6 @@ void EEVEE_volumes_compute(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) DRW_draw_pass(psl->volumetric_integration_ps); - if (USE_VOLUME_OPTI) { - glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT); - - glBindImageTexture(0, 0, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_R11F_G11F_B10F); - glBindImageTexture(1, 0, 0, GL_TRUE, 0, GL_WRITE_ONLY, GL_R11F_G11F_B10F); - } - SWAP(struct GPUFrameBuffer *, fbl->volumetric_scat_fb, fbl->volumetric_integ_fb); SWAP(GPUTexture *, txl->volume_scatter, txl->volume_scatter_history); SWAP(GPUTexture *, txl->volume_transmit, txl->volume_transmit_history); @@ -763,6 +753,10 @@ void EEVEE_volumes_resolve(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); e_data.depth_src = dtxl->depth; + if (USE_VOLUME_OPTI) { + GPU_memory_barrier(GPU_BARRIER_TEXTURE_FETCH); + } + /* Apply for opaque geometry. */ GPU_framebuffer_bind(fbl->main_color_fb); DRW_draw_pass(psl->volumetric_resolve_ps); diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl index f4276bd61bd..12b7d8acbea 100644 --- a/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl @@ -11,8 +11,8 @@ uniform sampler3D volumeScattering; /* Result of the scatter step */ uniform sampler3D volumeExtinction; #ifdef USE_VOLUME_OPTI -uniform layout(binding = 0, r11f_g11f_b10f) writeonly restrict image3D finalScattering_img; -uniform layout(binding = 1, r11f_g11f_b10f) writeonly restrict image3D finalTransmittance_img; +uniform layout(r11f_g11f_b10f) writeonly restrict image3D finalScattering_img; +uniform layout(r11f_g11f_b10f) writeonly restrict image3D finalTransmittance_img; vec3 finalScattering; vec3 finalTransmittance; |