summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/slang/slang_emit.c
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2008-06-10 16:59:44 -0400
committerZack Rusin <[email protected]>2008-06-12 14:15:37 -0400
commit68ef8e89a5f25cd9f80e2b9088604631a28edc3c (patch)
tree4f30579541c645b80dd2ed752528ee247c7971d3 /src/mesa/shader/slang/slang_emit.c
parent5ecb2f2d0fca0c5ea847d1968459aa0dd8138f14 (diff)
glsl: implement variable array indexes
Diffstat (limited to 'src/mesa/shader/slang/slang_emit.c')
-rw-r--r--src/mesa/shader/slang/slang_emit.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index ff63e05dd20..93256f8647c 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -223,6 +223,7 @@ storage_to_src_reg(struct prog_src_register *src, const slang_ir_storage *st)
assert(st->Size <= 4);
src->File = st->File;
src->Index = st->Index;
+ src->RelAddr = st->RelAddr;
if (st->Swizzle != SWIZZLE_NOOP)
src->Swizzle = st->Swizzle;
else
@@ -1488,11 +1489,16 @@ emit_array_element(slang_emit_info *emitInfo, slang_ir_node *n)
n->Store->Index = arrayAddr + index;
}
else {
- /* Variable index - PROBLEM */
- const GLint arrayAddr = n->Children[0]->Store->Index;
- const GLint index = 0;
- _mesa_problem(NULL, "variable array indexes not supported yet!");
- n->Store->Index = arrayAddr + index;
+ /* Variable index*/
+ struct prog_instruction *inst;
+ inst = new_instruction(emitInfo, OPCODE_ARL);
+ storage_to_dst_reg(&inst->DstReg, n->Store, n->Writemask);
+ storage_to_src_reg(&inst->SrcReg[0], n->Children[1]->Store);
+ inst->DstReg.File = PROGRAM_ADDRESS;
+ inst->Comment = _mesa_strdup("ARL ADDR");
+ n->Store->RelAddr = GL_TRUE;
+ n->Store->Index = inst->DstReg.Index;/*index of the array*/
+ inst->DstReg.Index = 0; /*addr index is always 0*/
}
return NULL; /* no instruction */
}