Fixed oDepth usage in GLSL profile. trunk
authorRyan C. Gordon <icculus@icculus.org>
Fri, 09 May 2008 23:06:12 -0400
branchtrunk
changeset 308 1970c3cd49ae
parent 306 053aaa9b4fb1
child 309 fe4e94d46cda
Fixed oDepth usage in GLSL profile. oDepth register is a float, not a vec4, so we need to handle swizzles appropriately.
mojoshader.c
--- a/mojoshader.c	Fri May 09 02:33:22 2008 -0400
+++ b/mojoshader.c	Fri May 09 23:06:12 2008 -0400
@@ -2349,7 +2349,14 @@
 
 static void emit_GLSL_MOV(Context *ctx)
 {
-    const char *src0 = make_GLSL_srcarg_string_masked(ctx, 0);
+    const char *src0 = NULL;
+
+    // oDepth is a float, not a vec4, but the writemask is .xyzw ... tweak it.
+    if (ctx->dest_arg.regtype == REG_TYPE_DEPTHOUT)
+        src0 = make_GLSL_srcarg_string_x(ctx, 0);
+    else
+        src0 = make_GLSL_srcarg_string_masked(ctx, 0);
+
     const char *code = make_GLSL_destarg_assign(ctx, "%s", src0);
     output_line(ctx, "%s", code);
 } // emit_GLSL_MOV