Merge pull request #49576 from clayjohn/VULKAN-SSAO-uniform-sets
Store SSAO uniform sets per viewport
This commit is contained in:
commit
3f613236e0
@ -940,10 +940,10 @@ void EffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i
|
|||||||
RD::get_singleton()->compute_list_end();
|
RD::get_singleton()->compute_list_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectsRD::gather_ssao(RD::ComputeListID p_compute_list, const Vector<RID> p_ao_slices, const SSAOSettings &p_settings, bool p_adaptive_base_pass) {
|
void EffectsRD::gather_ssao(RD::ComputeListID p_compute_list, const Vector<RID> p_ao_slices, const SSAOSettings &p_settings, bool p_adaptive_base_pass, RID p_gather_uniform_set, RID p_importance_map_uniform_set) {
|
||||||
RD::get_singleton()->compute_list_bind_uniform_set(p_compute_list, ssao.gather_uniform_set, 0);
|
RD::get_singleton()->compute_list_bind_uniform_set(p_compute_list, p_gather_uniform_set, 0);
|
||||||
if ((p_settings.quality == RS::ENV_SSAO_QUALITY_ULTRA) && !p_adaptive_base_pass) {
|
if ((p_settings.quality == RS::ENV_SSAO_QUALITY_ULTRA) && !p_adaptive_base_pass) {
|
||||||
RD::get_singleton()->compute_list_bind_uniform_set(p_compute_list, ssao.importance_map_uniform_set, 1);
|
RD::get_singleton()->compute_list_bind_uniform_set(p_compute_list, p_importance_map_uniform_set, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
@ -966,7 +966,7 @@ void EffectsRD::gather_ssao(RD::ComputeListID p_compute_list, const Vector<RID>
|
|||||||
RD::get_singleton()->compute_list_add_barrier(p_compute_list);
|
RD::get_singleton()->compute_list_add_barrier(p_compute_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer, RID p_depth_mipmaps_texture, const Vector<RID> &p_depth_mipmaps, RID p_ao, const Vector<RID> p_ao_slices, RID p_ao_pong, const Vector<RID> p_ao_pong_slices, RID p_upscale_buffer, RID p_importance_map, RID p_importance_map_pong, const CameraMatrix &p_projection, const SSAOSettings &p_settings, bool p_invalidate_uniform_sets) {
|
void EffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer, RID p_depth_mipmaps_texture, const Vector<RID> &p_depth_mipmaps, RID p_ao, const Vector<RID> p_ao_slices, RID p_ao_pong, const Vector<RID> p_ao_pong_slices, RID p_upscale_buffer, RID p_importance_map, RID p_importance_map_pong, const CameraMatrix &p_projection, const SSAOSettings &p_settings, bool p_invalidate_uniform_sets, RID &r_downsample_uniform_set, RID &r_gather_uniform_set, RID &r_importance_map_uniform_set) {
|
||||||
RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin();
|
RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin();
|
||||||
RD::get_singleton()->draw_command_begin_label("SSAO");
|
RD::get_singleton()->draw_command_begin_label("SSAO");
|
||||||
/* FIRST PASS */
|
/* FIRST PASS */
|
||||||
@ -996,7 +996,7 @@ void EffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer, RID p_dep
|
|||||||
u.ids.push_back(p_depth_mipmaps[3]);
|
u.ids.push_back(p_depth_mipmaps[3]);
|
||||||
uniforms.push_back(u);
|
uniforms.push_back(u);
|
||||||
}
|
}
|
||||||
ssao.downsample_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, ssao.downsample_shader.version_get_shader(ssao.downsample_shader_version, 2), 2);
|
r_downsample_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, ssao.downsample_shader.version_get_shader(ssao.downsample_shader_version, 2), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
float depth_linearize_mul = -p_projection.matrix[3][2];
|
float depth_linearize_mul = -p_projection.matrix[3][2];
|
||||||
@ -1031,7 +1031,7 @@ void EffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer, RID p_dep
|
|||||||
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_depth_buffer), 0);
|
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_depth_buffer), 0);
|
||||||
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_depth_mipmaps[0]), 1);
|
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_depth_mipmaps[0]), 1);
|
||||||
if (p_settings.quality > RS::ENV_SSAO_QUALITY_MEDIUM) {
|
if (p_settings.quality > RS::ENV_SSAO_QUALITY_MEDIUM) {
|
||||||
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, ssao.downsample_uniform_set, 2);
|
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, r_downsample_uniform_set, 2);
|
||||||
}
|
}
|
||||||
RD::get_singleton()->compute_list_set_push_constant(compute_list, &ssao.downsample_push_constant, sizeof(SSAODownsamplePushConstant));
|
RD::get_singleton()->compute_list_set_push_constant(compute_list, &ssao.downsample_push_constant, sizeof(SSAODownsamplePushConstant));
|
||||||
|
|
||||||
@ -1115,7 +1115,7 @@ void EffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer, RID p_dep
|
|||||||
u.ids.push_back(ssao.gather_constants_buffer);
|
u.ids.push_back(ssao.gather_constants_buffer);
|
||||||
uniforms.push_back(u);
|
uniforms.push_back(u);
|
||||||
}
|
}
|
||||||
ssao.gather_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, ssao.gather_shader.version_get_shader(ssao.gather_shader_version, 0), 0);
|
r_gather_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, ssao.gather_shader.version_get_shader(ssao.gather_shader_version, 0), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_invalidate_uniform_sets) {
|
if (p_invalidate_uniform_sets) {
|
||||||
@ -1142,7 +1142,7 @@ void EffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer, RID p_dep
|
|||||||
u.ids.push_back(ssao.importance_map_load_counter);
|
u.ids.push_back(ssao.importance_map_load_counter);
|
||||||
uniforms.push_back(u);
|
uniforms.push_back(u);
|
||||||
}
|
}
|
||||||
ssao.importance_map_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, ssao.gather_shader.version_get_shader(ssao.gather_shader_version, 2), 1);
|
r_importance_map_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, ssao.gather_shader.version_get_shader(ssao.gather_shader_version, 2), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_settings.quality == RS::ENV_SSAO_QUALITY_ULTRA) {
|
if (p_settings.quality == RS::ENV_SSAO_QUALITY_ULTRA) {
|
||||||
@ -1153,7 +1153,7 @@ void EffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer, RID p_dep
|
|||||||
ssao.importance_map_push_constant.power = p_settings.power;
|
ssao.importance_map_push_constant.power = p_settings.power;
|
||||||
//base pass
|
//base pass
|
||||||
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, ssao.pipelines[SSAO_GATHER_BASE]);
|
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, ssao.pipelines[SSAO_GATHER_BASE]);
|
||||||
gather_ssao(compute_list, p_ao_pong_slices, p_settings, true);
|
gather_ssao(compute_list, p_ao_pong_slices, p_settings, true, r_gather_uniform_set, RID());
|
||||||
//generate importance map
|
//generate importance map
|
||||||
|
|
||||||
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, ssao.pipelines[SSAO_GENERATE_IMPORTANCE_MAP]);
|
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, ssao.pipelines[SSAO_GENERATE_IMPORTANCE_MAP]);
|
||||||
@ -1184,7 +1184,7 @@ void EffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer, RID p_dep
|
|||||||
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, ssao.pipelines[SSAO_GATHER]);
|
RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, ssao.pipelines[SSAO_GATHER]);
|
||||||
}
|
}
|
||||||
|
|
||||||
gather_ssao(compute_list, p_ao_slices, p_settings, false);
|
gather_ssao(compute_list, p_ao_slices, p_settings, false, r_gather_uniform_set, r_importance_map_uniform_set);
|
||||||
RD::get_singleton()->draw_command_end_label(); // Gather SSAO
|
RD::get_singleton()->draw_command_end_label(); // Gather SSAO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,12 +385,10 @@ class EffectsRD {
|
|||||||
SSAODownsamplePushConstant downsample_push_constant;
|
SSAODownsamplePushConstant downsample_push_constant;
|
||||||
SsaoDownsampleShaderRD downsample_shader;
|
SsaoDownsampleShaderRD downsample_shader;
|
||||||
RID downsample_shader_version;
|
RID downsample_shader_version;
|
||||||
RID downsample_uniform_set;
|
|
||||||
|
|
||||||
SSAOGatherPushConstant gather_push_constant;
|
SSAOGatherPushConstant gather_push_constant;
|
||||||
SsaoShaderRD gather_shader;
|
SsaoShaderRD gather_shader;
|
||||||
RID gather_shader_version;
|
RID gather_shader_version;
|
||||||
RID gather_uniform_set;
|
|
||||||
RID gather_constants_buffer;
|
RID gather_constants_buffer;
|
||||||
bool gather_initialized = false;
|
bool gather_initialized = false;
|
||||||
|
|
||||||
@ -398,7 +396,6 @@ class EffectsRD {
|
|||||||
SsaoImportanceMapShaderRD importance_map_shader;
|
SsaoImportanceMapShaderRD importance_map_shader;
|
||||||
RID importance_map_shader_version;
|
RID importance_map_shader_version;
|
||||||
RID importance_map_load_counter;
|
RID importance_map_load_counter;
|
||||||
RID importance_map_uniform_set;
|
|
||||||
RID counter_uniform_set;
|
RID counter_uniform_set;
|
||||||
|
|
||||||
SSAOBlurPushConstant blur_push_constant;
|
SSAOBlurPushConstant blur_push_constant;
|
||||||
@ -746,8 +743,8 @@ public:
|
|||||||
|
|
||||||
void tonemapper(RID p_source_color, RID p_dst_framebuffer, const TonemapSettings &p_settings);
|
void tonemapper(RID p_source_color, RID p_dst_framebuffer, const TonemapSettings &p_settings);
|
||||||
|
|
||||||
void gather_ssao(RD::ComputeListID p_compute_list, const Vector<RID> p_ao_slices, const SSAOSettings &p_settings, bool p_adaptive_base_pass);
|
void gather_ssao(RD::ComputeListID p_compute_list, const Vector<RID> p_ao_slices, const SSAOSettings &p_settings, bool p_adaptive_base_pass, RID p_gather_uniform_set, RID p_importance_map_uniform_set);
|
||||||
void generate_ssao(RID p_depth_buffer, RID p_normal_buffer, RID p_depth_mipmaps_texture, const Vector<RID> &depth_mipmaps, RID p_ao, const Vector<RID> p_ao_slices, RID p_ao_pong, const Vector<RID> p_ao_pong_slices, RID p_upscale_buffer, RID p_importance_map, RID p_importance_map_pong, const CameraMatrix &p_projection, const SSAOSettings &p_settings, bool p_invalidate_uniform_sets);
|
void generate_ssao(RID p_depth_buffer, RID p_normal_buffer, RID p_depth_mipmaps_texture, const Vector<RID> &depth_mipmaps, RID p_ao, const Vector<RID> p_ao_slices, RID p_ao_pong, const Vector<RID> p_ao_pong_slices, RID p_upscale_buffer, RID p_importance_map, RID p_importance_map_pong, const CameraMatrix &p_projection, const SSAOSettings &p_settings, bool p_invalidate_uniform_sets, RID &r_downsample_uniform_set, RID &r_gather_uniform_set, RID &r_importance_map_uniform_set);
|
||||||
|
|
||||||
void roughness_limit(RID p_source_normal, RID p_roughness, const Size2i &p_size, float p_curve);
|
void roughness_limit(RID p_source_normal, RID p_roughness, const Size2i &p_size, float p_curve);
|
||||||
void cubemap_downsample(RID p_source_cubemap, RID p_dest_cubemap, const Size2i &p_size);
|
void cubemap_downsample(RID p_source_cubemap, RID p_dest_cubemap, const Size2i &p_size);
|
||||||
|
@ -1728,7 +1728,7 @@ void RendererSceneRenderRD::_process_ssao(RID p_render_buffers, RID p_environmen
|
|||||||
settings.half_screen_size = Size2i(buffer_width, buffer_height);
|
settings.half_screen_size = Size2i(buffer_width, buffer_height);
|
||||||
settings.quarter_screen_size = Size2i(half_width, half_height);
|
settings.quarter_screen_size = Size2i(half_width, half_height);
|
||||||
|
|
||||||
storage->get_effects()->generate_ssao(rb->depth_texture, p_normal_buffer, rb->ssao.depth, rb->ssao.depth_slices, rb->ssao.ao_deinterleaved, rb->ssao.ao_deinterleaved_slices, rb->ssao.ao_pong, rb->ssao.ao_pong_slices, rb->ssao.ao_final, rb->ssao.importance_map[0], rb->ssao.importance_map[1], p_projection, settings, uniform_sets_are_invalid);
|
storage->get_effects()->generate_ssao(rb->depth_texture, p_normal_buffer, rb->ssao.depth, rb->ssao.depth_slices, rb->ssao.ao_deinterleaved, rb->ssao.ao_deinterleaved_slices, rb->ssao.ao_pong, rb->ssao.ao_pong_slices, rb->ssao.ao_final, rb->ssao.importance_map[0], rb->ssao.importance_map[1], p_projection, settings, uniform_sets_are_invalid, rb->ssao.downsample_uniform_set, rb->ssao.gather_uniform_set, rb->ssao.importance_map_uniform_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const RenderDataRD *p_render_data) {
|
void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const RenderDataRD *p_render_data) {
|
||||||
|
@ -459,6 +459,10 @@ private:
|
|||||||
Vector<RID> ao_pong_slices;
|
Vector<RID> ao_pong_slices;
|
||||||
RID ao_final;
|
RID ao_final;
|
||||||
RID importance_map[2];
|
RID importance_map[2];
|
||||||
|
|
||||||
|
RID downsample_uniform_set;
|
||||||
|
RID gather_uniform_set;
|
||||||
|
RID importance_map_uniform_set;
|
||||||
} ssao;
|
} ssao;
|
||||||
|
|
||||||
struct SSR {
|
struct SSR {
|
||||||
|
Loading…
Reference in New Issue
Block a user