[Mesa-dev] [PATCH 1/8] tgsi: detect prim id and front face usage in fs

Zack Rusin zackr at vmware.com
Thu Aug 1 23:28:13 PDT 2013


Adding code to detect the usage of prim id and front face
semantics in fragment shaders.

Signed-off-by: Zack Rusin <zackr at vmware.com>
---
 src/gallium/auxiliary/tgsi/tgsi_scan.c |    9 +++++++--
 src/gallium/auxiliary/tgsi/tgsi_scan.h |    1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index 1fe1a07..e7bf6e6 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -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;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.h b/src/gallium/auxiliary/tgsi/tgsi_scan.h
index cfa2b8e..e2fa73a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.h
@@ -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;
-- 
1.7.10.4


More information about the mesa-dev mailing list