diff options
author | Brian Paul <brianp@vmware.com> | 2009-01-05 13:12:12 -0700 |
---|---|---|
committer | Xiang, Haihao <haihao.xiang@intel.com> | 2009-01-08 16:33:46 +0800 |
commit | a39496b480cdcaeea40eb9f945428f29de7bb68b (patch) | |
tree | 68dc9d83ad9f57dedb44afe55b5eb9167cc6cbf7 | |
parent | 2300dfd449b06744331c709f2d5856ec36102f26 (diff) |
mesa: fix a GLSL swizzled writemask bug
This fixes cases such as:
vec4 v4;
vec2 v2;
v4.xz.yx = v2;
The last line now correctly compiles into MOV TEMP[1].xz, TEMP[0].yyxw;
Helps to fix the Humus Domino demo. See bug 19189.
(cherry picked from commit 9736d8f03364068c9ca786f88a4c2881d98d5768)
-rw-r--r-- | src/mesa/shader/slang/slang_codegen.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 8abb642a72..5edb5b1260 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -3028,6 +3028,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 * @@ -3102,9 +3118,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. */ |