From bc9b7656b77afe3053d00b6ebfdc0d114d167aa2 Mon Sep 17 00:00:00 2001 From: steve-lunarg Date: Thu, 29 Sep 2016 08:43:22 -0600 Subject: [PATCH] Restrict uniform array flattening to sampler and texture arrays. 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 | 2 +- hlsl/hlslParseHelper.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index 30af4fe4..5d30ac2b 100644 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -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" ); diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index 65f7aa26..44a4230b 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -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)