Mesa (gallium-mesa-7.4): mesa: increase MAX_UNIFORMS to 1024 (of vec4 type)

Alan Hourihane alanh at kemper.freedesktop.org
Thu Feb 19 10:49:58 UTC 2009


Module: Mesa
Branch: gallium-mesa-7.4
Commit: b4b0668d4aaa93bda60d3087a65ba65455a80b87
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b4b0668d4aaa93bda60d3087a65ba65455a80b87

Author: Brian Paul <brianp at vmware.com>
Date:   Wed Feb 18 13:40:57 2009 -0700

mesa: increase MAX_UNIFORMS to 1024 (of vec4 type)

Old limit was 256.  Note that no arrays are declared to this size.
The only place we have to be careful about raising this limit is the
prog_src/dst_register Index bitfields.  These have been bumped up too.

Added assertions to check we don't exceed the bitfield in the future too.

(cherry picked from master, commit 5b2f8dc01300058d43d8043aa897722f39657e93)

---

 src/mesa/main/config.h             |    2 +-
 src/mesa/shader/prog_instruction.h |   16 ++++++++++++----
 src/mesa/shader/program.c          |    9 +++++++++
 3 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
index c3feffd..47fb433 100644
--- a/src/mesa/main/config.h
+++ b/src/mesa/main/config.h
@@ -189,7 +189,7 @@
 #define MAX_PROGRAM_CALL_DEPTH 8
 #define MAX_PROGRAM_TEMPS 128
 #define MAX_PROGRAM_ADDRESS_REGS 2
-#define MAX_UNIFORMS 256   /**< number of vec4 uniforms */
+#define MAX_UNIFORMS 1024  /**< number of vec4 uniforms */
 #define MAX_VARYING 8      /**< number of float[4] vectors */
 #define MAX_SAMPLERS MAX_TEXTURE_IMAGE_UNITS
 #define MAX_PROGRAM_INPUTS 32
diff --git a/src/mesa/shader/prog_instruction.h b/src/mesa/shader/prog_instruction.h
index f978334..2a68f03 100644
--- a/src/mesa/shader/prog_instruction.h
+++ b/src/mesa/shader/prog_instruction.h
@@ -240,12 +240,21 @@ typedef enum prog_opcode {
 
 
 /**
+ * Number of bits for the src/dst register Index field.
+ * This limits the size of temp/uniform register files.
+ */
+#define INST_INDEX_BITS 10
+
+
+/**
  * Instruction source register.
  */
 struct prog_src_register
 {
    GLuint File:4;	/**< One of the PROGRAM_* register file values. */
-   GLint Index:9;	/**< May be negative for relative addressing. */
+   GLint Index:(INST_INDEX_BITS+1); /**< Extra bit here for sign bit.
+                                     * May be negative for relative addressing.
+                                     */
    GLuint Swizzle:12;
    GLuint RelAddr:1;
 
@@ -289,7 +298,7 @@ struct prog_src_register
 struct prog_dst_register
 {
    GLuint File:4;      /**< One of the PROGRAM_* register file values */
-   GLuint Index:8;
+   GLuint Index:INST_INDEX_BITS;  /**< Unsigned, never negative */
    GLuint WriteMask:4;
    GLuint RelAddr:1;
 
@@ -322,8 +331,7 @@ struct prog_dst_register
     */
    GLuint CondSrc:1;
    /*@}*/
-
-   GLuint pad:30;
+   GLuint pad:28;
 };
 
 
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c
index 7a3b827..00655f0 100644
--- a/src/mesa/shader/program.c
+++ b/src/mesa/shader/program.c
@@ -53,6 +53,15 @@ _mesa_init_program(GLcontext *ctx)
 {
    GLuint i;
 
+   /*
+    * If this assertion fails, we need to increase the field
+    * size for register indexes.
+    */
+   ASSERT(ctx->Const.VertexProgram.MaxUniformComponents / 4
+          <= (1 << INST_INDEX_BITS));
+   ASSERT(ctx->Const.FragmentProgram.MaxUniformComponents / 4
+          <= (1 << INST_INDEX_BITS));
+
    ctx->Program.ErrorPos = -1;
    ctx->Program.ErrorString = _mesa_strdup("");
 




More information about the mesa-commit mailing list