Mesa (master): mesa: fix assignment / parameter passing of sampler types

Brian Paul brianp at kemper.freedesktop.org
Sat Nov 1 15:05:47 PDT 2008


Module: Mesa
Branch: master
Commit: 1e1ba54a94d4c0a0685c430bffad49d47cec15ca
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1e1ba54a94d4c0a0685c430bffad49d47cec15ca

Author: Brian Paul <brian.paul at tungstengraphics.com>
Date:   Sat Nov  1 15:53:14 2008 -0600

mesa: fix assignment / parameter passing of sampler types

---

 src/mesa/shader/slang/slang_codegen.c  |   14 +++++++-------
 src/mesa/shader/slang/slang_emit.c     |    8 ++++++++
 src/mesa/shader/slang/slang_vartable.c |   15 ++++++++++++++-
 3 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index de7e96f..d8a92e2 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -2439,12 +2439,6 @@ _slang_gen_var_decl(slang_assemble_ctx *A, slang_variable *var)
    /*assert(!var->declared);*/
    var->declared = GL_TRUE;
 
-   if(is_sampler_type(&var->type)) {
-      slang_info_log_error(A->log, "redeclaration of sampler '%s'",
-			   (char*) var->a_name);
-      return NULL;
-   }
-
    n = new_node0(IR_VAR_DECL);
    if (n) {
       _slang_attach_storage(n, var);
@@ -2453,7 +2447,13 @@ _slang_gen_var_decl(slang_assemble_ctx *A, slang_variable *var)
       assert(n->Store);
       assert(n->Store->Index < 0);
 
-      n->Store->File = PROGRAM_TEMPORARY;
+      if (is_sampler_type(&var->type)) {
+         n->Store->File = PROGRAM_SAMPLER;
+      }
+      else {
+         n->Store->File = PROGRAM_TEMPORARY;
+      }
+
       n->Store->Size = _slang_sizeof_type_specifier(&n->Var->type.specifier);
 
       if (n->Store->Size <= 0) {
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index 9e8daa1..010b558 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -1085,6 +1085,14 @@ emit_copy(slang_emit_info *emitInfo, slang_ir_node *n)
 
    n->Store = n->Children[0]->Store;
 
+   if (n->Store->File == PROGRAM_SAMPLER) {
+      /* no code generated for sampler assignments,
+       * just copy the sampler index at compile time.
+       */
+      n->Store->Index = n->Children[1]->Store->Index;
+      return NULL;
+   }
+
 #if PEEPHOLE_OPTIMIZATIONS
    if (inst &&
        _slang_is_temp(emitInfo->vt, n->Children[1]->Store) &&
diff --git a/src/mesa/shader/slang/slang_vartable.c b/src/mesa/shader/slang/slang_vartable.c
index 9b607e6..95971a7 100644
--- a/src/mesa/shader/slang/slang_vartable.c
+++ b/src/mesa/shader/slang/slang_vartable.c
@@ -115,6 +115,11 @@ _slang_pop_var_table(slang_var_table *vt)
                       store->Index,
                       _mesa_swizzle_string(store->Swizzle, 0, 0));
 
+      if (store->File == PROGRAM_SAMPLER) {
+         /* samplers have no storage */
+         continue;
+      }
+
       if (store->Size == 1)
          comp = GET_SWZ(store->Swizzle, 0);
       else
@@ -241,7 +246,15 @@ GLboolean
 _slang_alloc_var(slang_var_table *vt, slang_ir_storage *store)
 {
    struct table *t = vt->Top;
-   const int i = alloc_reg(vt, store->Size, GL_FALSE);
+   int i;
+
+   if (store->File == PROGRAM_SAMPLER) {
+      /* don't really allocate storage */
+      store->Index = 0;
+      return GL_TRUE;
+   }
+
+   i = alloc_reg(vt, store->Size, GL_FALSE);
    if (i < 0)
       return GL_FALSE;
 



More information about the mesa-commit mailing list