EEVEE-Next: Merge UBOs #112046

Merged
Miguel Pozo merged 8 commits from pragma37/blender:pull-eevee-merge-ubos into main 2023-09-08 21:03:45 +02:00
12 changed files with 47 additions and 3 deletions
Showing only changes of commit 2e0f769863 - Show all commits

View File

@ -54,6 +54,7 @@ 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_global_resources(&render_pass_ps_);
inst_.sampling.bind_resources(&render_pass_ps_);
inst_.hiz_buffer.bind_resources(&render_pass_ps_);

View File

@ -248,6 +248,7 @@ void DepthOfField::bokeh_lut_pass_sync()
/* Precompute bokeh texture. */
bokeh_lut_ps_.init();
bokeh_lut_ps_.shader_set(inst_.shaders.static_shader_get(DOF_BOKEH_LUT));
inst_.bind_global_resources(&bokeh_lut_ps_);
bokeh_lut_ps_.bind_image("out_gather_lut_img", &bokeh_gather_lut_tx_);
bokeh_lut_ps_.bind_image("out_scatter_lut_img", &bokeh_scatter_lut_tx_);
bokeh_lut_ps_.bind_image("out_resolve_lut_img", &bokeh_resolve_lut_tx_);
@ -262,6 +263,7 @@ void DepthOfField::setup_pass_sync()
setup_ps_.shader_set(inst_.shaders.static_shader_get(DOF_SETUP));
setup_ps_.bind_texture("color_tx", &input_color_tx_, no_filter);
setup_ps_.bind_texture("depth_tx", &render_buffers.depth_tx, no_filter);
inst_.bind_global_resources(&setup_ps_);
setup_ps_.bind_image("out_color_img", &setup_color_tx_);
setup_ps_.bind_image("out_coc_img", &setup_coc_tx_);
setup_ps_.dispatch(&dispatch_setup_size_);
@ -284,6 +286,7 @@ void DepthOfField::stabilize_pass_sync()
stabilize_ps_.bind_texture("velocity_tx", &render_buffers.vector_tx, no_filter);
stabilize_ps_.bind_texture("in_history_tx", &stabilize_input_, with_filter);
stabilize_ps_.bind_texture("depth_tx", &render_buffers.depth_tx, no_filter);
inst_.bind_global_resources(&stabilize_ps_);
stabilize_ps_.push_constant("u_use_history", &stabilize_valid_history_, 1);
stabilize_ps_.bind_image("out_coc_img", reduced_coc_tx_.mip_view(0));
stabilize_ps_.bind_image("out_color_img", reduced_color_tx_.mip_view(0));
@ -307,6 +310,7 @@ void DepthOfField::reduce_pass_sync()
{
reduce_ps_.init();
reduce_ps_.shader_set(inst_.shaders.static_shader_get(DOF_REDUCE));
inst_.bind_global_resources(&reduce_ps_);
reduce_ps_.bind_texture("downsample_tx", &downsample_tx_, no_filter);
reduce_ps_.bind_ssbo("scatter_fg_list_buf", scatter_fg_list_buf_);
reduce_ps_.bind_ssbo("scatter_bg_list_buf", scatter_bg_list_buf_);
@ -374,6 +378,7 @@ void DepthOfField::gather_pass_sync()
drw_pass.init();
inst_.sampling.bind_resources(&drw_pass);
drw_pass.shader_set(inst_.shaders.static_shader_get(sh_type));
inst_.bind_global_resources(&drw_pass);
drw_pass.bind_texture("color_bilinear_tx", reduced_color_tx_, gather_bilinear);
drw_pass.bind_texture("color_tx", reduced_color_tx_, gather_nearest);
drw_pass.bind_texture("coc_tx", reduced_coc_tx_, gather_nearest);
@ -437,6 +442,7 @@ void DepthOfField::hole_fill_pass_sync()
hole_fill_ps_.init();
inst_.sampling.bind_resources(&hole_fill_ps_);
hole_fill_ps_.shader_set(inst_.shaders.static_shader_get(DOF_GATHER_HOLE_FILL));
inst_.bind_global_resources(&hole_fill_ps_);
hole_fill_ps_.bind_texture("color_bilinear_tx", reduced_color_tx_, gather_bilinear);
hole_fill_ps_.bind_texture("color_tx", reduced_color_tx_, gather_nearest);
hole_fill_ps_.bind_texture("coc_tx", reduced_coc_tx_, gather_nearest);
@ -457,6 +463,7 @@ void DepthOfField::resolve_pass_sync()
resolve_ps_.init();
inst_.sampling.bind_resources(&resolve_ps_);
resolve_ps_.shader_set(inst_.shaders.static_shader_get(sh_type));
inst_.bind_global_resources(&resolve_ps_);
resolve_ps_.bind_texture("depth_tx", &render_buffers.depth_tx, no_filter);
resolve_ps_.bind_texture("color_tx", &input_color_tx_, no_filter);
resolve_ps_.bind_texture("stable_color_tx", &resolve_stable_color_tx_, no_filter);

View File

@ -434,6 +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));
inst_.bind_global_resources(&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]));

