diff options
author | Brian Paul <[email protected]> | 2008-11-13 18:18:07 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-01-06 08:47:40 -0700 |
commit | ebcf06702c22419221c136a438c934469c2422cc (patch) | |
tree | 1cd2a5112e5e38872391e9fedf61740376862453 /src/mesa | |
parent | 9681119bbb0317c87dcf781da561174752c02bc8 (diff) |
mesa: no longer need Writemask field in GLSL IR nodes
The Swizzle and Size fields carry all the info we need now.
(cherry picked from commit 80d6379722a1249ce13db79a898d340644936f67)
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/shader/slang/slang_codegen.c | 4 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_emit.c | 69 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_ir.c | 18 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_ir.h | 1 |
4 files changed, 23 insertions, 69 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 8e1dc47b089..0f7b5a5d123 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -477,7 +477,6 @@ new_node3(slang_ir_opcode op, n->Children[0] = c0; n->Children[1] = c1; n->Children[2] = c2; - n->Writemask = WRITEMASK_XYZW; n->InstLocation = -1; } return n; @@ -3045,7 +3044,6 @@ _slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper) rhs = _slang_gen_swizzle(rhs, newSwizzle); } n = new_node2(IR_COPY, lhs, rhs); - n->Writemask = writemask; return n; } else { @@ -3202,8 +3200,6 @@ _slang_gen_array_element(slang_assemble_ctx * A, slang_operation *oper) SWIZZLE_NIL, SWIZZLE_NIL); n = _slang_gen_swizzle(n, swizzle); - /*n->Store = _slang_clone_ir_storage_swz(n->Store, */ - n->Writemask = WRITEMASK_X << index; } assert(n->Store); return n; diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index ccd937a294d..706b260a578 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); @@ -1242,14 +1228,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 @@ -1260,7 +1239,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; @@ -1715,10 +1693,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) { diff --git a/src/mesa/shader/slang/slang_ir.c b/src/mesa/shader/slang/slang_ir.c index 3a0b8bf3a0d..105ab5b4b69 100644 --- a/src/mesa/shader/slang/slang_ir.c +++ b/src/mesa/shader/slang/slang_ir.c @@ -239,22 +239,6 @@ _slang_free_ir_tree(slang_ir_node *n) } - -static const char * -writemask_string(GLuint writemask) -{ - static char s[6]; - GLuint i, j = 0; - s[j++] = '.'; - for (i = 0; i < 4; i++) { - if (writemask & (1 << i)) - s[j++] = "xyzw"[i]; - } - s[j] = 0; - return s; -} - - static const char * storage_string(const slang_ir_storage *st) { @@ -328,7 +312,7 @@ _slang_print_ir_tree(const slang_ir_node *n, int indent) _slang_print_ir_tree(n->Children[0], indent + 3); break; case IR_COPY: - printf("COPY (writemask = %s)\n", writemask_string(n->Writemask)); + printf("COPY\n"); _slang_print_ir_tree(n->Children[0], indent+3); _slang_print_ir_tree(n->Children[1], indent+3); break; diff --git a/src/mesa/shader/slang/slang_ir.h b/src/mesa/shader/slang/slang_ir.h index f64f9a93b78..4cd81f0fc74 100644 --- a/src/mesa/shader/slang/slang_ir.h +++ b/src/mesa/shader/slang/slang_ir.h @@ -170,7 +170,6 @@ typedef struct slang_ir_node_ /** special fields depending on Opcode: */ const char *Field; /**< If Opcode == IR_FIELD */ - GLuint Writemask; /**< If Opcode == IR_MOVE */ GLfloat Value[4]; /**< If Opcode == IR_FLOAT */ slang_variable *Var; /**< If Opcode == IR_VAR or IR_VAR_DECL */ struct slang_ir_node_ *List; /**< For various linked lists */ |