tgsi: add support for system values to TGSI interpreter
authorBrian Paul <brianp@vmware.com>
Thu, 9 Dec 2010 01:19:14 +0000 (18:19 -0700)
committerBrian Paul <brianp@vmware.com>
Thu, 9 Dec 2010 01:19:14 +0000 (18:19 -0700)
src/gallium/auxiliary/tgsi/tgsi_exec.c
src/gallium/auxiliary/tgsi/tgsi_exec.h

index 7892a67f04c683099e9944f2525af1b069b0f331..35b2742351300e1c1ea7c15485f5bb4ddb2323bb 100644 (file)
@@ -1038,7 +1038,6 @@ fetch_src_file_channel(const struct tgsi_exec_machine *mach,
       break;
 
    case TGSI_FILE_INPUT:
-   case TGSI_FILE_SYSTEM_VALUE:
       for (i = 0; i < QUAD_SIZE; i++) {
          /*
          if (TGSI_PROCESSOR_GEOMETRY == mach->Processor) {
@@ -1053,6 +1052,15 @@ fetch_src_file_channel(const struct tgsi_exec_machine *mach,
       }
       break;
 
+   case TGSI_FILE_SYSTEM_VALUE:
+      /* XXX no swizzling at this point.  Will be needed if we put
+       * gl_FragCoord, for example, in a sys value register.
+       */
+      for (i = 0; i < QUAD_SIZE; i++) {
+         chan->f[i] = mach->SystemValue[index->i[i]][0];
+      }
+      break;
+
    case TGSI_FILE_TEMPORARY:
       for (i = 0; i < QUAD_SIZE; i++) {
          assert(index->i[i] < TGSI_EXEC_NUM_TEMPS);
@@ -1907,8 +1915,7 @@ exec_declaration(struct tgsi_exec_machine *mach,
                  const struct tgsi_full_declaration *decl)
 {
    if (mach->Processor == TGSI_PROCESSOR_FRAGMENT) {
-      if (decl->Declaration.File == TGSI_FILE_INPUT ||
-          decl->Declaration.File == TGSI_FILE_SYSTEM_VALUE) {
+      if (decl->Declaration.File == TGSI_FILE_INPUT) {
          uint first, last, mask;
 
          first = decl->Range.First;
@@ -1921,6 +1928,7 @@ exec_declaration(struct tgsi_exec_machine *mach,
           * ureg code to emit the right UsageMask value (WRITEMASK_X).
           * Then, we could remove the tgsi_exec_machine::Face field.
           */
+         /* XXX make FACE a system value */
          if (decl->Semantic.Name == TGSI_SEMANTIC_FACE) {
             uint i;
 
@@ -1962,8 +1970,13 @@ exec_declaration(struct tgsi_exec_machine *mach,
          }
       }
    }
+
+   if (decl->Declaration.File == TGSI_FILE_SYSTEM_VALUE) {
+      mach->SysSemanticToIndex[decl->Declaration.Semantic] = decl->Range.First;
+   }
 }
 
+
 typedef void (* micro_op)(union tgsi_exec_channel *dst);
 
 static void
index b5ebbfbfaabaa9b65fdf43fb21c103d9c53af90f..6c204c737144f953fc973d3c404a3738a8a2c13e 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "pipe/p_compiler.h"
 #include "pipe/p_state.h"
+#include "pipe/p_shader_tokens.h"
 
 #if defined __cplusplus
 extern "C" {
@@ -181,6 +182,8 @@ struct tgsi_sampler
 /* The maximum total number of vertices */
 #define TGSI_MAX_TOTAL_VERTICES (TGSI_MAX_PRIM_VERTICES * TGSI_MAX_PRIMITIVES * PIPE_MAX_ATTRIBS)
 
+#define TGSI_MAX_MISC_INPUTS 8
+
 /** function call/activation record */
 struct tgsi_call_record
 {
@@ -228,6 +231,10 @@ struct tgsi_exec_machine
    struct tgsi_exec_vector       Inputs[TGSI_MAX_PRIM_VERTICES * PIPE_MAX_ATTRIBS];
    struct tgsi_exec_vector       Outputs[TGSI_MAX_TOTAL_VERTICES];
 
+   /* System values */
+   unsigned                      SysSemanticToIndex[TGSI_SEMANTIC_COUNT];
+   float                         SystemValue[TGSI_MAX_MISC_INPUTS][4];
+
    struct tgsi_exec_vector       *Addrs;
    struct tgsi_exec_vector       *Predicates;