summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/slang/slang_codegen.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-07-21 13:58:50 -0600
committerBrian Paul <[email protected]>2008-07-29 17:16:17 -0600
commitffbc66bf614c5a2b9bc3a68a6fa7d027405a55b9 (patch)
tree4cbf99c92188da1cb3ae9f3ca77392517fa30d18 /src/mesa/shader/slang/slang_codegen.c
parent74a19b0abd382574ff583eab81a374acead9254d (diff)
mesa: assorted glsl uniform/attribute fixes
Fix incorrect uniform/attribute size query results. Add missing error checking for glUniform, glUniformMatrix params Fix an array size/allocation error.
Diffstat (limited to 'src/mesa/shader/slang/slang_codegen.c')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 659ea60471d..32ee71f42ae 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -3037,6 +3037,23 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper)
}
+/**
+ * Compute total size of array give size of element, number of elements.
+ */
+static GLint
+array_size(GLint baseSize, GLint arrayLen)
+{
+ GLint total;
+ if (arrayLen > 1) {
+ /* round up base type to multiple of 4 */
+ total = ((baseSize + 3) & ~0x3) * MAX2(arrayLen, 1);
+ }
+ else {
+ total = baseSize;
+ }
+ return total;
+}
+
/**
* Called by compiler when a global variable has been parsed/compiled.
@@ -3076,7 +3093,7 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
}
else if (var->type.qualifier == SLANG_QUAL_UNIFORM) {
/* Uniform variable */
- const GLint totalSize = size * MAX2(var->array_len, 1);
+ const GLint totalSize = array_size(size, var->array_len);
const GLuint swizzle = _slang_var_swizzle(totalSize, 0);
if (prog) {
/* user-defined uniform */
@@ -3161,7 +3178,7 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
/* user-defined vertex attribute */
const GLint attr = -1; /* unknown */
GLint index = _mesa_add_attribute(prog->Attributes, varName,
- size, attr);
+ size, datatype, attr);
assert(index >= 0);
store = _slang_new_ir_storage(PROGRAM_INPUT,
VERT_ATTRIB_GENERIC0 + index, size);