From 8a2a42d6a6e2d1e6f5942cb6293b74da6f42e6e4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 1 Sep 2020 17:54:47 -0400 Subject: [PATCH] radeonsi: stop using TGSI_PROPERTY_TES_POINT_MODE / TES_PRIM_MODE Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- .../drivers/radeonsi/gfx10_shader_ngg.c | 4 +-- .../drivers/radeonsi/si_shader_llvm_tess.c | 10 +++--- src/gallium/drivers/radeonsi/si_shader_nir.c | 9 ++---- .../drivers/radeonsi/si_state_shaders.c | 32 +++++++++++-------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c b/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c index e8e04933fca..28c913676fe 100644 --- a/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c +++ b/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c @@ -109,9 +109,9 @@ static LLVMValueRef ngg_get_vertices_per_prim(struct si_shader_context *ctx, uns } else { assert(ctx->stage == MESA_SHADER_TESS_EVAL); - if (info->properties[TGSI_PROPERTY_TES_POINT_MODE]) + if (info->base.tess.point_mode) *num_vertices = 1; - else if (info->properties[TGSI_PROPERTY_TES_PRIM_MODE] == PIPE_PRIM_LINES) + else if (info->base.tess.primitive_mode == GL_LINES) *num_vertices = 2; else *num_vertices = 3; diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_tess.c b/src/gallium/drivers/radeonsi/si_shader_llvm_tess.c index 5969d08816b..75d80b0ac5b 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm_tess.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm_tess.c @@ -615,7 +615,7 @@ static LLVMValueRef si_load_tess_coord(struct ac_shader_abi *abi) ctx->ac.f32_0, ctx->ac.f32_0}; /* For triangles, the vector should be (u, v, 1-u-v). */ - if (ctx->shader->selector->info.properties[TGSI_PROPERTY_TES_PRIM_MODE] == PIPE_PRIM_TRIANGLES) { + if (ctx->shader->selector->info.base.tess.primitive_mode == GL_TRIANGLES) { coord[2] = LLVMBuildFSub(ctx->ac.builder, ctx->ac.f32_1, LLVMBuildFAdd(ctx->ac.builder, coord[0], coord[1], ""), ""); } @@ -756,17 +756,17 @@ static void si_write_tess_factors(struct si_shader_context *ctx, LLVMValueRef re /* Determine the layout of one tess factor element in the buffer. */ switch (shader->key.part.tcs.epilog.prim_mode) { - case PIPE_PRIM_LINES: + case GL_LINES: stride = 2; /* 2 dwords, 1 vec2 store */ outer_comps = 2; inner_comps = 0; break; - case PIPE_PRIM_TRIANGLES: + case GL_TRIANGLES: stride = 4; /* 4 dwords, 1 vec4 store */ outer_comps = 3; inner_comps = 1; break; - case PIPE_PRIM_QUADS: + case GL_QUADS: stride = 6; /* 6 dwords, 2 stores (vec4 + vec2) */ outer_comps = 4; inner_comps = 2; @@ -808,7 +808,7 @@ static void si_write_tess_factors(struct si_shader_context *ctx, LLVMValueRef re } } - if (shader->key.part.tcs.epilog.prim_mode == PIPE_PRIM_LINES) { + if (shader->key.part.tcs.epilog.prim_mode == GL_LINES) { /* For isolines, the hardware expects tess factors in the * reverse order from what NIR specifies. */ diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c index 71bafb4497e..629a97cdf35 100644 --- a/src/gallium/drivers/radeonsi/si_shader_nir.c +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c @@ -457,18 +457,15 @@ void si_nir_scan_shader(const struct nir_shader *nir, struct si_shader_info *inf info->stage = nir->info.stage; if (nir->info.stage == MESA_SHADER_TESS_EVAL) { - if (nir->info.tess.primitive_mode == GL_ISOLINES) - info->properties[TGSI_PROPERTY_TES_PRIM_MODE] = PIPE_PRIM_LINES; - else - info->properties[TGSI_PROPERTY_TES_PRIM_MODE] = nir->info.tess.primitive_mode; - STATIC_ASSERT((TESS_SPACING_EQUAL + 1) % 3 == PIPE_TESS_SPACING_EQUAL); STATIC_ASSERT((TESS_SPACING_FRACTIONAL_ODD + 1) % 3 == PIPE_TESS_SPACING_FRACTIONAL_ODD); STATIC_ASSERT((TESS_SPACING_FRACTIONAL_EVEN + 1) % 3 == PIPE_TESS_SPACING_FRACTIONAL_EVEN); info->properties[TGSI_PROPERTY_TES_SPACING] = (nir->info.tess.spacing + 1) % 3; info->properties[TGSI_PROPERTY_TES_VERTEX_ORDER_CW] = !nir->info.tess.ccw; - info->properties[TGSI_PROPERTY_TES_POINT_MODE] = nir->info.tess.point_mode; + + if (info->base.tess.primitive_mode == GL_ISOLINES) + info->base.tess.primitive_mode = GL_LINES; } if (nir->info.stage == MESA_SHADER_GEOMETRY) { diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index c629c28fa61..12b3d83061b 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -312,20 +312,20 @@ static void si_set_tesseval_regs(struct si_screen *sscreen, const struct si_shad struct si_pm4_state *pm4) { const struct si_shader_info *info = &tes->info; - unsigned tes_prim_mode = info->properties[TGSI_PROPERTY_TES_PRIM_MODE]; + unsigned tes_prim_mode = info->base.tess.primitive_mode; unsigned tes_spacing = info->properties[TGSI_PROPERTY_TES_SPACING]; bool tes_vertex_order_cw = info->properties[TGSI_PROPERTY_TES_VERTEX_ORDER_CW]; - bool tes_point_mode = info->properties[TGSI_PROPERTY_TES_POINT_MODE]; + bool tes_point_mode = info->base.tess.point_mode; unsigned type, partitioning, topology, distribution_mode; switch (tes_prim_mode) { - case PIPE_PRIM_LINES: + case GL_LINES: type = V_028B6C_TESS_ISOLINE; break; - case PIPE_PRIM_TRIANGLES: + case GL_TRIANGLES: type = V_028B6C_TESS_TRIANGLE; break; - case PIPE_PRIM_QUADS: + case GL_QUADS: type = V_028B6C_TESS_QUAD; break; default: @@ -350,7 +350,7 @@ static void si_set_tesseval_regs(struct si_screen *sscreen, const struct si_shad if (tes_point_mode) topology = V_028B6C_OUTPUT_POINT; - else if (tes_prim_mode == PIPE_PRIM_LINES) + else if (tes_prim_mode == GL_LINES) topology = V_028B6C_OUTPUT_LINE; else if (tes_vertex_order_cw) /* for some reason, this must be the other way around */ @@ -1025,9 +1025,9 @@ unsigned si_get_input_prim(const struct si_shader_selector *gs) return gs->info.properties[TGSI_PROPERTY_GS_INPUT_PRIM]; if (gs->info.stage == MESA_SHADER_TESS_EVAL) { - if (gs->info.properties[TGSI_PROPERTY_TES_POINT_MODE]) + if (gs->info.base.tess.point_mode) return PIPE_PRIM_POINTS; - if (gs->info.properties[TGSI_PROPERTY_TES_PRIM_MODE] == PIPE_PRIM_LINES) + if (gs->info.base.tess.primitive_mode == GL_LINES) return PIPE_PRIM_LINES; return PIPE_PRIM_TRIANGLES; } @@ -1832,7 +1832,7 @@ static inline void si_shader_selector_key(struct pipe_context *ctx, struct si_sh } key->part.tcs.epilog.prim_mode = - sctx->tes_shader.cso->info.properties[TGSI_PROPERTY_TES_PRIM_MODE]; + sctx->tes_shader.cso->info.base.tess.primitive_mode; key->part.tcs.epilog.invoc0_tess_factors_are_def = sel->info.tessfactors_are_def_in_all_invocs; key->part.tcs.epilog.tes_reads_tess_factors = sctx->tes_shader.cso->info.reads_tess_factors; @@ -2700,12 +2700,16 @@ static void *si_create_shader_selector(struct pipe_context *ctx, assert(((sel->esgs_itemsize / 4) & C_028AAC_ITEMSIZE) == 0); /* Only for TES: */ - if (sel->info.properties[TGSI_PROPERTY_TES_POINT_MODE]) - sel->rast_prim = PIPE_PRIM_POINTS; - else if (sel->info.properties[TGSI_PROPERTY_TES_PRIM_MODE] == PIPE_PRIM_LINES) - sel->rast_prim = PIPE_PRIM_LINE_STRIP; - else + if (sel->info.stage == MESA_SHADER_TESS_EVAL) { + if (sel->info.base.tess.point_mode) + sel->rast_prim = PIPE_PRIM_POINTS; + else if (sel->info.base.tess.primitive_mode == GL_LINES) + sel->rast_prim = PIPE_PRIM_LINE_STRIP; + else + sel->rast_prim = PIPE_PRIM_TRIANGLES; + } else { sel->rast_prim = PIPE_PRIM_TRIANGLES; + } break; case MESA_SHADER_FRAGMENT: -- 2.30.2