Restrict uniform array flattening to sampler and texture arrays.
authorsteve-lunarg <steve_gh@khasekhemwy.net>
Thu, 29 Sep 2016 14:43:22 +0000 (08:43 -0600)
committersteve-lunarg <steve_gh@khasekhemwy.net>
Thu, 29 Sep 2016 20:01:25 +0000 (14:01 -0600)
Previously the uniform array flattening feature would trigger on loose
uniform arrays of any basic type (e.g, floats).  This PR restricts it
to sampler and texture arrays.  Other arrays would end up in their own
uniform block (anonymous or otherwise).  (Atomic counter arrays might be an
exception, but those are not currently flattened).

StandAlone/StandAlone.cpp
hlsl/hlslParseHelper.cpp

index 30af4fe..5d30ac2 100644 (file)
@@ -941,7 +941,7 @@ void usage()
            "                                          explicit bindings.\n"
            "  --amb                                   synonym for --auto-map-bindings\n"
            "\n"
-           "  --flatten-uniform-arrays                flatten uniform array references to scalars\n"
+           "  --flatten-uniform-arrays                flatten uniform texture & sampler arrays to scalars\n"
            "  --fua                                   synonym for --flatten-uniform-arrays\n"
            );
 
index 65f7aa2..44a4230 100755 (executable)
@@ -736,7 +736,9 @@ bool HlslParseContext::shouldFlattenUniform(const TType& type) const
 
     return type.isArray() &&
         intermediate.getFlattenUniformArrays() &&
-        qualifier == EvqUniform;
+        qualifier == EvqUniform &&
+        // Testing the EbtSampler basic type covers samplers and textures
+        type.getBasicType() == EbtSampler;
 }
 
 void HlslParseContext::flatten(const TSourceLoc& loc, const TVariable& variable)