diff options
author | Zack Rusin <[email protected]> | 2008-06-08 23:05:15 -0400 |
---|---|---|
committer | Zack Rusin <[email protected]> | 2008-06-12 15:15:34 -0400 |
commit | effb73befa56099ba78ef2d93be4f980dad157b3 (patch) | |
tree | e656b84e97aaf8699509a1aa16c603c94ad9c122 /src/mesa/shader/slang | |
parent | 19659a50f9356023c59942794bd4e6e075f120bd (diff) |
glsl: fix array size initialiazers using const variables
e.g.
const int kernelSize = 9;
uniform vec2 kernel[kernelSize];
Diffstat (limited to 'src/mesa/shader/slang')
-rw-r--r-- | src/mesa/shader/slang/slang_compile.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 46b5c54bbeb..f2e8aab8b0c 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -258,9 +258,33 @@ parse_array_len(slang_parse_ctx * C, slang_output_ctx * O, GLuint * len) /* evaluate compile-time expression which is array size */ _slang_simplify(&array_size, &space, C->atoms); - result = (array_size.type == SLANG_OPER_LITERAL_INT); - *len = (GLint) array_size.literal[0]; + if (array_size.type == SLANG_OPER_LITERAL_INT) { + result = GL_TRUE; + *len = (GLint) array_size.literal[0]; + } else if (array_size.type == SLANG_OPER_IDENTIFIER) { + slang_variable *var = _slang_locate_variable(array_size.locals, array_size.a_id, GL_TRUE); + if (!var) { + slang_info_log_error(C->L, "undefined variable '%s'", + (char *) array_size.a_id); + result = GL_FALSE; + } else if (var->type.qualifier == SLANG_QUAL_CONST && + var->type.specifier.type == SLANG_SPEC_INT) { + if (var->initializer && + var->initializer->type == SLANG_OPER_LITERAL_INT) { + *len = (GLint) var->initializer->literal[0]; + result = GL_TRUE; + } else { + slang_info_log_error(C->L, "unable to parse array size declaration"); + result = GL_FALSE; + } + } else { + slang_info_log_error(C->L, "unable to parse array size declaration"); + result = GL_FALSE; + } + } else { + result = GL_FALSE; + } slang_operation_destruct(&array_size); return result; |