summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZack Rusin <zack@tungstengraphics.com>2008-06-10 16:59:44 -0400
committerZack Rusin <zack@tungstengraphics.com>2008-06-12 14:15:37 -0400
commit68ef8e89a5f25cd9f80e2b9088604631a28edc3c (patch)
tree4f30579541c645b80dd2ed752528ee247c7971d3 /src
parent5ecb2f2d0fca0c5ea847d1968459aa0dd8138f14 (diff)
glsl: implement variable array indexes
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/tgsi/util/tgsi_dump.c9
-rw-r--r--src/mesa/shader/arbprogparse.c2
-rw-r--r--src/mesa/shader/prog_print.c17
-rw-r--r--src/mesa/shader/slang/slang_emit.c16
-rw-r--r--src/mesa/shader/slang/slang_ir.h1
-rw-r--r--src/mesa/state_tracker/st_mesa_to_tgsi.c4
6 files changed, 34 insertions, 15 deletions
diff --git a/src/gallium/auxiliary/tgsi/util/tgsi_dump.c b/src/gallium/auxiliary/tgsi/util/tgsi_dump.c
index d1a3dfd9c7..92aff88925 100644
--- a/src/gallium/auxiliary/tgsi/util/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/util/tgsi_dump.c
@@ -803,7 +803,14 @@ tgsi_dump_instruction(
ENM( src->SrcRegister.File, TGSI_FILES_SHORT );
CHR( '[' );
- SID( src->SrcRegister.Index );
+ if (src->SrcRegister.Indirect) {
+ TXT( "addr" );
+ if (src->SrcRegister.Index > 0)
+ CHR( '+' );
+ SID( src->SrcRegister.Index );
+ }
+ else
+ SID( src->SrcRegister.Index );
CHR( ']' );
if (src->SrcRegister.SwizzleX != TGSI_SWIZZLE_X ||
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index b60b9656c6..a6bbdc64f1 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -3880,7 +3880,7 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target,
}
#if DEBUG_FP
- _mesa_printf("____________Fragment program %u ________\n", program->Base.ID);
+ _mesa_printf("____________Fragment program %u ________\n", program->Base.Id);
_mesa_print_program(&program->Base);
#endif
}
diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c
index 1c35ce3fec..09bf15f004 100644
--- a/src/mesa/shader/prog_print.c
+++ b/src/mesa/shader/prog_print.c
@@ -206,7 +206,7 @@ arb_output_attrib_string(GLint index, GLenum progType)
*/
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];
@@ -214,7 +214,10 @@ reg_string(enum register_file f, GLint index, gl_prog_print_mode mode,
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:
@@ -401,7 +404,7 @@ print_dst_reg(const struct prog_dst_register *dstReg, gl_prog_print_mode mode,
{
_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) {
@@ -424,9 +427,9 @@ print_src_reg(const struct prog_src_register *srcReg, gl_prog_print_mode mode,
{
_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),
@@ -590,7 +593,9 @@ _mesa_print_instruction_opt(const struct prog_instruction *inst, GLint indent,
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;
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index ff63e05dd2..93256f8647 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 */
}
diff --git a/src/mesa/shader/slang/slang_ir.h b/src/mesa/shader/slang/slang_ir.h
index c7c0ddbf9a..ba0735d64d 100644
--- a/src/mesa/shader/slang/slang_ir.h
+++ b/src/mesa/shader/slang/slang_ir.h
@@ -146,6 +146,7 @@ struct _slang_ir_storage
GLint Size; /**< number of floats */
GLuint Swizzle;
GLint RefCount; /**< Used during IR tree delete */
+ GLboolean RelAddr;
};
typedef struct _slang_ir_storage slang_ir_storage;
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 12979de523..a8b6faad1c 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -68,8 +68,8 @@ map_register_file(
case PROGRAM_STATE_VAR:
case PROGRAM_NAMED_PARAM:
case PROGRAM_UNIFORM:
- if (immediateMapping[index] != ~0)
- return TGSI_FILE_IMMEDIATE;
+ if (immediateMapping && immediateMapping[index] != ~0)
+ return TGSI_FILE_IMMEDIATE;
else
return TGSI_FILE_CONSTANT;
case PROGRAM_CONSTANT: