summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang
diff options
context:
space:
mode:
authorBrian <brian@yutani.localnet.net>2007-02-20 15:22:38 -0700
committerBrian <brian@yutani.localnet.net>2007-02-20 15:22:38 -0700
commit10f42ddb9ea75fcce05d5777e8c64cdf42152ff2 (patch)
treebe1ae0186d9909731b12cacfdd4e6042c95f4f11 /src/mesa/shader/slang
parent361b60678e7d2c005593c289baf3263a1a461bf5 (diff)
work on struct/array handling
Diffstat (limited to 'src/mesa/shader/slang')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 4088720fdb..a23d4e16d0 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -94,20 +94,11 @@ is_sampler_type(const slang_fully_specified_type *t)
}
-static GLuint
-_slang_sizeof_struct(const slang_struct *s)
-{
- /* XXX TBD */
- return 0;
-}
-
-
GLuint
_slang_sizeof_type_specifier(const slang_type_specifier *spec)
{
switch (spec->type) {
case SLANG_SPEC_VOID:
- abort();
return 0;
case SLANG_SPEC_BOOL:
return 1;
@@ -147,11 +138,22 @@ _slang_sizeof_type_specifier(const slang_type_specifier *spec)
case SLANG_SPEC_SAMPLER2DSHADOW:
return 1; /* special case */
case SLANG_SPEC_STRUCT:
- return _slang_sizeof_struct(spec->_struct);
+ {
+ GLuint sum = 0, i;
+ for (i = 0; i < spec->_struct->fields->num_variables; i++) {
+ slang_variable *v = spec->_struct->fields->variables[i];
+ GLuint sz = _slang_sizeof_type_specifier(&v->type.specifier);
+ /* XXX verify padding */
+ if (sz < 4)
+ sz = 4;
+ sum += sz;
+ }
+ return sum;
+ }
case SLANG_SPEC_ARRAY:
- return 1; /* XXX */
+ return _slang_sizeof_type_specifier(spec->_array);
default:
- abort();
+ _mesa_problem(NULL, "Unexpected type in _slang_sizeof_type_specifier()");
return 0;
}
return 0;
@@ -2612,7 +2614,8 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
}
else if (var->type.qualifier == SLANG_QUAL_UNIFORM) {
/* Uniform variable */
- const GLint size = _slang_sizeof_type_specifier(&var->type.specifier);
+ const GLint size = _slang_sizeof_type_specifier(&var->type.specifier)
+ * MAX2(var->array_len, 1);
if (prog) {
/* user-defined uniform */
GLint uniformLoc = _mesa_add_uniform(prog->Parameters, varName, size);
@@ -2625,7 +2628,7 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
*/
store = _slang_new_ir_storage(PROGRAM_STATE_VAR, -1, size);
}
- if (dbg) printf("UNIFORM ");
+ if (dbg) printf("UNIFORM (sz %d) ", size);
}
else if (var->type.qualifier == SLANG_QUAL_VARYING) {
const GLint size = 4; /* XXX fix */