tgsi: detect prim id and front face usage in fs
authorZack Rusin <zackr@vmware.com>
Fri, 2 Aug 2013 05:24:41 +0000 (01:24 -0400)
committerZack Rusin <zackr@vmware.com>
Sat, 3 Aug 2013 00:11:18 +0000 (20:11 -0400)
Adding code to detect the usage of prim id and front face
semantics in fragment shaders.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/tgsi/tgsi_scan.c
src/gallium/auxiliary/tgsi/tgsi_scan.h

index 1fe1a07d7c3dbce61f438088d836052825139bf3..e7bf6e660e0fefd3776ba64985c41ba21d1db766 100644 (file)
@@ -166,9 +166,14 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
                   info->input_cylindrical_wrap[reg] = (ubyte)fulldecl->Interp.CylindricalWrap;
                   info->num_inputs++;
 
-                  if (procType == TGSI_PROCESSOR_FRAGMENT &&
-                      fulldecl->Semantic.Name == TGSI_SEMANTIC_POSITION)
+                  if (procType == TGSI_PROCESSOR_FRAGMENT) {
+                     if (fulldecl->Semantic.Name == TGSI_SEMANTIC_POSITION)
                         info->reads_position = TRUE;
+                     else if (fulldecl->Semantic.Name == TGSI_SEMANTIC_PRIMID)
+                        info->uses_primid = TRUE;
+                     else if (fulldecl->Semantic.Name == TGSI_SEMANTIC_FACE)
+                        info->uses_frontface = TRUE;
+                  }
                }
                else if (file == TGSI_FILE_SYSTEM_VALUE) {
                   unsigned index = fulldecl->Range.First;
index cfa2b8e66c5289582dafe3f756ac38b8d20ca98e..e2fa73a3fa78eb88640e85c340d52062c98d90d2 100644 (file)
@@ -74,6 +74,7 @@ struct tgsi_shader_info
    boolean uses_instanceid;
    boolean uses_vertexid;
    boolean uses_primid;
+   boolean uses_frontface;
    boolean origin_lower_left;
    boolean pixel_center_integer;
    boolean color0_writes_all_cbufs;