From 22b71f9af97e01f7f2539177efef4ccef9c93912 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Thu, 10 May 2018 15:49:28 +0200 Subject: [PATCH] Skip outermost array when assigning locations to auto-array interfaces When assigning a location to an interface whose stage automatically converts the interfaces to an array, it now strips off the outermost array from the type before calculating how many locations it consumes. --- glslang/MachineIndependent/iomapper.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/glslang/MachineIndependent/iomapper.cpp b/glslang/MachineIndependent/iomapper.cpp index fd40329e..297c1237 100644 --- a/glslang/MachineIndependent/iomapper.cpp +++ b/glslang/MachineIndependent/iomapper.cpp @@ -478,7 +478,16 @@ struct TDefaultIoResolverBase : public glslang::TIoMapResolver // Placeholder. This does not do proper cross-stage lining up, nor // work with mixed location/no-location declarations. int location = nextLocation; - nextLocation += TIntermediate::computeTypeLocationSize(type, stage); + int typeLocationSize; + // Don’t take into account the outer-most array if the stage’s + // interface is automatically an array. + if (type.getQualifier().isArrayedIo(stage)) { + TType elementType(type, 0); + typeLocationSize = TIntermediate::computeTypeLocationSize(elementType, stage); + } else { + typeLocationSize = TIntermediate::computeTypeLocationSize(type, stage); + } + nextLocation += typeLocationSize; return location; }