diff options
author | Brian Paul <[email protected]> | 2008-11-13 18:18:07 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2008-11-13 18:19:12 -0700 |
commit | 80d6379722a1249ce13db79a898d340644936f67 (patch) | |
tree | c3b1c97ef221cf68398630b12d3487832adace74 /src/mesa/shader/slang/slang_emit.c | |
parent | 3a7ed9779b159f9dccbc98d1d556be2cd83cc1fd (diff) |
mesa: no longer need Writemask field in GLSL IR nodes
The Swizzle and Size fields carry all the info we need now.
Diffstat (limited to 'src/mesa/shader/slang/slang_emit.c')
-rw-r--r-- | src/mesa/shader/slang/slang_emit.c | 69 |
1 files changed, 22 insertions, 47 deletions
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index 482e3e825c1..b67cea7617d 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -257,8 +257,7 @@ fix_swizzle(GLuint swizzle) * Convert IR storage to an instruction dst register. */ static void -storage_to_dst_reg(struct prog_dst_register *dst, const slang_ir_storage *st, - GLuint writemask) +storage_to_dst_reg(struct prog_dst_register *dst, const slang_ir_storage *st) { const GLint size = st->Size; GLint index = st->Index; @@ -280,23 +279,29 @@ storage_to_dst_reg(struct prog_dst_register *dst, const slang_ir_storage *st, assert(size >= 1); assert(size <= 4); -#if 0 - if (size == 1) { - GLuint comp = GET_SWZ(swizzle, 0); - assert(comp < 4); - dst->WriteMask = WRITEMASK_X << comp; - } - else { - dst->WriteMask = writemask; - } -#elif 1 if (swizzle != SWIZZLE_XYZW) { dst->WriteMask = swizzle_to_writemask(swizzle); } else { + GLuint writemask; + switch (size) { + case 1: + writemask = WRITEMASK_X << GET_SWZ(st->Swizzle, 0); + break; + case 2: + writemask = WRITEMASK_XY; + break; + case 3: + writemask = WRITEMASK_XYZ; + break; + case 4: + writemask = WRITEMASK_XYZW; + break; + default: + ; /* error would have been caught above */ + } dst->WriteMask = writemask; } -#endif } @@ -422,27 +427,8 @@ emit_instruction(slang_emit_info *emitInfo, inst->Opcode = opcode; inst->BranchTarget = -1; /* invalid */ - if (dst) { - GLuint writemask; - switch (dst->Size) { - case 4: - writemask = WRITEMASK_XYZW; - break; - case 3: - writemask = WRITEMASK_XYZ; - break; - case 2: - writemask = WRITEMASK_XY; - break; - case 1: - writemask = WRITEMASK_X << GET_SWZ(dst->Swizzle, 0); - break; - default: - writemask = WRITEMASK_XYZW; - assert(0); - } - storage_to_dst_reg(&inst->DstReg, dst, writemask); - } + if (dst) + storage_to_dst_reg(&inst->DstReg, dst); if (src1) storage_to_src_reg(&inst->SrcReg[0], src1); @@ -1245,14 +1231,7 @@ emit_copy(slang_emit_info *emitInfo, slang_ir_node *n) /* fixup the previous instruction (which stored the RHS result) */ assert(n->Children[0]->Store->Index >= 0); - /* use tighter writemask when possible */ -#if 0 - if (n->Writemask == WRITEMASK_XYZW) { - n->Writemask = inst->DstReg.WriteMask; - printf("Narrow writemask to 0x%x\n", n->Writemask); - } -#endif - storage_to_dst_reg(&inst->DstReg, n->Children[0]->Store, n->Writemask); + storage_to_dst_reg(&inst->DstReg, n->Children[0]->Store); return inst; } else @@ -1263,7 +1242,6 @@ emit_copy(slang_emit_info *emitInfo, slang_ir_node *n) slang_ir_storage dstStore = *n->Children[0]->Store; slang_ir_storage srcStore = *n->Children[1]->Store; GLint size = srcStore.Size; - ASSERT(n->Children[0]->Writemask == WRITEMASK_XYZW); ASSERT(n->Children[1]->Store->Swizzle == SWIZZLE_NOOP); dstStore.Size = 4; srcStore.Size = 4; @@ -1718,10 +1696,7 @@ move_block(slang_emit_info *emitInfo, /* move matrix/struct etc (block of registers) */ slang_ir_storage dstStore = *dst; slang_ir_storage srcStore = *src; - //GLint size = srcStore.Size; - /*ASSERT(n->Children[0]->Writemask == WRITEMASK_XYZW); - ASSERT(n->Children[1]->Store->Swizzle == SWIZZLE_NOOP); - */ + dstStore.Size = 4; srcStore.Size = 4; while (size >= 4) { |