diff options
Diffstat (limited to 'src/mesa/shader/slang/slang_emit.c')
-rw-r--r-- | src/mesa/shader/slang/slang_emit.c | 70 |
1 files changed, 27 insertions, 43 deletions
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index 912c325bb2..f1af6902ea 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -161,9 +161,7 @@ free_temp_storage(slang_var_table *vt, slang_ir_node *n) if (_slang_is_temp(vt, n->Store)) { _slang_free_temp(vt, n->Store); n->Store->Index = -1; - n->Store->Size = -1; - /*_mesa_free(n->Store);*/ /* XXX leak */ - n->Store = NULL; + n->Store = NULL; /* XXX this may not be needed */ } } } @@ -258,6 +256,12 @@ storage_to_src_reg(struct prog_src_register *src, const slang_ir_storage *st) } assert(st->File >= 0); +#if 1 /* XXX temporary */ + if (st->File == PROGRAM_UNDEFINED) { + slang_ir_storage *st0 = (slang_ir_storage *) st; + st0->File = PROGRAM_TEMPORARY; + } +#endif assert(st->File < PROGRAM_UNDEFINED); src->File = st->File; @@ -627,7 +631,11 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n) emit(emitInfo, n->Children[0]); emit(emitInfo, n->Children[1]); - assert(n->Children[0]->Store->Size == n->Children[1]->Store->Size); + if (n->Children[0]->Store->Size != n->Children[1]->Store->Size) { + slang_info_log_error(emitInfo->log, "invalid operands to == or !="); + return NULL; + } + size = n->Children[0]->Store->Size; if (size == 1) { @@ -717,10 +725,10 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n) for (i = 0; i < num; i++) { /* SNE t0, left[i], right[i] */ inst = new_instruction(emitInfo, OPCODE_SNE); - inst->SrcReg[0].File = n->Children[0]->Store->File; - inst->SrcReg[0].Index = n->Children[0]->Store->Index + i; - inst->SrcReg[1].File = n->Children[1]->Store->File; - inst->SrcReg[1].Index = n->Children[1]->Store->Index + i; + storage_to_src_reg(&inst->SrcReg[0], n->Children[0]->Store); + storage_to_src_reg(&inst->SrcReg[1], n->Children[1]->Store); + inst->SrcReg[0].Index += i; + inst->SrcReg[1].Index += i; if (i == 0) { inst->DstReg.File = accTemp.File; inst->DstReg.Index = accTemp.Index; @@ -1547,48 +1555,24 @@ emit_array_element(slang_emit_info *emitInfo, slang_ir_node *n) return NULL; } - if (n->Children[1]->Opcode == IR_FLOAT) { - /* Constant array index */ -#if 0 /* just debug code */ - const GLint arrayAddr = n->Children[0]->Store->Index; - const GLint index = (GLint) n->Children[1]->Value[0]; - assert(index == n->Store->Index); - assert(arrayAddr == parent->Index); - assert(n->Children[0]->Store == parent); - assert(n->Children[0]->Store->Index == parent->Index); -#endif - - GLint index = n->Store->Index; - - slang_ir_storage *p = n->Store; - index = 0; - while (p->Parent) { - int sz = (p->Size + 3) / 4; - /*printf("element [%d] of size %d (%d)\n", p->Index, p->Size, sz);*/ - index += sz * p->Index; - p = p->Parent; - } - index += p->Index; - - assert(root->File != PROGRAM_UNDEFINED); + /* do codegen for array */ + emit(emitInfo, n->Children[0]); - /* resolve new absolute storage location */ - assert(n->Store); - n->Store->File = root->File; - if (root->File == PROGRAM_STATE_VAR) - n->Store->Index = 0; - else - n->Store->Index = index; + if (n->Children[1]->Opcode == IR_FLOAT) { + /* Constant array index. + * Set Store's index to be the offset of the array element in + * the register file. + */ + const GLint element = (GLint) n->Children[1]->Value[0]; + const GLint sz = (n->Store->Size + 3) / 4; /* size in slots/registers */ - n->Store->Parent = NULL; + n->Store->Index = sz * element; + assert(n->Store->Parent); } else { /* Variable array index */ struct prog_instruction *inst; - /* do codegen for array */ - emit(emitInfo, n->Children[0]); - /* do codegen for array index expression */ emit(emitInfo, n->Children[1]); |