slang: support uniform arrays
authorAlan Hourihane <alanh@vmware.com>
Thu, 19 Mar 2009 22:06:10 +0000 (22:06 +0000)
committerAlan Hourihane <alanh@vmware.com>
Thu, 19 Mar 2009 22:06:53 +0000 (22:06 +0000)
src/mesa/shader/slang/slang_codegen.c

index 13a801c18a2ea687cccc0c74edf79a5c95dcfe7d..8263aae3343e9b5f3a4ed0878d70aadaf3dc6ecf 100644 (file)
@@ -4354,13 +4354,25 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
       if (prog) {
          /* user-defined uniform */
          if (datatype == GL_NONE) {
-            if (var->type.specifier.type == SLANG_SPEC_STRUCT) {
+           if ((var->type.specifier.type == SLANG_SPEC_ARRAY &&
+                var->type.specifier._array->type == SLANG_SPEC_STRUCT) ||
+                (var->type.specifier.type == SLANG_SPEC_STRUCT)) {
                /* temporary work-around */
                GLenum datatype = GL_FLOAT;
                GLint uniformLoc = _mesa_add_uniform(prog->Parameters, varName,
                                                     totalSize, datatype, NULL);
                store = _slang_new_ir_storage_swz(PROGRAM_UNIFORM, uniformLoc,
                                                  totalSize, swizzle);
+        
+              if (arrayLen > 0) {
+                 GLint a = arrayLen - 1;
+                 GLint i;
+                 for (i = 0; i < a; i++) {
+                     GLfloat value = (GLfloat)(i + uniformLoc + 1);
+                     (void) _mesa_add_parameter(prog->Parameters, PROGRAM_UNIFORM,
+                                 varName, 1, datatype, &value, NULL, 0x0);
+                  }
+              }
 
                /* XXX what we need to do is unroll the struct into its
                 * basic types, creating a uniform variable for each.