From: Brian Date: Thu, 22 Mar 2007 15:15:39 +0000 (-0600) Subject: First pass at implementing structure compares. X-Git-Tag: android-x86-1.6~2267^2~21 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=0aad9e262784b0f2ac85afdce88414c986dae2f7;p=android-x86%2Fexternal-mesa.git 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. --- 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;