radeonsi: stop using TGSI_PROPERTY_TES_POINT_MODE / TES_PRIM_MODE
authorMarek Olšák <marek.olsak@amd.com>
Tue, 1 Sep 2020 21:54:47 +0000 (17:54 -0400)
committerVivek Pandya <vivekvpandya@gmail.com>
Mon, 7 Sep 2020 15:55:16 +0000 (21:25 +0530)
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6624>

src/gallium/drivers/radeonsi/gfx10_shader_ngg.c
src/gallium/drivers/radeonsi/si_shader_llvm_tess.c
src/gallium/drivers/radeonsi/si_shader_nir.c
src/gallium/drivers/radeonsi/si_state_shaders.c

index e8e04933fcab6a0dfbaec1f8a9a6322b20f1c437..28c913676fecc6c1d47edea8d26b60beef4538a5 100644 (file)
@@ -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;
index 5969d08816b1a456d0274686301c08b4441402b9..75d80b0ac5b55a746702d49df25c76a4d8c44bb2 100644 (file)
@@ -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.
        */
index 71bafb4497e1a3755d25582cd571fab19f5c9a86..629a97cdf351cdcc477cc67c9e601c36f0d40759 100644 (file)
@@ -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) {
index c629c28fa614c12304968640e81c3b48089d6a2e..12b3d83061b5ed179f932dcc11fbce7551b33a2e 100644 (file)
@@ -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: