Mesa (master): glsl: simplify IR storage for samplers

Brian Paul brianp at kemper.freedesktop.org
Wed Jan 14 19:17:18 UTC 2009


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

Author: Brian Paul <brianp at vmware.com>
Date:   Wed Jan 14 11:58:45 2009 -0700

glsl: simplify IR storage for samplers

Don't overload the Size field with the texture target, to avoid confusion.

---

 src/mesa/shader/slang/slang_codegen.c |    2 +-
 src/mesa/shader/slang/slang_emit.c    |   10 +++-------
 src/mesa/shader/slang/slang_ir.c      |   22 +++++++++++++++++++++-
 src/mesa/shader/slang/slang_ir.h      |   13 +++++++++----
 4 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index b046cc2..2112604 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -4293,7 +4293,7 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
 #endif
       {
          GLint sampNum = _mesa_add_sampler(prog->Parameters, varName, datatype);
-         store = _slang_new_ir_storage(PROGRAM_SAMPLER, sampNum, texIndex);
+         store = _slang_new_ir_storage_sampler(sampNum, texIndex, totalSize);
 
          /* If we have a sampler array, then we need to allocate the 
 	  * additional samplers to ensure we don't allocate them elsewhere.
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index 08b7d51..414d3e6 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -1300,14 +1300,10 @@ emit_tex(slang_emit_info *emitInfo, slang_ir_node *n)
                            NULL,
                            NULL);
 
-   /* Store->Index is the sampler index */
+   /* Store->Index is the uniform/sampler index */
    assert(n->Children[0]->Store->Index >= 0);
-   /* Store->Size is the texture target */
-   assert(n->Children[0]->Store->Size >= TEXTURE_1D_INDEX);
-   assert(n->Children[0]->Store->Size <= TEXTURE_RECT_INDEX);
-
-   inst->TexSrcTarget = n->Children[0]->Store->Size;
-   inst->TexSrcUnit = n->Children[0]->Store->Index; /* i.e. uniform's index */
+   inst->TexSrcUnit = n->Children[0]->Store->Index;
+   inst->TexSrcTarget = n->Children[0]->Store->TexTarget;
 
    /* mark the sampler as being used */
    _mesa_use_uniform(emitInfo->prog->Parameters,
diff --git a/src/mesa/shader/slang/slang_ir.c b/src/mesa/shader/slang/slang_ir.c
index c33c80d..e4c6e0e 100644
--- a/src/mesa/shader/slang/slang_ir.c
+++ b/src/mesa/shader/slang/slang_ir.c
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.1
  *
  * Copyright (C) 2005-2008  Brian Paul   All Rights Reserved.
+ * Copyright (C) 2009  VMware, Inc.   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -216,6 +216,26 @@ _slang_new_ir_storage_indirect(enum register_file file,
 }
 
 
+/**
+ * Allocate IR storage for a texture sampler.
+ * \param sampNum  the sampler number/index
+ * \param texTarget  one of TEXTURE_x_INDEX values
+ * \param size  number of samplers (in case of sampler array)
+ */
+slang_ir_storage *
+_slang_new_ir_storage_sampler(GLint sampNum, GLuint texTarget, GLint size)
+{
+   slang_ir_storage *st;
+   assert(texTarget < NUM_TEXTURE_TARGETS);
+   st = _slang_new_ir_storage(PROGRAM_SAMPLER, sampNum, size);
+   if (st) {
+      st->TexTarget = texTarget;
+   }
+   return st;
+}
+
+
+
 /* XXX temporary function */
 void
 _slang_copy_ir_storage(slang_ir_storage *dst, const slang_ir_storage *src)
diff --git a/src/mesa/shader/slang/slang_ir.h b/src/mesa/shader/slang/slang_ir.h
index a258e92..644269d 100644
--- a/src/mesa/shader/slang/slang_ir.h
+++ b/src/mesa/shader/slang/slang_ir.h
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.3
  *
- * Copyright (C) 2005-2007  Brian Paul   All Rights Reserved.
+ * Copyright (C) 2005-2008  Brian Paul   All Rights Reserved.
+ * Copyright (C) 2009  VMware, Inc.   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -168,8 +168,8 @@ typedef enum
 struct slang_ir_storage_
 {
    enum register_file File;  /**< PROGRAM_TEMPORARY, PROGRAM_INPUT, etc */
-   GLint Index;  /**< -1 means unallocated */
-   GLint Size;  /**< number of floats */
+   GLint Index;    /**< -1 means unallocated */
+   GLint Size;     /**< number of floats or ints */
    GLuint Swizzle; /**< Swizzle AND writemask info */
    GLint RefCount; /**< Used during IR tree delete */
 
@@ -179,6 +179,7 @@ struct slang_ir_storage_
    enum register_file IndirectFile;
    GLint IndirectIndex;
    GLuint IndirectSwizzle;
+   GLuint TexTarget;  /**< If File==PROGRAM_SAMPLER, one of TEXTURE_x_INDEX */
 
    /** If Parent is non-null, Index is relative to parent.
     * The other fields are ignored.
@@ -254,6 +255,10 @@ _slang_new_ir_storage_indirect(enum register_file file,
                                GLint indirectIndex,
                                GLuint indirectSwizzle);
 
+extern slang_ir_storage *
+_slang_new_ir_storage_sampler(GLint sampNum, GLuint texTarget, GLint size);
+
+
 extern void
 _slang_copy_ir_storage(slang_ir_storage *dst, const slang_ir_storage *src);
 




More information about the mesa-commit mailing list