From 691a9ccb33de44db0cb806e65b01c011d95b9931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 19 Nov 2024 09:03:13 -0500 Subject: [PATCH] radeonsi: prepare for making SI_NGG_CULL_TRIANGLES/LINES VS only, rename them They will have no effect on TES and GS, so this will make it more obvious. Acked-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/gfx10_shader_ngg.c | 2 +- src/gallium/drivers/radeonsi/si_nir_lower_abi.c | 2 +- src/gallium/drivers/radeonsi/si_shader.h | 13 ++++++++----- src/gallium/drivers/radeonsi/si_state.c | 6 ++---- src/gallium/drivers/radeonsi/si_state_draw.cpp | 3 ++- src/gallium/drivers/radeonsi/si_state_shaders.cpp | 2 +- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c b/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c index 35c173f6039..e4b440bf6f9 100644 --- a/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c +++ b/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c @@ -18,7 +18,7 @@ unsigned gfx10_ngg_get_vertices_per_prim(struct si_shader *shader) if (info->base.vs.blit_sgprs_amd) { /* Blits always use axis-aligned rectangles with 3 vertices. */ return 3; - } else if (shader->key.ge.opt.ngg_culling & SI_NGG_CULL_LINES) + } else if (shader->key.ge.opt.ngg_culling & SI_NGG_CULL_VS_LINES) return 2; else { /* The shader compiler replaces 0 with 3. The generated code will be correct regardless diff --git a/src/gallium/drivers/radeonsi/si_nir_lower_abi.c b/src/gallium/drivers/radeonsi/si_nir_lower_abi.c index 14319a7d28d..57410f423ea 100644 --- a/src/gallium/drivers/radeonsi/si_nir_lower_abi.c +++ b/src/gallium/drivers/radeonsi/si_nir_lower_abi.c @@ -673,7 +673,7 @@ static bool lower_intrinsic(nir_builder *b, nir_instr *instr, struct lower_abi_s replacement = ac_nir_unpack_arg(b, &args->ac, args->ac.gs_tg_info, 22, 9); break; case nir_intrinsic_load_initial_edgeflags_amd: - if (shader->key.ge.opt.ngg_culling & SI_NGG_CULL_LINES || + if (shader->key.ge.opt.ngg_culling & SI_NGG_CULL_VS_LINES || (shader->selector->stage == MESA_SHADER_VERTEX && shader->selector->info.base.vs.blit_sgprs_amd)) { /* Line primitives and blits don't need edge flags. */ diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h index 420b261d3b0..7db03acf619 100644 --- a/src/gallium/drivers/radeonsi/si_shader.h +++ b/src/gallium/drivers/radeonsi/si_shader.h @@ -328,10 +328,13 @@ enum MAX_SI_VS_BLIT_SGPRS = 10, /* +1 for the attribute ring address */ }; -#define SI_NGG_CULL_TRIANGLES (1 << 0) /* this implies W, view.xy, and small prim culling */ -#define SI_NGG_CULL_BACK_FACE (1 << 1) /* back faces */ -#define SI_NGG_CULL_FRONT_FACE (1 << 2) /* front faces */ -#define SI_NGG_CULL_LINES (1 << 3) /* the primitive type is lines */ +/* The following two are only set for vertex shaders that cull. + * TES and GS get the primitive type from shader_info. + */ +#define SI_NGG_CULL_VS_TRIANGLES (1 << 0) /* this implies W, view.xy, and small prim culling */ +#define SI_NGG_CULL_VS_LINES (1 << 1) /* this implies W and view.xy culling */ +#define SI_NGG_CULL_BACK_FACE (1 << 2) /* back faces */ +#define SI_NGG_CULL_FRONT_FACE (1 << 3) /* front faces */ #define SI_NGG_CULL_SMALL_LINES_DIAMOND_EXIT (1 << 4) /* cull small lines according to the diamond exit rule */ #define SI_NGG_CULL_CLIP_PLANE_ENABLE(enable) (((enable) & 0xff) << 5) #define SI_NGG_CULL_GET_CLIP_PLANE_ENABLE(x) (((x) >> 5) & 0xff) @@ -1118,7 +1121,7 @@ static inline bool gfx10_edgeflags_have_effect(struct si_shader *shader) { if (shader->selector->stage == MESA_SHADER_VERTEX && !shader->selector->info.base.vs.blit_sgprs_amd && - !(shader->key.ge.opt.ngg_culling & SI_NGG_CULL_LINES)) + !(shader->key.ge.opt.ngg_culling & SI_NGG_CULL_VS_LINES)) return true; return false; diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 52349f38f91..0dd6b377cc6 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -1015,12 +1015,10 @@ static void *si_create_rs_state(struct pipe_context *ctx, const struct pipe_rast S_028810_DX_RASTERIZATION_KILL(state->rasterizer_discard) | S_028810_DX_LINEAR_ATTR_CLIP_ENA(1); - rs->ngg_cull_flags_tris = SI_NGG_CULL_TRIANGLES | - SI_NGG_CULL_CLIP_PLANE_ENABLE(state->clip_plane_enable); + rs->ngg_cull_flags_tris = SI_NGG_CULL_CLIP_PLANE_ENABLE(state->clip_plane_enable); rs->ngg_cull_flags_tris_y_inverted = rs->ngg_cull_flags_tris; - rs->ngg_cull_flags_lines = SI_NGG_CULL_LINES | - (!rs->perpendicular_end_caps ? SI_NGG_CULL_SMALL_LINES_DIAMOND_EXIT : 0) | + rs->ngg_cull_flags_lines = (!rs->perpendicular_end_caps ? SI_NGG_CULL_SMALL_LINES_DIAMOND_EXIT : 0) | SI_NGG_CULL_CLIP_PLANE_ENABLE(state->clip_plane_enable); if (rs->rasterizer_discard) { diff --git a/src/gallium/drivers/radeonsi/si_state_draw.cpp b/src/gallium/drivers/radeonsi/si_state_draw.cpp index 6cba34faf0e..d4ba59f5e56 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.cpp +++ b/src/gallium/drivers/radeonsi/si_state_draw.cpp @@ -2249,10 +2249,11 @@ static void si_draw(struct pipe_context *ctx, if (util_prim_is_lines(sctx->current_rast_prim)) { /* Overwrite it to mask out face cull flags. */ ngg_culling = rs->ngg_cull_flags_lines; + ngg_culling |= SI_NGG_CULL_VS_LINES; } else { ngg_culling = sctx->viewport0_y_inverted ? rs->ngg_cull_flags_tris_y_inverted : rs->ngg_cull_flags_tris; - assert(ngg_culling); /* rasterizer state should always set this to non-zero */ + ngg_culling |= SI_NGG_CULL_VS_TRIANGLES; } if (ngg_culling != old_ngg_culling) { diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.cpp b/src/gallium/drivers/radeonsi/si_state_shaders.cpp index 08e781d9f5b..3d02be77c14 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.cpp +++ b/src/gallium/drivers/radeonsi/si_state_shaders.cpp @@ -1365,7 +1365,7 @@ unsigned si_get_input_prim(const struct si_shader_selector *gs, const union si_s return MESA_PRIM_TRIANGLES; } - if (key->ge.opt.ngg_culling & SI_NGG_CULL_LINES) + if (key->ge.opt.ngg_culling & SI_NGG_CULL_VS_LINES) return MESA_PRIM_LINES; return MESA_PRIM_TRIANGLES; /* worst case for all callers */