diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2021-03-12 21:23:46 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2021-03-13 22:59:20 +0300 |
commit | 83b7f7dfb7bef5a752b662819174f1c42f6fe26d (patch) | |
tree | 83635ace2b8fc48643307becdb0124bf0ad1873a | |
parent | 40d579b69f2f0acdf2695fe23a315212ebffae13 (diff) |
Cleanup: EEVEE: Remove SSR shader variations
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_private.h | 11 | ||||
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_screen_raytrace.c | 42 | ||||
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_shaders.c | 57 | ||||
-rw-r--r-- | source/blender/draw/tests/shaders_test.cc | 6 |
4 files changed, 30 insertions, 86 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index d03f52fd3a2..f73f10360e9 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -200,13 +200,6 @@ enum { KEY_SHADOW = (1 << 3), }; -/* SSR shader variations */ -typedef enum EEVEE_SSRShaderOptions { - SSR_RESOLVE = (1 << 0), - SSR_FULL_TRACE = (1 << 1), - SSR_MAX_SHADER = (1 << 2), -} EEVEE_SSRShaderOptions; - /* DOF Gather pass shader variations */ typedef enum EEVEE_DofGatherPass { DOF_GATHER_FOREGROUND = 0, @@ -731,7 +724,6 @@ typedef struct EEVEE_EffectsInfo { bool ssr_was_persp; bool ssr_was_valid_double_buffer; int ssr_neighbor_ofs; - int ssr_halfres_ofs[2]; struct GPUTexture *ssr_normal_input; /* Textures from pool */ struct GPUTexture *ssr_specrough_input; struct GPUTexture *ssr_hit_output; @@ -1215,7 +1207,8 @@ struct GPUShader *EEVEE_shaders_effect_motion_blur_velocity_tiles_expand_sh_get( struct GPUShader *EEVEE_shaders_effect_ambient_occlusion_sh_get(void); struct GPUShader *EEVEE_shaders_effect_ambient_occlusion_layer_sh_get(void); struct GPUShader *EEVEE_shaders_effect_ambient_occlusion_debug_sh_get(void); -struct GPUShader *EEVEE_shaders_effect_screen_raytrace_sh_get(EEVEE_SSRShaderOptions options); +struct GPUShader *EEVEE_shaders_effect_reflection_trace_sh_get(void); +struct GPUShader *EEVEE_shaders_effect_reflection_resolve_sh_get(void); struct GPUShader *EEVEE_shaders_renderpasses_post_process_sh_get(void); struct GPUShader *EEVEE_shaders_cryptomatte_sh_get(bool is_hair); struct GPUShader *EEVEE_shaders_shadow_sh_get(void); diff --git a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c index f5b4e4d43a5..c49f9ccc48c 100644 --- a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c +++ b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c @@ -126,14 +126,9 @@ void EEVEE_screen_raytrace_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *v EEVEE_EffectsInfo *effects = stl->effects; LightCache *lcache = stl->g_data->light_cache; - struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); - if ((effects->enabled_effects & EFFECT_SSR) != 0) { - EEVEE_SSRShaderOptions options = (effects->reflection_trace_full) ? SSR_FULL_TRACE : 0; - - struct GPUShader *trace_shader = EEVEE_shaders_effect_screen_raytrace_sh_get(options); - struct GPUShader *resolve_shader = EEVEE_shaders_effect_screen_raytrace_sh_get(SSR_RESOLVE | - options); + struct GPUShader *trace_shader = EEVEE_shaders_effect_reflection_trace_sh_get(); + struct GPUShader *resolve_shader = EEVEE_shaders_effect_reflection_resolve_sh_get(); /** Screen space raytracing overview * @@ -160,10 +155,7 @@ void EEVEE_screen_raytrace_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *v DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo); DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo); DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined); - if (!effects->reflection_trace_full) { - DRW_shgroup_uniform_ivec2(grp, "halfresOffset", effects->ssr_halfres_ofs, 1); - } - DRW_shgroup_call(grp, quad, NULL); + DRW_shgroup_call_procedural_triangles(grp, NULL, 1); eGPUSamplerState no_filter = GPU_SAMPLER_DEFAULT; @@ -190,8 +182,7 @@ void EEVEE_screen_raytrace_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *v DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined); DRW_shgroup_uniform_int(grp, "neighborOffset", &effects->ssr_neighbor_ofs, 1); DRW_shgroup_uniform_texture_ref(grp, "horizonBuffer", &effects->gtao_horizons); - - DRW_shgroup_call(grp, quad, NULL); + DRW_shgroup_call_procedural_triangles(grp, NULL, 1); } } @@ -230,31 +221,6 @@ void EEVEE_reflection_compute(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *v EEVEE_effects_downsample_radiance_buffer(vedata, txl->color_double_buffer); - /* Resolve at fullres */ - int samp = (DRW_state_is_image_render()) ? effects->taa_render_sample : - effects->taa_current_sample; - /* Doing a neighbor shift only after a few iteration. - * We wait for a prime number of cycles to avoid noise correlation. - * This reduces variance faster. */ - effects->ssr_neighbor_ofs = ((samp / 5) % 8) * 4; - switch ((samp / 11) % 4) { - case 0: - effects->ssr_halfres_ofs[0] = 0; - effects->ssr_halfres_ofs[1] = 0; - break; - case 1: - effects->ssr_halfres_ofs[0] = 0; - effects->ssr_halfres_ofs[1] = 1; - break; - case 2: - effects->ssr_halfres_ofs[0] = 1; - effects->ssr_halfres_ofs[1] = 0; - break; - case 4: - effects->ssr_halfres_ofs[0] = 1; - effects->ssr_halfres_ofs[1] = 1; - break; - } GPU_framebuffer_bind(fbl->main_color_fb); DRW_draw_pass(psl->ssr_resolve); diff --git a/source/blender/draw/engines/eevee/eevee_shaders.c b/source/blender/draw/engines/eevee/eevee_shaders.c index f7b83fa6d23..8c9e1fae715 100644 --- a/source/blender/draw/engines/eevee/eevee_shaders.c +++ b/source/blender/draw/engines/eevee/eevee_shaders.c @@ -132,7 +132,8 @@ static struct { struct GPUShader *cryptomatte_sh[2]; /* Screen Space Reflection */ - struct GPUShader *ssr_sh[SSR_MAX_SHADER]; + struct GPUShader *reflection_trace; + struct GPUShader *reflection_resolve; /* Shadows */ struct GPUShader *shadow_sh; @@ -747,42 +748,29 @@ GPUShader *EEVEE_shaders_cryptomatte_sh_get(bool is_hair) /** \} */ /* -------------------------------------------------------------------- */ -/** \name Screen Raytrace +/** \name Raytraced Reflections * \{ */ -struct GPUShader *EEVEE_shaders_effect_screen_raytrace_sh_get(EEVEE_SSRShaderOptions options) +struct GPUShader *EEVEE_shaders_effect_reflection_trace_sh_get(void) { - if (e_data.ssr_sh[options] == NULL) { - DRWShaderLibrary *lib = EEVEE_shader_lib_get(); - - DynStr *ds_defines = BLI_dynstr_new(); - BLI_dynstr_append(ds_defines, SHADER_DEFINES); - if (options & SSR_RESOLVE) { - BLI_dynstr_append(ds_defines, "#define STEP_RESOLVE\n"); - } - else { - BLI_dynstr_append(ds_defines, "#define STEP_RAYTRACE\n"); - BLI_dynstr_append(ds_defines, "#define PLANAR_PROBE_RAYTRACE\n"); - } - if (options & SSR_FULL_TRACE) { - BLI_dynstr_append(ds_defines, "#define FULLRES\n"); - } - char *ssr_define_str = BLI_dynstr_get_cstring(ds_defines); - BLI_dynstr_free(ds_defines); - - if (options & SSR_RESOLVE) { - e_data.ssr_sh[options] = DRW_shader_create_fullscreen_with_shaderlib( - datatoc_effect_reflection_resolve_frag_glsl, lib, ssr_define_str); - } - else { - e_data.ssr_sh[options] = DRW_shader_create_fullscreen_with_shaderlib( - datatoc_effect_reflection_trace_frag_glsl, lib, ssr_define_str); - } - - MEM_freeN(ssr_define_str); + if (e_data.reflection_trace == NULL) { + e_data.reflection_trace = DRW_shader_create_fullscreen_with_shaderlib( + datatoc_effect_reflection_trace_frag_glsl, + e_data.lib, + SHADER_DEFINES "#define STEP_RAYTRACE\n"); } + return e_data.reflection_trace; +} - return e_data.ssr_sh[options]; +struct GPUShader *EEVEE_shaders_effect_reflection_resolve_sh_get(void) +{ + if (e_data.reflection_resolve == NULL) { + e_data.reflection_resolve = DRW_shader_create_fullscreen_with_shaderlib( + datatoc_effect_reflection_resolve_frag_glsl, + e_data.lib, + SHADER_DEFINES "#define STEP_RESOLVE\n"); + } + return e_data.reflection_resolve; } /** \} */ @@ -1636,9 +1624,8 @@ void EEVEE_shaders_free(void) DRW_SHADER_FREE_SAFE(e_data.bloom_upsample_sh[i]); DRW_SHADER_FREE_SAFE(e_data.bloom_resolve_sh[i]); } - for (int i = 0; i < SSR_MAX_SHADER; i++) { - DRW_SHADER_FREE_SAFE(e_data.ssr_sh[i]); - } + DRW_SHADER_FREE_SAFE(e_data.reflection_trace); + DRW_SHADER_FREE_SAFE(e_data.reflection_resolve); DRW_SHADER_LIB_FREE_SAFE(e_data.lib); if (e_data.default_world) { diff --git a/source/blender/draw/tests/shaders_test.cc b/source/blender/draw/tests/shaders_test.cc index 126e7230843..62932b5122e 100644 --- a/source/blender/draw/tests/shaders_test.cc +++ b/source/blender/draw/tests/shaders_test.cc @@ -372,10 +372,8 @@ TEST_F(DrawTest, eevee_glsl_shaders_static) EXPECT_NE(EEVEE_shaders_velocity_resolve_sh_get(), nullptr); EXPECT_NE(EEVEE_shaders_taa_resolve_sh_get(EFFECT_TAA), nullptr); EXPECT_NE(EEVEE_shaders_taa_resolve_sh_get(EFFECT_TAA_REPROJECT), nullptr); - for (int index = 0; index < SSR_MAX_SHADER; index++) { - EEVEE_SSRShaderOptions ssr_option = (EEVEE_SSRShaderOptions)index; - EXPECT_NE(EEVEE_shaders_effect_screen_raytrace_sh_get(ssr_option), nullptr); - } + EXPECT_NE(EEVEE_shaders_effect_reflection_trace_sh_get(), nullptr); + EXPECT_NE(EEVEE_shaders_effect_reflection_resolve_sh_get(), nullptr); EEVEE_shaders_free(); } |