tgsi: Check in scan for fs position and depth reads
authorJakob Bornecrantz <jakob@vmware.com>
Thu, 7 Apr 2011 12:20:33 +0000 (13:20 +0100)
committerBrian Paul <brianp@vmware.com>
Thu, 22 Sep 2011 14:26:36 +0000 (08:26 -0600)
src/gallium/auxiliary/tgsi/tgsi_scan.c
src/gallium/auxiliary/tgsi/tgsi_scan.h

index f165f8240e652aeef70c1199cbab2aef2100bbcd..60de80d0918ee8965ef66548cef5d82b4876ff0b 100644 (file)
@@ -108,6 +108,17 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
                      assert(ind < PIPE_MAX_SHADER_INPUTS);
                      info->input_usage_mask[ind] |= usage_mask;
                   }
+
+                  if (procType == TGSI_PROCESSOR_FRAGMENT &&
+                      src->Register.File == TGSI_FILE_INPUT &&
+                      info->reads_position &&
+                      src->Register.Index == 0 &&
+                      (src->Register.SwizzleX == TGSI_SWIZZLE_Z ||
+                       src->Register.SwizzleY == TGSI_SWIZZLE_Z ||
+                       src->Register.SwizzleZ == TGSI_SWIZZLE_Z ||
+                       src->Register.SwizzleW == TGSI_SWIZZLE_Z)) {
+                     info->reads_z = TRUE;
+                  }
                }
 
                /* check for indirect register reads */
@@ -150,6 +161,10 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
                   info->input_centroid[reg] = (ubyte)fulldecl->Declaration.Centroid;
                   info->input_cylindrical_wrap[reg] = (ubyte)fulldecl->Declaration.CylindricalWrap;
                   info->num_inputs++;
+
+                  if (procType == TGSI_PROCESSOR_FRAGMENT &&
+                      fulldecl->Semantic.Name == TGSI_SEMANTIC_POSITION)
+                        info->reads_position = TRUE;
                }
                else if (file == TGSI_FILE_SYSTEM_VALUE) {
                   unsigned index = fulldecl->Range.First;
index d6e593b3968de26d6be41a2b2f7e92256eae91cc..30834b4d0003ccef7df6925a0ba1f606bfb5927a 100644 (file)
@@ -63,6 +63,8 @@ struct tgsi_shader_info
 
    uint opcode_count[TGSI_OPCODE_LAST];  /**< opcode histogram */
 
+   boolean reads_position; /**< does fragment shader read position? */
+   boolean reads_z; /**< does fragment shader read depth? */
    boolean writes_z;  /**< does fragment shader write Z value? */
    boolean writes_stencil; /**< does fragment shader write stencil value? */
    boolean writes_edgeflag; /**< vertex shader outputs edgeflag */