summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang/slang_ir.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-11-19 14:12:25 -0700
committerBrian Paul <brian.paul@tungstengraphics.com>2008-11-19 14:12:25 -0700
commitae0ff8097b85d3537a7be1674d55a44a9bd6018e (patch)
tree61c822bc84183fce03a329893daaf19d548eb278 /src/mesa/shader/slang/slang_ir.c
parente709d68d92ef6f2392b118d0a22452e8f4c53e9a (diff)
mesa: rework GLSL array code generation
We now express arrays in terms of indirect addressing. For example: dst = a[i]; becomes: MOV dst, TEMP[1 + TEMP[2].y]; At instruction-emit time indirect addressing is converted into ARL/ ADDR-relative form: ARL ADDR.x, TEMP[2].y; MOV dst, TEMP[1 + ADDR.x]; This fixes a number of array-related issues. Arrays of arrays and complex array/struct nesting works now. There may be some regressions, but more work is coming.
Diffstat (limited to 'src/mesa/shader/slang/slang_ir.c')
-rw-r--r--src/mesa/shader/slang/slang_ir.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/mesa/shader/slang/slang_ir.c b/src/mesa/shader/slang/slang_ir.c
index 4fe3a2b85d..c33c80da99 100644
--- a/src/mesa/shader/slang/slang_ir.c
+++ b/src/mesa/shader/slang/slang_ir.c
@@ -116,6 +116,20 @@ _slang_ir_info(slang_ir_opcode opcode)
}
+void
+_slang_init_ir_storage(slang_ir_storage *st,
+ enum register_file file, GLint index, GLint size,
+ GLuint swizzle)
+{
+ st->File = file;
+ st->Index = index;
+ st->Size = size;
+ st->Swizzle = swizzle;
+ st->Parent = NULL;
+ st->IsIndirect = GL_FALSE;
+}
+
+
/**
* Return a new slang_ir_storage object.
*/
@@ -130,6 +144,7 @@ _slang_new_ir_storage(enum register_file file, GLint index, GLint size)
st->Size = size;
st->Swizzle = SWIZZLE_NOOP;
st->Parent = NULL;
+ st->IsIndirect = GL_FALSE;
}
return st;
}
@@ -150,6 +165,7 @@ _slang_new_ir_storage_swz(enum register_file file, GLint index, GLint size,
st->Size = size;
st->Swizzle = swizzle;
st->Parent = NULL;
+ st->IsIndirect = GL_FALSE;
}
return st;
}
@@ -170,11 +186,45 @@ _slang_new_ir_storage_relative(GLint index, GLint size,
st->Size = size;
st->Swizzle = SWIZZLE_NOOP;
st->Parent = parent;
+ st->IsIndirect = GL_FALSE;
+ }
+ return st;
+}
+
+
+slang_ir_storage *
+_slang_new_ir_storage_indirect(enum register_file file,
+ GLint index,
+ GLint size,
+ enum register_file indirectFile,
+ GLint indirectIndex,
+ GLuint indirectSwizzle)
+{
+ slang_ir_storage *st;
+ st = (slang_ir_storage *) _slang_alloc(sizeof(slang_ir_storage));
+ if (st) {
+ st->File = file;
+ st->Index = index;
+ st->Size = size;
+ st->Swizzle = SWIZZLE_NOOP;
+ st->IsIndirect = GL_TRUE;
+ st->IndirectFile = indirectFile;
+ st->IndirectIndex = indirectIndex;
+ st->IndirectSwizzle = indirectSwizzle;
}
return st;
}
+/* XXX temporary function */
+void
+_slang_copy_ir_storage(slang_ir_storage *dst, const slang_ir_storage *src)
+{
+ *dst = *src;
+ dst->Parent = NULL;
+}
+
+
static const char *
_slang_ir_name(slang_ir_opcode opcode)