diff options
Diffstat (limited to 'src/mesa/shader')
-rw-r--r-- | src/mesa/shader/slang/slang_codegen.c | 20 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_emit.c | 10 |
2 files changed, 22 insertions, 8 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 4976daf533b..8e28be8abd1 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -3323,6 +3323,22 @@ is_store_writable(const slang_assemble_ctx *A, const slang_ir_storage *store) /** + * Walk up an IR storage path to compute the final swizzle. + * This is used when we find an expression such as "foo.xz.yx". + */ +static GLuint +root_swizzle(const slang_ir_storage *st) +{ + GLuint swizzle = st->Swizzle; + while (st->Parent) { + st = st->Parent; + swizzle = _slang_swizzle_swizzle(st->Swizzle, swizzle); + } + return swizzle; +} + + +/** * Generate IR tree for an assignment (=). */ static slang_ir_node * @@ -3397,9 +3413,9 @@ _slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper) rhs = _slang_gen_operation(A, &oper->children[1]); if (lhs && rhs) { /* convert lhs swizzle into writemask */ + const GLuint swizzle = root_swizzle(lhs->Store); GLuint writemask, newSwizzle; - if (!swizzle_to_writemask(A, lhs->Store->Swizzle, - &writemask, &newSwizzle)) { + if (!swizzle_to_writemask(A, swizzle, &writemask, &newSwizzle)) { /* Non-simple writemask, need to swizzle right hand side in * order to put components into the right place. */ diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index b7a3cfb6177..1c0a7bbbd6e 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -310,24 +310,22 @@ storage_to_dst_reg(struct prog_dst_register *dst, const slang_ir_storage *st) dst->WriteMask = swizzle_to_writemask(swizzle); } else { - GLuint writemask; switch (size) { case 1: - writemask = WRITEMASK_X << GET_SWZ(st->Swizzle, 0); + dst->WriteMask = WRITEMASK_X << GET_SWZ(st->Swizzle, 0); break; case 2: - writemask = WRITEMASK_XY; + dst->WriteMask = WRITEMASK_XY; break; case 3: - writemask = WRITEMASK_XYZ; + dst->WriteMask = WRITEMASK_XYZ; break; case 4: - writemask = WRITEMASK_XYZW; + dst->WriteMask = WRITEMASK_XYZW; break; default: ; /* error would have been caught above */ } - dst->WriteMask = writemask; } dst->RelAddr = relAddr; |