From 53aa36772a1ab7764cc02498ccfec4a515393231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 20 Nov 2023 05:11:33 -0500 Subject: [PATCH] radeonsi: rewrite si_get_total_colormask as si_any_colorbuffer_written The result is only used as bool. Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/si_blit.c | 2 +- src/gallium/drivers/radeonsi/si_pipe.h | 20 +++++++------------ .../drivers/radeonsi/si_state_shaders.cpp | 4 ++-- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_blit.c b/src/gallium/drivers/radeonsi/si_blit.c index 230ea7bd27c..81142d75560 100644 --- a/src/gallium/drivers/radeonsi/si_blit.c +++ b/src/gallium/drivers/radeonsi/si_blit.c @@ -733,7 +733,7 @@ static void si_check_render_feedback(struct si_context *sctx) /* There is no render feedback if color writes are disabled. * (e.g. a pixel shader with image stores) */ - if (!si_get_total_colormask(sctx)) + if (!si_any_colorbuffer_written(sctx)) return; for (int i = 0; i < SI_NUM_GRAPHICS_SHADERS; ++i) { diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 901d7d14098..5cf091451b6 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -1972,24 +1972,18 @@ static inline unsigned si_get_ps_iter_samples(struct si_context *sctx) return MIN2(sctx->ps_iter_samples, sctx->framebuffer.nr_color_samples); } -static inline unsigned si_get_total_colormask(struct si_context *sctx) +static inline bool si_any_colorbuffer_written(struct si_context *sctx) { if (sctx->queued.named.rasterizer->rasterizer_discard) - return 0; + return false; struct si_shader_selector *ps = sctx->shader.ps.cso; - if (!ps) - return 0; + if (!ps || !ps->info.colors_written_4bit) + return false; - unsigned colormask = - sctx->framebuffer.colorbuf_enabled_4bit & sctx->queued.named.blend->cb_target_mask; - - if (!ps->info.color0_writes_all_cbufs) - colormask &= ps->info.colors_written_4bit; - else if (!ps->info.colors_written_4bit) - colormask = 0; /* color0 writes all cbufs, but it's not written */ - - return colormask; + return (sctx->framebuffer.colorbuf_enabled_4bit & + sctx->queued.named.blend->cb_target_enabled_4bit & + (ps->info.color0_writes_all_cbufs ? ~0 : ps->info.colors_written_4bit)) != 0; } #define UTIL_ALL_PRIM_LINE_MODES \ diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.cpp b/src/gallium/drivers/radeonsi/si_state_shaders.cpp index a7d74aa8c33..bc4af64780c 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.cpp +++ b/src/gallium/drivers/radeonsi/si_state_shaders.cpp @@ -2208,10 +2208,10 @@ void si_update_ps_inputs_read_or_disabled(struct si_context *sctx) sctx->queued.named.dsa->alpha_func != PIPE_FUNC_ALWAYS || sctx->queued.named.rasterizer->poly_stipple_enable || sctx->queued.named.rasterizer->point_smooth; - unsigned ps_colormask = si_get_total_colormask(sctx); ps_disabled = sctx->queued.named.rasterizer->rasterizer_discard || - (!ps_colormask && !ps_modifies_zs && !ps->info.base.writes_memory); + (!ps_modifies_zs && !ps->info.base.writes_memory && + !si_any_colorbuffer_written(sctx)); } uint64_t ps_inputs_read_or_disabled;