From f2923168baa0eb7a704136a9e41303fb36d8c5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 25 Jan 2023 01:10:41 -0500 Subject: [PATCH] radeonsi: merge si_ps_key_update_framebuffer_blend & .._update_blend_rasterizer Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/si_state.c | 7 +++-- src/gallium/drivers/radeonsi/si_state.h | 3 +-- .../drivers/radeonsi/si_state_shaders.cpp | 27 ++++++------------- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 340ed595625..aca0672ecab 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -755,8 +755,7 @@ static void si_bind_blend_state(struct pipe_context *ctx, void *state) old_blend->dual_src_blend != blend->dual_src_blend || old_blend->blend_enable_4bit != blend->blend_enable_4bit || old_blend->need_src_alpha_4bit != blend->need_src_alpha_4bit) { - si_ps_key_update_framebuffer_blend(sctx); - si_ps_key_update_blend_rasterizer(sctx); + si_ps_key_update_framebuffer_blend_rasterizer(sctx); si_update_ps_inputs_read_or_disabled(sctx); sctx->do_update_shaders = true; } @@ -1214,7 +1213,7 @@ static void si_bind_rs_state(struct pipe_context *ctx, void *state) old_rs->clamp_fragment_color != rs->clamp_fragment_color || old_rs->force_persample_interp != rs->force_persample_interp || old_rs->polygon_mode_is_points != rs->polygon_mode_is_points) { - si_ps_key_update_blend_rasterizer(sctx); + si_ps_key_update_framebuffer_blend_rasterizer(sctx); si_ps_key_update_rasterizer(sctx); si_ps_key_update_framebuffer_rasterizer_sample_shading(sctx); si_update_ps_inputs_read_or_disabled(sctx); @@ -3195,7 +3194,7 @@ static void si_set_framebuffer_state(struct pipe_context *ctx, } si_ps_key_update_framebuffer(sctx); - si_ps_key_update_framebuffer_blend(sctx); + si_ps_key_update_framebuffer_blend_rasterizer(sctx); si_ps_key_update_framebuffer_rasterizer_sample_shading(sctx); si_update_ps_inputs_read_or_disabled(sctx); sctx->do_update_shaders = true; diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h index 8d296de5a00..62297c929ef 100644 --- a/src/gallium/drivers/radeonsi/si_state.h +++ b/src/gallium/drivers/radeonsi/si_state.h @@ -589,8 +589,7 @@ void si_update_vrs_flat_shading(struct si_context *sctx); unsigned si_get_input_prim(const struct si_shader_selector *gs, const union si_shader_key *key); bool si_update_ngg(struct si_context *sctx); void si_ps_key_update_framebuffer(struct si_context *sctx); -void si_ps_key_update_framebuffer_blend(struct si_context *sctx); -void si_ps_key_update_blend_rasterizer(struct si_context *sctx); +void si_ps_key_update_framebuffer_blend_rasterizer(struct si_context *sctx); void si_ps_key_update_rasterizer(struct si_context *sctx); void si_ps_key_update_dsa(struct si_context *sctx); void si_ps_key_update_sample_shading(struct si_context *sctx); diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.cpp b/src/gallium/drivers/radeonsi/si_state_shaders.cpp index 0bf0bf1b6f7..7320de2a707 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.cpp +++ b/src/gallium/drivers/radeonsi/si_state_shaders.cpp @@ -2278,15 +2278,21 @@ void si_ps_key_update_framebuffer(struct si_context *sctx) } } -void si_ps_key_update_framebuffer_blend(struct si_context *sctx) +void si_ps_key_update_framebuffer_blend_rasterizer(struct si_context *sctx) { struct si_shader_selector *sel = sctx->shader.ps.cso; union si_shader_key *key = &sctx->shader.ps.key; struct si_state_blend *blend = sctx->queued.named.blend; + struct si_state_rasterizer *rs = sctx->queued.named.rasterizer; if (!sel) return; + key->ps.part.epilog.alpha_to_one = blend->alpha_to_one && rs->multisample_enable; + key->ps.part.epilog.alpha_to_coverage_via_mrtz = + sctx->gfx_level >= GFX11 && blend->alpha_to_coverage && rs->multisample_enable && + (sel->info.writes_z || sel->info.writes_stencil || sel->info.writes_samplemask); + /* Select the shader color format based on whether * blending or alpha are needed. */ @@ -2370,22 +2376,6 @@ void si_ps_key_update_framebuffer_blend(struct si_context *sctx) key->ps.opt.prefer_mono = 0; } -void si_ps_key_update_blend_rasterizer(struct si_context *sctx) -{ - union si_shader_key *key = &sctx->shader.ps.key; - struct si_state_blend *blend = sctx->queued.named.blend; - struct si_state_rasterizer *rs = sctx->queued.named.rasterizer; - struct si_shader_selector *ps = sctx->shader.ps.cso; - - if (!ps) - return; - - key->ps.part.epilog.alpha_to_one = blend->alpha_to_one && rs->multisample_enable; - key->ps.part.epilog.alpha_to_coverage_via_mrtz = - sctx->gfx_level >= GFX11 && blend->alpha_to_coverage && rs->multisample_enable && - (ps->info.writes_z || ps->info.writes_stencil || ps->info.writes_samplemask); -} - void si_ps_key_update_rasterizer(struct si_context *sctx) { struct si_shader_selector *sel = sctx->shader.ps.cso; @@ -3626,8 +3616,7 @@ static void si_bind_ps_shader(struct pipe_context *ctx, void *state) si_update_ps_colorbuf0_slot(sctx); si_ps_key_update_framebuffer(sctx); - si_ps_key_update_framebuffer_blend(sctx); - si_ps_key_update_blend_rasterizer(sctx); + si_ps_key_update_framebuffer_blend_rasterizer(sctx); si_ps_key_update_rasterizer(sctx); si_ps_key_update_dsa(sctx); si_ps_key_update_sample_shading(sctx);