[Mesa-dev] [PATCH 1/6] tgsi/scan: add basic info about tessellation OUT and IN uses

Marek Olšák maraeo at gmail.com
Sun Feb 19 16:27:42 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

not all of them will be used immediately
---
 src/gallium/auxiliary/tgsi/tgsi_scan.c | 26 ++++++++++++++++++++++++++
 src/gallium/auxiliary/tgsi/tgsi_scan.h |  8 ++++++++
 2 files changed, 34 insertions(+)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index a9aa36b..7d5496c 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -192,20 +192,42 @@ scan_src_operand(struct tgsi_shader_info *info,
                   info->uses_linear_sample = TRUE;
                   break;
                }
                break;
                /* TGSI_INTERPOLATE_CONSTANT doesn't do any interpolation. */
             }
          }
       }
    }
 
+   if (info->processor == PIPE_SHADER_TESS_CTRL &&
+       src->Register.File == TGSI_FILE_OUTPUT) {
+      unsigned input;
+
+      if (src->Register.Indirect && src->Indirect.ArrayID)
+         input = info->output_array_first[src->Indirect.ArrayID];
+      else
+         input = src->Register.Index;
+
+      switch (info->output_semantic_name[input]) {
+      case TGSI_SEMANTIC_PATCH:
+         info->reads_perpatch_outputs = true;
+         break;
+      case TGSI_SEMANTIC_TESSINNER:
+      case TGSI_SEMANTIC_TESSOUTER:
+         info->reads_tessfactor_outputs = true;
+         break;
+      default:
+         info->reads_pervertex_outputs = true;
+      }
+   }
+
    /* check for indirect register reads */
    if (src->Register.Indirect) {
       info->indirect_files |= (1 << src->Register.File);
       info->indirect_files_read |= (1 << src->Register.File);
 
       /* record indirect constant buffer indexing */
       if (src->Register.File == TGSI_FILE_CONSTANT) {
          if (src->Register.Dimension) {
             if (src->Dimension.Indirect)
                info->const_buffers_indirect = info->const_buffers_declared;
@@ -532,20 +554,24 @@ scan_declaration(struct tgsi_shader_info *info,
             break;
          case TGSI_SEMANTIC_POSITION:
             info->reads_position = TRUE;
             break;
          case TGSI_SEMANTIC_FACE:
             info->uses_frontface = TRUE;
             break;
          case TGSI_SEMANTIC_SAMPLEMASK:
             info->reads_samplemask = TRUE;
             break;
+         case TGSI_SEMANTIC_TESSINNER:
+         case TGSI_SEMANTIC_TESSOUTER:
+            info->reads_tess_factors = true;
+            break;
          }
          break;
 
       case TGSI_FILE_OUTPUT:
          info->output_semantic_name[reg] = (ubyte) semName;
          info->output_semantic_index[reg] = (ubyte) semIndex;
          info->output_usagemask[reg] |= fulldecl->Declaration.UsageMask;
          info->num_outputs = MAX2(info->num_outputs, reg + 1);
 
          if (fulldecl->Declaration.UsageMask & TGSI_WRITEMASK_X) {
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.h b/src/gallium/auxiliary/tgsi/tgsi_scan.h
index 4add2f7..e3c24e9 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.h
@@ -77,25 +77,33 @@ struct tgsi_shader_info
    ubyte output_array_first[PIPE_MAX_SHADER_OUTPUTS];
    ubyte output_array_last[PIPE_MAX_SHADER_OUTPUTS];
    unsigned array_max[TGSI_FILE_COUNT];  /**< highest index array per register file */
 
    uint immediate_count; /**< number of immediates declared */
    uint num_instructions;
    uint num_memory_instructions; /**< sampler, buffer, and image instructions */
 
    uint opcode_count[TGSI_OPCODE_LAST];  /**< opcode histogram */
 
+   /**
+    * If a tessellation control shader reads outputs, this describes which ones.
+    */
+   boolean reads_pervertex_outputs;
+   boolean reads_perpatch_outputs;
+   boolean reads_tessfactor_outputs;
+
    ubyte colors_read; /**< which color components are read by the FS */
    ubyte colors_written;
    boolean reads_position; /**< does fragment shader read position? */
    boolean reads_z; /**< does fragment shader read depth? */
    boolean reads_samplemask; /**< does fragment shader read sample mask? */
+   boolean reads_tess_factors; /**< If TES reads TESSINNER or TESSOUTER */
    boolean writes_z;  /**< does fragment shader write Z value? */
    boolean writes_stencil; /**< does fragment shader write stencil value? */
    boolean writes_samplemask; /**< does fragment shader write sample mask? */
    boolean writes_edgeflag; /**< vertex shader outputs edgeflag */
    boolean uses_kill;  /**< KILL or KILL_IF instruction used? */
    boolean uses_persp_center;
    boolean uses_persp_centroid;
    boolean uses_persp_sample;
    boolean uses_linear_center;
    boolean uses_linear_centroid;
-- 
2.7.4



More information about the mesa-dev mailing list