AGAL write mask

Please, hit the right answer for next AGAL code:
mul vt2.yxzw, vt0.xy, vt1.zyx

Wrong answer is:
vt2.x = vt0.y*vt1.y;
vt2.y = vt0.x*vt1.z;
vt2.z = vt0.y*vt1.x;
vt2.w = vt0.y*vt1.x;

Why is this? All simple.
for vt2 write mask is 1111 (yxzw or xyzw or wxyz or etc. all the same)
vt0 swizzle to xyyy
vt1 swizzle to zyxx

Right answer is:
vt2.x = vt0.x * vt1.z
vt2.y = vt0.y * vt1.y
vt2.z = vt0.y * vt1.x
vt2.w = vt0.y * vt1.x

Thanks to Ariel Nehmad and Sebastian Marketsmueller for explanation.

SergeyGonchar
flash-developer
Visit Gonchar Website.

6 Responses to “AGAL write mask”

  1. Hyzhak says:

    Tricky questions for agal ultra geeks 🙂

  2. Wow. Is it normal behaviour or bug?

  3. Gonchar says:

    Yes, it’s normal if you use AGALMiniAssembler.as

  4. Nils Schneider says:

    Is a write mask that doesn’t start with the first bit a valid operation? For example

    mov vt0.zw vt1.xy

    I’m unable to find any information in the livedocs

  5. Gonchar says:

    you must do this
    mov vt0.zw, vt1.xxxy

    otherwise, if you do mov vt0.zw vt1.xy
    vt0 write mask is 0011
    vt1 swizzle to vt1.xyyy
    vt0.z = vt1.y
    vt0.w = vt1.y

  6. […] I’ve been banging my head for quite a number of hours just to understand the wonders of AGAL write mask (Thank you so much Sergey Gonchar for that explanation!), but for some reason AGAL decided to be […]

Leave a Reply

×
%d bloggers like this: