From e5f6c57f8c1b5a7a9fd1c16d86a058444543d8a8 Mon Sep 17 00:00:00 2001 From: Miguel Pozo Date: Fri, 8 Sep 2023 21:03:37 +0200 Subject: [PATCH] EEVEE-Next: Merge UBOs Merge all the small UBOs used by the engine to save binding slots. Each module is still responsible for filling its own data (by storing a reference to it at construction) and this data is still private for other modules. The engine instance pushes the data to the GPU at the end of `end_sync`, so only the modules that modify their data outside of the sync functions need to manually call `Instance::push_uniform_data()`. Pull Request: https://projects.blender.org/blender/blender/pulls/112046 --- .../eevee_next/eevee_ambient_occlusion.cc | 4 +- .../eevee_next/eevee_ambient_occlusion.hh | 9 +- .../draw/engines/eevee_next/eevee_camera.cc | 1 - .../draw/engines/eevee_next/eevee_camera.hh | 8 +- .../draw/engines/eevee_next/eevee_defines.hh | 19 +-- .../draw/engines/eevee_next/eevee_film.cc | 7 +- .../draw/engines/eevee_next/eevee_film.hh | 4 +- .../engines/eevee_next/eevee_hizbuffer.cc | 1 - .../engines/eevee_next/eevee_hizbuffer.hh | 6 +- .../draw/engines/eevee_next/eevee_instance.cc | 2 + .../draw/engines/eevee_next/eevee_instance.hh | 28 +++- .../draw/engines/eevee_next/eevee_light.cc | 1 + .../draw/engines/eevee_next/eevee_pipeline.cc | 51 ++---- .../draw/engines/eevee_next/eevee_raytrace.cc | 14 +- .../draw/engines/eevee_next/eevee_raytrace.hh | 4 +- .../engines/eevee_next/eevee_renderbuffers.cc | 1 - .../engines/eevee_next/eevee_renderbuffers.hh | 4 +- .../engines/eevee_next/eevee_shader_shared.hh | 29 +++- .../draw/engines/eevee_next/eevee_shadow.cc | 3 + .../engines/eevee_next/eevee_subsurface.cc | 5 +- .../engines/eevee_next/eevee_subsurface.hh | 9 +- .../draw/engines/eevee_next/eevee_volume.cc | 8 +- .../draw/engines/eevee_next/eevee_volume.hh | 8 +- .../shaders/eevee_ambient_occlusion_lib.glsl | 8 +- .../eevee_ambient_occlusion_pass_comp.glsl | 2 +- .../shaders/eevee_cryptomatte_lib.glsl | 4 +- .../shaders/eevee_deferred_light_frag.glsl | 12 +- .../eevee_depth_of_field_stabilize_comp.glsl | 6 +- .../eevee_next/shaders/eevee_film_frag.glsl | 16 +- .../eevee_next/shaders/eevee_film_lib.glsl | 158 +++++++++--------- .../shaders/eevee_nodetree_lib.glsl | 22 +-- .../eevee_ray_denoise_bilateral_comp.glsl | 4 +- .../eevee_ray_denoise_spatial_comp.glsl | 10 +- .../eevee_ray_denoise_temporal_comp.glsl | 6 +- .../shaders/eevee_ray_generate_comp.glsl | 2 +- .../shaders/eevee_ray_tile_classify_comp.glsl | 4 +- .../shaders/eevee_ray_tile_compact_comp.glsl | 6 +- .../shaders/eevee_ray_trace_screen_comp.glsl | 10 +- .../eevee_shadow_tag_usage_volume_comp.glsl | 12 +- .../shaders/eevee_subsurface_eval_frag.glsl | 12 +- .../shaders/eevee_surf_deferred_frag.glsl | 8 +- .../shaders/eevee_surf_forward_frag.glsl | 16 +- .../shaders/eevee_surf_world_frag.glsl | 16 +- .../eevee_volume_integration_comp.glsl | 2 +- .../eevee_next/shaders/eevee_volume_lib.glsl | 38 ++--- .../shaders/eevee_volume_material_comp.glsl | 4 +- .../shaders/eevee_volume_resolve_frag.glsl | 4 +- .../shaders/eevee_volume_scatter_comp.glsl | 8 +- .../infos/eevee_ambient_occlusion_info.hh | 15 +- .../shaders/infos/eevee_film_info.hh | 3 +- .../shaders/infos/eevee_hiz_info.hh | 2 +- .../shaders/infos/eevee_material_info.hh | 35 ++-- .../shaders/infos/eevee_shadow_info.hh | 1 - .../shaders/infos/eevee_subsurface_info.hh | 3 +- .../shaders/infos/eevee_tracing_info.hh | 24 +-- .../shaders/infos/eevee_volume_info.hh | 11 +- 56 files changed, 340 insertions(+), 370 deletions(-) diff --git a/source/blender/draw/engines/eevee_next/eevee_ambient_occlusion.cc b/source/blender/draw/engines/eevee_next/eevee_ambient_occlusion.cc index 641ee03cc00..a192e61c40e 100644 --- a/source/blender/draw/engines/eevee_next/eevee_ambient_occlusion.cc +++ b/source/blender/draw/engines/eevee_next/eevee_ambient_occlusion.cc @@ -42,8 +42,6 @@ void AmbientOcclusion::init() data_.quality = inst_.scene->eevee.gtao_quality; /* Size is multiplied by 2 because it is applied in NDC [-1..1] range. */ data_.pixel_size = float2(2.0f) / float2(inst_.film.render_extent_get()); - - data_.push_update(); } void AmbientOcclusion::sync() @@ -56,9 +54,9 @@ void AmbientOcclusion::sync() render_pass_ps_.shader_set(inst_.shaders.static_shader_get(AMBIENT_OCCLUSION_PASS)); render_pass_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, &inst_.pipelines.utility_tx); + inst_.bind_uniform_data(&render_pass_ps_); inst_.sampling.bind_resources(&render_pass_ps_); inst_.hiz_buffer.bind_resources(&render_pass_ps_); - bind_resources(&render_pass_ps_); render_pass_ps_.bind_image("in_normal_img", &inst_.render_buffers.rp_color_tx); render_pass_ps_.push_constant("in_normal_img_layer_index", &inst_.render_buffers.data.normal_id); diff --git a/source/blender/draw/engines/eevee_next/eevee_ambient_occlusion.hh b/source/blender/draw/engines/eevee_next/eevee_ambient_occlusion.hh index dc3c52715c9..5526194790b 100644 --- a/source/blender/draw/engines/eevee_next/eevee_ambient_occlusion.hh +++ b/source/blender/draw/engines/eevee_next/eevee_ambient_occlusion.hh @@ -30,11 +30,11 @@ class AmbientOcclusion { bool render_pass_enabled_; - AODataBuf data_; + AOData &data_; PassSimple render_pass_ps_ = {"AO Render Pass"}; public: - AmbientOcclusion(Instance &inst) : inst_(inst){}; + AmbientOcclusion(Instance &inst, AOData &data) : inst_(inst), data_(data){}; ~AmbientOcclusion(){}; void init(); @@ -43,11 +43,6 @@ class AmbientOcclusion { void render(View &view); void render_pass(View &view); - - template void bind_resources(draw::detail::PassBase *pass) - { - pass->bind_ubo(AO_BUF_SLOT, &data_); - } }; /** \} */ diff --git a/source/blender/draw/engines/eevee_next/eevee_camera.cc b/source/blender/draw/engines/eevee_next/eevee_camera.cc index e35c352f5a8..2365b68a4bd 100644 --- a/source/blender/draw/engines/eevee_next/eevee_camera.cc +++ b/source/blender/draw/engines/eevee_next/eevee_camera.cc @@ -180,7 +180,6 @@ void Camera::sync() } data_.initialized = true; - data_.push_update(); update_bounds(); } diff --git a/source/blender/draw/engines/eevee_next/eevee_camera.hh b/source/blender/draw/engines/eevee_next/eevee_camera.hh index 18b0b28eed5..dc2c24a5807 100644 --- a/source/blender/draw/engines/eevee_next/eevee_camera.hh +++ b/source/blender/draw/engines/eevee_next/eevee_camera.hh @@ -93,7 +93,7 @@ class Camera { private: Instance &inst_; - CameraDataBuf data_; + CameraData &data_; struct { float3 center; @@ -104,7 +104,7 @@ class Camera { bool overscan_changed_; public: - Camera(Instance &inst) : inst_(inst){}; + Camera(Instance &inst, CameraData &data) : inst_(inst), data_(data){}; ~Camera(){}; void init(); @@ -118,10 +118,6 @@ class Camera { BLI_assert(data_.initialized); return data_; } - GPUUniformBuf *ubo_get() const - { - return data_; - } bool is_panoramic() const { return eevee::is_panoramic(data_.type); diff --git a/source/blender/draw/engines/eevee_next/eevee_defines.hh b/source/blender/draw/engines/eevee_next/eevee_defines.hh index 4c81a4fb0ea..f8c5a36c0cf 100644 --- a/source/blender/draw/engines/eevee_next/eevee_defines.hh +++ b/source/blender/draw/engines/eevee_next/eevee_defines.hh @@ -154,21 +154,14 @@ /* Uniform Buffers. */ /* Slot 0 is GPU_NODE_TREE_UBO_SLOT. */ -#define CAMERA_BUF_SLOT 1 -#define RBUFS_BUF_SLOT 2 +#define UNIFORM_BUF_SLOT 1 /* Only during surface shading (forward and deferred eval). */ -#define HIZ_BUF_SLOT 3 -#define IRRADIANCE_GRID_BUF_SLOT 4 -#define AO_BUF_SLOT 5 -#define VOLUMES_INFO_BUF_SLOT 6 -/* SLOT 6 is used by render shaders (Film, DoF and Motion Blur). Need to check if it should be - * assigned a different slot. */ -/* TODO(fclem): This is above the limit of slot 6 for engines. Keep it lower by merging others. */ -#define REFLECTION_PROBE_BUF_SLOT 7 +#define IRRADIANCE_GRID_BUF_SLOT 2 +#define REFLECTION_PROBE_BUF_SLOT 3 /* Only during pre-pass. */ -#define VELOCITY_CAMERA_PREV_BUF 3 -#define VELOCITY_CAMERA_CURR_BUF 4 -#define VELOCITY_CAMERA_NEXT_BUF 5 +#define VELOCITY_CAMERA_PREV_BUF 2 +#define VELOCITY_CAMERA_CURR_BUF 3 +#define VELOCITY_CAMERA_NEXT_BUF 4 /* Storage Buffers. */ #define LIGHT_CULL_BUF_SLOT 0 diff --git a/source/blender/draw/engines/eevee_next/eevee_film.cc b/source/blender/draw/engines/eevee_next/eevee_film.cc index 6ae18507f1c..da6017d0a7d 100644 --- a/source/blender/draw/engines/eevee_next/eevee_film.cc +++ b/source/blender/draw/engines/eevee_next/eevee_film.cc @@ -434,7 +434,7 @@ void Film::sync() accumulate_ps_.init(); accumulate_ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS); accumulate_ps_.shader_set(inst_.shaders.static_shader_get(shader)); - accumulate_ps_.bind_ubo("film_buf", &data_); + inst_.bind_uniform_data(&accumulate_ps_); accumulate_ps_.bind_ubo("camera_prev", &(*velocity.camera_steps[STEP_PREVIOUS])); accumulate_ps_.bind_ubo("camera_curr", &(*velocity.camera_steps[STEP_CURRENT])); accumulate_ps_.bind_ubo("camera_next", &(*velocity.camera_steps[step_next])); @@ -455,7 +455,6 @@ void Film::sync() accumulate_ps_.bind_image("color_accum_img", &color_accum_tx_); accumulate_ps_.bind_image("value_accum_img", &value_accum_tx_); accumulate_ps_.bind_image("cryptomatte_img", &cryptomatte_tx_); - accumulate_ps_.bind_ubo(RBUFS_BUF_SLOT, &inst_.render_buffers.data); /* Sync with rendering passes. */ accumulate_ps_.barrier(GPU_BARRIER_TEXTURE_FETCH | GPU_BARRIER_SHADER_IMAGE_ACCESS); if (use_compute) { @@ -646,7 +645,7 @@ void Film::accumulate(const DRWView *view, GPUTexture *combined_final_tx) combined_final_tx_ = combined_final_tx; data_.display_only = false; - data_.push_update(); + inst_.push_uniform_data(); draw::View drw_view("MainView", view); @@ -675,7 +674,7 @@ void Film::display() combined_final_tx_ = inst_.render_buffers.combined_tx; data_.display_only = true; - data_.push_update(); + inst_.push_uniform_data(); draw::View drw_view("MainView", DRW_view_default_get()); diff --git a/source/blender/draw/engines/eevee_next/eevee_film.hh b/source/blender/draw/engines/eevee_next/eevee_film.hh index 620efcf99d0..5c79f74aff2 100644 --- a/source/blender/draw/engines/eevee_next/eevee_film.hh +++ b/source/blender/draw/engines/eevee_next/eevee_film.hh @@ -75,13 +75,13 @@ class Film { PassSimple accumulate_ps_ = {"Film.Accumulate"}; PassSimple cryptomatte_post_ps_ = {"Film.Cryptomatte.Post"}; - FilmDataBuf data_; + FilmData &data_; int2 display_extent; eViewLayerEEVEEPassType enabled_passes_ = eViewLayerEEVEEPassType(0); public: - Film(Instance &inst) : inst_(inst){}; + Film(Instance &inst, FilmData &data) : inst_(inst), data_(data){}; ~Film(){}; void init(const int2 &full_extent, const rcti *output_rect); diff --git a/source/blender/draw/engines/eevee_next/eevee_hizbuffer.cc b/source/blender/draw/engines/eevee_next/eevee_hizbuffer.cc index 57a198620eb..c1ebad51ff0 100644 --- a/source/blender/draw/engines/eevee_next/eevee_hizbuffer.cc +++ b/source/blender/draw/engines/eevee_next/eevee_hizbuffer.cc @@ -31,7 +31,6 @@ void HiZBuffer::sync() GPU_texture_mipmap_mode(hiz_tx_, true, false); data_.uv_scale = float2(render_extent) / float2(hiz_extent); - data_.push_update(); { hiz_update_ps_.init(); diff --git a/source/blender/draw/engines/eevee_next/eevee_hizbuffer.hh b/source/blender/draw/engines/eevee_next/eevee_hizbuffer.hh index 6fe40250271..e11e423d762 100644 --- a/source/blender/draw/engines/eevee_next/eevee_hizbuffer.hh +++ b/source/blender/draw/engines/eevee_next/eevee_hizbuffer.hh @@ -42,10 +42,10 @@ class HiZBuffer { /** Dirty flag to check if the update is necessary. */ bool is_dirty_ = true; - HiZDataBuf data_; + HiZData &data_; public: - HiZBuffer(Instance &inst) : inst_(inst) + HiZBuffer(Instance &inst, HiZData &data) : inst_(inst), data_(data) { atomic_tile_counter_.clear_to_zero(); }; @@ -72,13 +72,11 @@ class HiZBuffer { void bind_resources(DRWShadingGroup *grp) { DRW_shgroup_uniform_texture_ref(grp, "hiz_tx", &hiz_tx_); - DRW_shgroup_uniform_block_ref(grp, "hiz_buf", &data_); } template void bind_resources(draw::detail::PassBase *pass) { pass->bind_texture(HIZ_TEX_SLOT, &hiz_tx_); - pass->bind_ubo(HIZ_BUF_SLOT, &data_); } }; diff --git a/source/blender/draw/engines/eevee_next/eevee_instance.cc b/source/blender/draw/engines/eevee_next/eevee_instance.cc index 1572acb90ce..f8bc955c9d4 100644 --- a/source/blender/draw/engines/eevee_next/eevee_instance.cc +++ b/source/blender/draw/engines/eevee_next/eevee_instance.cc @@ -280,6 +280,8 @@ void Instance::end_sync() light_probes.end_sync(); reflection_probes.end_sync(); volume.end_sync(); + + global_ubo_.push_update(); } void Instance::render_sync() diff --git a/source/blender/draw/engines/eevee_next/eevee_instance.hh b/source/blender/draw/engines/eevee_next/eevee_instance.hh index e28e0383904..0b303a49598 100644 --- a/source/blender/draw/engines/eevee_next/eevee_instance.hh +++ b/source/blender/draw/engines/eevee_next/eevee_instance.hh @@ -51,6 +51,8 @@ class Instance { friend VelocityModule; friend MotionBlurModule; + UniformDataBuf global_ubo_; + public: ShaderModule &shaders; SyncModule sync; @@ -115,29 +117,29 @@ class Instance { : shaders(*ShaderModule::module_get()), sync(*this), materials(*this), - subsurface(*this), + subsurface(*this, global_ubo_.subsurface), pipelines(*this), shadows(*this), lights(*this), - ambient_occlusion(*this), - raytracing(*this), + ambient_occlusion(*this, global_ubo_.ao), + raytracing(*this, global_ubo_.raytrace), reflection_probes(*this), velocity(*this), motion_blur(*this), depth_of_field(*this), cryptomatte(*this), - hiz_buffer(*this), + hiz_buffer(*this, global_ubo_.hiz), sampling(*this), - camera(*this), - film(*this), - render_buffers(*this), + camera(*this, global_ubo_.camera), + film(*this, global_ubo_.film), + render_buffers(*this, global_ubo_.render_pass), main_view(*this), capture_view(*this), world(*this), lookdev(*this), light_probes(*this), irradiance_cache(*this), - volume(*this){}; + volume(*this, global_ubo_.volumes){}; ~Instance(){}; /* Render & Viewport. */ @@ -216,6 +218,16 @@ class Instance { ((v3d->shading.flag & V3D_SHADING_SCENE_WORLD_RENDER) == 0))); } + void push_uniform_data() + { + global_ubo_.push_update(); + } + + template void bind_uniform_data(draw::detail::PassBase *pass) + { + pass->bind_ubo(UNIFORM_BUF_SLOT, &global_ubo_); + } + private: static void object_sync_render(void *instance_, Object *ob, diff --git a/source/blender/draw/engines/eevee_next/eevee_light.cc b/source/blender/draw/engines/eevee_next/eevee_light.cc index 0a229ce4b46..dd8fe4255c9 100644 --- a/source/blender/draw/engines/eevee_next/eevee_light.cc +++ b/source/blender/draw/engines/eevee_next/eevee_light.cc @@ -417,6 +417,7 @@ void LightModule::debug_pass_sync() debug_draw_ps_.init(); debug_draw_ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_CUSTOM); debug_draw_ps_.shader_set(inst_.shaders.static_shader_get(LIGHT_CULLING_DEBUG)); + inst_.bind_uniform_data(&debug_draw_ps_); inst_.hiz_buffer.bind_resources(&debug_draw_ps_); debug_draw_ps_.bind_ssbo("light_buf", &culling_light_buf_); debug_draw_ps_.bind_ssbo("light_cull_buf", &culling_data_buf_); diff --git a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc index abddbd3838b..8d390874058 100644 --- a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc +++ b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc @@ -43,8 +43,7 @@ void BackgroundPipeline::sync(GPUMaterial *gpumat, const float background_opacit /* Required by validation layers. */ inst_.cryptomatte.bind_resources(&world_ps_); - world_ps_.bind_ubo(CAMERA_BUF_SLOT, inst_.camera.ubo_get()); - world_ps_.bind_ubo(RBUFS_BUF_SLOT, &inst_.render_buffers.data); + inst_.bind_uniform_data(&world_ps_); world_ps_.draw(DRW_cache_fullscreen_quad_get(), handle); /* To allow opaque pass rendering over it. */ @@ -82,8 +81,7 @@ void WorldPipeline::sync(GPUMaterial *gpumat) pass.push_constant("world_opacity_fade", 1.0f); pass.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx); - pass.bind_ubo(CAMERA_BUF_SLOT, inst_.camera.ubo_get()); - pass.bind_ubo(RBUFS_BUF_SLOT, &inst_.render_buffers.data); + inst_.bind_uniform_data(&pass); pass.bind_image("rp_normal_img", dummy_renderpass_tx_); pass.bind_image("rp_light_img", dummy_renderpass_tx_); pass.bind_image("rp_diffuse_color_img", dummy_renderpass_tx_); @@ -118,6 +116,7 @@ void WorldVolumePipeline::sync(GPUMaterial *gpumat) { world_ps_.init(); world_ps_.state_set(DRW_STATE_WRITE_COLOR); + inst_.bind_uniform_data(&world_ps_); inst_.volume.bind_properties_buffers(world_ps_); inst_.sampling.bind_resources(&world_ps_); @@ -152,10 +151,10 @@ void ShadowPipeline::sync() surface_ps_.state_set(DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS); surface_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx); surface_ps_.bind_image(SHADOW_ATLAS_IMG_SLOT, inst_.shadows.atlas_tx_); - surface_ps_.bind_ubo(CAMERA_BUF_SLOT, inst_.camera.ubo_get()); surface_ps_.bind_ssbo(SHADOW_RENDER_MAP_BUF_SLOT, &inst_.shadows.render_map_buf_); surface_ps_.bind_ssbo(SHADOW_VIEWPORT_INDEX_BUF_SLOT, &inst_.shadows.viewport_index_buf_); surface_ps_.bind_ssbo(SHADOW_PAGE_INFO_SLOT, &inst_.shadows.pages_infos_data_); + inst_.bind_uniform_data(&surface_ps_); inst_.sampling.bind_resources(&surface_ps_); } @@ -192,9 +191,8 @@ void ForwardPipeline::sync() /* Textures. */ prepass_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx); - /* Uniform Buffer. */ - prepass_ps_.bind_ubo(CAMERA_BUF_SLOT, inst_.camera.ubo_get()); + inst_.bind_uniform_data(&prepass_ps_); inst_.velocity.bind_resources(&prepass_ps_); inst_.sampling.bind_resources(&prepass_ps_); } @@ -224,16 +222,11 @@ void ForwardPipeline::sync() /* Textures. */ opaque_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx); - /* Uniform Buffer. */ - opaque_ps_.bind_ubo(CAMERA_BUF_SLOT, inst_.camera.ubo_get()); - opaque_ps_.bind_ubo(RBUFS_BUF_SLOT, &inst_.render_buffers.data); - + inst_.bind_uniform_data(&opaque_ps_); inst_.lights.bind_resources(&opaque_ps_); inst_.shadows.bind_resources(&opaque_ps_); inst_.sampling.bind_resources(&opaque_ps_); inst_.hiz_buffer.bind_resources(&opaque_ps_); - inst_.ambient_occlusion.bind_resources(&opaque_ps_); - inst_.cryptomatte.bind_resources(&opaque_ps_); } opaque_single_sided_ps_ = &opaque_ps_.sub("SingleSided"); @@ -253,15 +246,13 @@ void ForwardPipeline::sync() /* Textures. */ sub.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx); - /* Uniform Buffer. */ - sub.bind_ubo(CAMERA_BUF_SLOT, inst_.camera.ubo_get()); + inst_.bind_uniform_data(&sub); inst_.lights.bind_resources(&sub); inst_.shadows.bind_resources(&sub); inst_.volume.bind_resources(sub); inst_.sampling.bind_resources(&sub); inst_.hiz_buffer.bind_resources(&sub); - inst_.ambient_occlusion.bind_resources(&sub); } } @@ -368,9 +359,8 @@ void DeferredLayer::begin_sync() /* Textures. */ prepass_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx); - /* Uniform Buffer. */ - prepass_ps_.bind_ubo(CAMERA_BUF_SLOT, inst_.camera.ubo_get()); + inst_.bind_uniform_data(&prepass_ps_); inst_.velocity.bind_resources(&prepass_ps_); inst_.sampling.bind_resources(&prepass_ps_); } @@ -410,13 +400,10 @@ void DeferredLayer::begin_sync() /* Storage Buffer. */ /* Textures. */ gbuffer_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx); - /* Uniform Buffer. */ - gbuffer_ps_.bind_ubo(CAMERA_BUF_SLOT, inst_.camera.ubo_get()); - gbuffer_ps_.bind_ubo(RBUFS_BUF_SLOT, &inst_.render_buffers.data); + inst_.bind_uniform_data(&gbuffer_ps_); inst_.sampling.bind_resources(&gbuffer_ps_); inst_.hiz_buffer.bind_resources(&gbuffer_ps_); - inst_.ambient_occlusion.bind_resources(&gbuffer_ps_); inst_.cryptomatte.bind_resources(&gbuffer_ps_); } @@ -455,13 +442,12 @@ void DeferredLayer::end_sync() eval_light_ps_.bind_image(RBUFS_COLOR_SLOT, &inst_.render_buffers.rp_color_tx); eval_light_ps_.bind_image(RBUFS_VALUE_SLOT, &inst_.render_buffers.rp_value_tx); eval_light_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx); - eval_light_ps_.bind_ubo(RBUFS_BUF_SLOT, &inst_.render_buffers.data); + inst_.bind_uniform_data(&eval_light_ps_); inst_.lights.bind_resources(&eval_light_ps_); inst_.shadows.bind_resources(&eval_light_ps_); inst_.sampling.bind_resources(&eval_light_ps_); inst_.hiz_buffer.bind_resources(&eval_light_ps_); - inst_.ambient_occlusion.bind_resources(&eval_light_ps_); inst_.reflection_probes.bind_resources(&eval_light_ps_); inst_.irradiance_cache.bind_resources(&eval_light_ps_); @@ -617,6 +603,7 @@ void VolumePipeline::sync() { volume_ps_.init(); volume_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx); + inst_.bind_uniform_data(&volume_ps_); inst_.volume.bind_properties_buffers(volume_ps_); inst_.sampling.bind_resources(&volume_ps_); } @@ -646,9 +633,8 @@ void DeferredProbeLayer::begin_sync() /* Textures. */ prepass_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx); - /* Uniform Buffer. */ - prepass_ps_.bind_ubo(CAMERA_BUF_SLOT, inst_.camera.ubo_get()); + inst_.bind_uniform_data(&prepass_ps_); inst_.velocity.bind_resources(&prepass_ps_); inst_.sampling.bind_resources(&prepass_ps_); } @@ -680,13 +666,10 @@ void DeferredProbeLayer::begin_sync() /* Storage Buffer. */ /* Textures. */ gbuffer_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx); - /* Uniform Buffer. */ - gbuffer_ps_.bind_ubo(CAMERA_BUF_SLOT, inst_.camera.ubo_get()); - gbuffer_ps_.bind_ubo(RBUFS_BUF_SLOT, &inst_.render_buffers.data); + inst_.bind_uniform_data(&gbuffer_ps_); inst_.sampling.bind_resources(&gbuffer_ps_); inst_.hiz_buffer.bind_resources(&gbuffer_ps_); - inst_.ambient_occlusion.bind_resources(&gbuffer_ps_); inst_.cryptomatte.bind_resources(&gbuffer_ps_); } @@ -728,13 +711,12 @@ void DeferredProbeLayer::end_sync() eval_light_ps_.bind_image(RBUFS_COLOR_SLOT, &inst_.render_buffers.rp_color_tx); eval_light_ps_.bind_image(RBUFS_VALUE_SLOT, &inst_.render_buffers.rp_value_tx); eval_light_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx); - eval_light_ps_.bind_ubo(RBUFS_BUF_SLOT, &inst_.render_buffers.data); + inst_.bind_uniform_data(&eval_light_ps_); inst_.lights.bind_resources(&eval_light_ps_); inst_.shadows.bind_resources(&eval_light_ps_); inst_.sampling.bind_resources(&eval_light_ps_); inst_.hiz_buffer.bind_resources(&eval_light_ps_); - inst_.ambient_occlusion.bind_resources(&eval_light_ps_); inst_.reflection_probes.bind_resources(&eval_light_ps_); inst_.irradiance_cache.bind_resources(&eval_light_ps_); @@ -845,8 +827,9 @@ void CapturePipeline::sync() surface_ps_.bind_ssbo(CAPTURE_BUF_SLOT, &inst_.irradiance_cache.bake.capture_info_buf_); surface_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx); - /* TODO(fclem): Remove. There should be no view dependent behavior during capture. */ - surface_ps_.bind_ubo(CAMERA_BUF_SLOT, inst_.camera.ubo_get()); + /* TODO(fclem): Remove. Binded to get the camera data, + * but there should be no view dependent behavior during capture. */ + inst_.bind_uniform_data(&surface_ps_); } PassMain::Sub *CapturePipeline::surface_material_add(GPUMaterial *gpumat) diff --git a/source/blender/draw/engines/eevee_next/eevee_raytrace.cc b/source/blender/draw/engines/eevee_next/eevee_raytrace.cc index ae638a92dd9..e6154666308 100644 --- a/source/blender/draw/engines/eevee_next/eevee_raytrace.cc +++ b/source/blender/draw/engines/eevee_next/eevee_raytrace.cc @@ -48,7 +48,7 @@ void RayTraceModule::sync() pass.bind_image("tile_mask_img", &tile_mask_tx_); pass.bind_ssbo("ray_dispatch_buf", &ray_dispatch_buf_); pass.bind_ssbo("denoise_dispatch_buf", &denoise_dispatch_buf_); - pass.bind_ubo("raytrace_buf", &data_); + inst_.bind_uniform_data(&pass); pass.dispatch(&tile_classify_dispatch_size_); pass.barrier(GPU_BARRIER_SHADER_IMAGE_ACCESS | GPU_BARRIER_SHADER_STORAGE); } @@ -61,7 +61,7 @@ void RayTraceModule::sync() pass.bind_ssbo("denoise_dispatch_buf", &denoise_dispatch_buf_); pass.bind_ssbo("ray_tiles_buf", &ray_tiles_buf_); pass.bind_ssbo("denoise_tiles_buf", &denoise_tiles_buf_); - pass.bind_ubo("raytrace_buf", &data_); + inst_.bind_uniform_data(&pass); pass.dispatch(&tile_compact_dispatch_size_); pass.barrier(GPU_BARRIER_SHADER_STORAGE); } @@ -91,7 +91,7 @@ void RayTraceModule::sync() pass.bind_image("ray_data_img", &ray_data_tx_); pass.bind_image("ray_time_img", &ray_time_tx_); pass.bind_image("ray_radiance_img", &ray_radiance_tx_); - pass.bind_ubo("raytrace_buf", &data_); + inst_.bind_uniform_data(&pass); inst_.hiz_buffer.bind_resources(&pass); inst_.sampling.bind_resources(&pass); inst_.reflection_probes.bind_resources(&pass); @@ -115,7 +115,7 @@ void RayTraceModule::sync() pass.bind_image("out_variance_img", &hit_variance_tx_); pass.bind_image("out_hit_depth_img", &hit_depth_tx_); pass.bind_image("tile_mask_img", &tile_mask_tx_); - pass.bind_ubo("raytrace_buf", &data_); + inst_.bind_uniform_data(&pass); inst_.sampling.bind_resources(&pass); inst_.hiz_buffer.bind_resources(&pass); pass.dispatch(denoise_dispatch_buf_); @@ -125,7 +125,7 @@ void RayTraceModule::sync() PassSimple &pass = denoise_temporal_ps_; pass.init(); pass.shader_set(inst_.shaders.static_shader_get(RAY_DENOISE_TEMPORAL)); - pass.bind_ubo("raytrace_buf", &data_); + inst_.bind_uniform_data(&pass); pass.bind_texture("radiance_history_tx", &radiance_history_tx_); pass.bind_texture("variance_history_tx", &variance_history_tx_); pass.bind_texture("tilemask_history_tx", &tilemask_history_tx_); @@ -151,7 +151,7 @@ void RayTraceModule::sync() pass.bind_image("in_variance_img", &denoise_variance_tx_); pass.bind_image("tile_mask_img", &tile_mask_tx_); pass.bind_ssbo("tiles_coord_buf", &denoise_tiles_buf_); - pass.bind_ubo("raytrace_buf", &data_); + inst_.bind_uniform_data(&pass); inst_.sampling.bind_resources(&pass); inst_.hiz_buffer.bind_resources(&pass); pass.dispatch(denoise_dispatch_buf_); @@ -248,7 +248,7 @@ RayTraceResult RayTraceModule::trace(RayTraceBuffer &rt_buffer, data_.full_resolution = extent; data_.full_resolution_inv = 1.0f / float2(extent); data_.skip_denoise = !use_spatial_denoise; - data_.push_update(); + inst_.push_uniform_data(); tile_mask_tx_.acquire(tile_mask_extent, RAYTRACE_TILEMASK_FORMAT); denoise_tiles_buf_.resize(ceil_to_multiple_u(denoise_tile_count, 512)); diff --git a/source/blender/draw/engines/eevee_next/eevee_raytrace.hh b/source/blender/draw/engines/eevee_next/eevee_raytrace.hh index 455b9501fd8..623728c874e 100644 --- a/source/blender/draw/engines/eevee_next/eevee_raytrace.hh +++ b/source/blender/draw/engines/eevee_next/eevee_raytrace.hh @@ -159,10 +159,10 @@ class RayTraceModule { RaytraceEEVEE reflection_options_; RaytraceEEVEE refraction_options_; - RayTraceDataBuf data_; + RayTraceData &data_; public: - RayTraceModule(Instance &inst) : inst_(inst){}; + RayTraceModule(Instance &inst, RayTraceData &data) : inst_(inst), data_(data){}; void init(); diff --git a/source/blender/draw/engines/eevee_next/eevee_renderbuffers.cc b/source/blender/draw/engines/eevee_next/eevee_renderbuffers.cc index 98d48bf333f..77497747a62 100644 --- a/source/blender/draw/engines/eevee_next/eevee_renderbuffers.cc +++ b/source/blender/draw/engines/eevee_next/eevee_renderbuffers.cc @@ -51,7 +51,6 @@ void RenderBuffers::sync() data.ambient_occlusion_id = pass_index_get(EEVEE_RENDER_PASS_AO); data.aovs = inst_.film.aovs_info; - data.push_update(); } void RenderBuffers::acquire(int2 extent) diff --git a/source/blender/draw/engines/eevee_next/eevee_renderbuffers.hh b/source/blender/draw/engines/eevee_next/eevee_renderbuffers.hh index 0c7471c3cf4..13500eea399 100644 --- a/source/blender/draw/engines/eevee_next/eevee_renderbuffers.hh +++ b/source/blender/draw/engines/eevee_next/eevee_renderbuffers.hh @@ -22,7 +22,7 @@ class Instance; class RenderBuffers { public: - UniformBuffer data; + RenderBuffersInfoData &data; Texture depth_tx; TextureFromPool combined_tx; @@ -38,7 +38,7 @@ class RenderBuffers { Instance &inst_; public: - RenderBuffers(Instance &inst) : inst_(inst){}; + RenderBuffers(Instance &inst, RenderBuffersInfoData &data) : data(data), inst_(inst){}; /** WARNING: RenderBuffers and Film use different storage types for AO and Shadow. */ static ePassStorageType pass_storage_type(eViewLayerEEVEEPassType pass_type) diff --git a/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh b/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh index 90ecedad75f..a91ac421593 100644 --- a/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh +++ b/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh @@ -1164,6 +1164,9 @@ struct RayTraceData { bool1 skip_denoise; /** Closure being ray-traced. */ eClosureBits closure_active; + int _pad0; + int _pad1; + int _pad2; }; BLI_STATIC_ASSERT_ALIGN(RayTraceData, 16) @@ -1249,6 +1252,25 @@ BLI_STATIC_ASSERT_ALIGN(ReflectionProbeData, 16) /** \} */ +/* -------------------------------------------------------------------- */ +/** \name Uniform Data + * \{ */ + +/* Combines data from several modules to avoid wasting binding slots. */ +struct UniformData { + AOData ao; + CameraData camera; + FilmData film; + HiZData hiz; + RayTraceData raytrace; + RenderBuffersInfoData render_pass; + SubsurfaceData subsurface; + VolumesInfoData volumes; +}; +BLI_STATIC_ASSERT_ALIGN(UniformData, 16) + +/** \} */ + /* -------------------------------------------------------------------- */ /** \name Utility Texture * \{ */ @@ -1313,8 +1335,7 @@ using DepthOfFieldDataBuf = draw::UniformBuffer; using DepthOfFieldScatterListBuf = draw::StorageArrayBuffer; using DrawIndirectBuf = draw::StorageBuffer; using DispatchIndirectBuf = draw::StorageBuffer; -using FilmDataBuf = draw::UniformBuffer; -using HiZDataBuf = draw::UniformBuffer; +using UniformDataBuf = draw::UniformBuffer; using IrradianceGridDataBuf = draw::UniformArrayBuffer; using IrradianceBrickBuf = draw::StorageVectorBuffer; using LightCullingDataBuf = draw::StorageBuffer; @@ -1326,7 +1347,6 @@ using LightDataBuf = draw::StorageArrayBuffer; using MotionBlurDataBuf = draw::UniformBuffer; using MotionBlurTileIndirectionBuf = draw::StorageBuffer; using RayTraceTileBuf = draw::StorageArrayBuffer; -using RayTraceDataBuf = draw::UniformBuffer; using ReflectionProbeDataBuf = draw::UniformArrayBuffer; using SamplingDataBuf = draw::StorageBuffer; @@ -1337,7 +1357,6 @@ using ShadowPageCacheBuf = draw::StorageArrayBuffer; using ShadowTileMapClipBuf = draw::StorageArrayBuffer; using ShadowTileDataBuf = draw::StorageArrayBuffer; -using SubsurfaceDataBuf = draw::UniformBuffer; using SurfelBuf = draw::StorageArrayBuffer; using SurfelRadianceBuf = draw::StorageArrayBuffer; using CaptureInfoBuf = draw::StorageBuffer; @@ -1345,9 +1364,7 @@ using SurfelListInfoBuf = draw::StorageBuffer; using VelocityGeometryBuf = draw::StorageArrayBuffer; using VelocityIndexBuf = draw::StorageArrayBuffer; using VelocityObjectBuf = draw::StorageArrayBuffer; -using VolumesInfoDataBuf = draw::UniformBuffer; using CryptomatteObjectBuf = draw::StorageArrayBuffer; -using AODataBuf = draw::UniformBuffer; } // namespace blender::eevee #endif diff --git a/source/blender/draw/engines/eevee_next/eevee_shadow.cc b/source/blender/draw/engines/eevee_next/eevee_shadow.cc index 34d5e32b7f7..f7b064754cb 100644 --- a/source/blender/draw/engines/eevee_next/eevee_shadow.cc +++ b/source/blender/draw/engines/eevee_next/eevee_shadow.cc @@ -780,6 +780,7 @@ void ShadowModule::begin_sync() sub.push_constant("pixel_world_radius", &pixel_world_radius_); sub.push_constant("fb_resolution", &usage_tag_fb_resolution_); sub.push_constant("fb_lod", &usage_tag_fb_lod_); + inst_.bind_uniform_data(&sub); inst_.hiz_buffer.bind_resources(&sub); inst_.lights.bind_resources(&sub); @@ -981,6 +982,7 @@ void ShadowModule::end_sync() sub.bind_ssbo("tilemaps_buf", &tilemap_pool.tilemaps_data); sub.bind_ssbo("tiles_buf", &tilemap_pool.tiles_data); sub.push_constant("tilemap_projection_ratio", &tilemap_projection_ratio_); + inst_.bind_uniform_data(&sub); inst_.hiz_buffer.bind_resources(&sub); inst_.sampling.bind_resources(&sub); inst_.lights.bind_resources(&sub); @@ -1121,6 +1123,7 @@ void ShadowModule::debug_end_sync() debug_draw_ps_.push_constant("debug_tilemap_index", light.tilemap_index); debug_draw_ps_.bind_ssbo("tilemaps_buf", &tilemap_pool.tilemaps_data); debug_draw_ps_.bind_ssbo("tiles_buf", &tilemap_pool.tiles_data); + inst_.bind_uniform_data(&debug_draw_ps_); inst_.hiz_buffer.bind_resources(&debug_draw_ps_); inst_.lights.bind_resources(&debug_draw_ps_); inst_.shadows.bind_resources(&debug_draw_ps_); diff --git a/source/blender/draw/engines/eevee_next/eevee_subsurface.cc b/source/blender/draw/engines/eevee_next/eevee_subsurface.cc index 6de262ef82a..e2741d07ff8 100644 --- a/source/blender/draw/engines/eevee_next/eevee_subsurface.cc +++ b/source/blender/draw/engines/eevee_next/eevee_subsurface.cc @@ -31,19 +31,16 @@ void SubsurfaceModule::end_sync() precompute_samples_location(); - data_.push_update(); - subsurface_ps_.init(); subsurface_ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_STENCIL_EQUAL | DRW_STATE_BLEND_ADD_FULL); subsurface_ps_.state_stencil(0x00u, 0xFFu, CLOSURE_SSS); subsurface_ps_.shader_set(inst_.shaders.static_shader_get(SUBSURFACE_EVAL)); - inst_.subsurface.bind_resources(&subsurface_ps_); + inst_.bind_uniform_data(&subsurface_ps_); inst_.hiz_buffer.bind_resources(&subsurface_ps_); subsurface_ps_.bind_texture("radiance_tx", &diffuse_light_tx_); subsurface_ps_.bind_texture("gbuffer_closure_tx", &inst_.gbuffer.closure_tx); subsurface_ps_.bind_texture("gbuffer_color_tx", &inst_.gbuffer.color_tx); - subsurface_ps_.bind_ubo(RBUFS_BUF_SLOT, &inst_.render_buffers.data); subsurface_ps_.bind_image(RBUFS_COLOR_SLOT, &inst_.render_buffers.rp_color_tx); /** NOTE: Not used in the shader, but we bind it to avoid debug warnings. */ subsurface_ps_.bind_image(RBUFS_VALUE_SLOT, &inst_.render_buffers.rp_value_tx); diff --git a/source/blender/draw/engines/eevee_next/eevee_subsurface.hh b/source/blender/draw/engines/eevee_next/eevee_subsurface.hh index 1819ca743bb..2433ba1ce78 100644 --- a/source/blender/draw/engines/eevee_next/eevee_subsurface.hh +++ b/source/blender/draw/engines/eevee_next/eevee_subsurface.hh @@ -34,14 +34,14 @@ struct SubsurfaceModule { private: Instance &inst_; /** Contains samples locations. */ - SubsurfaceDataBuf data_; + SubsurfaceData &data_; /** Scene diffuse irradiance. Pointer binded at sync time, set at render time. */ GPUTexture *diffuse_light_tx_; /** Subsurface eval pass. Runs after the deferred pass. */ PassSimple subsurface_ps_ = {"Subsurface"}; public: - SubsurfaceModule(Instance &inst) : inst_(inst) + SubsurfaceModule(Instance &inst, SubsurfaceData &data) : inst_(inst), data_(data) { /* Force first update. */ data_.sample_len = -1; @@ -56,11 +56,6 @@ struct SubsurfaceModule { void render(View &view, Framebuffer &fb, Texture &diffuse_light_tx); - template void bind_resources(draw::detail::PassBase *pass) - { - pass->bind_ubo("sss_buf", data_); - } - private: void precompute_samples_location(); diff --git a/source/blender/draw/engines/eevee_next/eevee_volume.cc b/source/blender/draw/engines/eevee_next/eevee_volume.cc index ca534830cb0..d64d5b6c4bd 100644 --- a/source/blender/draw/engines/eevee_next/eevee_volume.cc +++ b/source/blender/draw/engines/eevee_next/eevee_volume.cc @@ -22,7 +22,7 @@ namespace blender::eevee { -bool VolumeModule::GridAABB::init(Object *ob, const Camera &camera, const VolumesInfoDataBuf &data) +bool VolumeModule::GridAABB::init(Object *ob, const Camera &camera, const VolumesInfoData &data) { /* Returns the unified volume grid cell index of a world space coordinate. */ auto to_global_grid_coords = [&](float3 wP) -> int3 { @@ -149,8 +149,6 @@ void VolumeModule::begin_sync() data_.depth_distribution = 1.0f / (integration_end - integration_start); } - data_.push_update(); - enabled_ = inst_.world.has_volume(); } @@ -272,7 +270,7 @@ void VolumeModule::end_sync() integration_ps_.init(); integration_ps_.shader_set(inst_.shaders.static_shader_get(VOLUME_INTEGRATION)); - integration_ps_.bind_ubo(VOLUMES_INFO_BUF_SLOT, data_); + inst_.bind_uniform_data(&integration_ps_); integration_ps_.bind_texture("in_scattering_tx", &scatter_tx_); integration_ps_.bind_texture("in_extinction_tx", &extinction_tx_); integration_ps_.bind_image("out_scattering_img", &integrated_scatter_tx_); @@ -285,9 +283,9 @@ void VolumeModule::end_sync() resolve_ps_.init(); resolve_ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_CUSTOM); resolve_ps_.shader_set(inst_.shaders.static_shader_get(VOLUME_RESOLVE)); + inst_.bind_uniform_data(&resolve_ps_); bind_resources(resolve_ps_); resolve_ps_.bind_texture("depth_tx", &inst_.render_buffers.depth_tx); - resolve_ps_.bind_ubo(RBUFS_BUF_SLOT, &inst_.render_buffers.data); resolve_ps_.bind_image(RBUFS_COLOR_SLOT, &inst_.render_buffers.rp_color_tx); /* Sync with the integration pass. */ resolve_ps_.barrier(GPU_BARRIER_TEXTURE_FETCH); diff --git a/source/blender/draw/engines/eevee_next/eevee_volume.hh b/source/blender/draw/engines/eevee_next/eevee_volume.hh index 5c9c0509c8d..98ba84afc5c 100644 --- a/source/blender/draw/engines/eevee_next/eevee_volume.hh +++ b/source/blender/draw/engines/eevee_next/eevee_volume.hh @@ -47,7 +47,7 @@ class VolumeModule { bool enabled_; - VolumesInfoDataBuf data_; + VolumesInfoData &data_; /* Material Parameters */ Texture prop_scattering_tx_; @@ -82,7 +82,7 @@ class VolumeModule { int3 min, max; /* Returns true if visible. */ - bool init(Object *ob, const Camera &camera, const VolumesInfoDataBuf &data); + bool init(Object *ob, const Camera &camera, const VolumesInfoData &data); bool overlaps(const GridAABB &aabb); }; @@ -92,7 +92,7 @@ class VolumeModule { Map> subpass_aabbs_; public: - VolumeModule(Instance &inst) : inst_(inst) + VolumeModule(Instance &inst, VolumesInfoData &data) : inst_(inst), data_(data) { dummy_scatter_tx_.ensure_3d(GPU_RGBA8, int3(1), GPU_TEXTURE_USAGE_SHADER_READ, float4(0.0f)); dummy_transmit_tx_.ensure_3d(GPU_RGBA8, int3(1), GPU_TEXTURE_USAGE_SHADER_READ, float4(1.0f)); @@ -103,7 +103,6 @@ class VolumeModule { /* Bind resources needed by external passes to perform their own resolve. */ template void bind_resources(PassType &ps) { - ps.bind_ubo(VOLUMES_INFO_BUF_SLOT, data_); ps.bind_texture(VOLUME_SCATTERING_TEX_SLOT, &transparent_pass_scatter_tx_); ps.bind_texture(VOLUME_TRANSMITTANCE_TEX_SLOT, &transparent_pass_transmit_tx_); } @@ -111,7 +110,6 @@ class VolumeModule { /* Bind the common resources needed by all volumetric passes. */ template void bind_properties_buffers(PassType &ps) { - ps.bind_ubo(VOLUMES_INFO_BUF_SLOT, &data_); ps.bind_image(VOLUME_PROP_SCATTERING_IMG_SLOT, &prop_scattering_tx_); ps.bind_image(VOLUME_PROP_EXTINCTION_IMG_SLOT, &prop_extinction_tx_); ps.bind_image(VOLUME_PROP_EMISSION_IMG_SLOT, &prop_emission_tx_); diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_ambient_occlusion_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_ambient_occlusion_lib.glsl index f351b197d29..60e2ad503c6 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_ambient_occlusion_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_ambient_occlusion_lib.glsl @@ -102,10 +102,10 @@ float ambient_ambient_occlusion_search_horizon(vec3 vI, /* Gives us good precision at center and ensure we cross at least one pixel per iteration. */ time = 1.0 + iter + sqr((iter + noise) / sample_count) * ssray.max_time; float stride = time - prev_time; - float lod = (log2(stride) - noise) / (1.0 + ao_buf.quality); + float lod = (log2(stride) - noise) / (1.0 + uniform_buf.ao.quality); vec2 uv = ssray.origin.xy + ssray.direction.xy * time; - float depth = textureLod(depth_tx, uv * hiz_buf.uv_scale, floor(lod)).r; + float depth = textureLod(depth_tx, uv * uniform_buf.hiz.uv_scale, floor(lod)).r; if (depth == 1.0 && inverted == 0.0) { /* Skip background. Avoids making shadow on the geometry near the far plane. */ @@ -163,13 +163,13 @@ OcclusionData ambient_occlusion_search(vec3 vP, ScreenSpaceRay ssray; - ssray = raytrace_screenspace_ray_create(ray, ao_buf.pixel_size); + ssray = raytrace_screenspace_ray_create(ray, uniform_buf.ao.pixel_size); data.horizons[0 + i * 2] = ambient_ambient_occlusion_search_horizon( vI, vP, noise.y, ssray, depth_tx, inverted, radius, dir_sample_count); ray.direction = -ray.direction; - ssray = raytrace_screenspace_ray_create(ray, ao_buf.pixel_size); + ssray = raytrace_screenspace_ray_create(ray, uniform_buf.ao.pixel_size); data.horizons[1 + i * 2] = -ambient_ambient_occlusion_search_horizon( vI, vP, noise.y, ssray, depth_tx, inverted, radius, dir_sample_count); diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_ambient_occlusion_pass_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_ambient_occlusion_pass_comp.glsl index 697204dc516..48fdc7897f8 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_ambient_occlusion_pass_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_ambient_occlusion_pass_comp.glsl @@ -81,7 +81,7 @@ void main() vec3 Ng = transform_direction(ViewMatrixInverse, vNg); vec3 N = imageLoad(in_normal_img, ivec3(texel, in_normal_img_layer_index)).xyz; - OcclusionData data = ambient_occlusion_search(vP, hiz_tx, texel, ao_buf.distance, 0.0, 8.0); + OcclusionData data = ambient_occlusion_search(vP, hiz_tx, texel, uniform_buf.ao.distance, 0.0, 8.0); float visibility; float visibility_error_out; diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_cryptomatte_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_cryptomatte_lib.glsl index 4eea35cc208..706b9365941 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_cryptomatte_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_cryptomatte_lib.glsl @@ -45,7 +45,7 @@ void cryptomatte_store_film_sample(FilmSample dst, if (crypto_sample.y == 0.0) { return; } - for (int i = 0; i < film_buf.cryptomatte_samples_len / 2; i++) { + for (int i = 0; i < uniform_buf.film.cryptomatte_samples_len / 2; i++) { ivec3 img_co = ivec3(dst.texel, cryptomatte_layer_id + i); vec4 sample_pair = imageLoad(cryptomatte_img, img_co); if (cryptomatte_can_merge_sample(sample_pair.xy, crypto_sample)) { @@ -60,7 +60,7 @@ void cryptomatte_store_film_sample(FilmSample dst, else if (cryptomatte_can_merge_sample(sample_pair.zw, crypto_sample)) { sample_pair.zw = cryptomatte_merge_sample(sample_pair.zw, crypto_sample); } - else if (i == film_buf.cryptomatte_samples_len / 2 - 1) { + else if (i == uniform_buf.film.cryptomatte_samples_len / 2 - 1) { /* TODO(jbakker): New hash detected, but there is no space left to store it. Currently we * will ignore this sample, but ideally we could replace a sample with a lowest weight. */ continue; diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_deferred_light_frag.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_deferred_light_frag.glsl index 6c35f9a62b5..54e80476430 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_deferred_light_frag.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_deferred_light_frag.glsl @@ -91,15 +91,15 @@ void main() diffuse_data.color = is_refraction ? vec3(0.0) : gbuffer_color_unpack(color_1_packed); /* Light passes. */ - if (rp_buf.diffuse_light_id >= 0) { - imageStore(rp_color_img, ivec3(texel, rp_buf.diffuse_light_id), vec4(diffuse_light, 1.0)); + if (uniform_buf.render_pass.diffuse_light_id >= 0) { + imageStore(rp_color_img, ivec3(texel, uniform_buf.render_pass.diffuse_light_id), vec4(diffuse_light, 1.0)); } - if (rp_buf.specular_light_id >= 0) { + if (uniform_buf.render_pass.specular_light_id >= 0) { vec3 specular_light = reflection_light + refraction_light; - imageStore(rp_color_img, ivec3(texel, rp_buf.specular_light_id), vec4(specular_light, 1.0)); + imageStore(rp_color_img, ivec3(texel, uniform_buf.render_pass.specular_light_id), vec4(specular_light, 1.0)); } - if (rp_buf.shadow_id >= 0) { - imageStore(rp_value_img, ivec3(texel, rp_buf.shadow_id), vec4(shadow)); + if (uniform_buf.render_pass.shadow_id >= 0) { + imageStore(rp_value_img, ivec3(texel, uniform_buf.render_pass.shadow_id), vec4(shadow)); } if (!is_last_eval_pass) { diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_depth_of_field_stabilize_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_depth_of_field_stabilize_comp.glsl index 4c6952e5e5d..5323e742242 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_depth_of_field_stabilize_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_depth_of_field_stabilize_comp.glsl @@ -249,9 +249,9 @@ DofSample dof_sample_history(vec2 input_texel) /* Slide 92. */ vec2 weight_12 = weights[1] + weights[2]; - vec2 uv_12 = (center_texel + weights[2] / weight_12) * film_buf.extent_inv; - vec2 uv_0 = (center_texel - 1.0) * film_buf.extent_inv; - vec2 uv_3 = (center_texel + 2.0) * film_buf.extent_inv; + vec2 uv_12 = (center_texel + weights[2] / weight_12) * uniform_buf.film.extent_inv; + vec2 uv_0 = (center_texel - 1.0) * uniform_buf.film.extent_inv; + vec2 uv_3 = (center_texel + 2.0) * uniform_buf.film.extent_inv; vec4 color; vec4 weight_cross = weight_12.xyyx * vec4(weights[0].yx, weights[3].xy); diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_film_frag.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_film_frag.glsl index ee244eb22f9..4d1681ba7ef 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_film_frag.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_film_frag.glsl @@ -7,25 +7,25 @@ void main() { - ivec2 texel_film = ivec2(gl_FragCoord.xy) - film_buf.offset; + ivec2 texel_film = ivec2(gl_FragCoord.xy) - uniform_buf.film.offset; float out_depth; - if (film_buf.display_only) { + if (uniform_buf.film.display_only) { out_depth = imageLoad(depth_img, texel_film).r; - if (film_buf.display_id == -1) { + if (uniform_buf.film.display_id == -1) { out_color = texelFetch(in_combined_tx, texel_film, 0); } - else if (film_buf.display_storage_type == PASS_STORAGE_VALUE) { - out_color.rgb = imageLoad(value_accum_img, ivec3(texel_film, film_buf.display_id)).rrr; + else if (uniform_buf.film.display_storage_type == PASS_STORAGE_VALUE) { + out_color.rgb = imageLoad(value_accum_img, ivec3(texel_film, uniform_buf.film.display_id)).rrr; out_color.a = 1.0; } - else if (film_buf.display_storage_type == PASS_STORAGE_COLOR) { - out_color = imageLoad(color_accum_img, ivec3(texel_film, film_buf.display_id)); + else if (uniform_buf.film.display_storage_type == PASS_STORAGE_COLOR) { + out_color = imageLoad(color_accum_img, ivec3(texel_film, uniform_buf.film.display_id)); } else /* PASS_STORAGE_CRYPTOMATTE */ { out_color = cryptomatte_false_color( - imageLoad(cryptomatte_img, ivec3(texel_film, film_buf.display_id)).r); + imageLoad(cryptomatte_img, ivec3(texel_film, uniform_buf.film.display_id)).r); } } else { diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_film_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_film_lib.glsl index b080f463659..c577b7ee3a7 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_film_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_film_lib.glsl @@ -39,7 +39,7 @@ float film_luma_weight(float luma) { /* Slide 20 of "High Quality Temporal Supersampling" by Brian Karis at Siggraph 2014. */ /* To preserve more details in dark areas, we use a bigger bias. */ - return 1.0 / (4.0 + luma * film_buf.exposure_scale); + return 1.0 / (4.0 + luma * uniform_buf.film.exposure_scale); } /* -------------------------------------------------------------------- */ @@ -55,21 +55,21 @@ FilmSample film_sample_get(int sample_n, ivec2 texel_film) #else # ifdef SCALED_RENDERING - texel_film /= film_buf.scaling_factor; + texel_film /= uniform_buf.film.scaling_factor; # endif - FilmSample film_sample = film_buf.samples[sample_n]; - film_sample.texel += texel_film + film_buf.render_offset; + FilmSample film_sample = uniform_buf.film.samples[sample_n]; + film_sample.texel += texel_film + uniform_buf.film.render_offset; /* Use extend on borders. */ - film_sample.texel = clamp(film_sample.texel, ivec2(0, 0), film_buf.render_extent - 1); + film_sample.texel = clamp(film_sample.texel, ivec2(0, 0), uniform_buf.film.render_extent - 1); /* TODO(fclem): Panoramic projection will need to compute the sample weight in the shader * instead of precomputing it on CPU. */ # ifdef SCALED_RENDERING /* We need to compute the real distance and weight since a sample * can be used by many final pixel. */ - vec2 offset = film_buf.subpixel_offset - vec2(texel_film % film_buf.scaling_factor); - film_sample.weight = film_filter_weight(film_buf.filter_size, len_squared(offset)); + vec2 offset = uniform_buf.film.subpixel_offset - vec2(texel_film % uniform_buf.film.scaling_factor); + film_sample.weight = film_filter_weight(uniform_buf.film.filter_size, len_squared(offset)); # endif #endif /* PANORAMIC */ @@ -85,12 +85,12 @@ float film_weight_accumulation(ivec2 texel_film) { #if 0 /* TODO(fclem): Reference implementation, also needed for panoramic cameras. */ float weight = 0.0; - for (int i = 0; i < film_buf.samples_len; i++) { + for (int i = 0; i < uniform_buf.film.samples_len; i++) { weight += film_sample_get(i, texel_film).weight; } return weight; #endif - return film_buf.samples_weight_total; + return uniform_buf.film.samples_weight_total; } void film_sample_accum( @@ -113,7 +113,7 @@ void film_sample_accum( void film_sample_accum_mist(FilmSample samp, inout float accum) { - if (film_buf.mist_id == -1) { + if (uniform_buf.film.mist_id == -1) { return; } float depth = texelFetch(depth_tx, samp.texel, 0).x; @@ -122,15 +122,15 @@ void film_sample_accum_mist(FilmSample samp, inout float accum) bool is_persp = ProjectionMatrix[3][3] == 0.0; float mist = (is_persp) ? length(vP) : abs(vP.z); /* Remap to 0..1 range. */ - mist = saturate(mist * film_buf.mist_scale + film_buf.mist_bias); + mist = saturate(mist * uniform_buf.film.mist_scale + uniform_buf.film.mist_bias); /* Falloff. */ - mist = pow(mist, film_buf.mist_exponent); + mist = pow(mist, uniform_buf.film.mist_exponent); accum += mist * samp.weight; } void film_sample_accum_combined(FilmSample samp, inout vec4 accum, inout float weight_accum) { - if (film_buf.combined_id == -1) { + if (uniform_buf.film.combined_id == -1) { return; } vec4 color = film_texelfetch_as_YCoCg_opacity(combined_tx, samp.texel); @@ -179,7 +179,7 @@ void film_cryptomatte_layer_accum_and_store( } /* x = hash, y = accumulated weight. Only keep track of 4 highest weighted samples. */ vec2 crypto_samples[4] = vec2[4](vec2(0.0), vec2(0.0), vec2(0.0), vec2(0.0)); - for (int i = 0; i < film_buf.samples_len; i++) { + for (int i = 0; i < uniform_buf.film.samples_len; i++) { FilmSample src = film_sample_get(i, texel_film); film_sample_cryptomatte_accum(src, layer_component, cryptomatte_tx, crypto_samples); } @@ -200,7 +200,7 @@ float film_distance_load(ivec2 texel) /* Repeat texture coordinates as the weight can be optimized to a small portion of the film. */ texel = texel % imageSize(in_weight_img).xy; - if (!film_buf.use_history || film_buf.use_reprojection) { + if (!uniform_buf.film.use_history || uniform_buf.film.use_reprojection) { return 1.0e16; } return imageLoad(in_weight_img, ivec3(texel, FILM_WEIGHT_LAYER_DISTANCE)).x; @@ -211,7 +211,7 @@ float film_weight_load(ivec2 texel) /* Repeat texture coordinates as the weight can be optimized to a small portion of the film. */ texel = texel % imageSize(in_weight_img).xy; - if (!film_buf.use_history || film_buf.use_reprojection) { + if (!uniform_buf.film.use_history || uniform_buf.film.use_reprojection) { return 0.0; } return imageLoad(in_weight_img, ivec3(texel, FILM_WEIGHT_LAYER_ACCUMULATION)).x; @@ -239,7 +239,7 @@ vec2 film_pixel_history_motion_vector(ivec2 texel_sample) vec4 vector = velocity_resolve(vector_tx, nearest_texel, min_depth); /* Transform to pixel space. */ - vector.xy *= vec2(film_buf.extent); + vector.xy *= vec2(uniform_buf.film.extent); return vector.xy; } @@ -297,9 +297,9 @@ vec4 film_sample_catmull_rom(sampler2D color_tx, vec2 input_texel) /* Slide 92. */ vec2 weight_12 = weights[1] + weights[2]; - vec2 uv_12 = (center_texel + weights[2] / weight_12) * film_buf.extent_inv; - vec2 uv_0 = (center_texel - 1.0) * film_buf.extent_inv; - vec2 uv_3 = (center_texel + 2.0) * film_buf.extent_inv; + vec2 uv_12 = (center_texel + weights[2] / weight_12) * uniform_buf.film.extent_inv; + vec2 uv_0 = (center_texel - 1.0) * uniform_buf.film.extent_inv; + vec2 uv_3 = (center_texel + 2.0) * uniform_buf.film.extent_inv; vec4 color; vec4 weight_cross = weight_12.xyyx * vec4(weights[0].yx, weights[3].xy); @@ -430,11 +430,11 @@ float film_history_blend_factor(float velocity, /* Linearly blend when history gets below to 25% of the bbox size. */ blend *= saturate(distance_to_luma_clip * 4.0 + 0.1); /* Discard out of view history. */ - if (any(lessThan(texel, vec2(0))) || any(greaterThanEqual(texel, vec2(film_buf.extent)))) { + if (any(lessThan(texel, vec2(0))) || any(greaterThanEqual(texel, vec2(uniform_buf.film.extent)))) { blend = 1.0; } /* Discard history if invalid. */ - if (film_buf.use_history == false) { + if (uniform_buf.film.use_history == false) { blend = 1.0; } return blend; @@ -444,7 +444,7 @@ float film_history_blend_factor(float velocity, void film_store_combined( FilmSample dst, ivec2 src_texel, vec4 color, float color_weight, inout vec4 display) { - if (film_buf.combined_id == -1) { + if (uniform_buf.film.combined_id == -1) { return; } @@ -454,7 +454,7 @@ void film_store_combined( /* Undo the weighting to get final spatially-filtered color. */ color_src = color / color_weight; - if (film_buf.use_reprojection) { + if (uniform_buf.film.use_reprojection) { /* Interactive accumulation. Do reprojection and Temporal Anti-Aliasing. */ /* Reproject by finding where this pixel was in the previous frame. */ @@ -507,7 +507,7 @@ void film_store_combined( color = vec4(0.0, 0.0, 0.0, 1.0); } - if (film_buf.display_id == -1) { + if (uniform_buf.film.display_id == -1) { display = color; } imageStore(out_combined_img, dst.texel, color); @@ -528,7 +528,7 @@ void film_store_color(FilmSample dst, int pass_id, vec4 color, inout vec4 displa color = vec4(0.0, 0.0, 0.0, 1.0); } - if (film_buf.display_id == pass_id) { + if (uniform_buf.film.display_id == pass_id) { display = color; } imageStore(color_accum_img, ivec3(dst.texel, pass_id), color); @@ -549,7 +549,7 @@ void film_store_value(FilmSample dst, int pass_id, float value, inout vec4 displ value = 0.0; } - if (film_buf.display_id == pass_id) { + if (uniform_buf.film.display_id == pass_id) { display = vec4(value, value, value, 1.0); } imageStore(value_accum_img, ivec3(dst.texel, pass_id), vec4(value)); @@ -562,7 +562,7 @@ void film_store_data(ivec2 texel_film, int pass_id, vec4 data_sample, inout vec4 return; } - if (film_buf.display_id == pass_id) { + if (uniform_buf.film.display_id == pass_id) { display = data_sample; } imageStore(color_accum_img, ivec3(texel_film, pass_id), data_sample); @@ -570,7 +570,7 @@ void film_store_data(ivec2 texel_film, int pass_id, vec4 data_sample, inout vec4 void film_store_depth(ivec2 texel_film, float value, out float out_depth) { - if (film_buf.depth_id == -1) { + if (uniform_buf.film.depth_id == -1) { return; } @@ -624,13 +624,13 @@ void film_process_data(ivec2 texel_film, out vec4 out_color, out float out_depth /* NOTE: We split the accumulations into separate loops to avoid using too much registers and * maximize occupancy. */ - if (film_buf.combined_id != -1) { + if (uniform_buf.film.combined_id != -1) { /* NOTE: Do weight accumulation again since we use custom weights. */ float weight_accum = 0.0; vec4 combined_accum = vec4(0.0); FilmSample src; - for (int i = film_buf.samples_len - 1; i >= 0; i--) { + for (int i = uniform_buf.film.samples_len - 1; i >= 0; i--) { src = film_sample_get(i, texel_film); film_sample_accum_combined(src, combined_accum, weight_accum); } @@ -638,62 +638,62 @@ void film_process_data(ivec2 texel_film, out vec4 out_color, out float out_depth film_store_combined(dst, src.texel, combined_accum, weight_accum, out_color); } - if (film_buf.has_data) { + if (uniform_buf.film.has_data) { float film_distance = film_distance_load(texel_film); /* Get sample closest to target texel. It is always sample 0. */ FilmSample film_sample = film_sample_get(0, texel_film); - if (film_buf.use_reprojection || film_sample.weight < film_distance) { - vec4 normal = texelFetch(rp_color_tx, ivec3(film_sample.texel, rp_buf.normal_id), 0); + if (uniform_buf.film.use_reprojection || film_sample.weight < film_distance) { + vec4 normal = texelFetch(rp_color_tx, ivec3(film_sample.texel, uniform_buf.render_pass.normal_id), 0); float depth = texelFetch(depth_tx, film_sample.texel, 0).x; vec4 vector = velocity_resolve(vector_tx, film_sample.texel, depth); /* Transform to pixel space. */ - vector *= vec4(vec2(film_buf.render_extent), -vec2(film_buf.render_extent)); + vector *= vec4(vec2(uniform_buf.film.render_extent), -vec2(uniform_buf.film.render_extent)); film_store_depth(texel_film, depth, out_depth); - film_store_data(texel_film, film_buf.normal_id, normal, out_color); - film_store_data(texel_film, film_buf.vector_id, vector, out_color); + film_store_data(texel_film, uniform_buf.film.normal_id, normal, out_color); + film_store_data(texel_film, uniform_buf.film.vector_id, vector, out_color); film_store_distance(texel_film, film_sample.weight); } else { out_depth = imageLoad(depth_img, texel_film).r; - if (film_buf.display_id != -1 && film_buf.display_id == film_buf.normal_id) { - out_color = imageLoad(color_accum_img, ivec3(texel_film, film_buf.display_id)); + if (uniform_buf.film.display_id != -1 && uniform_buf.film.display_id == uniform_buf.film.normal_id) { + out_color = imageLoad(color_accum_img, ivec3(texel_film, uniform_buf.film.display_id)); } } } - if (film_buf.any_render_pass_1) { + if (uniform_buf.film.any_render_pass_1) { vec4 diffuse_light_accum = vec4(0.0); vec4 specular_light_accum = vec4(0.0); vec4 volume_light_accum = vec4(0.0); vec4 emission_accum = vec4(0.0); - for (int i = 0; i < film_buf.samples_len; i++) { + for (int i = 0; i < uniform_buf.film.samples_len; i++) { FilmSample src = film_sample_get(i, texel_film); film_sample_accum(src, - film_buf.diffuse_light_id, - rp_buf.diffuse_light_id, + uniform_buf.film.diffuse_light_id, + uniform_buf.render_pass.diffuse_light_id, rp_color_tx, diffuse_light_accum); film_sample_accum(src, - film_buf.specular_light_id, - rp_buf.specular_light_id, + uniform_buf.film.specular_light_id, + uniform_buf.render_pass.specular_light_id, rp_color_tx, specular_light_accum); film_sample_accum( - src, film_buf.volume_light_id, rp_buf.volume_light_id, rp_color_tx, volume_light_accum); + src, uniform_buf.film.volume_light_id, uniform_buf.render_pass.volume_light_id, rp_color_tx, volume_light_accum); film_sample_accum( - src, film_buf.emission_id, rp_buf.emission_id, rp_color_tx, emission_accum); + src, uniform_buf.film.emission_id, uniform_buf.render_pass.emission_id, rp_color_tx, emission_accum); } - film_store_color(dst, film_buf.diffuse_light_id, diffuse_light_accum, out_color); - film_store_color(dst, film_buf.specular_light_id, specular_light_accum, out_color); - film_store_color(dst, film_buf.volume_light_id, volume_light_accum, out_color); - film_store_color(dst, film_buf.emission_id, emission_accum, out_color); + film_store_color(dst, uniform_buf.film.diffuse_light_id, diffuse_light_accum, out_color); + film_store_color(dst, uniform_buf.film.specular_light_id, specular_light_accum, out_color); + film_store_color(dst, uniform_buf.film.volume_light_id, volume_light_accum, out_color); + film_store_color(dst, uniform_buf.film.emission_id, emission_accum, out_color); } - if (film_buf.any_render_pass_2) { + if (uniform_buf.film.any_render_pass_2) { vec4 diffuse_color_accum = vec4(0.0); vec4 specular_color_accum = vec4(0.0); vec4 environment_accum = vec4(0.0); @@ -701,64 +701,64 @@ void film_process_data(ivec2 texel_film, out vec4 out_color, out float out_depth float shadow_accum = 0.0; float ao_accum = 0.0; - for (int i = 0; i < film_buf.samples_len; i++) { + for (int i = 0; i < uniform_buf.film.samples_len; i++) { FilmSample src = film_sample_get(i, texel_film); film_sample_accum(src, - film_buf.diffuse_color_id, - rp_buf.diffuse_color_id, + uniform_buf.film.diffuse_color_id, + uniform_buf.render_pass.diffuse_color_id, rp_color_tx, diffuse_color_accum); film_sample_accum(src, - film_buf.specular_color_id, - rp_buf.specular_color_id, + uniform_buf.film.specular_color_id, + uniform_buf.render_pass.specular_color_id, rp_color_tx, specular_color_accum); film_sample_accum( - src, film_buf.environment_id, rp_buf.environment_id, rp_color_tx, environment_accum); - film_sample_accum(src, film_buf.shadow_id, rp_buf.shadow_id, rp_value_tx, shadow_accum); + src, uniform_buf.film.environment_id, uniform_buf.render_pass.environment_id, rp_color_tx, environment_accum); + film_sample_accum(src, uniform_buf.film.shadow_id, uniform_buf.render_pass.shadow_id, rp_value_tx, shadow_accum); film_sample_accum( - src, film_buf.ambient_occlusion_id, rp_buf.ambient_occlusion_id, rp_value_tx, ao_accum); + src, uniform_buf.film.ambient_occlusion_id, uniform_buf.render_pass.ambient_occlusion_id, rp_value_tx, ao_accum); film_sample_accum_mist(src, mist_accum); } - film_store_color(dst, film_buf.diffuse_color_id, diffuse_color_accum, out_color); - film_store_color(dst, film_buf.specular_color_id, specular_color_accum, out_color); - film_store_color(dst, film_buf.environment_id, environment_accum, out_color); - film_store_color(dst, film_buf.shadow_id, vec4(vec3(shadow_accum), 1.0), out_color); - film_store_color(dst, film_buf.ambient_occlusion_id, vec4(vec3(ao_accum), 1.0), out_color); - film_store_value(dst, film_buf.mist_id, mist_accum, out_color); + film_store_color(dst, uniform_buf.film.diffuse_color_id, diffuse_color_accum, out_color); + film_store_color(dst, uniform_buf.film.specular_color_id, specular_color_accum, out_color); + film_store_color(dst, uniform_buf.film.environment_id, environment_accum, out_color); + film_store_color(dst, uniform_buf.film.shadow_id, vec4(vec3(shadow_accum), 1.0), out_color); + film_store_color(dst, uniform_buf.film.ambient_occlusion_id, vec4(vec3(ao_accum), 1.0), out_color); + film_store_value(dst, uniform_buf.film.mist_id, mist_accum, out_color); } - for (int aov = 0; aov < film_buf.aov_color_len; aov++) { + for (int aov = 0; aov < uniform_buf.film.aov_color_len; aov++) { vec4 aov_accum = vec4(0.0); - for (int i = 0; i < film_buf.samples_len; i++) { + for (int i = 0; i < uniform_buf.film.samples_len; i++) { FilmSample src = film_sample_get(i, texel_film); - film_sample_accum(src, 0, rp_buf.color_len + aov, rp_color_tx, aov_accum); + film_sample_accum(src, 0, uniform_buf.render_pass.color_len + aov, rp_color_tx, aov_accum); } - film_store_color(dst, film_buf.aov_color_id + aov, aov_accum, out_color); + film_store_color(dst, uniform_buf.film.aov_color_id + aov, aov_accum, out_color); } - for (int aov = 0; aov < film_buf.aov_value_len; aov++) { + for (int aov = 0; aov < uniform_buf.film.aov_value_len; aov++) { float aov_accum = 0.0; - for (int i = 0; i < film_buf.samples_len; i++) { + for (int i = 0; i < uniform_buf.film.samples_len; i++) { FilmSample src = film_sample_get(i, texel_film); - film_sample_accum(src, 0, rp_buf.value_len + aov, rp_value_tx, aov_accum); + film_sample_accum(src, 0, uniform_buf.render_pass.value_len + aov, rp_value_tx, aov_accum); } - film_store_value(dst, film_buf.aov_value_id + aov, aov_accum, out_color); + film_store_value(dst, uniform_buf.film.aov_value_id + aov, aov_accum, out_color); } - if (film_buf.cryptomatte_samples_len != 0) { + if (uniform_buf.film.cryptomatte_samples_len != 0) { /* Cryptomatte passes cannot be cleared by a weighted store like other passes. */ - if (!film_buf.use_history || film_buf.use_reprojection) { + if (!uniform_buf.film.use_history || uniform_buf.film.use_reprojection) { cryptomatte_clear_samples(dst); } film_cryptomatte_layer_accum_and_store( - dst, texel_film, film_buf.cryptomatte_object_id, 0, out_color); + dst, texel_film, uniform_buf.film.cryptomatte_object_id, 0, out_color); film_cryptomatte_layer_accum_and_store( - dst, texel_film, film_buf.cryptomatte_asset_id, 1, out_color); + dst, texel_film, uniform_buf.film.cryptomatte_asset_id, 1, out_color); film_cryptomatte_layer_accum_and_store( - dst, texel_film, film_buf.cryptomatte_material_id, 2, out_color); + dst, texel_film, uniform_buf.film.cryptomatte_material_id, 2, out_color); } } diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_nodetree_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_nodetree_lib.glsl index d3b99c8e5dd..36c4abf85f8 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_nodetree_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_nodetree_lib.glsl @@ -378,11 +378,11 @@ void output_renderpass_value(int id, float value) void clear_aovs() { #if defined(MAT_RENDER_PASS_SUPPORT) && defined(GPU_FRAGMENT_SHADER) - for (int i = 0; i < AOV_MAX && i < rp_buf.aovs.color_len; i++) { - output_renderpass_color(rp_buf.color_len + i, vec4(0)); + for (int i = 0; i < AOV_MAX && i < uniform_buf.render_pass.aovs.color_len; i++) { + output_renderpass_color(uniform_buf.render_pass.color_len + i, vec4(0)); } - for (int i = 0; i < AOV_MAX && i < rp_buf.aovs.value_len; i++) { - output_renderpass_value(rp_buf.value_len + i, 0.0); + for (int i = 0; i < AOV_MAX && i < uniform_buf.render_pass.aovs.value_len; i++) { + output_renderpass_value(uniform_buf.render_pass.value_len + i, 0.0); } #endif } @@ -390,15 +390,15 @@ void clear_aovs() void output_aov(vec4 color, float value, uint hash) { #if defined(MAT_RENDER_PASS_SUPPORT) && defined(GPU_FRAGMENT_SHADER) - for (int i = 0; i < AOV_MAX && i < rp_buf.aovs.color_len; i++) { - if (rp_buf.aovs.hash_color[i].x == hash) { - imageStore(rp_color_img, ivec3(ivec2(gl_FragCoord.xy), rp_buf.color_len + i), color); + for (int i = 0; i < AOV_MAX && i < uniform_buf.render_pass.aovs.color_len; i++) { + if (uniform_buf.render_pass.aovs.hash_color[i].x == hash) { + imageStore(rp_color_img, ivec3(ivec2(gl_FragCoord.xy), uniform_buf.render_pass.color_len + i), color); return; } } - for (int i = 0; i < AOV_MAX && i < rp_buf.aovs.value_len; i++) { - if (rp_buf.aovs.hash_value[i].x == hash) { - imageStore(rp_value_img, ivec3(ivec2(gl_FragCoord.xy), rp_buf.value_len + i), vec4(value)); + for (int i = 0; i < AOV_MAX && i < uniform_buf.render_pass.aovs.value_len; i++) { + if (uniform_buf.render_pass.aovs.hash_value[i].x == hash) { + imageStore(rp_value_img, ivec3(ivec2(gl_FragCoord.xy), uniform_buf.render_pass.value_len + i), vec4(value)); return; } } @@ -497,7 +497,7 @@ vec3 coordinate_screen(vec3 P) else { /* TODO(fclem): Actual camera transform. */ window.xy = project_point(ProjectionMatrix, transform_point(ViewMatrix, P)).xy * 0.5 + 0.5; - window.xy = window.xy * camera_buf.uv_scale + camera_buf.uv_bias; + window.xy = window.xy * uniform_buf.camera.uv_scale + uniform_buf.camera.uv_bias; } return window; } diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_ray_denoise_bilateral_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_ray_denoise_bilateral_comp.glsl index 8ab7a07726e..86f3f718145 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_ray_denoise_bilateral_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_ray_denoise_bilateral_comp.glsl @@ -102,7 +102,7 @@ void main() const uint tile_size = RAYTRACE_GROUP_SIZE; uvec2 tile_coord = unpackUvec2x16(tiles_coord_buf[gl_WorkGroupID.x]); ivec2 texel_fullres = ivec2(gl_LocalInvocationID.xy + tile_coord * tile_size); - vec2 center_uv = vec2(texel_fullres) * raytrace_buf.full_resolution_inv; + vec2 center_uv = vec2(texel_fullres) * uniform_buf.raytrace.full_resolution_inv; float center_depth = texelFetch(hiz_tx, texel_fullres, 0).r; vec3 center_P = get_world_space_from_depth(center_uv, center_depth); @@ -160,7 +160,7 @@ void main() } float sample_depth = texelFetch(hiz_tx, sample_texel, 0).r; - vec2 sample_uv = vec2(sample_texel) * raytrace_buf.full_resolution_inv; + vec2 sample_uv = vec2(sample_texel) * uniform_buf.raytrace.full_resolution_inv; vec3 sample_P = get_world_space_from_depth(sample_uv, sample_depth); /* Background case. */ diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_ray_denoise_spatial_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_ray_denoise_spatial_comp.glsl index 0a3d54f31fa..df027262d2c 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_ray_denoise_spatial_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_ray_denoise_spatial_comp.glsl @@ -107,9 +107,9 @@ void main() uvec2 tile_coord = unpackUvec2x16(tiles_coord_buf[gl_WorkGroupID.x]); ivec2 texel_fullres = ivec2(gl_LocalInvocationID.xy + tile_coord * tile_size); - ivec2 texel = (texel_fullres) / raytrace_buf.resolution_scale; + ivec2 texel = (texel_fullres) / uniform_buf.raytrace.resolution_scale; - if (raytrace_buf.skip_denoise) { + if (uniform_buf.raytrace.skip_denoise) { imageStore(out_radiance_img, texel_fullres, imageLoad(ray_radiance_img, texel)); return; } @@ -152,7 +152,7 @@ void main() return; } - vec2 uv = (vec2(texel_fullres) + 0.5) * raytrace_buf.full_resolution_inv; + vec2 uv = (vec2(texel_fullres) + 0.5) * uniform_buf.raytrace.full_resolution_inv; vec3 V = transform_direction(ViewMatrixInverse, get_view_vector_from_screen_uv(uv)); ClosureT closure; @@ -166,7 +166,7 @@ void main() /* NOTE: filter_size should never be greater than twice RAYTRACE_GROUP_SIZE. Otherwise, the * reconstruction can becomes ill defined since we don't know if further tiles are valid. */ filter_size = 12.0 * sqrt(filter_size_factor); - if (raytrace_buf.resolution_scale > 1) { + if (uniform_buf.raytrace.resolution_scale > 1) { /* Filter at least 1 trace pixel to fight the undersampling. */ filter_size = max(filter_size, 3.0); sample_count = max(sample_count, 5u); @@ -189,7 +189,7 @@ void main() ivec2 sample_texel = texel + offset; /* Reject samples outside of valid neighbor tiles. */ - ivec2 sample_tile = ivec2(sample_texel * raytrace_buf.resolution_scale) / int(tile_size); + ivec2 sample_tile = ivec2(sample_texel * uniform_buf.raytrace.resolution_scale) / int(tile_size); ivec2 sample_tile_relative = sample_tile - ivec2(tile_coord); if (neighbor_tile_mask_bit_get(invalid_neighbor_tile_mask, sample_tile_relative)) { continue; diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_ray_denoise_temporal_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_ray_denoise_temporal_comp.glsl index d1e3dfe33f9..374921b8668 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_ray_denoise_temporal_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_ray_denoise_temporal_comp.glsl @@ -111,7 +111,7 @@ vec4 radiance_history_fetch(ivec2 texel, float bilinear_weight) vec4 radiance_history_sample(vec3 P, LocalStatistics local) { - vec2 uv = project_point(raytrace_buf.history_persmat, P).xy * 0.5 + 0.5; + vec2 uv = project_point(uniform_buf.raytrace.history_persmat, P).xy * 0.5 + 0.5; /* FIXME(fclem): Find why we need this half pixel offset. */ vec2 texel_co = uv * vec2(textureSize(radiance_history_tx, 0).xy) - 0.5; @@ -139,7 +139,7 @@ vec4 radiance_history_sample(vec3 P, LocalStatistics local) vec2 variance_history_sample(vec3 P) { - vec2 uv = project_point(raytrace_buf.history_persmat, P).xy * 0.5 + 0.5; + vec2 uv = project_point(uniform_buf.raytrace.history_persmat, P).xy * 0.5 + 0.5; if (!in_range_exclusive(uv, vec2(0.0), vec2(1.0))) { /* Out of history view. Return sample without weight. */ @@ -164,7 +164,7 @@ void main() const uint tile_size = RAYTRACE_GROUP_SIZE; uvec2 tile_coord = unpackUvec2x16(tiles_coord_buf[gl_WorkGroupID.x]); ivec2 texel_fullres = ivec2(gl_LocalInvocationID.xy + tile_coord * tile_size); - vec2 uv = (vec2(texel_fullres) + 0.5) * raytrace_buf.full_resolution_inv; + vec2 uv = (vec2(texel_fullres) + 0.5) * uniform_buf.raytrace.full_resolution_inv; float in_variance = imageLoad(in_variance_img, texel_fullres).r; vec3 in_radiance = imageLoad(in_radiance_img, texel_fullres).rgb; diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_ray_generate_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_ray_generate_comp.glsl index 122fdf16726..faed374a368 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_ray_generate_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_ray_generate_comp.glsl @@ -19,7 +19,7 @@ void main() uvec2 tile_coord = unpackUvec2x16(tiles_coord_buf[gl_WorkGroupID.x]); ivec2 texel = ivec2(gl_LocalInvocationID.xy + tile_coord * tile_size); - ivec2 texel_fullres = texel * raytrace_buf.resolution_scale + raytrace_buf.resolution_bias; + ivec2 texel_fullres = texel * uniform_buf.raytrace.resolution_scale + uniform_buf.raytrace.resolution_bias; bool valid_texel = in_texture_range(texel_fullres, stencil_tx); uint closure_bits = (!valid_texel) ? 0u : texelFetch(stencil_tx, texel_fullres, 0).r; diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_ray_tile_classify_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_ray_tile_classify_comp.glsl index 53c83515abd..4e90cf032dd 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_ray_tile_classify_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_ray_tile_classify_comp.glsl @@ -44,8 +44,8 @@ void main() eClosureBits closure_bits = eClosureBits(texelFetch(stencil_tx, texel, 0).r); - if (flag_test(closure_bits, raytrace_buf.closure_active)) { - int gbuffer_layer = raytrace_buf.closure_active == CLOSURE_REFRACTION ? 1 : 0; + if (flag_test(closure_bits, uniform_buf.raytrace.closure_active)) { + int gbuffer_layer = uniform_buf.raytrace.closure_active == CLOSURE_REFRACTION ? 1 : 0; vec4 gbuffer_packed = texelFetch(gbuffer_closure_tx, ivec3(texel, gbuffer_layer), 0); float roughness = gbuffer_packed.z; diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_ray_tile_compact_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_ray_tile_compact_comp.glsl index a293f6f4e74..01fed6a960f 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_ray_tile_compact_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_ray_tile_compact_comp.glsl @@ -18,9 +18,9 @@ void main() ivec2 tile = ivec2(gl_GlobalInvocationID.xy); bool tracing_tile_is_used = false; - for (int x = 0; x < raytrace_buf.resolution_scale; x++) { - for (int y = 0; y < raytrace_buf.resolution_scale; y++) { - ivec2 full_res_tile = tile * raytrace_buf.resolution_scale + ivec2(x, y); + for (int x = 0; x < uniform_buf.raytrace.resolution_scale; x++) { + for (int y = 0; y < uniform_buf.raytrace.resolution_scale; y++) { + ivec2 full_res_tile = tile * uniform_buf.raytrace.resolution_scale + ivec2(x, y); if (any(greaterThanEqual(full_res_tile, imageSize(tile_mask_img)))) { continue; } diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_ray_trace_screen_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_ray_trace_screen_comp.glsl index 8b502e4a352..66384a5f04f 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_ray_trace_screen_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_ray_trace_screen_comp.glsl @@ -20,10 +20,10 @@ void main() uvec2 tile_coord = unpackUvec2x16(tiles_coord_buf[gl_WorkGroupID.x]); ivec2 texel = ivec2(gl_LocalInvocationID.xy + tile_coord * tile_size); - ivec2 texel_fullres = texel * raytrace_buf.resolution_scale + raytrace_buf.resolution_bias; + ivec2 texel_fullres = texel * uniform_buf.raytrace.resolution_scale + uniform_buf.raytrace.resolution_bias; float depth = texelFetch(hiz_tx, texel_fullres, 0).r; - vec2 uv = (vec2(texel_fullres) + 0.5) * raytrace_buf.full_resolution_inv; + vec2 uv = (vec2(texel_fullres) + 0.5) * uniform_buf.raytrace.full_resolution_inv; vec4 ray_data = imageLoad(ray_data_img, texel); float ray_pdf_inv = ray_data.w; @@ -68,8 +68,8 @@ void main() * (raytrace_clip_ray_to_near_plane) is not taking it into account. */ ray_view.max_time = 1.0; - hit = raytrace_screen(raytrace_buf, - hiz_buf, + hit = raytrace_screen(uniform_buf.raytrace, + uniform_buf.hiz, hiz_tx, rand_trace, roughness, @@ -101,7 +101,7 @@ void main() } float luma = max(1e-8, max_v3(radiance)); - radiance *= 1.0 - max(0.0, luma - raytrace_buf.brightness_clamp) / luma; + radiance *= 1.0 - max(0.0, luma - uniform_buf.raytrace.brightness_clamp) / luma; imageStore(ray_time_img, texel, vec4(hit_time)); imageStore(ray_radiance_img, texel, vec4(radiance, 0.0)); diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_tag_usage_volume_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_tag_usage_volume_comp.glsl index ea7229e64b8..0af1914d771 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_tag_usage_volume_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_tag_usage_volume_comp.glsl @@ -17,7 +17,7 @@ void main() { ivec3 froxel = ivec3(gl_GlobalInvocationID); - if (any(greaterThanEqual(froxel, volumes_info_buf.tex_size))) { + if (any(greaterThanEqual(froxel, uniform_buf.volumes.tex_size))) { return; } @@ -29,18 +29,18 @@ void main() } vec3 jitter = sampling_rng_3D_get(SAMPLING_VOLUME_U); - vec3 volume_ndc = volume_to_ndc((vec3(froxel) + jitter) * volumes_info_buf.inv_tex_size); + vec3 volume_ndc = volume_to_ndc((vec3(froxel) + jitter) * uniform_buf.volumes.inv_tex_size); vec3 vP = get_view_space_from_depth(volume_ndc.xy, volume_ndc.z); vec3 P = point_view_to_world(vP); - float depth = texelFetch(hiz_tx, froxel.xy, volumes_info_buf.tile_size_lod).r; + float depth = texelFetch(hiz_tx, froxel.xy, uniform_buf.volumes.tile_size_lod).r; if (depth < volume_ndc.z) { return; } - vec2 pixel = (vec2(froxel.xy) + vec2(0.5)) / vec2(volumes_info_buf.tex_size.xy) / - volumes_info_buf.viewport_size_inv; + vec2 pixel = (vec2(froxel.xy) + vec2(0.5)) / vec2(uniform_buf.volumes.tex_size.xy) / + uniform_buf.volumes.viewport_size_inv; - int bias = volumes_info_buf.tile_size_lod; + int bias = uniform_buf.volumes.tile_size_lod; shadow_tag_usage(vP, P, cameraVec(P), 0.01, length(vP), pixel, bias); } diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_subsurface_eval_frag.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_subsurface_eval_frag.glsl index 435799c1f0f..27c137069c6 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_subsurface_eval_frag.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_subsurface_eval_frag.glsl @@ -99,11 +99,11 @@ void main(void) /* TODO/OPTI(fclem) Make separate sample set for lower radius. */ - for (int i = 0; i < sss_buf.sample_len; i++) { - vec2 sample_uv = center_uv + sample_space * sss_buf.samples[i].xy; - float pdf_inv = sss_buf.samples[i].z; + for (int i = 0; i < uniform_buf.subsurface.sample_len; i++) { + vec2 sample_uv = center_uv + sample_space * uniform_buf.subsurface.samples[i].xy; + float pdf_inv = uniform_buf.subsurface.samples[i].z; - float sample_depth = textureLod(hiz_tx, sample_uv * hiz_buf.uv_scale, 0.0).r; + float sample_depth = textureLod(hiz_tx, sample_uv * uniform_buf.hiz.uv_scale, 0.0).r; vec3 sample_vP = get_view_space_from_depth(sample_uv, sample_depth); vec4 sample_data = texture(radiance_tx, sample_uv); @@ -129,8 +129,8 @@ void main(void) /* Normalize the sum (slide 34). */ accum /= accum_weight; - if (rp_buf.diffuse_light_id >= 0) { - imageStore(rp_color_img, ivec3(texel, rp_buf.diffuse_light_id), vec4(accum, 1.0)); + if (uniform_buf.render_pass.diffuse_light_id >= 0) { + imageStore(rp_color_img, ivec3(texel, uniform_buf.render_pass.diffuse_light_id), vec4(accum, 1.0)); } /* This pass uses additive blending. diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_surf_deferred_frag.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_surf_deferred_frag.glsl index 626bc0b1bc5..55eb3b6dc1d 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_surf_deferred_frag.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_surf_deferred_frag.glsl @@ -76,10 +76,10 @@ void main() cryptomatte_object_buf[resource_id], node_tree.crypto_hash, 0.0); imageStore(rp_cryptomatte_img, out_texel, cryptomatte_output); } - output_renderpass_color(rp_buf.normal_id, vec4(out_normal, 1.0)); - output_renderpass_color(rp_buf.diffuse_color_id, vec4(g_diffuse_data.color, 1.0)); - output_renderpass_color(rp_buf.specular_color_id, vec4(specular_color, 1.0)); - output_renderpass_color(rp_buf.emission_id, vec4(g_emission, 1.0)); + output_renderpass_color(uniform_buf.render_pass.normal_id, vec4(out_normal, 1.0)); + output_renderpass_color(uniform_buf.render_pass.diffuse_color_id, vec4(g_diffuse_data.color, 1.0)); + output_renderpass_color(uniform_buf.render_pass.specular_color_id, vec4(specular_color, 1.0)); + output_renderpass_color(uniform_buf.render_pass.emission_id, vec4(g_emission, 1.0)); #endif /* ----- GBuffer output ----- */ diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_surf_forward_frag.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_surf_forward_frag.glsl index a078a2e4f33..d91c5b32333 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_surf_forward_frag.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_surf_forward_frag.glsl @@ -120,19 +120,19 @@ void main() cryptomatte_object_buf[resource_id], node_tree.crypto_hash, 0.0); imageStore(rp_cryptomatte_img, out_texel, cryptomatte_output); } - output_renderpass_color(rp_buf.normal_id, vec4(out_normal, 1.0)); - output_renderpass_color(rp_buf.diffuse_color_id, vec4(g_diffuse_data.color, 1.0)); - output_renderpass_color(rp_buf.diffuse_light_id, vec4(diffuse_light, 1.0)); - output_renderpass_color(rp_buf.specular_color_id, vec4(specular_color, 1.0)); - output_renderpass_color(rp_buf.specular_light_id, vec4(specular_light, 1.0)); - output_renderpass_color(rp_buf.emission_id, vec4(g_emission, 1.0)); - output_renderpass_value(rp_buf.shadow_id, shadow); + output_renderpass_color(uniform_buf.render_pass.normal_id, vec4(out_normal, 1.0)); + output_renderpass_color(uniform_buf.render_pass.diffuse_color_id, vec4(g_diffuse_data.color, 1.0)); + output_renderpass_color(uniform_buf.render_pass.diffuse_light_id, vec4(diffuse_light, 1.0)); + output_renderpass_color(uniform_buf.render_pass.specular_color_id, vec4(specular_color, 1.0)); + output_renderpass_color(uniform_buf.render_pass.specular_light_id, vec4(specular_light, 1.0)); + output_renderpass_color(uniform_buf.render_pass.emission_id, vec4(g_emission, 1.0)); + output_renderpass_value(uniform_buf.render_pass.shadow_id, shadow); /** NOTE: AO is done on its own pass. */ #endif #ifdef MAT_TRANSPARENT /* Volumetric resolve and compositing. */ - vec2 uvs = gl_FragCoord.xy * volumes_info_buf.viewport_size_inv; + vec2 uvs = gl_FragCoord.xy * uniform_buf.volumes.viewport_size_inv; VolumeResolveSample vol = volume_resolve( vec3(uvs, gl_FragCoord.z), volume_transmittance_tx, volume_scattering_tx); diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_surf_world_frag.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_surf_world_frag.glsl index 4719d7544f3..0cbef0761d2 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_surf_world_frag.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_surf_world_frag.glsl @@ -42,16 +42,16 @@ void main() vec4 environment = out_background; environment.a = 1.0 - environment.a; environment.rgb *= environment.a; - output_renderpass_color(rp_buf.environment_id, environment); + output_renderpass_color(uniform_buf.render_pass.environment_id, environment); vec4 clear_color = vec4(0.0, 0.0, 0.0, 1.0); - output_renderpass_color(rp_buf.normal_id, clear_color); - output_renderpass_color(rp_buf.diffuse_light_id, clear_color); - output_renderpass_color(rp_buf.specular_light_id, clear_color); - output_renderpass_color(rp_buf.diffuse_color_id, clear_color); - output_renderpass_color(rp_buf.specular_color_id, clear_color); - output_renderpass_color(rp_buf.emission_id, clear_color); - output_renderpass_value(rp_buf.shadow_id, 1.0); + output_renderpass_color(uniform_buf.render_pass.normal_id, clear_color); + output_renderpass_color(uniform_buf.render_pass.diffuse_light_id, clear_color); + output_renderpass_color(uniform_buf.render_pass.specular_light_id, clear_color); + output_renderpass_color(uniform_buf.render_pass.diffuse_color_id, clear_color); + output_renderpass_color(uniform_buf.render_pass.specular_color_id, clear_color); + output_renderpass_color(uniform_buf.render_pass.emission_id, clear_color); + output_renderpass_value(uniform_buf.render_pass.shadow_id, 1.0); /** NOTE: AO is done on its own pass. */ imageStore(rp_cryptomatte_img, texel, vec4(0.0)); } diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_volume_integration_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_volume_integration_comp.glsl index 07c5da7beec..9ab19fdce28 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_volume_integration_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_volume_integration_comp.glsl @@ -13,7 +13,7 @@ void main() { ivec2 texel = ivec2(gl_GlobalInvocationID.xy); - ivec3 tex_size = volumes_info_buf.tex_size; + ivec3 tex_size = uniform_buf.volumes.tex_size; if (any(greaterThanEqual(texel, tex_size.xy))) { return; diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_volume_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_volume_lib.glsl index 73caf6181ca..7e55f064edc 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_volume_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_volume_lib.glsl @@ -4,7 +4,7 @@ /** * The resources expected to be defined are: - * - volumes_info_buf + * - uniform_buf.volumes */ #pragma BLENDER_REQUIRE(common_view_lib.glsl) @@ -17,9 +17,9 @@ /* Volume slice to view space depth. */ float volume_z_to_view_z(float z) { - float near = volumes_info_buf.depth_near; - float far = volumes_info_buf.depth_far; - float distribution = volumes_info_buf.depth_distribution; + float near = uniform_buf.volumes.depth_near; + float far = uniform_buf.volumes.depth_far; + float distribution = uniform_buf.volumes.depth_distribution; bool is_persp = ProjectionMatrix[3][3] == 0.0; /* Implemented in eevee_shader_shared.cc */ return volume_z_to_view_z(near, far, distribution, is_persp, z); @@ -27,9 +27,9 @@ float volume_z_to_view_z(float z) float view_z_to_volume_z(float depth) { - float near = volumes_info_buf.depth_near; - float far = volumes_info_buf.depth_far; - float distribution = volumes_info_buf.depth_distribution; + float near = uniform_buf.volumes.depth_near; + float far = uniform_buf.volumes.depth_far; + float distribution = uniform_buf.volumes.depth_distribution; bool is_persp = ProjectionMatrix[3][3] == 0.0; /* Implemented in eevee_shader_shared.cc */ return view_z_to_volume_z(near, far, distribution, is_persp, depth); @@ -40,16 +40,16 @@ vec3 volume_to_ndc(vec3 coord) { coord.z = volume_z_to_view_z(coord.z); coord.z = get_depth_from_view_z(coord.z); - coord.xy /= volumes_info_buf.coord_scale; + coord.xy /= uniform_buf.volumes.coord_scale; return coord; } vec3 ndc_to_volume(vec3 coord) { - float near = volumes_info_buf.depth_near; - float far = volumes_info_buf.depth_far; - float distribution = volumes_info_buf.depth_distribution; - vec2 coord_scale = volumes_info_buf.coord_scale; + float near = uniform_buf.volumes.depth_near; + float far = uniform_buf.volumes.depth_far; + float distribution = uniform_buf.volumes.depth_distribution; + vec2 coord_scale = uniform_buf.volumes.coord_scale; /* Implemented in eevee_shader_shared.cc */ return ndc_to_volume(ProjectionMatrix, near, far, distribution, coord_scale, coord); } @@ -74,7 +74,7 @@ vec3 volume_light(LightData ld, vec3 L, float l_dist) if (ld.type != LIGHT_SUN) { float volume_radius_squared = ld.radius_squared; - float light_clamp = volumes_info_buf.light_clamp; + float light_clamp = uniform_buf.volumes.light_clamp; if (light_clamp != 0.0) { /* 0.0 light clamp means it's disabled. */ float max_power = max_v3(ld.color) * ld.volume_power; @@ -113,7 +113,7 @@ vec3 volume_light(LightData ld, vec3 L, float l_dist) vec3 volume_shadow(LightData ld, vec3 ray_wpos, vec3 L, float l_dist, sampler3D extinction_tx) { #if defined(VOLUME_SHADOW) - if (volumes_info_buf.shadow_steps == 0) { + if (uniform_buf.volumes.shadow_steps == 0) { return vec3(1.0); } @@ -122,7 +122,7 @@ vec3 volume_shadow(LightData ld, vec3 ray_wpos, vec3 L, float l_dist, sampler3D /* TODO(Miguel Pozo): Soft shadows support. */ # if 0 /* If light is shadowed, use the shadow vector, if not, reuse the light vector. */ - if (volumes_info_buf.use_soft_shadows && ld.shadowid >= 0.0) { + if (uniform_buf.volumes.use_soft_shadows && ld.shadowid >= 0.0) { ShadowData sd = shadows_data[int(ld.shadowid)]; if (ld.type == LIGHT_SUN) { @@ -137,8 +137,8 @@ vec3 volume_shadow(LightData ld, vec3 ray_wpos, vec3 L, float l_dist, sampler3D # endif /* Heterogeneous volume shadows. */ - float dd = l_vector.w / volumes_info_buf.shadow_steps; - L = l_vector.xyz / volumes_info_buf.shadow_steps; + float dd = l_vector.w / uniform_buf.volumes.shadow_steps; + L = l_vector.xyz / uniform_buf.volumes.shadow_steps; if (is_sun_light(ld.type)) { /* For sun light we scan the whole frustum. So we need to get the correct endpoints. */ @@ -151,13 +151,13 @@ vec3 volume_shadow(LightData ld, vec3 ray_wpos, vec3 L, float l_dist, sampler3D vec4 L_hom = ViewMatrixInverse * (ProjectionMatrixInverse * vec4(frustum_isect, 1.0)); L = (L_hom.xyz / L_hom.w) - ray_wpos; - L /= volumes_info_buf.shadow_steps; + L /= uniform_buf.volumes.shadow_steps; dd = length(L); } /* TODO use shadow maps instead. */ vec3 shadow = vec3(1.0); - for (float s = 1.0; s < VOLUMETRIC_SHADOW_MAX_STEP && s <= volumes_info_buf.shadow_steps; + for (float s = 1.0; s < VOLUMETRIC_SHADOW_MAX_STEP && s <= uniform_buf.volumes.shadow_steps; s += 1.0) { vec3 pos = ray_wpos + L * s; diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_volume_material_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_volume_material_comp.glsl index 06e58f7ee9b..2fd291026ef 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_volume_material_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_volume_material_comp.glsl @@ -47,12 +47,12 @@ void main() froxel += grid_coords_min; #endif - if (any(greaterThanEqual(froxel, volumes_info_buf.tex_size))) { + if (any(greaterThanEqual(froxel, uniform_buf.volumes.tex_size))) { return; } vec3 jitter = sampling_rng_3D_get(SAMPLING_VOLUME_U); - vec3 ndc_cell = volume_to_ndc((vec3(froxel) + jitter) * volumes_info_buf.inv_tex_size); + vec3 ndc_cell = volume_to_ndc((vec3(froxel) + jitter) * uniform_buf.volumes.inv_tex_size); vec3 vP = get_view_space_from_depth(ndc_cell.xy, ndc_cell.z); vec3 wP = point_view_to_world(vP); diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_volume_resolve_frag.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_volume_resolve_frag.glsl index c947f8c7020..a127bc2bd94 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_volume_resolve_frag.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_volume_resolve_frag.glsl @@ -20,9 +20,9 @@ void main() out_radiance = vec4(vol.scattering, 0.0); out_transmittance = vec4(vol.transmittance, saturate(avg(vol.transmittance))); - if (rp_buf.volume_light_id >= 0) { + if (uniform_buf.render_pass.volume_light_id >= 0) { imageStore(rp_color_img, - ivec3(ivec2(gl_FragCoord.xy), rp_buf.volume_light_id), + ivec3(ivec2(gl_FragCoord.xy), uniform_buf.render_pass.volume_light_id), vec4(vol.scattering, 1.0)); } } diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_volume_scatter_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_volume_scatter_comp.glsl index 6852bbec91e..12b34a56b90 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_volume_scatter_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_volume_scatter_comp.glsl @@ -57,7 +57,7 @@ void main() { ivec3 froxel = ivec3(gl_GlobalInvocationID); - if (any(greaterThanEqual(froxel, volumes_info_buf.tex_size))) { + if (any(greaterThanEqual(froxel, uniform_buf.volumes.tex_size))) { return; } @@ -67,7 +67,7 @@ void main() vec3 s_scattering = imageLoad(in_scattering_img, froxel).rgb; vec3 jitter = sampling_rng_3D_get(SAMPLING_VOLUME_U); - vec3 volume_ndc = volume_to_ndc((vec3(froxel) + jitter) * volumes_info_buf.inv_tex_size); + vec3 volume_ndc = volume_to_ndc((vec3(froxel) + jitter) * uniform_buf.volumes.inv_tex_size); vec3 vP = get_view_space_from_depth(volume_ndc.xy, volume_ndc.z); vec3 P = point_view_to_world(vP); vec3 V = cameraVec(P); @@ -85,8 +85,8 @@ void main() } LIGHT_FOREACH_END - vec2 pixel = (vec2(froxel.xy) + vec2(0.5)) / vec2(volumes_info_buf.tex_size.xy) / - volumes_info_buf.viewport_size_inv; + vec2 pixel = (vec2(froxel.xy) + vec2(0.5)) / vec2(uniform_buf.volumes.tex_size.xy) / + uniform_buf.volumes.viewport_size_inv; LIGHT_FOREACH_BEGIN_LOCAL (light_cull_buf, light_zbin_buf, light_tile_buf, pixel, vP.z, l_idx) { scattering += volume_scatter_light_eval(P, V, l_idx, s_anisotropy) * s_scattering; diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_ambient_occlusion_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_ambient_occlusion_info.hh index eb2dfe7f173..61ba724952d 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_ambient_occlusion_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_ambient_occlusion_info.hh @@ -5,20 +5,17 @@ #include "eevee_defines.hh" #include "gpu_shader_create_info.hh" -GPU_SHADER_CREATE_INFO(eevee_ambient_occlusion_data) - .additional_info("draw_view", - "eevee_shared", - "eevee_hiz_data", - "eevee_sampling_data", - "eevee_utility_texture") - .uniform_buf(AO_BUF_SLOT, "AOData", "ao_buf"); - GPU_SHADER_CREATE_INFO(eevee_ambient_occlusion_pass) - .additional_info("eevee_ambient_occlusion_data") .compute_source("eevee_ambient_occlusion_pass_comp.glsl") .local_group_size(AMBIENT_OCCLUSION_PASS_TILE_SIZE, AMBIENT_OCCLUSION_PASS_TILE_SIZE) .image(0, GPU_RGBA16F, Qualifier::READ, ImageType::FLOAT_2D_ARRAY, "in_normal_img") .push_constant(Type::INT, "in_normal_img_layer_index") .image(1, GPU_RG16F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_ao_img") .push_constant(Type::INT, "out_ao_img_layer_index") + .additional_info("draw_view", + "eevee_shared", + "eevee_hiz_data", + "eevee_sampling_data", + "eevee_utility_texture", + "eevee_global_ubo") .do_static_compilation(true); diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_film_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_film_info.hh index 98534134dc6..7d727b894b3 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_film_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_film_info.hh @@ -6,7 +6,6 @@ #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(eevee_film) - .uniform_buf(6, "FilmData", "film_buf") .sampler(0, ImageType::DEPTH_2D, "depth_tx") .sampler(1, ImageType::FLOAT_2D, "combined_tx") .sampler(2, ImageType::FLOAT_2D, "vector_tx") @@ -24,8 +23,8 @@ GPU_SHADER_CREATE_INFO(eevee_film) .image(5, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D_ARRAY, "color_accum_img") .image(6, GPU_R16F, Qualifier::READ_WRITE, ImageType::FLOAT_2D_ARRAY, "value_accum_img") .image(7, GPU_RGBA32F, Qualifier::READ_WRITE, ImageType::FLOAT_2D_ARRAY, "cryptomatte_img") - .uniform_buf(RBUFS_BUF_SLOT, "RenderBuffersInfoData", "rp_buf") .additional_info("eevee_shared") + .additional_info("eevee_global_ubo") .additional_info("eevee_velocity_camera") .additional_info("draw_view"); diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_hiz_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_hiz_info.hh index 26fe30c477c..3ea9474777e 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_hiz_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_hiz_info.hh @@ -7,7 +7,7 @@ GPU_SHADER_CREATE_INFO(eevee_hiz_data) .sampler(HIZ_TEX_SLOT, ImageType::FLOAT_2D, "hiz_tx") - .uniform_buf(HIZ_BUF_SLOT, "HiZData", "hiz_buf"); + .additional_info("eevee_global_ubo"); GPU_SHADER_CREATE_INFO(eevee_hiz_update) .do_static_compilation(true) 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 07bf65c5110..b0999507573 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 @@ -14,6 +14,9 @@ GPU_SHADER_CREATE_INFO(eevee_shared) .typedef_source("eevee_defines.hh") .typedef_source("eevee_shader_shared.hh"); +GPU_SHADER_CREATE_INFO(eevee_global_ubo) + .uniform_buf(UNIFORM_BUF_SLOT, "UniformData", "uniform_buf"); + GPU_SHADER_CREATE_INFO(eevee_sampling_data) .define("EEVEE_SAMPLING_DATA") .additional_info("eevee_shared") @@ -23,8 +26,6 @@ GPU_SHADER_CREATE_INFO(eevee_utility_texture) .define("EEVEE_UTILITY_TX") .sampler(RBUFS_UTILITY_TEX_SLOT, ImageType::FLOAT_2D_ARRAY, "utility_tx"); -GPU_SHADER_CREATE_INFO(eevee_camera).uniform_buf(CAMERA_BUF_SLOT, "CameraData", "camera_buf"); - /** \} */ /* -------------------------------------------------------------------- */ @@ -108,9 +109,9 @@ GPU_SHADER_INTERFACE_INFO(eevee_surf_flat_iface, "interp_flat") GPU_SHADER_CREATE_INFO(eevee_render_pass_out) .define("MAT_RENDER_PASS_SUPPORT") + .additional_info("eevee_global_ubo") .image_array_out(RBUFS_COLOR_SLOT, Qualifier::WRITE, GPU_RGBA16F, "rp_color_img") - .image_array_out(RBUFS_VALUE_SLOT, Qualifier::WRITE, GPU_R16F, "rp_value_img") - .uniform_buf(RBUFS_BUF_SLOT, "RenderBuffersInfoData", "rp_buf"); + .image_array_out(RBUFS_VALUE_SLOT, Qualifier::WRITE, GPU_R16F, "rp_value_img"); GPU_SHADER_CREATE_INFO(eevee_cryptomatte_out) .storage_buf(CRYPTOMATTE_BUF_SLOT, Qualifier::READ, "vec2", "cryptomatte_object_buf[]") @@ -129,13 +130,12 @@ GPU_SHADER_CREATE_INFO(eevee_surf_deferred) .image_array_out(GBUF_CLOSURE_SLOT, Qualifier::WRITE, GPU_RGBA16, "out_gbuff_closure_img") .image_array_out(GBUF_COLOR_SLOT, Qualifier::WRITE, GPU_RGB10_A2, "out_gbuff_color_img") .fragment_source("eevee_surf_deferred_frag.glsl") - .additional_info("eevee_camera", + .additional_info("eevee_global_ubo", "eevee_utility_texture", "eevee_sampling_data", /* Added at runtime because of test shaders not having `node_tree`. */ // "eevee_render_pass_out", - "eevee_cryptomatte_out", - "eevee_ambient_occlusion_data"); + "eevee_cryptomatte_out"); GPU_SHADER_CREATE_INFO(eevee_surf_forward) .vertex_out(eevee_surf_iface) @@ -146,17 +146,15 @@ 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") - .additional_info("eevee_light_data", - "eevee_camera", + .additional_info("eevee_global_ubo", + "eevee_light_data", "eevee_utility_texture", "eevee_sampling_data", "eevee_shadow_data", - "eevee_volume_lib", - "eevee_ambient_occlusion_data" + "eevee_volume_lib" /* Optionally added depending on the material. */ // "eevee_render_pass_out", // "eevee_cryptomatte_out", - // "eevee_raytrace_data", ); GPU_SHADER_CREATE_INFO(eevee_surf_capture) @@ -166,14 +164,14 @@ GPU_SHADER_CREATE_INFO(eevee_surf_capture) .storage_buf(SURFEL_BUF_SLOT, Qualifier::WRITE, "Surfel", "surfel_buf[]") .storage_buf(CAPTURE_BUF_SLOT, Qualifier::READ_WRITE, "CaptureInfoData", "capture_info_buf") .fragment_source("eevee_surf_capture_frag.glsl") - .additional_info("eevee_camera", "eevee_utility_texture"); + .additional_info("eevee_global_ubo", "eevee_utility_texture"); GPU_SHADER_CREATE_INFO(eevee_surf_depth) .define("MAT_DEPTH") .vertex_out(eevee_surf_iface) .vertex_out(eevee_surf_flat_iface) .fragment_source("eevee_surf_depth_frag.glsl") - .additional_info("eevee_sampling_data", "eevee_camera", "eevee_utility_texture"); + .additional_info("eevee_global_ubo", "eevee_sampling_data", "eevee_utility_texture"); GPU_SHADER_CREATE_INFO(eevee_surf_world) .vertex_out(eevee_surf_iface) @@ -181,9 +179,9 @@ GPU_SHADER_CREATE_INFO(eevee_surf_world) .push_constant(Type::FLOAT, "world_opacity_fade") .fragment_out(0, Type::VEC4, "out_background") .fragment_source("eevee_surf_world_frag.glsl") - .additional_info("eevee_render_pass_out", + .additional_info("eevee_global_ubo", + "eevee_render_pass_out", "eevee_cryptomatte_out", - "eevee_camera", "eevee_utility_texture"); GPU_SHADER_CREATE_INFO(eevee_surf_shadow) @@ -209,7 +207,7 @@ GPU_SHADER_CREATE_INFO(eevee_surf_shadow) ImageType::UINT_2D_ARRAY, "shadow_atlas_img") .fragment_source("eevee_surf_shadow_frag.glsl") - .additional_info("eevee_camera", "eevee_utility_texture", "eevee_sampling_data"); + .additional_info("eevee_global_ubo", "eevee_utility_texture", "eevee_sampling_data"); #undef image_out #undef image_array_out @@ -224,13 +222,12 @@ GPU_SHADER_CREATE_INFO(eevee_volume_material_common) .compute_source("eevee_volume_material_comp.glsl") .local_group_size(VOLUME_GROUP_SIZE, VOLUME_GROUP_SIZE, VOLUME_GROUP_SIZE) .define("VOLUMETRICS") - .uniform_buf(VOLUMES_INFO_BUF_SLOT, "VolumesInfoData", "volumes_info_buf") .additional_info("draw_modelmat_new_common", "draw_resource_id_uniform", "draw_view", "eevee_shared", + "eevee_global_ubo", "eevee_sampling_data", - "eevee_camera", "eevee_utility_texture"); GPU_SHADER_CREATE_INFO(eevee_volume_object) diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_shadow_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_shadow_info.hh index 4aab81e521c..285f6bfdea5 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_shadow_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_shadow_info.hh @@ -117,7 +117,6 @@ GPU_SHADER_CREATE_INFO(eevee_shadow_tag_usage_volume) .local_group_size(VOLUME_GROUP_SIZE, VOLUME_GROUP_SIZE, VOLUME_GROUP_SIZE) .storage_buf(4, Qualifier::READ_WRITE, "ShadowTileMapData", "tilemaps_buf[]") .storage_buf(5, Qualifier::READ_WRITE, SHADOW_TILE_DATA_PACKED, "tiles_buf[]") - .uniform_buf(VOLUMES_INFO_BUF_SLOT, "VolumesInfoData", "volumes_info_buf") .push_constant(Type::FLOAT, "tilemap_projection_ratio") .additional_info("eevee_volume_properties_data", "eevee_shared", diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_subsurface_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_subsurface_info.hh index 1a93a9a70f3..5130711fc63 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_subsurface_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_subsurface_info.hh @@ -7,8 +7,7 @@ GPU_SHADER_CREATE_INFO(eevee_subsurface_eval) .do_static_compilation(true) - .additional_info("eevee_shared", "eevee_render_pass_out") - .uniform_buf(0, "SubsurfaceData", "sss_buf") + .additional_info("eevee_shared", "eevee_global_ubo", "eevee_render_pass_out") .sampler(0, ImageType::FLOAT_2D_ARRAY, "gbuffer_closure_tx") .sampler(1, ImageType::FLOAT_2D_ARRAY, "gbuffer_color_tx") .sampler(2, ImageType::FLOAT_2D, "radiance_tx") diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_tracing_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_tracing_info.hh index 7934fe2d958..331cd73bc85 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_tracing_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_tracing_info.hh @@ -22,37 +22,38 @@ GPU_SHADER_CREATE_INFO(eevee_ray_tile_classify) .do_static_compilation(true) .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) - .additional_info("eevee_shared") + .additional_info("eevee_shared", "eevee_global_ubo") .typedef_source("draw_shader_shared.h") .sampler(0, ImageType::FLOAT_2D_ARRAY, "gbuffer_closure_tx") .sampler(1, ImageType::UINT_2D, "stencil_tx") .image(0, RAYTRACE_TILEMASK_FORMAT, Qualifier::WRITE, ImageType::UINT_2D, "tile_mask_img") .storage_buf(0, Qualifier::WRITE, "DispatchCommand", "ray_dispatch_buf") .storage_buf(1, Qualifier::WRITE, "DispatchCommand", "denoise_dispatch_buf") - .uniform_buf(1, "RayTraceData", "raytrace_buf") .compute_source("eevee_ray_tile_classify_comp.glsl"); GPU_SHADER_CREATE_INFO(eevee_ray_tile_compact) .do_static_compilation(true) .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) - .additional_info("eevee_shared") + .additional_info("eevee_shared", "eevee_global_ubo") .typedef_source("draw_shader_shared.h") .image(0, RAYTRACE_TILEMASK_FORMAT, Qualifier::READ, ImageType::UINT_2D, "tile_mask_img") .storage_buf(0, Qualifier::READ_WRITE, "DispatchCommand", "ray_dispatch_buf") .storage_buf(1, Qualifier::READ_WRITE, "DispatchCommand", "denoise_dispatch_buf") .storage_buf(2, Qualifier::WRITE, "uint", "ray_tiles_buf[]") .storage_buf(3, Qualifier::WRITE, "uint", "denoise_tiles_buf[]") - .uniform_buf(1, "RayTraceData", "raytrace_buf") .compute_source("eevee_ray_tile_compact_comp.glsl"); GPU_SHADER_CREATE_INFO(eevee_ray_generate) .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) - .additional_info("eevee_shared", "eevee_sampling_data", "draw_view", "eevee_utility_texture") + .additional_info("eevee_shared", + "eevee_global_ubo", + "eevee_sampling_data", + "draw_view", + "eevee_utility_texture") .sampler(0, ImageType::UINT_2D, "stencil_tx") .sampler(1, ImageType::FLOAT_2D_ARRAY, "gbuffer_closure_tx") .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_ray_data_img") .storage_buf(4, Qualifier::READ, "uint", "tiles_coord_buf[]") - .uniform_buf(1, "RayTraceData", "raytrace_buf") .compute_source("eevee_ray_generate_comp.glsl"); EEVEE_RAYTRACE_CLOSURE_VARIATION(eevee_ray_generate) @@ -60,6 +61,7 @@ EEVEE_RAYTRACE_CLOSURE_VARIATION(eevee_ray_generate) GPU_SHADER_CREATE_INFO(eevee_ray_trace_screen) .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) .additional_info("eevee_shared", + "eevee_global_ubo", "eevee_sampling_data", "draw_view", "eevee_hiz_data", @@ -68,7 +70,6 @@ GPU_SHADER_CREATE_INFO(eevee_ray_trace_screen) .image(1, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "ray_time_img") .image(2, RAYTRACE_RADIANCE_FORMAT, Qualifier::WRITE, ImageType::FLOAT_2D, "ray_radiance_img") .storage_buf(4, Qualifier::READ, "uint", "tiles_coord_buf[]") - .uniform_buf(1, "RayTraceData", "raytrace_buf") .compute_source("eevee_ray_trace_screen_comp.glsl"); EEVEE_RAYTRACE_CLOSURE_VARIATION(eevee_ray_trace_screen) @@ -76,6 +77,7 @@ EEVEE_RAYTRACE_CLOSURE_VARIATION(eevee_ray_trace_screen) GPU_SHADER_CREATE_INFO(eevee_ray_denoise_spatial) .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) .additional_info("eevee_shared", + "eevee_global_ubo", "eevee_sampling_data", "draw_view", "eevee_hiz_data", @@ -90,7 +92,6 @@ GPU_SHADER_CREATE_INFO(eevee_ray_denoise_spatial) .image(5, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "out_hit_depth_img") .image(6, RAYTRACE_TILEMASK_FORMAT, Qualifier::READ, ImageType::UINT_2D, "tile_mask_img") .storage_buf(4, Qualifier::READ, "uint", "tiles_coord_buf[]") - .uniform_buf(1, "RayTraceData", "raytrace_buf") .compute_source("eevee_ray_denoise_spatial_comp.glsl"); EEVEE_RAYTRACE_CLOSURE_VARIATION(eevee_ray_denoise_spatial) @@ -98,8 +99,7 @@ EEVEE_RAYTRACE_CLOSURE_VARIATION(eevee_ray_denoise_spatial) GPU_SHADER_CREATE_INFO(eevee_ray_denoise_temporal) .do_static_compilation(true) .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) - .additional_info("eevee_shared", "draw_view", "eevee_hiz_data") - .uniform_buf(1, "RayTraceData", "raytrace_buf") + .additional_info("eevee_shared", "eevee_global_ubo", "draw_view", "eevee_hiz_data") .sampler(0, ImageType::FLOAT_2D, "radiance_history_tx") .sampler(1, ImageType::FLOAT_2D, "variance_history_tx") .sampler(2, ImageType::UINT_2D, "tilemask_history_tx") @@ -113,14 +113,14 @@ GPU_SHADER_CREATE_INFO(eevee_ray_denoise_temporal) GPU_SHADER_CREATE_INFO(eevee_ray_denoise_bilateral) .local_group_size(RAYTRACE_GROUP_SIZE, RAYTRACE_GROUP_SIZE) - .additional_info("eevee_shared", "eevee_sampling_data", "draw_view", "eevee_hiz_data") + .additional_info( + "eevee_shared", "eevee_global_ubo", "eevee_sampling_data", "draw_view", "eevee_hiz_data") .sampler(0, ImageType::FLOAT_2D_ARRAY, "gbuffer_closure_tx") .image(1, RAYTRACE_RADIANCE_FORMAT, Qualifier::READ, ImageType::FLOAT_2D, "in_radiance_img") .image(2, RAYTRACE_RADIANCE_FORMAT, Qualifier::WRITE, ImageType::FLOAT_2D, "out_radiance_img") .image(3, RAYTRACE_VARIANCE_FORMAT, Qualifier::READ, ImageType::FLOAT_2D, "in_variance_img") .image(6, RAYTRACE_TILEMASK_FORMAT, Qualifier::READ, ImageType::UINT_2D, "tile_mask_img") .storage_buf(4, Qualifier::READ, "uint", "tiles_coord_buf[]") - .uniform_buf(1, "RayTraceData", "raytrace_buf") .compute_source("eevee_ray_denoise_bilateral_comp.glsl"); EEVEE_RAYTRACE_CLOSURE_VARIATION(eevee_ray_denoise_bilateral) diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_volume_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_volume_info.hh index e9b8c1aaf06..9d4baf2d31b 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_volume_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_volume_info.hh @@ -8,13 +8,12 @@ /* Used for shaders that need the final accumulated volume transmittance and scattering. */ GPU_SHADER_CREATE_INFO(eevee_volume_lib) - .additional_info("eevee_shared") - .additional_info("draw_view") - .uniform_buf(VOLUMES_INFO_BUF_SLOT, "VolumesInfoData", "volumes_info_buf") + .additional_info("eevee_shared", "eevee_global_ubo", "draw_view") .sampler(VOLUME_SCATTERING_TEX_SLOT, ImageType::FLOAT_3D, "volume_scattering_tx") .sampler(VOLUME_TRANSMITTANCE_TEX_SLOT, ImageType::FLOAT_3D, "volume_transmittance_tx"); GPU_SHADER_CREATE_INFO(eevee_volume_properties_data) + .additional_info("eevee_global_ubo") .image(VOLUME_PROP_SCATTERING_IMG_SLOT, GPU_R11F_G11F_B10F, Qualifier::READ, @@ -38,6 +37,7 @@ GPU_SHADER_CREATE_INFO(eevee_volume_properties_data) GPU_SHADER_CREATE_INFO(eevee_volume_scatter) .additional_info("eevee_shared") + .additional_info("eevee_global_ubo") .additional_info("draw_resource_id_varying") .additional_info("draw_view") .additional_info("eevee_light_data") @@ -46,7 +46,6 @@ GPU_SHADER_CREATE_INFO(eevee_volume_scatter) .additional_info("eevee_sampling_data") .compute_source("eevee_volume_scatter_comp.glsl") .local_group_size(VOLUME_GROUP_SIZE, VOLUME_GROUP_SIZE, VOLUME_GROUP_SIZE) - .uniform_buf(VOLUMES_INFO_BUF_SLOT, "VolumesInfoData", "volumes_info_buf") .additional_info("eevee_volume_properties_data") .image(4, GPU_R11F_G11F_B10F, Qualifier::WRITE, ImageType::FLOAT_3D, "out_scattering_img") .image(5, GPU_R11F_G11F_B10F, Qualifier::WRITE, ImageType::FLOAT_3D, "out_extinction_img") @@ -61,11 +60,9 @@ GPU_SHADER_CREATE_INFO(eevee_volume_scatter_with_lights) .do_static_compilation(true); GPU_SHADER_CREATE_INFO(eevee_volume_integration) - .additional_info("eevee_shared") - .additional_info("draw_view") + .additional_info("eevee_shared", "eevee_global_ubo", "draw_view") .compute_source("eevee_volume_integration_comp.glsl") .local_group_size(VOLUME_INTEGRATION_GROUP_SIZE, VOLUME_INTEGRATION_GROUP_SIZE, 1) - .uniform_buf(VOLUMES_INFO_BUF_SLOT, "VolumesInfoData", "volumes_info_buf") /* Inputs. */ .sampler(0, ImageType::FLOAT_3D, "in_scattering_tx") .sampler(1, ImageType::FLOAT_3D, "in_extinction_tx")