radeonsi: eliminate shader code computing killed Z/S/samplemask PS outputs

Compile a monolithic optimized shader to do that, and clean up the comments.

Reviewed-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32713>
This commit is contained in:
Marek Olšák 2024-12-13 16:07:00 -05:00 committed by Marge Bot
parent 58132d6fc8
commit 5003465c42

View file

@ -2698,23 +2698,27 @@ void si_ps_key_update_framebuffer_blend_dsa_rasterizer(struct si_context *sctx)
!sel->info.base.writes_memory && !sel->info.base.writes_memory &&
!key->ps.part.epilog.spi_shader_col_format; !key->ps.part.epilog.spi_shader_col_format;
/* Eliminate shader code computing output values that are unused. /* Compile PS monolithically if it eliminates code or improves performance. */
* This enables dead code elimination between shader parts. if (sel->info.colors_written_4bit &
* Check if any output is eliminated. /* Dual source blending never has color buffer 1 enabled, so ignore it. */
* (blend->dual_src_blend ? 0xffffff0f : 0xffffffff) &
* Dual source blending never has color buffer 1 enabled, so ignore it. ~(sctx->framebuffer.colorbuf_enabled_4bit & blend->cb_target_enabled_4bit)) {
* /* Eliminate shader code computing the color outputs that have missing color buffer
* On gfx11, pixel shaders that write memory should be compiled with an inlined epilog, * attachments or are disabled by colormask.
*/
key->ps.opt.prefer_mono = 1;
} else if (sctx->gfx_level >= GFX11 && sel->info.base.writes_memory) {
/* On gfx11, pixel shaders that write memory should be compiled with an inlined epilog,
* so that the compiler can see s_endpgm and deallocates VGPRs before memory stores return. * so that the compiler can see s_endpgm and deallocates VGPRs before memory stores return.
*/ */
if (sel->info.colors_written_4bit &
(blend->dual_src_blend ? 0xffffff0f : 0xffffffff) &
~(sctx->framebuffer.colorbuf_enabled_4bit & blend->cb_target_enabled_4bit))
key->ps.opt.prefer_mono = 1; key->ps.opt.prefer_mono = 1;
else if (sctx->gfx_level >= GFX11 && sel->info.base.writes_memory) } else if (key->ps.part.epilog.kill_z || key->ps.part.epilog.kill_stencil ||
key->ps.part.epilog.kill_samplemask) {
/* Eliminate shader code computing the Z/S/samplemask outputs. */
key->ps.opt.prefer_mono = 1; key->ps.opt.prefer_mono = 1;
else } else {
key->ps.opt.prefer_mono = 0; key->ps.opt.prefer_mono = 0;
}
/* Update shaders only if the key changed. */ /* Update shaders only if the key changed. */
if (memcmp(&key->ps.part.epilog, &old_epilog, sizeof(old_epilog)) || if (memcmp(&key->ps.part.epilog, &old_epilog, sizeof(old_epilog)) ||