View File

@ -327,8 +327,6 @@ bool Instance::do_probe_sync() const
**/
void Instance::render_sample()
{
GPU_uniformbuf_bind(global_data_, GLOBAL_BUF_SLOT);
if (sampling.finished_viewport()) {
film.display();
return;

View File

@ -223,6 +223,11 @@ class Instance {
global_data_.push_update();
}
template<typename T> void bind_global_resources(draw::detail::PassBase<T> *pass)
{
pass->bind_ubo(GLOBAL_BUF_SLOT, &global_data_);
}
private:
static void object_sync_render(void *instance_,
Object *ob,

View File

@ -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_global_resources(&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_);

View File

@ -146,6 +146,7 @@ void MotionBlurModule::sync()
eShaderType shader = vector_tx_format == GPU_RG16F ? MOTION_BLUR_TILE_FLATTEN_RG :
MOTION_BLUR_TILE_FLATTEN_RGBA;
sub.shader_set(inst_.shaders.static_shader_get(shader));
inst_.bind_global_resources(&sub);
sub.bind_texture("depth_tx", &render_buffers.depth_tx);
sub.bind_image("velocity_img", &render_buffers.vector_tx);
sub.bind_image("out_tiles_img", &tiles_tx_);
@ -165,6 +166,7 @@ void MotionBlurModule::sync()
/* Do the motion blur gather algorithm. */
PassSimple::Sub &sub = motion_blur_ps_.sub("ConvolveGather");
sub.shader_set(inst_.shaders.static_shader_get(MOTION_BLUR_GATHER));
inst_.bind_global_resources(&sub);
sub.bind_ssbo("tile_indirection_buf", tile_indirection_buf_);
sub.bind_texture("depth_tx", &render_buffers.depth_tx, no_filter);
sub.bind_texture("velocity_tx", &render_buffers.vector_tx, no_filter);

View File

@ -43,6 +43,8 @@ void BackgroundPipeline::sync(GPUMaterial *gpumat, const float background_opacit
/* Required by validation layers. */
inst_.cryptomatte.bind_resources(&world_ps_);
inst_.bind_global_resources(&world_ps_);
world_ps_.draw(DRW_cache_fullscreen_quad_get(), handle);
/* To allow opaque pass rendering over it. */
world_ps_.barrier(GPU_BARRIER_SHADER_IMAGE_ACCESS);
@ -79,6 +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);
inst_.bind_global_resources(&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_);
@ -113,6 +116,7 @@ void WorldVolumePipeline::sync(GPUMaterial *gpumat)
{
world_ps_.init();
world_ps_.state_set(DRW_STATE_WRITE_COLOR);
inst_.bind_global_resources(&world_ps_);
inst_.volume.bind_properties_buffers(world_ps_);
inst_.sampling.bind_resources(&world_ps_);
@ -150,6 +154,7 @@ void ShadowPipeline::sync()
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_global_resources(&surface_ps_);
inst_.sampling.bind_resources(&surface_ps_);
}
@ -187,6 +192,7 @@ void ForwardPipeline::sync()
/* Textures. */
prepass_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx);
inst_.bind_global_resources(&prepass_ps_);
inst_.velocity.bind_resources(&prepass_ps_);
inst_.sampling.bind_resources(&prepass_ps_);
}
@ -216,6 +222,7 @@ void ForwardPipeline::sync()
/* Textures. */
opaque_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx);
inst_.bind_global_resources(&opaque_ps_);
inst_.lights.bind_resources(&opaque_ps_);
inst_.shadows.bind_resources(&opaque_ps_);
inst_.sampling.bind_resources(&opaque_ps_);
@ -240,6 +247,7 @@ void ForwardPipeline::sync()
/* Textures. */
sub.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx);
inst_.bind_global_resources(&sub);
inst_.lights.bind_resources(&sub);
inst_.shadows.bind_resources(&sub);
inst_.volume.bind_resources(sub);
@ -352,6 +360,7 @@ void DeferredLayer::begin_sync()
/* Textures. */
prepass_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx);
inst_.bind_global_resources(&prepass_ps_);
inst_.velocity.bind_resources(&prepass_ps_);
inst_.sampling.bind_resources(&prepass_ps_);
}
@ -392,6 +401,7 @@ void DeferredLayer::begin_sync()
/* Textures. */
gbuffer_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx);
inst_.bind_global_resources(&gbuffer_ps_);
inst_.sampling.bind_resources(&gbuffer_ps_);
inst_.hiz_buffer.bind_resources(&gbuffer_ps_);
inst_.cryptomatte.bind_resources(&gbuffer_ps_);
@ -433,6 +443,7 @@ void DeferredLayer::end_sync()
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);
inst_.bind_global_resources(&eval_light_ps_);
inst_.lights.bind_resources(&eval_light_ps_);
inst_.shadows.bind_resources(&eval_light_ps_);
inst_.sampling.bind_resources(&eval_light_ps_);
@ -592,6 +603,7 @@ void VolumePipeline::sync()
{
volume_ps_.init();
volume_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx);
inst_.bind_global_resources(&volume_ps_);
inst_.volume.bind_properties_buffers(volume_ps_);
inst_.sampling.bind_resources(&volume_ps_);
}
@ -622,6 +634,7 @@ void DeferredProbeLayer::begin_sync()
/* Textures. */
prepass_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx);
inst_.bind_global_resources(&prepass_ps_);
inst_.velocity.bind_resources(&prepass_ps_);
inst_.sampling.bind_resources(&prepass_ps_);
}
@ -654,6 +667,7 @@ void DeferredProbeLayer::begin_sync()
/* Textures. */
gbuffer_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx);
inst_.bind_global_resources(&gbuffer_ps_);
inst_.sampling.bind_resources(&gbuffer_ps_);
inst_.hiz_buffer.bind_resources(&gbuffer_ps_);
inst_.cryptomatte.bind_resources(&gbuffer_ps_);
@ -698,6 +712,7 @@ void DeferredProbeLayer::end_sync()
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);
inst_.bind_global_resources(&eval_light_ps_);
inst_.lights.bind_resources(&eval_light_ps_);
inst_.shadows.bind_resources(&eval_light_ps_);
inst_.sampling.bind_resources(&eval_light_ps_);
@ -812,7 +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): There should be no view dependent behavior during capture. */
/* TODO(fclem): Remove. Binded to get the camera data,
* but there should be no view dependent behavior during capture. */
inst_.bind_global_resources(&surface_ps_);
}
PassMain::Sub *CapturePipeline::surface_material_add(GPUMaterial *gpumat)

