Flag more registers as scalar. Fixes use of dcl_fog, oPts and oFog registers.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 12 Apr 2012 23:13:16 -0400
changeset 1075 61e5b2764ec8
parent 1074 3fdc7cbd0c37
child 1076 e17375519c45
Flag more registers as scalar. Fixes use of dcl_fog, oPts and oFog registers.
mojoshader.c
mojoshader_internal.h
--- 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);
--- a/mojoshader_internal.h	Wed Jan 04 13:07:50 2012 -0800
+++ b/mojoshader_internal.h	Thu Apr 12 23:13:16 2012 -0400
@@ -399,13 +399,20 @@
     RegisterType regtype;
 } DestArgInfo;
 
-// NOTE: This will NOT know a dcl_psize output register should be scalar!
-//  This function doesn't have access to that information.
+// NOTE: This will NOT know a dcl_psize or dcl_fog output register should be
+//        scalar! This function doesn't have access to that information.
 static inline int scalar_register(const MOJOSHADER_shaderType shader_type,
                                   const RegisterType regtype, const int regnum)
 {
     switch (regtype)
     {
+        case REG_TYPE_RASTOUT:
+            if (((const RastOutType) regnum) == RASTOUT_TYPE_FOG)
+                return 1;
+            else if (((const RastOutType) regnum) == RASTOUT_TYPE_POINT_SIZE)
+                return 1;
+            return 0;
+
         case REG_TYPE_DEPTHOUT:
         case REG_TYPE_CONSTBOOL:
         case REG_TYPE_LOOP: