summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang/slang_emit.c
diff options
context:
space:
mode:
authorBrian <brian@yutani.localnet.net>2007-02-20 17:00:16 -0700
committerBrian <brian@yutani.localnet.net>2007-02-20 17:00:16 -0700
commitaa7ddbd0ff97ad5233a766976bbbb31e7cb1cd51 (patch)
treec7c598ab5e8b0ff5fe2018781d756dfcabc4a4af /src/mesa/shader/slang/slang_emit.c
parent760c114b24fd679bb5c5d386c5935f53ef03e8e5 (diff)
clean-up, move IR_ELEMENT code
Diffstat (limited to 'src/mesa/shader/slang/slang_emit.c')
-rw-r--r--src/mesa/shader/slang/slang_emit.c66
1 files changed, 36 insertions, 30 deletions
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index c174f7b6b4..d993fbddc5 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -1309,12 +1309,40 @@ emit_swizzle(slang_var_table *vt, slang_ir_node *n, struct gl_program *prog)
/**
+ * Dereference array element. Just resolve storage for the array
+ * element represented by this node.
+ */
+static struct prog_instruction *
+emit_array_element(slang_var_table *vt, slang_ir_node *n,
+ struct gl_program *prog)
+{
+ assert(n->Store);
+ assert(n->Store->File != PROGRAM_UNDEFINED);
+ assert(n->Store->Size > 0);
+ if (n->Children[1]->Opcode == IR_FLOAT) {
+ /* Constant index */
+ const GLint arrayAddr = n->Children[0]->Store->Index;
+ const GLint index = (GLint) n->Children[1]->Value[0];
+ 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;
+ }
+ return NULL; /* no instruction */
+}
+
+
+/**
* Resolve storage for accessing a structure field.
*/
static struct prog_instruction *
-emit_field(slang_var_table *vt, slang_ir_node *n, struct gl_program *prog)
+emit_struct_field(slang_var_table *vt, slang_ir_node *n,
+ struct gl_program *prog)
{
- /* field of a struct */
if (n->Children[0]->Store->File == PROGRAM_STATE_VAR) {
/* state variable sub-field */
GLint pos;
@@ -1331,11 +1359,10 @@ emit_field(slang_var_table *vt, slang_ir_node *n, struct gl_program *prog)
n->Store->Index = pos;
n->Store->Swizzle = swizzle;
}
-
- /*
- _mesa_problem(NULL, "glsl structs/fields not supported yet");
- */
- return NULL;
+ else {
+ _mesa_problem(NULL, "structs/fields not supported yet");
+ }
+ return NULL; /* no instruction */
}
@@ -1402,30 +1429,9 @@ emit(slang_var_table *vt, slang_ir_node *n, struct gl_program *prog)
break;
case IR_ELEMENT:
- /* Dereference array element. Just resolve storage for the array
- * element represented by this node.
- */
- assert(n->Store);
- assert(n->Store->File != PROGRAM_UNDEFINED);
- assert(n->Store->Size > 0);
- if (n->Children[1]->Opcode == IR_FLOAT) {
- /* OK, constant index */
- const GLint arrayAddr = n->Children[0]->Store->Index;
- const GLint index = (GLint) n->Children[1]->Value[0];
- n->Store->Index = arrayAddr + index;
- }
- else {
- /* Problem: variable index */
- 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;
- }
- return NULL; /* no instruction */
-
+ return emit_array_element(vt, n, prog);
case IR_FIELD:
- return emit_field(vt, n, prog);
-
+ return emit_struct_field(vt, n, prog);
case IR_SWIZZLE:
return emit_swizzle(vt, n, prog);