radv: use nir_opt_fragdepth

Cyberpunk 2077 writes unmodified depth.

Foz-DB Navi21:
Totals from 28 (0.04% of 79395) affected shaders:
Instrs: 6484 -> 6448 (-0.56%)
CodeSize: 36016 -> 35784 (-0.64%)
Latency: 58517 -> 58400 (-0.20%)
InvThroughput: 7719 -> 7717 (-0.03%)
Branches: 129 -> 119 (-7.75%)
PreVGPRs: 394 -> 372 (-5.58%)

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31874>
This commit is contained in:
Georg Lehmann
2024-10-28 14:45:48 +01:00
committed by Marge Bot
parent e52a599eba
commit 938f5ec7ce

View File

@@ -2665,6 +2665,15 @@ radv_graphics_shaders_compile(struct radv_device *device, struct vk_pipeline_cac
unsigned rast_prim = radv_get_rasterization_prim(stages, gfx_state); unsigned rast_prim = radv_get_rasterization_prim(stages, gfx_state);
NIR_PASS(_, stages[MESA_SHADER_FRAGMENT].nir, radv_nir_lower_fs_barycentric, gfx_state, rast_prim); NIR_PASS(_, stages[MESA_SHADER_FRAGMENT].nir, radv_nir_lower_fs_barycentric, gfx_state, rast_prim);
/* frag_depth = gl_FragCoord.z broadcasts to all samples of the fragment shader invocation,
* so only optimize it away if we know there is only one sample per invocation.
* Because we don't know if sample shading is used with factor 1.0f, this means
* we only optimize single sampled shaders.
*/
if ((gfx_state->lib_flags & VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT) &&
!gfx_state->dynamic_rasterization_samples && gfx_state->ms.rasterization_samples == 0)
NIR_PASS(_, stages[MESA_SHADER_FRAGMENT].nir, nir_opt_fragdepth);
} }
if (stages[MESA_SHADER_VERTEX].nir && !gfx_state->vs.has_prolog) if (stages[MESA_SHADER_VERTEX].nir && !gfx_state->vs.has_prolog)