You can mix and match "xyzw" and "rgba" writemasks, even in vertex shaders.
authorRyan C. Gordon <icculus@icculus.org>
Sat, 28 Feb 2009 18:32:05 -0500
changeset 720 7b0bbd985de7
parent 719 c18465fa4cb7
child 721 82d1aec6b549
You can mix and match "xyzw" and "rgba" writemasks, even in vertex shaders.
mojoshader_assembler.c
--- a/mojoshader_assembler.c	Sat Feb 28 18:27:23 2009 -0500
+++ b/mojoshader_assembler.c	Sat Feb 28 18:32:05 2009 -0500
@@ -614,18 +614,10 @@
         memcpy(tokenbytes, ctx->token, ((tokenlen < 4) ? tokenlen : 4));
         char *ptr = tokenbytes;
 
-        info->writemask0 = info->writemask1 = info->writemask2 = info->writemask3 = 0;
-        if (*ptr == 'x') { info->writemask0 = 1; ptr++; }
-        if (*ptr == 'y') { info->writemask1 = 1; ptr++; }
-        if (*ptr == 'z') { info->writemask2 = 1; ptr++; }
-        if (*ptr == 'w') { info->writemask3 = 1; ptr++; }
-        if ((ptr == ctx->token) && (shader_is_pixel(ctx)))
-        {
-            if (*ptr == 'r') { info->writemask0 = 1; ptr++; }
-            if (*ptr == 'g') { info->writemask1 = 1; ptr++; }
-            if (*ptr == 'b') { info->writemask2 = 1; ptr++; }
-            if (*ptr == 'a') { info->writemask3 = 1; ptr++; }
-        } // if
+        if ((*ptr == 'r') || (*ptr == 'x')) { info->writemask0 = 1; ptr++; }
+        if ((*ptr == 'g') || (*ptr == 'y')) { info->writemask1 = 1; ptr++; }
+        if ((*ptr == 'b') || (*ptr == 'z')) { info->writemask2 = 1; ptr++; }
+        if ((*ptr == 'a') || (*ptr == 'w')) { info->writemask3 = 1; ptr++; }
 
         if (*ptr != '\0')
             invalid_writemask = 1;