*/
static const char *
reg_string(enum register_file f, GLint index, gl_prog_print_mode mode,
- const struct gl_program *prog)
+ GLint relAddr, const struct gl_program *prog)
{
static char str[100];
switch (mode) {
case PROG_PRINT_DEBUG:
- sprintf(str, "%s[%d]", file_string(f, mode), index);
+ if (relAddr)
+ sprintf(str, "%s[ADDR%s%d]", file_string(f, mode), (index > 0) ? "+" : "", index);
+ else
+ sprintf(str, "%s[%d]", file_string(f, mode), index);
break;
case PROG_PRINT_ARB:
{
_mesa_printf("%s%s",
reg_string((enum register_file) dstReg->File,
- dstReg->Index, mode, prog),
+ dstReg->Index, mode, GL_FALSE, prog),
writemask_string(dstReg->WriteMask));
if (dstReg->CondMask != COND_TR) {
{
_mesa_printf("%s%s",
reg_string((enum register_file) srcReg->File,
- srcReg->Index, mode, prog),
+ srcReg->Index, mode, srcReg->RelAddr, prog),
_mesa_swizzle_string(srcReg->Swizzle,
- srcReg->NegateBase, GL_FALSE));
+ srcReg->NegateBase, GL_FALSE));
#if 0
_mesa_printf("%s[%d]%s",
file_string((enum register_file) srcReg->File, mode),
break;
case OPCODE_ARL:
- _mesa_printf("ARL addr.x, ");
+ _mesa_printf("ARL ");
+ print_dst_reg(&inst->DstReg, mode, prog);
+ _mesa_printf(", ");
print_src_reg(&inst->SrcReg[0], mode, prog);
print_comment(inst);
break;
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
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 */
}