Fix #113580: Workbench: Always setup in_front_depth_tx

Always setup in-front depth, since Overlays can be updated without causing a Workbench re-sync.
This commit is contained in:
Miguel Pozo 2023-10-13 17:12:40 +02:00
parent 5e67e44963
commit 42aa97a080
1 changed files with 14 additions and 12 deletions

View File

@ -430,6 +430,20 @@ class Instance {
int2 resolution = scene_state.resolution;
/** Always setup in-front depth, since Overlays can be updated without causing a Workbench
* re-sync (See #113580). */
bool needs_depth_in_front = !transparent_ps.accumulation_in_front_ps_.is_empty() ||
(!opaque_ps.gbuffer_in_front_ps_.is_empty() &&
scene_state.overlays_enabled && scene_state.sample == 0);
resources.depth_in_front_tx.wrap(needs_depth_in_front ? depth_in_front_tx : nullptr);
if ((!needs_depth_in_front && scene_state.overlays_enabled) ||
(needs_depth_in_front && opaque_ps.gbuffer_in_front_ps_.is_empty()))
{
resources.clear_in_front_fb.ensure(GPU_ATTACHMENT_TEXTURE(depth_in_front_tx));
resources.clear_in_front_fb.bind();
GPU_framebuffer_clear_depth_stencil(resources.clear_in_front_fb, 1.0f, 0x00);
}
if (scene_state.render_finished) {
/* Just copy back the already rendered result */
anti_aliasing_ps.draw(manager, view, scene_state, resources);
@ -454,18 +468,6 @@ class Instance {
GPU_framebuffer_multi_clear(resources.clear_fb, reinterpret_cast<float(*)[4]>(clear_colors));
GPU_framebuffer_clear_depth_stencil(resources.clear_fb, 1.0f, 0x00);
bool needs_depth_in_front = !transparent_ps.accumulation_in_front_ps_.is_empty() ||
(!opaque_ps.gbuffer_in_front_ps_.is_empty() &&
scene_state.overlays_enabled && scene_state.sample == 0);
resources.depth_in_front_tx.wrap(needs_depth_in_front ? depth_in_front_tx : nullptr);
if ((!needs_depth_in_front && scene_state.overlays_enabled) ||
(needs_depth_in_front && opaque_ps.gbuffer_in_front_ps_.is_empty()))
{
resources.clear_in_front_fb.ensure(GPU_ATTACHMENT_TEXTURE(depth_in_front_tx));
resources.clear_in_front_fb.bind();
GPU_framebuffer_clear_depth_stencil(resources.clear_in_front_fb, 1.0f, 0x00);
}
opaque_ps.draw(
manager, view, resources, resolution, scene_state.draw_shadows ? &shadow_ps : nullptr);
transparent_ps.draw(manager, view, resources, resolution);