View File

@ -48,6 +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_);
inst_.bind_global_resources(&pass);
pass.dispatch(&tile_classify_dispatch_size_);
pass.barrier(GPU_BARRIER_SHADER_IMAGE_ACCESS | GPU_BARRIER_SHADER_STORAGE);
}
@ -60,6 +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_);
inst_.bind_global_resources(&pass);
pass.dispatch(&tile_compact_dispatch_size_);
pass.barrier(GPU_BARRIER_SHADER_STORAGE);
}
@ -89,6 +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_);
inst_.bind_global_resources(&pass);
inst_.hiz_buffer.bind_resources(&pass);
inst_.sampling.bind_resources(&pass);
inst_.reflection_probes.bind_resources(&pass);
@ -112,6 +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_);
inst_.bind_global_resources(&pass);
inst_.sampling.bind_resources(&pass);
inst_.hiz_buffer.bind_resources(&pass);
pass.dispatch(denoise_dispatch_buf_);
@ -121,6 +125,7 @@ void RayTraceModule::sync()
PassSimple &pass = denoise_temporal_ps_;
pass.init();
pass.shader_set(inst_.shaders.static_shader_get(RAY_DENOISE_TEMPORAL));
inst_.bind_global_resources(&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_);
@ -146,6 +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_);
inst_.bind_global_resources(&pass);
inst_.sampling.bind_resources(&pass);
inst_.hiz_buffer.bind_resources(&pass);
pass.dispatch(denoise_dispatch_buf_);

View File

@ -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_global_resources(&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_global_resources(&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_global_resources(&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_);

View File

@ -38,6 +38,7 @@ void SubsurfaceModule::end_sync()
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_.bind_global_resources(&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);

View File

@ -271,6 +271,7 @@ void VolumeModule::end_sync()
integration_ps_.init();
integration_ps_.shader_set(inst_.shaders.static_shader_get(VOLUME_INTEGRATION));
inst_.bind_global_resources(&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_);
@ -283,6 +284,7 @@ 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_global_resources(&resolve_ps_);
bind_resources(resolve_ps_);
resolve_ps_.bind_texture("depth_tx", &inst_.render_buffers.depth_tx);
resolve_ps_.bind_image(RBUFS_COLOR_SLOT, &inst_.render_buffers.rp_color_tx);