mojoshader.c
changeset 1075 61e5b2764ec8
parent 1062 ea5c89942bd3
child 1076 e17375519c45
--- a/mojoshader.c	Wed Jan 04 13:07:50 2012 -0800
+++ b/mojoshader.c	Thu Apr 12 23:13:16 2012 -0400
@@ -144,6 +144,7 @@
     int determined_constants_arrays;
     int predicated;
     int uses_pointsize;
+    int uses_fog;
     int glsl_generated_lit_opcode;
     int glsl_generated_texldd_setup;
     int arb1_wrote_position;
@@ -592,6 +593,8 @@
 
     if ((rtype == REG_TYPE_OUTPUT) && (usage == MOJOSHADER_USAGE_POINTSIZE))
         ctx->uses_pointsize = 1;  // note that we have to check this later.
+    else if ((rtype == REG_TYPE_OUTPUT) && (usage == MOJOSHADER_USAGE_FOG))
+        ctx->uses_fog = 1;  // note that we have to check this later.
 } // add_attribute_register
 
 static inline void add_sampler(Context *ctx, const RegisterType rtype,
@@ -678,11 +681,17 @@
 static int isscalar(Context *ctx, const MOJOSHADER_shaderType shader_type,
                     const RegisterType rtype, const int rnum)
 {
-    if ((rtype == REG_TYPE_OUTPUT) && (ctx->uses_pointsize))
+    const int uses_psize = ctx->uses_pointsize;
+    const int uses_fog = ctx->uses_fog;
+    if ( (rtype == REG_TYPE_OUTPUT) && ((uses_psize) || (uses_fog)) )
     {
         const RegisterList *reg = reglist_find(&ctx->attributes, rtype, rnum);
         if (reg != NULL)
-            return (reg->usage == MOJOSHADER_USAGE_POINTSIZE);
+        {
+            const MOJOSHADER_usage usage = reg->usage;
+            return ( (uses_psize && (usage == MOJOSHADER_USAGE_POINTSIZE)) ||
+                     (uses_fog && (usage == MOJOSHADER_USAGE_FOG)) );
+        } // if
     } // if
 
     return scalar_register(shader_type, rtype, rnum);