summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-03-07 09:59:26 -0700
committerBrian <[email protected]>2007-03-07 09:59:26 -0700
commit3efd0c7b8d1aaa8abd78b35e4cb92dae4279dd77 (patch)
tree894f092b4ad695f94b94c86ec32004e30c6b465a
parentf3da222839151bc8cbedbbe1e84f771deb31148c (diff)
fix swizzled writemask bug
-rw-r--r--src/mesa/shader/slang/slang_codegen.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index b2c9c727104..5c2ee3c4388 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -1878,26 +1878,32 @@ _slang_gen_variable(slang_assemble_ctx * A, slang_operation *oper)
* v.xy = vec2(a, b);
* Hard example:
* vec3 v;
- * v.yz = vec2(a, b);
- * this would have to be transformed/swizzled into:
- * v.yz = vec2(a, b).*xy* (* = don't care)
- * Instead, we'll effectively do this:
- * v.y = vec2(a, b).xxxx;
- * v.z = vec2(a, b).yyyy;
- *
+ * v.zy = vec2(a, b);
+ * this gets transformed/swizzled into:
+ * v.zy = vec2(a, b).*yx* (* = don't care)
+ * This function helps to determine simple vs. non-simple.
*/
static GLboolean
-_slang_simple_writemask(GLuint writemask)
+_slang_simple_writemask(GLuint writemask, GLuint swizzle)
{
switch (writemask) {
case WRITEMASK_X:
+ return GET_SWZ(swizzle, 0) == SWIZZLE_X;
case WRITEMASK_Y:
+ return GET_SWZ(swizzle, 1) == SWIZZLE_Y;
case WRITEMASK_Z:
+ return GET_SWZ(swizzle, 2) == SWIZZLE_Z;
case WRITEMASK_W:
+ return GET_SWZ(swizzle, 3) == SWIZZLE_W;
case WRITEMASK_XY:
+ return (GET_SWZ(swizzle, 0) == SWIZZLE_X)
+ && (GET_SWZ(swizzle, 1) == SWIZZLE_Y);
case WRITEMASK_XYZ:
+ return (GET_SWZ(swizzle, 0) == SWIZZLE_X)
+ && (GET_SWZ(swizzle, 1) == SWIZZLE_Y)
+ && (GET_SWZ(swizzle, 2) == SWIZZLE_Z);
case WRITEMASK_XYZW:
- return GL_TRUE;
+ return swizzle == SWIZZLE_NOOP;
default:
return GL_FALSE;
}
@@ -1948,7 +1954,7 @@ swizzle_to_writemask(GLuint swizzle,
newSwizzle[2],
newSwizzle[3]);
- if (_slang_simple_writemask(mask)) {
+ if (_slang_simple_writemask(mask, *swizzleOut)) {
if (size >= 1)
assert(GET_SWZ(*swizzleOut, 0) == SWIZZLE_X);
if (size >= 2)