tgsi/scan: record compute shader system value usage
authorMarek Olšák <marek.olsak@amd.com>
Mon, 24 Apr 2017 14:29:22 +0000 (16:29 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 28 Apr 2017 19:47:35 +0000 (21:47 +0200)
v2: just do indexing with swizzle[i]

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/auxiliary/tgsi/tgsi_scan.c
src/gallium/auxiliary/tgsi/tgsi_scan.h

index bf614db8060237ab541ac9361ee9100f917643ed..d1ef769ec4dac1c7623a40ee6f0a709af386da11 100644 (file)
@@ -115,6 +115,39 @@ scan_src_operand(struct tgsi_shader_info *info,
 {
    int ind = src->Register.Index;
 
+   if (info->processor == PIPE_SHADER_COMPUTE &&
+       src->Register.File == TGSI_FILE_SYSTEM_VALUE) {
+      unsigned swizzle[4], i, name;
+
+      name = info->system_value_semantic_name[src->Register.Index];
+      swizzle[0] = src->Register.SwizzleX;
+      swizzle[1] = src->Register.SwizzleY;
+      swizzle[2] = src->Register.SwizzleZ;
+      swizzle[3] = src->Register.SwizzleW;
+
+      switch (name) {
+      case TGSI_SEMANTIC_THREAD_ID:
+      case TGSI_SEMANTIC_BLOCK_ID:
+         for (i = 0; i < 4; i++) {
+            if (swizzle[i] <= TGSI_SWIZZLE_Z) {
+               if (name == TGSI_SEMANTIC_THREAD_ID)
+                  info->uses_thread_id[swizzle[i]] = true;
+               else
+                  info->uses_block_id[swizzle[i]] = true;
+            }
+         }
+         break;
+      case TGSI_SEMANTIC_BLOCK_SIZE:
+         /* The block size is translated to IMM with a fixed block size. */
+         if (info->properties[TGSI_PROPERTY_CS_FIXED_BLOCK_WIDTH] == 0)
+            info->uses_block_size = true;
+         break;
+      case TGSI_SEMANTIC_GRID_SIZE:
+         info->uses_grid_size = true;
+         break;
+      }
+   }
+
    /* Mark which inputs are effectively used */
    if (src->Register.File == TGSI_FILE_INPUT) {
       if (src->Register.Indirect) {
index 3854827e5cb044dae8fa1b692674800a077a0f0f..98387c982c61fe6f1ef334b50e9615c09661cf5f 100644 (file)
@@ -121,6 +121,10 @@ struct tgsi_shader_info
    boolean uses_primid;
    boolean uses_frontface;
    boolean uses_invocationid;
+   boolean uses_thread_id[3];
+   boolean uses_block_id[3];
+   boolean uses_block_size;
+   boolean uses_grid_size;
    boolean writes_position;
    boolean writes_psize;
    boolean writes_clipvertex;