From 8f687bb5dcf665c2b57d99982eacea9d29810b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 5 Nov 2021 23:31:07 -0400 Subject: [PATCH] radeonsi: fix shader culling with integer pixel centers Only Nine was using them. Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/si_state.c | 4 ++++ src/gallium/drivers/radeonsi/si_state_viewport.c | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 53e1f7226c2..828b3467e63 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -1108,6 +1108,10 @@ static void si_bind_rs_state(struct pipe_context *ctx, void *state) si_mark_atom_dirty(sctx, &sctx->atoms.s.ngg_cull_state); } + if (sctx->screen->use_ngg_culling && + old_rs->half_pixel_center != rs->half_pixel_center) + si_mark_atom_dirty(sctx, &sctx->atoms.s.ngg_cull_state); + sctx->current_vs_state &= C_VS_STATE_CLAMP_VERTEX_COLOR; sctx->current_vs_state |= S_VS_STATE_CLAMP_VERTEX_COLOR(rs->clamp_vertex_color); diff --git a/src/gallium/drivers/radeonsi/si_state_viewport.c b/src/gallium/drivers/radeonsi/si_state_viewport.c index 991f3d6f4bd..f5d7a59a52e 100644 --- a/src/gallium/drivers/radeonsi/si_state_viewport.c +++ b/src/gallium/drivers/radeonsi/si_state_viewport.c @@ -55,6 +55,12 @@ void si_get_small_prim_cull_info(struct si_context *sctx, struct si_small_prim_c info.translate[1] = -info.translate[1]; } + /* This is what the hardware does. */ + if (!sctx->queued.named.rasterizer->half_pixel_center) { + info.translate[0] += 0.5; + info.translate[1] += 0.5; + } + /* Scale the framebuffer up, so that samples become pixels and small * primitive culling is the same for all sample counts. * This only works with the standard DX sample positions, because