From edf8212ab8c01f3ee5cc4384b8590c2ce67f92a8 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 29 Jan 2019 15:49:00 +0000 Subject: [PATCH] Add an option to report array variables with trailing [0] suffix * This is as expected by ARB_program_interface_query --- StandAlone/StandAlone.cpp | 3 +++ Test/baseResults/reflection.options.vert.out | 12 ++++++------ Test/runtests | 2 +- glslang/MachineIndependent/reflection.cpp | 4 ++++ glslang/Public/ShaderLang.h | 1 + 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index fd69810b..c9b1eded 100644 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -526,6 +526,8 @@ void ProcessArguments(std::vector>& workItem Options |= EOptionRelaxedErrors; } else if (lowerword == "reflect-strict-array-suffix") { ReflectOptions |= EShReflectionStrictArraySuffix; + } else if (lowerword == "reflect-basic-array-suffix") { + ReflectOptions |= EShReflectionBasicArraySuffix; } else if (lowerword == "resource-set-bindings" || // synonyms lowerword == "resource-set-binding" || lowerword == "rsb") { @@ -1522,6 +1524,7 @@ void usage() " --keep-uncalled | --ku don't eliminate uncalled functions\n" " --no-storage-format | --nsf use Unknown image format\n" " --reflect-strict-array-suffix use strict array suffix rules when reflecting\n" + " --reflect-basic-array-suffix arrays of basic types will have trailing [0]\n" " --resource-set-binding [stage] name set binding\n" " set descriptor set and binding for\n" " individual resources\n" diff --git a/Test/baseResults/reflection.options.vert.out b/Test/baseResults/reflection.options.vert.out index a4bf815b..22177c7c 100644 --- a/Test/baseResults/reflection.options.vert.out +++ b/Test/baseResults/reflection.options.vert.out @@ -1,11 +1,11 @@ reflection.options.vert Uniform reflection: -t[0].v[0].position: offset 0, type 1406, size 3, index 0, binding -1, stages 1 -t[0].v[1].position: offset 24, type 1406, size 3, index 0, binding -1, stages 1 -t[0].v[2].position: offset 48, type 1406, size 3, index 0, binding -1, stages 1 -t[0].v[0].normal: offset 12, type 1406, size 3, index 0, binding -1, stages 1 -t[0].v[1].normal: offset 36, type 1406, size 3, index 0, binding -1, stages 1 -t[0].v[2].normal: offset 60, type 1406, size 3, index 0, binding -1, stages 1 +t[0].v[0].position[0]: offset 0, type 1406, size 3, index 0, binding -1, stages 1 +t[0].v[1].position[0]: offset 24, type 1406, size 3, index 0, binding -1, stages 1 +t[0].v[2].position[0]: offset 48, type 1406, size 3, index 0, binding -1, stages 1 +t[0].v[0].normal[0]: offset 12, type 1406, size 3, index 0, binding -1, stages 1 +t[0].v[1].normal[0]: offset 36, type 1406, size 3, index 0, binding -1, stages 1 +t[0].v[2].normal[0]: offset 60, type 1406, size 3, index 0, binding -1, stages 1 Uniform block reflection: VertexCollection: offset -1, type ffffffff, size 360, index -1, binding -1, stages 0 diff --git a/Test/runtests b/Test/runtests index 890ebac5..c01366e6 100755 --- a/Test/runtests +++ b/Test/runtests @@ -32,7 +32,7 @@ diff -b $BASEDIR/badMacroArgs.frag.out $TARGETDIR/badMacroArgs.frag.out || HASER echo Running reflection... $EXE -l -q -C reflection.vert > $TARGETDIR/reflection.vert.out diff -b $BASEDIR/reflection.vert.out $TARGETDIR/reflection.vert.out || HASERROR=1 -$EXE -l -q -C --reflect-strict-array-suffix reflection.options.vert > $TARGETDIR/reflection.options.vert.out +$EXE -l -q -C --reflect-strict-array-suffix --reflect-basic-array-suffix reflection.options.vert > $TARGETDIR/reflection.options.vert.out diff -b $BASEDIR/reflection.options.vert.out $TARGETDIR/reflection.options.vert.out || HASERROR=1 $EXE -D -Od -e flizv -l -q -C -V -Od hlsl.reflection.vert > $TARGETDIR/hlsl.reflection.vert.out diff -b $BASEDIR/hlsl.reflection.vert.out $TARGETDIR/hlsl.reflection.vert.out || HASERROR=1 diff --git a/glslang/MachineIndependent/reflection.cpp b/glslang/MachineIndependent/reflection.cpp index 0f46daad..ec627a18 100644 --- a/glslang/MachineIndependent/reflection.cpp +++ b/glslang/MachineIndependent/reflection.cpp @@ -341,6 +341,10 @@ public: return; } + if ((reflection.options & EShReflectionBasicArraySuffix) && terminalType->isArray()) { + name.append(TString("[0]")); + } + // Finally, add a full string to the reflection database, and update the array size if necessary. // If the dereferenced entity to record is an array, compute the size and update the maximum size. diff --git a/glslang/Public/ShaderLang.h b/glslang/Public/ShaderLang.h index 3866f2de..9a1f4bf0 100755 --- a/glslang/Public/ShaderLang.h +++ b/glslang/Public/ShaderLang.h @@ -245,6 +245,7 @@ enum EShMessages { typedef enum { EShReflectionDefault = 0, // default is original behaviour before options were added EShReflectionStrictArraySuffix = (1 << 0), // reflection will follow stricter rules for array-of-structs suffixes + EShReflectionBasicArraySuffix = (1 << 1), // arrays of basic types will be appended with [0] as in GL reflection } EShReflectionOptions; // -- 2.34.1