diff options
author | Brian <[email protected]> | 2007-03-22 09:15:39 -0600 |
---|---|---|
committer | Brian <[email protected]> | 2007-03-22 09:15:39 -0600 |
commit | 0aad9e262784b0f2ac85afdce88414c986dae2f7 (patch) | |
tree | 9705533689ecce2a88c8bafeb4f35669d0f46125 | |
parent | 12229f119d754715e0315846fdd8d6e9213e8edf (diff) |
First pass at implementing structure compares.
Need to improve this. There may be holes in a structure so we can't
just blindly compare the full 4-float registers.
-rw-r--r-- | src/mesa/shader/slang/slang_emit.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index e578c829954..bc08104ada5 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -778,25 +778,48 @@ static struct prog_instruction * emit_compare(slang_emit_info *emitInfo, slang_ir_node *n) { struct prog_instruction *inst; + gl_inst_opcode opcode; assert(n->Opcode == IR_SEQUAL || n->Opcode == IR_SNEQUAL); + opcode = n->Opcode == IR_SEQUAL ? OPCODE_SEQ : OPCODE_SNE; + /* gen code for children */ emit(emitInfo, n->Children[0]); emit(emitInfo, n->Children[1]); assert(n->Children[0]->Store->Size == n->Children[1]->Store->Size); - /* gen this instruction and src registers */ - inst = new_instruction(emitInfo, - (n->Opcode == IR_SEQUAL) ? OPCODE_SEQ : OPCODE_SNE); + if (!n->Store) { + if (!alloc_temp_storage(emitInfo, n, 1)) /* 1 bool */ + return NULL; + } + if (n->Children[0]->Store->Size > 4) { /* struct compare */ - _mesa_problem(NULL, "struct compare not implemented!"); - return NULL; + GLint i, num = (n->Children[0]->Store->Size + 3) / 4; + + /*printf("BEGIN COMPARE size %d\n", num);*/ + for (i = 0; i < num; i++) { + inst = new_instruction(emitInfo, opcode); + 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; + inst->DstReg.File = n->Store->File; + inst->DstReg.Index = n->Store->Index; + if (i == 0) { + inst->CondUpdate = 1; /* update cond code */ + } + else { + inst->DstReg.CondMask = COND_NE; /* update if !=0 */ + } + /*_mesa_print_instruction(inst);*/ + } } else { /* small/simple types */ + inst = new_instruction(emitInfo, opcode); storage_to_src_reg(&inst->SrcReg[0], n->Children[0]->Store); storage_to_src_reg(&inst->SrcReg[1], n->Children[1]->Store); } @@ -806,10 +829,6 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n) free_temp_storage(emitInfo->vt, n->Children[1]); /* result storage */ - if (!n->Store) { - if (!alloc_temp_storage(emitInfo, n, 1)) /* 1 bool */ - return NULL; - } storage_to_dst_reg(&inst->DstReg, n->Store, n->Writemask); return inst; |