diff --git a/Test/baseResults/hlsl.reflection.vert.out b/Test/baseResults/hlsl.reflection.vert.out new file mode 100644 index 00000000..b97de159 --- /dev/null +++ b/Test/baseResults/hlsl.reflection.vert.out @@ -0,0 +1,84 @@ +hlsl.reflection.vert + +Linked vertex stage: + + +Uniform reflection: +anonMember3: offset 96, type 8b52, size 1, index 0 +s.a: offset -1, type 1404, size 1, index -1 +scalar: offset 12, type 1404, size 1, index 0 +m23: offset 16, type 8b67, size 1, index 0 +scalarAfterm23: offset 64, type 1404, size 1, index 0 +c_m23: offset 16, type 8b67, size 1, index 0 +c_scalarAfterm23: offset 64, type 1404, size 1, index 0 +scalarBeforeArray: offset 112, type 1404, size 1, index 0 +floatArray: offset 128, type 1406, size 5, index 0 +scalarAfterArray: offset 208, type 1404, size 1, index 0 +memfloat2: offset 48, type 8b50, size 1, index 0 +memf1: offset 56, type 1406, size 1, index 0 +memf2: offset 60, type 8b56, size 1, index 0 +memf3: offset 64, type 1404, size 1, index 0 +memfloat2a: offset 72, type 8b50, size 1, index 0 +m22: offset 80, type 8b5a, size 7, index 0 +dm22: offset -1, type 8b5a, size 4, index -1 +foo.n1.a: offset 0, type 1406, size 1, index 0 +foo.n2.b: offset 16, type 1406, size 1, index 0 +foo.n2.c: offset 20, type 1406, size 1, index 0 +foo.n2.d: offset 24, type 1406, size 1, index 0 +deepA[0].d2.d1[2].va: offset -1, type 8b50, size 2, index -1 +deepA[1].d2.d1[2].va: offset -1, type 8b50, size 2, index -1 +deepB[1].d2.d1[0].va: offset -1, type 8b50, size 2, index -1 +deepB[1].d2.d1[1].va: offset -1, type 8b50, size 2, index -1 +deepB[1].d2.d1[2].va: offset -1, type 8b50, size 2, index -1 +deepB[1].d2.d1[3].va: offset -1, type 8b50, size 2, index -1 +deepB[0].d2.d1[0].va: offset -1, type 8b50, size 2, index -1 +deepB[0].d2.d1[1].va: offset -1, type 8b50, size 2, index -1 +deepB[0].d2.d1[2].va: offset -1, type 8b50, size 2, index -1 +deepB[0].d2.d1[3].va: offset -1, type 8b50, size 2, index -1 +deepC[1].iv4: offset -1, type 8b52, size 1, index -1 +deepC[1].d2.i: offset -1, type 1404, size 1, index -1 +deepC[1].d2.d1[0].va: offset -1, type 8b50, size 3, index -1 +deepC[1].d2.d1[0].b: offset -1, type 8b56, size 1, index -1 +deepC[1].d2.d1[1].va: offset -1, type 8b50, size 3, index -1 +deepC[1].d2.d1[1].b: offset -1, type 8b56, size 1, index -1 +deepC[1].d2.d1[2].va: offset -1, type 8b50, size 3, index -1 +deepC[1].d2.d1[2].b: offset -1, type 8b56, size 1, index -1 +deepC[1].d2.d1[3].va: offset -1, type 8b50, size 3, index -1 +deepC[1].d2.d1[3].b: offset -1, type 8b56, size 1, index -1 +deepC[1].v3: offset -1, type 8b54, size 1, index -1 +deepD[0].iv4: offset -1, type 8b52, size 1, index -1 +deepD[0].d2.i: offset -1, type 1404, size 1, index -1 +deepD[0].d2.d1[0].va: offset -1, type 8b50, size 3, index -1 +deepD[0].d2.d1[0].b: offset -1, type 8b56, size 1, index -1 +deepD[0].d2.d1[1].va: offset -1, type 8b50, size 3, index -1 +deepD[0].d2.d1[1].b: offset -1, type 8b56, size 1, index -1 +deepD[0].d2.d1[2].va: offset -1, type 8b50, size 3, index -1 +deepD[0].d2.d1[2].b: offset -1, type 8b56, size 1, index -1 +deepD[0].d2.d1[3].va: offset -1, type 8b50, size 3, index -1 +deepD[0].d2.d1[3].b: offset -1, type 8b56, size 1, index -1 +deepD[0].v3: offset -1, type 8b54, size 1, index -1 +deepD[1].iv4: offset -1, type 8b52, size 1, index -1 +deepD[1].d2.i: offset -1, type 1404, size 1, index -1 +deepD[1].d2.d1[0].va: offset -1, type 8b50, size 3, index -1 +deepD[1].d2.d1[0].b: offset -1, type 8b56, size 1, index -1 +deepD[1].d2.d1[1].va: offset -1, type 8b50, size 3, index -1 +deepD[1].d2.d1[1].b: offset -1, type 8b56, size 1, index -1 +deepD[1].d2.d1[2].va: offset -1, type 8b50, size 3, index -1 +deepD[1].d2.d1[2].b: offset -1, type 8b56, size 1, index -1 +deepD[1].d2.d1[3].va: offset -1, type 8b50, size 3, index -1 +deepD[1].d2.d1[3].b: offset -1, type 8b56, size 1, index -1 +deepD[1].v3: offset -1, type 8b54, size 1, index -1 +foo: offset 0, type 1406, size 1, index 0 +anonMember1: offset 0, type 8b51, size 1, index 0 +uf1: offset -1, type 1406, size 1, index -1 + +Uniform block reflection: +: offset -1, type ffffffff, size 512, index -1 + +Vertex attribute reflection: +attributeFloat: offset 0, type 1406, size 0, index 0 +attributeFloat2: offset 0, type 8b50, size 0, index 0 +attributeFloat3: offset 0, type 8b51, size 0, index 0 +attributeFloat4: offset 0, type 8b52, size 0, index 0 +attributeMat4: offset 0, type 8b5c, size 0, index 0 + diff --git a/Test/hlsl.reflection.vert b/Test/hlsl.reflection.vert new file mode 100644 index 00000000..21cc8109 --- /dev/null +++ b/Test/hlsl.reflection.vert @@ -0,0 +1,165 @@ + +cbuffer nameless { + float3 anonMember1; + float3x2 m23; + int scalarAfterm23; + float4 anonDeadMember2; + float4 anonMember3; + int scalarBeforeArray; + float floatArray[5]; + int scalarAfterArray; + float2x2 m22[9]; +}; + +cbuffer c_nameless { + float3 c_anonMember1; + float3x2 c_m23; + int c_scalarAfterm23; + float4 c_anonDeadMember2; + float4 c_anonMember3; +}; + +cbuffer named { + float3 deadMember1; + int scalar; + float4 member2; + float4 member3; + float2 memfloat2; + float memf1; + bool memf2; + int memf3; + float2 memfloat2a; + float2x2 m22[7]; +} ablock; + +cbuffer namelessdead { + int a; +}; + +cbuffer namedDead { + int b; +} bblock; + +struct N1 { + float a; +}; + +struct N2 { + float b; + float c; + float d; +}; + +struct N3 { + N1 n1; + N2 n2; +}; + +cbuffer nested { + N3 foo; +} nest; + +struct TS { + int a; + int dead; +}; + +uniform TS s; + +uniform float uf1; +uniform float uf2; +uniform float ufDead3; +uniform float ufDead4; + +uniform float2x2 dm22[10]; + +struct deep1 { + float2 va[3]; + bool b; +}; + +struct deep2 { + int i; + deep1 d1[4]; +}; + +struct deep3 { + float4 iv4; + deep2 d2; + int3 v3; +}; + + + + +uniform deep3 deepA[2], deepB[2], deepC[3], deepD[2]; + +const bool control = true; + +void deadFunction() +{ + float3 v3 = ablock.deadMember1; + float4 v = anonDeadMember2; + float f = ufDead4; +} + +void liveFunction2() +{ + float3 v = anonMember1; + float f = uf1; +} + +tbuffer abl { + float foo; +} arrBl; + +tbuffer abl2 { + float foo; +} arrBl2; + +void flizv(in float attributeFloat, in float2 attributeFloat2, in float3 attributeFloat3, in float4 attributeFloat4, in float4x4 attributeMat4) +{ + liveFunction2(); + + if (! control) + deadFunction(); + + float f; + int i; + if (control) { + liveFunction2(); + f = anonMember3.z; + f = s.a; + f = ablock.scalar; + f = m23[1].y + scalarAfterm23; + f = c_m23[1].y + c_scalarAfterm23; + f += scalarBeforeArray; + f += floatArray[2]; + f += floatArray[4]; + f += scalarAfterArray; + f += ablock.memfloat2.x; + f += ablock.memf1; + f += float(ablock.memf2); + f += ablock.memf3; + f += ablock.memfloat2a.y; + f += ablock.m22[i][1][0]; + f += dm22[3][0][1]; + f += m22[2][1].y; + f += nest.foo.n1.a + nest.foo.n2.b + nest.foo.n2.c + nest.foo.n2.d; + f += deepA[i].d2.d1[2].va[1].x; + f += deepB[1].d2.d1[i].va[1].x; + f += deepB[i].d2.d1[i].va[1].x; + deep3 d = deepC[1]; + deep3 da[2] = deepD; + } else + f = ufDead3; + + f += arrBl.foo + arrBl.foo; + f += arrBl2.foo; + + f += attributeFloat; + f += attributeFloat2.x; + f += attributeFloat3.x; + f += attributeFloat4.x; + f += attributeMat4[0][1]; +} diff --git a/Test/runtests b/Test/runtests index 5e777a8b..18513380 100755 --- a/Test/runtests +++ b/Test/runtests @@ -31,6 +31,8 @@ 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 -D -e flizv -l -q -C -V hlsl.reflection.vert > $TARGETDIR/hlsl.reflection.vert.out +diff -b $BASEDIR/hlsl.reflection.vert.out $TARGETDIR/hlsl.reflection.vert.out || HASERROR=1 # # multi-threaded test diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index bf8f2285..32969be1 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -2,5 +2,5 @@ // For the version, it uses the latest git tag followed by the number of commits. // For the date, it uses the current date (when then script is run). -#define GLSLANG_REVISION "Overload400-PrecQual.1501" +#define GLSLANG_REVISION "Overload400-PrecQual.1502" #define GLSLANG_DATE "19-Sep-2016" diff --git a/glslang/MachineIndependent/linkValidate.cpp b/glslang/MachineIndependent/linkValidate.cpp index afffb374..f213dd6c 100644 --- a/glslang/MachineIndependent/linkValidate.cpp +++ b/glslang/MachineIndependent/linkValidate.cpp @@ -75,8 +75,8 @@ void TIntermediate::merge(TInfoSink& infoSink, TIntermediate& unit) if (source != unit.source) error(infoSink, "can't link compilation units from different source languages"); - if (source == EShSourceHlsl && unit.entryPointName.size() > 0) { - if (entryPointName.size() > 0) + if (source == EShSourceHlsl && unit.getNumEntryPoints() > 0) { + if (getNumEntryPoints() > 0) error(infoSink, "can't handle multiple entry points per stage"); else entryPointName = unit.entryPointName; diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index 9f1cff18..9018606a 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -859,6 +859,7 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l inEntryPoint = function.getName().compare(intermediate.getEntryPointName().c_str()) == 0; if (inEntryPoint) { intermediate.setEntryPointMangledName(function.getMangledName().c_str()); + intermediate.incrementEntryPointCount(); remapEntryPointIO(function); if (entryPointOutput) { if (shouldFlatten(entryPointOutput->getType()))