mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 04:38:03 +02:00
clean-up, move IR_ELEMENT code
This commit is contained in:
parent
760c114b24
commit
aa7ddbd0ff
1 changed files with 36 additions and 30 deletions
|
|
@ -1308,13 +1308,41 @@ 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.
|
* Resolve storage for accessing a structure field.
|
||||||
*/
|
*/
|
||||||
static struct prog_instruction *
|
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) {
|
if (n->Children[0]->Store->File == PROGRAM_STATE_VAR) {
|
||||||
/* state variable sub-field */
|
/* state variable sub-field */
|
||||||
GLint pos;
|
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->Index = pos;
|
||||||
n->Store->Swizzle = swizzle;
|
n->Store->Swizzle = swizzle;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
/*
|
_mesa_problem(NULL, "structs/fields not supported yet");
|
||||||
_mesa_problem(NULL, "glsl structs/fields not supported yet");
|
}
|
||||||
*/
|
return NULL; /* no instruction */
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1402,30 +1429,9 @@ emit(slang_var_table *vt, slang_ir_node *n, struct gl_program *prog)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IR_ELEMENT:
|
case IR_ELEMENT:
|
||||||
/* Dereference array element. Just resolve storage for the array
|
return emit_array_element(vt, n, prog);
|
||||||
* 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 */
|
|
||||||
|
|
||||||
case IR_FIELD:
|
case IR_FIELD:
|
||||||
return emit_field(vt, n, prog);
|
return emit_struct_field(vt, n, prog);
|
||||||
|
|
||||||
case IR_SWIZZLE:
|
case IR_SWIZZLE:
|
||||||
return emit_swizzle(vt, n, prog);
|
return emit_swizzle(vt, n, prog);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue