diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-08-27 10:18:46 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-08-27 10:18:46 +0300 |
commit | 75ef33c7d35f86462ae0e447d87cbba66a01d563 (patch) | |
tree | 7084a1efb89462a8f6cee7b44ea1036a6154752f /source | |
parent | 69e337f47e0747a6789f8d2e761d3b4b1bfdc41d (diff) |
EEVEEE-Next: Share resource slot definition avoiding lots of constants sharing
Diffstat (limited to 'source')
8 files changed, 92 insertions, 49 deletions
diff --git a/source/blender/draw/engines/eevee_next/eevee_defines.hh b/source/blender/draw/engines/eevee_next/eevee_defines.hh index 67643471639..ec05cce3d02 100644 --- a/source/blender/draw/engines/eevee_next/eevee_defines.hh +++ b/source/blender/draw/engines/eevee_next/eevee_defines.hh @@ -68,3 +68,37 @@ #define DOF_FILTER_GROUP_SIZE 8 #define DOF_GATHER_GROUP_SIZE DOF_TILES_SIZE #define DOF_RESOLVE_GROUP_SIZE (DOF_TILES_SIZE * 2) + +/* Resource bindings. */ + +/* Texture. */ +#define RBUFS_UTILITY_TEX_SLOT 14 + +/* Images. */ +#define RBUFS_NORMAL_SLOT 0 +#define RBUFS_LIGHT_SLOT 1 +#define RBUFS_DIFF_COLOR_SLOT 2 +#define RBUFS_SPEC_COLOR_SLOT 3 +#define RBUFS_EMISSION_SLOT 4 +#define RBUFS_AOV_COLOR_SLOT 5 +#define RBUFS_AOV_VALUE_SLOT 6 + +/* Uniform Bufs. */ +/* Only during prepass. */ +#define VELOCITY_CAMERA_PREV_BUF 3 +#define VELOCITY_CAMERA_CURR_BUF 4 +#define VELOCITY_CAMERA_NEXT_BUF 5 + +/* Storage Bufs. */ +#define LIGHT_CULL_BUF_SLOT 0 +#define LIGHT_BUF_SLOT 1 +#define LIGHT_ZBIN_BUF_SLOT 2 +#define LIGHT_TILE_BUF_SLOT 3 +#define RBUFS_AOV_BUF_SLOT 5 +#define SAMPLING_BUF_SLOT 6 +/* Only during prepass. */ +#define VELOCITY_OBJ_PREV_BUF_SLOT 0 +#define VELOCITY_OBJ_NEXT_BUF_SLOT 1 +#define VELOCITY_GEO_PREV_BUF_SLOT 2 +#define VELOCITY_GEO_NEXT_BUF_SLOT 3 +#define VELOCITY_INDIRECTION_BUF_SLOT 4 diff --git a/source/blender/draw/engines/eevee_next/eevee_light.hh b/source/blender/draw/engines/eevee_next/eevee_light.hh index 61c2d0593a8..afa207805a5 100644 --- a/source/blender/draw/engines/eevee_next/eevee_light.hh +++ b/source/blender/draw/engines/eevee_next/eevee_light.hh @@ -157,10 +157,10 @@ class LightModule { template<typename T> void bind_resources(draw::detail::Pass<T> *pass) { /* Storage Buf. */ - pass->bind(0, &culling_data_buf_); - pass->bind(1, &culling_light_buf_); - pass->bind(2, &culling_zbin_buf_); - pass->bind(3, &culling_tile_buf_); + pass->bind(LIGHT_CULL_BUF_SLOT, &culling_data_buf_); + pass->bind(LIGHT_BUF_SLOT, &culling_light_buf_); + pass->bind(LIGHT_ZBIN_BUF_SLOT, &culling_zbin_buf_); + pass->bind(LIGHT_TILE_BUF_SLOT, &culling_tile_buf_); } private: diff --git a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc index 91dc358b242..aae63bfaa99 100644 --- a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc +++ b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc @@ -75,9 +75,10 @@ void ForwardPipeline::sync() /* Common resources. */ /* Textures. */ - prepass_ps_.bind(14, inst_.pipelines.utility_tx); + prepass_ps_.bind(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx); inst_.velocity.bind_resources(&prepass_ps_); + inst_.sampling.bind_resources(&prepass_ps_); } prepass_double_sided_static_ps_ = &prepass_ps_.sub("DoubleSided.Static"); @@ -99,18 +100,18 @@ void ForwardPipeline::sync() /* Common resources. */ /* RenderPasses. */ - opaque_ps_.bind(0, as_image(&inst_.render_buffers.normal_tx)); - opaque_ps_.bind(1, as_image(&inst_.render_buffers.light_tx)); - opaque_ps_.bind(2, as_image(&inst_.render_buffers.diffuse_color_tx)); - opaque_ps_.bind(3, as_image(&inst_.render_buffers.specular_color_tx)); - opaque_ps_.bind(4, as_image(&inst_.render_buffers.emission_tx)); + opaque_ps_.bind(RBUFS_NORMAL_SLOT, as_image(&inst_.render_buffers.normal_tx)); + opaque_ps_.bind(RBUFS_LIGHT_SLOT, as_image(&inst_.render_buffers.light_tx)); + opaque_ps_.bind(RBUFS_DIFF_COLOR_SLOT, as_image(&inst_.render_buffers.diffuse_color_tx)); + opaque_ps_.bind(RBUFS_SPEC_COLOR_SLOT, as_image(&inst_.render_buffers.specular_color_tx)); + opaque_ps_.bind(RBUFS_EMISSION_SLOT, as_image(&inst_.render_buffers.emission_tx)); /* AOVs. */ - opaque_ps_.bind(5, as_image(&inst_.render_buffers.aov_color_tx)); - opaque_ps_.bind(6, as_image(&inst_.render_buffers.aov_value_tx)); + opaque_ps_.bind(RBUFS_AOV_COLOR_SLOT, as_image(&inst_.render_buffers.aov_color_tx)); + opaque_ps_.bind(RBUFS_AOV_VALUE_SLOT, as_image(&inst_.render_buffers.aov_value_tx)); /* Storage Buf. */ - opaque_ps_.bind(5, &inst_.film.aovs_info); + opaque_ps_.bind(RBUFS_AOV_BUF_SLOT, &inst_.film.aovs_info); /* Textures. */ - opaque_ps_.bind(14, inst_.pipelines.utility_tx); + opaque_ps_.bind(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx); inst_.lights.bind_resources(&opaque_ps_); inst_.sampling.bind_resources(&opaque_ps_); diff --git a/source/blender/draw/engines/eevee_next/eevee_sampling.hh b/source/blender/draw/engines/eevee_next/eevee_sampling.hh index 7ad6aeb9313..597721c1b9b 100644 --- a/source/blender/draw/engines/eevee_next/eevee_sampling.hh +++ b/source/blender/draw/engines/eevee_next/eevee_sampling.hh @@ -90,7 +90,7 @@ class Sampling { template<typename T> void bind_resources(draw::detail::Pass<T> *pass) { /* Storage Buf. */ - pass->bind(6, &data_); + pass->bind(SAMPLING_BUF_SLOT, &data_); } /* Returns a pseudo random number in [0..1] range. Each dimension are de-correlated. */ diff --git a/source/blender/draw/engines/eevee_next/eevee_velocity.hh b/source/blender/draw/engines/eevee_next/eevee_velocity.hh index addd887c297..d142dbeadf7 100644 --- a/source/blender/draw/engines/eevee_next/eevee_velocity.hh +++ b/source/blender/draw/engines/eevee_next/eevee_velocity.hh @@ -67,7 +67,9 @@ class VelocityModule { private: Instance &inst_; + /** Step being synced. */ eVelocityStep step_ = STEP_CURRENT; + /** Step referenced as next step. */ eVelocityStep next_step_ = STEP_NEXT; public: @@ -116,15 +118,15 @@ class VelocityModule { template<typename T> void bind_resources(draw::detail::Pass<T> *pass) { /* Storage Buf. */ - pass->bind(0, &(*object_steps[STEP_PREVIOUS])); - pass->bind(1, &(*object_steps[next_step_])); - pass->bind(2, &(*geometry_steps[STEP_PREVIOUS])); - pass->bind(3, &(*geometry_steps[next_step_])); - pass->bind(4, &indirection_buf); + pass->bind(VELOCITY_OBJ_PREV_BUF_SLOT, &(*object_steps[STEP_PREVIOUS])); + pass->bind(VELOCITY_OBJ_NEXT_BUF_SLOT, &(*object_steps[next_step_])); + pass->bind(VELOCITY_GEO_PREV_BUF_SLOT, &(*geometry_steps[STEP_PREVIOUS])); + pass->bind(VELOCITY_GEO_NEXT_BUF_SLOT, &(*geometry_steps[next_step_])); + pass->bind(VELOCITY_INDIRECTION_BUF_SLOT, &indirection_buf); /* Uniform Buf. */ - pass->bind(3, &(*camera_steps[STEP_PREVIOUS])); - pass->bind(4, &(*camera_steps[STEP_CURRENT])); - pass->bind(5, &(*camera_steps[next_step_])); + pass->bind(VELOCITY_CAMERA_PREV_BUF, &(*camera_steps[STEP_PREVIOUS])); + pass->bind(VELOCITY_CAMERA_CURR_BUF, &(*camera_steps[STEP_CURRENT])); + pass->bind(VELOCITY_CAMERA_NEXT_BUF, &(*camera_steps[next_step_])); } bool camera_has_motion() const; diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_light_culling_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_light_culling_info.hh index c54f05719d3..41602426a1d 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_light_culling_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_light_culling_info.hh @@ -8,10 +8,10 @@ * \{ */ GPU_SHADER_CREATE_INFO(eevee_light_data) - .storage_buf(0, Qualifier::READ, "LightCullingData", "light_cull_buf") - .storage_buf(1, Qualifier::READ, "LightData", "light_buf[]") - .storage_buf(2, Qualifier::READ, "uint", "light_zbin_buf[]") - .storage_buf(3, Qualifier::READ, "uint", "light_tile_buf[]"); + .storage_buf(LIGHT_CULL_BUF_SLOT, Qualifier::READ, "LightCullingData", "light_cull_buf") + .storage_buf(LIGHT_BUF_SLOT, Qualifier::READ, "LightData", "light_buf[]") + .storage_buf(LIGHT_ZBIN_BUF_SLOT, Qualifier::READ, "uint", "light_zbin_buf[]") + .storage_buf(LIGHT_TILE_BUF_SLOT, Qualifier::READ, "uint", "light_tile_buf[]"); /** \} */ diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh index 045f1523c62..7bd4da864c3 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ +#include "eevee_defines.hh" #include "gpu_shader_create_info.hh" /* -------------------------------------------------------------------- */ @@ -16,7 +17,8 @@ GPU_SHADER_CREATE_INFO(eevee_sampling_data) .additional_info("eevee_shared") .storage_buf(6, Qualifier::READ, "SamplingData", "sampling_buf"); -GPU_SHADER_CREATE_INFO(eevee_utility_texture).sampler(14, ImageType::FLOAT_2D_ARRAY, "utility_tx"); +GPU_SHADER_CREATE_INFO(eevee_utility_texture) + .sampler(RBUFS_UTILITY_TEX_SLOT, ImageType::FLOAT_2D_ARRAY, "utility_tx"); /** \} */ @@ -78,9 +80,9 @@ GPU_SHADER_INTERFACE_INFO(eevee_surf_iface, "interp") GPU_SHADER_CREATE_INFO(eevee_aov_out) .define("MAT_AOV_SUPPORT") - .image_array_out(5, Qualifier::WRITE, GPU_RGBA16F, "aov_color_img") - .image_array_out(6, Qualifier::WRITE, GPU_R16F, "aov_value_img") - .storage_buf(5, Qualifier::READ, "AOVsInfoData", "aov_buf"); + .image_array_out(RBUFS_AOV_COLOR_SLOT, Qualifier::WRITE, GPU_RGBA16F, "aov_color_img") + .image_array_out(RBUFS_AOV_VALUE_SLOT, Qualifier::WRITE, GPU_R16F, "aov_value_img") + .storage_buf(RBUFS_AOV_BUF_SLOT, Qualifier::READ, "AOVsInfoData", "aov_buf"); GPU_SHADER_CREATE_INFO(eevee_surf_deferred) .vertex_out(eevee_surf_iface) @@ -111,11 +113,11 @@ GPU_SHADER_CREATE_INFO(eevee_surf_forward) .fragment_out(0, Type::VEC4, "out_radiance", DualBlend::SRC_0) .fragment_out(0, Type::VEC4, "out_transmittance", DualBlend::SRC_1) .fragment_source("eevee_surf_forward_frag.glsl") - .image_out(0, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_normal_img") - .image_array_out(1, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_light_img") - .image_out(2, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_diffuse_color_img") - .image_out(3, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_specular_color_img") - .image_out(4, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_emission_img") + .image_out(RBUFS_NORMAL_SLOT, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_normal_img") + .image_array_out(RBUFS_LIGHT_SLOT, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_light_img") + .image_out(RBUFS_DIFF_COLOR_SLOT, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_diffuse_color_img") + .image_out(RBUFS_SPEC_COLOR_SLOT, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_specular_color_img") + .image_out(RBUFS_EMISSION_SLOT, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_emission_img") .additional_info("eevee_aov_out", "eevee_light_data", "eevee_utility_texture", @@ -135,11 +137,11 @@ GPU_SHADER_CREATE_INFO(eevee_surf_depth) GPU_SHADER_CREATE_INFO(eevee_surf_world) .vertex_out(eevee_surf_iface) - .image_out(0, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_normal_img") - .image_array_out(1, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_light_img") - .image_out(2, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_diffuse_color_img") - .image_out(3, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_specular_color_img") - .image_out(4, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_emission_img") + .image_out(RBUFS_NORMAL_SLOT, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_normal_img") + .image_array_out(RBUFS_LIGHT_SLOT, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_light_img") + .image_out(RBUFS_DIFF_COLOR_SLOT, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_diffuse_color_img") + .image_out(RBUFS_SPEC_COLOR_SLOT, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_specular_color_img") + .image_out(RBUFS_EMISSION_SLOT, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_emission_img") .push_constant(Type::FLOAT, "world_opacity_fade") .fragment_out(0, Type::VEC4, "out_background") .fragment_source("eevee_surf_world_frag.glsl") diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_velocity_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_velocity_info.hh index bea120dadd5..0a1c2721c61 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_velocity_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_velocity_info.hh @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ +#include "eevee_defines.hh" #include "gpu_shader_create_info.hh" /* -------------------------------------------------------------------- */ @@ -17,17 +18,20 @@ GPU_SHADER_INTERFACE_INFO(eevee_velocity_surface_iface, "motion") GPU_SHADER_CREATE_INFO(eevee_velocity_camera) .define("VELOCITY_CAMERA") - .uniform_buf(3, "CameraData", "camera_prev") - .uniform_buf(4, "CameraData", "camera_curr") - .uniform_buf(5, "CameraData", "camera_next"); + .uniform_buf(VELOCITY_CAMERA_PREV_BUF, "CameraData", "camera_prev") + .uniform_buf(VELOCITY_CAMERA_CURR_BUF, "CameraData", "camera_curr") + .uniform_buf(VELOCITY_CAMERA_NEXT_BUF, "CameraData", "camera_next"); GPU_SHADER_CREATE_INFO(eevee_velocity_geom) .define("MAT_VELOCITY") - .storage_buf(0, Qualifier::READ, "mat4", "velocity_obj_prev_buf[]") - .storage_buf(1, Qualifier::READ, "mat4", "velocity_obj_next_buf[]") - .storage_buf(2, Qualifier::READ, "vec4", "velocity_geo_prev_buf[]") - .storage_buf(3, Qualifier::READ, "vec4", "velocity_geo_next_buf[]") - .storage_buf(4, Qualifier::READ, "VelocityIndex", "velocity_indirection_buf[]") + .storage_buf(VELOCITY_OBJ_PREV_BUF_SLOT, Qualifier::READ, "mat4", "velocity_obj_prev_buf[]") + .storage_buf(VELOCITY_OBJ_NEXT_BUF_SLOT, Qualifier::READ, "mat4", "velocity_obj_next_buf[]") + .storage_buf(VELOCITY_GEO_PREV_BUF_SLOT, Qualifier::READ, "vec4", "velocity_geo_prev_buf[]") + .storage_buf(VELOCITY_GEO_NEXT_BUF_SLOT, Qualifier::READ, "vec4", "velocity_geo_next_buf[]") + .storage_buf(VELOCITY_INDIRECTION_BUF_SLOT, + Qualifier::READ, + "VelocityIndex", + "velocity_indirection_buf[]") .vertex_out(eevee_velocity_surface_iface) .fragment_out(0, Type::VEC4, "out_velocity") .additional_info("eevee_velocity_camera"); |