diff --git a/README-spirv-remap.txt b/README-spirv-remap.txt index 8e3259f895..3e5288aac5 100644 --- a/README-spirv-remap.txt +++ b/README-spirv-remap.txt @@ -98,7 +98,7 @@ options. See REMAPPING AND OPTIMIZATION OPTIONS. On error, the function supplied to registerErrorHandler() will be invoked. This can be a standard C/C++ function, a lambda function, or a functor. The default handler simply calls exit(5); The error handler is a static -members, so need only be set up once, not once per spirvbin_t instance. +member, so need only be set up once, not once per spirvbin_t instance. Log messages are supplied to registerLogHandler(). By default, log messages are eaten silently. The log handler is also a static member. diff --git a/SPIRV/CMakeLists.txt b/SPIRV/CMakeLists.txt index 9628a82f15..48a6c468fb 100755 --- a/SPIRV/CMakeLists.txt +++ b/SPIRV/CMakeLists.txt @@ -3,21 +3,27 @@ set(SOURCES InReadableOrder.cpp Logger.cpp SpvBuilder.cpp - SPVRemapper.cpp doc.cpp disassemble.cpp) +set(SPVREMAP_SOURCES + SPVRemapper.cpp + doc.cpp) + set(HEADERS spirv.hpp GLSL.std.450.h GlslangToSpv.h Logger.h SpvBuilder.h - SPVRemapper.h spvIR.h doc.h disassemble.h) +set(SPVREMAP_HEADERS + SPVRemapper.h + doc.h) + if(ENABLE_AMD_EXTENSIONS) set(HEADERS GLSL.ext.AMD.h) @@ -26,9 +32,13 @@ endif(ENABLE_AMD_EXTENSIONS) add_library(SPIRV STATIC ${SOURCES} ${HEADERS}) set_property(TARGET SPIRV PROPERTY FOLDER glslang) +add_library(SPVRemapper STATIC ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS}) +set_property(TARGET SPVRemapper PROPERTY FOLDER glslang) + if(WIN32) source_group("Source" FILES ${SOURCES} ${HEADERS}) + source_group("Source" FILES ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS}) endif(WIN32) -install(TARGETS SPIRV +install(TARGETS SPIRV SPVRemapper ARCHIVE DESTINATION lib) diff --git a/SPIRV/SPVRemapper.h b/SPIRV/SPVRemapper.h index e24db7ced0..43ec1ae794 100755 --- a/SPIRV/SPVRemapper.h +++ b/SPIRV/SPVRemapper.h @@ -82,7 +82,7 @@ class spirvbin_t : public spirvbin_base_t public: spirvbin_t(int /*verbose = 0*/) { } - void remap(std::vector& /*spv*/, unsigned int /*opts = 0*/) + void remap(std::vector& /*spv*/, unsigned int /*opts = 0*/) { printf("Tool not compiled for C++11, which is required for SPIR-V remapping.\n"); exit(5); diff --git a/SPIRV/disassemble.cpp b/SPIRV/disassemble.cpp index a7838a1b49..b1023b9218 100644 --- a/SPIRV/disassemble.cpp +++ b/SPIRV/disassemble.cpp @@ -217,10 +217,12 @@ void SpirvStream::outputIndent() void SpirvStream::formatId(Id id, std::stringstream& idStream) { - if (id >= bound) - Kill(out, "Bad "); - if (id != 0) { + // On instructions with no IDs, this is called with "0", which does not + // have to be within ID bounds on null shaders. + if (id >= bound) + Kill(out, "Bad "); + idStream << id; if (idDescriptor[id].size() > 0) idStream << "(" << idDescriptor[id] << ")"; @@ -334,7 +336,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode, idDescriptor[resultId] = (const char*)(&stream[word]); } else { - if (idDescriptor[resultId].size() == 0) { + if (resultId != 0 && idDescriptor[resultId].size() == 0) { switch (opCode) { case OpTypeInt: idDescriptor[resultId] = "int"; diff --git a/StandAlone/CMakeLists.txt b/StandAlone/CMakeLists.txt index d69351ef3c..231ba277a7 100644 --- a/StandAlone/CMakeLists.txt +++ b/StandAlone/CMakeLists.txt @@ -24,6 +24,7 @@ set(LIBRARIES OSDependent HLSL SPIRV + SPVRemapper glslang-default-resource-limits) if(WIN32) diff --git a/Test/baseResults/remap.basic.dcefunc.frag.out b/Test/baseResults/remap.basic.dcefunc.frag.out new file mode 100644 index 0000000000..0f367c9678 --- /dev/null +++ b/Test/baseResults/remap.basic.dcefunc.frag.out @@ -0,0 +1,40 @@ +remap.basic.dcefunc.frag +Warning, version 450 is not yet complete; most version-specific features are present, but some are missing. + + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 19 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 14 16 + ExecutionMode 4 OriginUpperLeft + Source GLSL 450 + Name 4 "main" + Name 9 "dead_fn(" + Name 14 "outf4" + Name 16 "inf" + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 3 + 8: TypeFunction 7(fvec3) + 10: 6(float) Constant 0 + 11: 7(fvec3) ConstantComposite 10 10 10 + 12: TypeVector 6(float) 4 + 13: TypePointer Output 12(fvec4) + 14(outf4): 13(ptr) Variable Output + 15: TypePointer Input 6(float) + 16(inf): 15(ptr) Variable Input + 4(main): 2 Function None 3 + 5: Label + 17: 6(float) Load 16(inf) + 18: 12(fvec4) CompositeConstruct 17 17 17 17 + Store 14(outf4) 18 + Return + FunctionEnd diff --git a/Test/baseResults/remap.basic.dcevartype.frag.out b/Test/baseResults/remap.basic.dcevartype.frag.out new file mode 100644 index 0000000000..dd03946d2c --- /dev/null +++ b/Test/baseResults/remap.basic.dcevartype.frag.out @@ -0,0 +1,12 @@ +remap.basic.dcevartype.frag +ERROR: #version: ES shaders for Vulkan SPIR-V require version 310 or higher +Warning, version 310 is not yet complete; most version-specific features are present, but some are missing. +ERROR: 1 compilation errors. No code generated. + + + +Linked fragment stage: + +ERROR: Linking fragment stage: Missing entry point: Each stage requires one "void main()" entry point + +SPIR-V is not generated for failed compile or link diff --git a/Test/baseResults/remap.basic.everything.frag.out b/Test/baseResults/remap.basic.everything.frag.out new file mode 100644 index 0000000000..f6d6ed448b --- /dev/null +++ b/Test/baseResults/remap.basic.everything.frag.out @@ -0,0 +1,31 @@ +remap.basic.everything.frag +Warning, version 450 is not yet complete; most version-specific features are present, but some are missing. + + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 24969 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 5663 "main" 4539 3773 + ExecutionMode 5663 OriginUpperLeft + 8: TypeVoid + 1282: TypeFunction 8 + 13: TypeFloat 32 + 29: TypeVector 13(float) 4 + 666: TypePointer Output 29(fvec4) + 4539: 666(ptr) Variable Output + 650: TypePointer Input 13(float) + 3773: 650(ptr) Variable Input + 5663: 8 Function None 1282 + 24968: Label + 17486: 13(float) Load 3773 + 17691: 29(fvec4) CompositeConstruct 17486 17486 17486 17486 + Store 4539 17691 + Return + FunctionEnd diff --git a/Test/baseResults/remap.basic.none.frag.out b/Test/baseResults/remap.basic.none.frag.out new file mode 100644 index 0000000000..3632309a24 --- /dev/null +++ b/Test/baseResults/remap.basic.none.frag.out @@ -0,0 +1,44 @@ +remap.basic.none.frag +Warning, version 450 is not yet complete; most version-specific features are present, but some are missing. + + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 20 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 15 17 + ExecutionMode 4 OriginUpperLeft + Source GLSL 450 + Name 4 "main" + Name 9 "dead_fn(" + Name 15 "outf4" + Name 17 "inf" + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 3 + 8: TypeFunction 7(fvec3) + 11: 6(float) Constant 0 + 12: 7(fvec3) ConstantComposite 11 11 11 + 13: TypeVector 6(float) 4 + 14: TypePointer Output 13(fvec4) + 15(outf4): 14(ptr) Variable Output + 16: TypePointer Input 6(float) + 17(inf): 16(ptr) Variable Input + 4(main): 2 Function None 3 + 5: Label + 18: 6(float) Load 17(inf) + 19: 13(fvec4) CompositeConstruct 18 18 18 18 + Store 15(outf4) 19 + Return + FunctionEnd + 9(dead_fn(): 7(fvec3) Function None 8 + 10: Label + ReturnValue 12 + FunctionEnd diff --git a/Test/baseResults/remap.basic.strip.frag.out b/Test/baseResults/remap.basic.strip.frag.out new file mode 100644 index 0000000000..d34ce8ff3a --- /dev/null +++ b/Test/baseResults/remap.basic.strip.frag.out @@ -0,0 +1,39 @@ +remap.basic.strip.frag +Warning, version 450 is not yet complete; most version-specific features are present, but some are missing. + + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 20 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 15 17 + ExecutionMode 4 OriginUpperLeft + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 3 + 8: TypeFunction 7(fvec3) + 11: 6(float) Constant 0 + 12: 7(fvec3) ConstantComposite 11 11 11 + 13: TypeVector 6(float) 4 + 14: TypePointer Output 13(fvec4) + 15: 14(ptr) Variable Output + 16: TypePointer Input 6(float) + 17: 16(ptr) Variable Input + 4: 2 Function None 3 + 5: Label + 18: 6(float) Load 17 + 19: 13(fvec4) CompositeConstruct 18 18 18 18 + Store 15 19 + Return + FunctionEnd + 9: 7(fvec3) Function None 8 + 10: Label + ReturnValue 12 + FunctionEnd diff --git a/Test/baseResults/remap.hlsl.sample.basic.everything.frag.out b/Test/baseResults/remap.hlsl.sample.basic.everything.frag.out new file mode 100644 index 0000000000..2347ace506 --- /dev/null +++ b/Test/baseResults/remap.hlsl.sample.basic.everything.frag.out @@ -0,0 +1,213 @@ +remap.hlsl.sample.basic.everything.frag +WARNING: 0:4: 'immediate sampler state' : unimplemented + + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 24916 + + Capability Shader + Capability Sampled1D + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 5663 "main" + ExecutionMode 5663 OriginUpperLeft + Decorate 4727 DescriptorSet 0 + Decorate 4727 Binding 0 + Decorate 3305 DescriptorSet 0 + Decorate 3305 Binding 0 + Decorate 4743 DescriptorSet 0 + Decorate 4807 DescriptorSet 0 + Decorate 5042 DescriptorSet 0 + Decorate 5058 DescriptorSet 0 + Decorate 5122 DescriptorSet 0 + Decorate 3967 DescriptorSet 0 + Decorate 3983 DescriptorSet 0 + Decorate 4047 DescriptorSet 0 + Decorate 3789 DescriptorSet 0 + Decorate 3805 DescriptorSet 0 + Decorate 3869 DescriptorSet 0 + MemberDecorate 1032 1 BuiltIn FragDepth + 8: TypeVoid + 1282: TypeFunction 8 + 12: TypeInt 32 1 + 1335: TypeStruct 12(int) 12(int) 12(int) 12(int) 12(int) 12(int) 12(int) 12(int) 12(int) 12(int) 12(int) 12(int) + 1972: TypePointer Function 1335(struct) + 2574: 12(int) Constant 1 + 649: TypePointer Function 12(int) + 2577: 12(int) Constant 2 + 2580: 12(int) Constant 3 + 2583: 12(int) Constant 4 + 2586: 12(int) Constant 5 + 2589: 12(int) Constant 6 + 2571: 12(int) Constant 0 + 2592: 12(int) Constant 7 + 2595: 12(int) Constant 8 + 2598: 12(int) Constant 9 + 2601: 12(int) Constant 10 + 2604: 12(int) Constant 11 + 13: TypeFloat 32 + 29: TypeVector 13(float) 4 + 666: TypePointer Function 29(fvec4) + 149: TypeImage 13(float) 1D sampled format:Unknown + 786: TypePointer UniformConstant 149 + 4727: 786(ptr) Variable UniformConstant + 508: TypeSampler + 1145: TypePointer UniformConstant 508 + 3305: 1145(ptr) Variable UniformConstant + 510: TypeSampledImage 149 + 2935: 13(float) Constant 1036831949 + 26: TypeVector 12(int) 4 + 148: TypeImage 12(int) 1D sampled format:Unknown + 785: TypePointer UniformConstant 148 + 4743: 785(ptr) Variable UniformConstant + 511: TypeSampledImage 148 + 2821: 13(float) Constant 1045220557 + 11: TypeInt 32 0 + 23: TypeVector 11(int) 4 + 147: TypeImage 11(int) 1D sampled format:Unknown + 784: TypePointer UniformConstant 147 + 4807: 784(ptr) Variable UniformConstant + 512: TypeSampledImage 147 + 2151: 13(float) Constant 1050253722 + 150: TypeImage 13(float) 2D sampled format:Unknown + 787: TypePointer UniformConstant 150 + 5042: 787(ptr) Variable UniformConstant + 513: TypeSampledImage 150 + 19: TypeVector 13(float) 2 + 1825: 19(fvec2) ConstantComposite 2935 2821 + 151: TypeImage 12(int) 2D sampled format:Unknown + 788: TypePointer UniformConstant 151 + 5058: 788(ptr) Variable UniformConstant + 514: TypeSampledImage 151 + 2707: 13(float) Constant 1053609165 + 2028: 19(fvec2) ConstantComposite 2151 2707 + 152: TypeImage 11(int) 2D sampled format:Unknown + 789: TypePointer UniformConstant 152 + 5122: 789(ptr) Variable UniformConstant + 515: TypeSampledImage 152 + 252: 13(float) Constant 1056964608 + 2037: 13(float) Constant 1058642330 + 2684: 19(fvec2) ConstantComposite 252 2037 + 153: TypeImage 13(float) 3D sampled format:Unknown + 790: TypePointer UniformConstant 153 + 3967: 790(ptr) Variable UniformConstant + 516: TypeSampledImage 153 + 24: TypeVector 13(float) 3 + 1660: 24(fvec3) ConstantComposite 2935 2821 2151 + 154: TypeImage 12(int) 3D sampled format:Unknown + 791: TypePointer UniformConstant 154 + 3983: 791(ptr) Variable UniformConstant + 517: TypeSampledImage 154 + 2174: 24(fvec3) ConstantComposite 2707 252 2037 + 155: TypeImage 11(int) 3D sampled format:Unknown + 792: TypePointer UniformConstant 155 + 4047: 792(ptr) Variable UniformConstant + 518: TypeSampledImage 155 + 808: 13(float) Constant 1060320051 + 2593: 13(float) Constant 1061997773 + 1364: 13(float) Constant 1063675494 + 2476: 24(fvec3) ConstantComposite 808 2593 1364 + 156: TypeImage 13(float) Cube sampled format:Unknown + 793: TypePointer UniformConstant 156 + 3789: 793(ptr) Variable UniformConstant + 519: TypeSampledImage 156 + 157: TypeImage 12(int) Cube sampled format:Unknown + 794: TypePointer UniformConstant 157 + 3805: 794(ptr) Variable UniformConstant + 520: TypeSampledImage 157 + 158: TypeImage 11(int) Cube sampled format:Unknown + 795: TypePointer UniformConstant 158 + 3869: 795(ptr) Variable UniformConstant + 521: TypeSampledImage 158 + 1032: TypeStruct 29(fvec4) 13(float) + 1669: TypePointer Function 1032(struct) + 138: 13(float) Constant 1065353216 + 1284: 29(fvec4) ConstantComposite 138 138 138 138 + 650: TypePointer Function 13(float) + 5663: 8 Function None 1282 + 24915: Label + 5830: 1972(ptr) Variable Function + 5072: 1669(ptr) Variable Function + 22097: 649(ptr) AccessChain 5830 2574 + Store 22097 2574 + 19732: 649(ptr) AccessChain 5830 2577 + Store 19732 2574 + 19733: 649(ptr) AccessChain 5830 2580 + Store 19733 2574 + 19734: 649(ptr) AccessChain 5830 2583 + Store 19734 2574 + 19735: 649(ptr) AccessChain 5830 2586 + Store 19735 2574 + 19736: 649(ptr) AccessChain 5830 2589 + Store 19736 2574 + 19737: 649(ptr) AccessChain 5830 2571 + Store 19737 2574 + 19738: 649(ptr) AccessChain 5830 2592 + Store 19738 2574 + 19739: 649(ptr) AccessChain 5830 2595 + Store 19739 2574 + 19740: 649(ptr) AccessChain 5830 2598 + Store 19740 2574 + 19741: 649(ptr) AccessChain 5830 2601 + Store 19741 2574 + 19656: 649(ptr) AccessChain 5830 2604 + Store 19656 2574 + 14934: 149 Load 4727 + 11686: 508 Load 3305 + 11940: 510 SampledImage 14934 11686 + 7877: 29(fvec4) ImageSampleImplicitLod 11940 2935 + 15360: 148 Load 4743 + 15706: 508 Load 3305 + 11941: 511 SampledImage 15360 15706 + 7878: 26(ivec4) ImageSampleImplicitLod 11941 2821 + 15361: 147 Load 4807 + 15707: 508 Load 3305 + 11942: 512 SampledImage 15361 15707 + 7879: 23(ivec4) ImageSampleImplicitLod 11942 2151 + 15362: 150 Load 5042 + 15708: 508 Load 3305 + 11943: 513 SampledImage 15362 15708 + 7880: 29(fvec4) ImageSampleImplicitLod 11943 1825 + 15363: 151 Load 5058 + 15709: 508 Load 3305 + 11944: 514 SampledImage 15363 15709 + 7881: 26(ivec4) ImageSampleImplicitLod 11944 2028 + 15364: 152 Load 5122 + 15710: 508 Load 3305 + 11945: 515 SampledImage 15364 15710 + 7882: 23(ivec4) ImageSampleImplicitLod 11945 2684 + 15365: 153 Load 3967 + 15711: 508 Load 3305 + 11946: 516 SampledImage 15365 15711 + 7883: 29(fvec4) ImageSampleImplicitLod 11946 1660 + 15366: 154 Load 3983 + 15712: 508 Load 3305 + 11947: 517 SampledImage 15366 15712 + 7884: 26(ivec4) ImageSampleImplicitLod 11947 2174 + 15367: 155 Load 4047 + 15713: 508 Load 3305 + 11948: 518 SampledImage 15367 15713 + 7885: 23(ivec4) ImageSampleImplicitLod 11948 2476 + 15368: 156 Load 3789 + 15714: 508 Load 3305 + 11949: 519 SampledImage 15368 15714 + 7886: 29(fvec4) ImageSampleImplicitLod 11949 1660 + 15369: 157 Load 3805 + 15715: 508 Load 3305 + 11950: 520 SampledImage 15369 15715 + 7887: 26(ivec4) ImageSampleImplicitLod 11950 2174 + 15370: 158 Load 3869 + 15716: 508 Load 3305 + 12016: 521 SampledImage 15370 15716 + 7204: 23(ivec4) ImageSampleImplicitLod 12016 2476 + 20158: 666(ptr) AccessChain 5072 2571 + Store 20158 1284 + 19657: 650(ptr) AccessChain 5072 2574 + Store 19657 138 + 21536:1032(struct) Load 5072 + ReturnValue 21536 + FunctionEnd diff --git a/Test/baseResults/remap.hlsl.sample.basic.none.frag.out b/Test/baseResults/remap.hlsl.sample.basic.none.frag.out new file mode 100644 index 0000000000..3c1e9e9228 --- /dev/null +++ b/Test/baseResults/remap.hlsl.sample.basic.none.frag.out @@ -0,0 +1,293 @@ +remap.hlsl.sample.basic.none.frag +WARNING: 0:4: 'immediate sampler state' : unimplemented + + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 183 + + Capability Shader + Capability Sampled1D + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" + ExecutionMode 4 OriginUpperLeft + Name 4 "main" + Name 7 "MemberTest" + MemberName 7(MemberTest) 0 "Sample" + MemberName 7(MemberTest) 1 "CalculateLevelOfDetail" + MemberName 7(MemberTest) 2 "CalculateLevelOfDetailUnclamped" + MemberName 7(MemberTest) 3 "Gather" + MemberName 7(MemberTest) 4 "GetDimensions" + MemberName 7(MemberTest) 5 "GetSamplePosition" + MemberName 7(MemberTest) 6 "Load" + MemberName 7(MemberTest) 7 "SampleBias" + MemberName 7(MemberTest) 8 "SampleCmp" + MemberName 7(MemberTest) 9 "SampleCmpLevelZero" + MemberName 7(MemberTest) 10 "SampleGrad" + MemberName 7(MemberTest) 11 "SampleLevel" + Name 9 "mtest" + Name 38 "txval10" + Name 41 "g_tTex1df4" + Name 45 "g_sSamp" + Name 53 "txval11" + Name 56 "g_tTex1di4" + Name 66 "txval12" + Name 69 "g_tTex1du4" + Name 76 "txval20" + Name 79 "g_tTex2df4" + Name 87 "txval21" + Name 90 "g_tTex2di4" + Name 98 "txval22" + Name 101 "g_tTex2du4" + Name 110 "txval30" + Name 113 "g_tTex3df4" + Name 121 "txval31" + Name 124 "g_tTex3di4" + Name 131 "txval32" + Name 134 "g_tTex3du4" + Name 144 "txval40" + Name 147 "g_tTexcdf4" + Name 153 "txval41" + Name 156 "g_tTexcdi4" + Name 162 "txval42" + Name 165 "g_tTexcdu4" + Name 171 "PS_OUTPUT" + MemberName 171(PS_OUTPUT) 0 "Color" + MemberName 171(PS_OUTPUT) 1 "Depth" + Name 173 "psout" + Name 180 "g_sSamp2d" + Name 181 "g_sSamp2D_b" + Name 182 "g_tTex1df4a" + Decorate 41(g_tTex1df4) DescriptorSet 0 + Decorate 41(g_tTex1df4) Binding 0 + Decorate 45(g_sSamp) DescriptorSet 0 + Decorate 45(g_sSamp) Binding 0 + Decorate 56(g_tTex1di4) DescriptorSet 0 + Decorate 69(g_tTex1du4) DescriptorSet 0 + Decorate 79(g_tTex2df4) DescriptorSet 0 + Decorate 90(g_tTex2di4) DescriptorSet 0 + Decorate 101(g_tTex2du4) DescriptorSet 0 + Decorate 113(g_tTex3df4) DescriptorSet 0 + Decorate 124(g_tTex3di4) DescriptorSet 0 + Decorate 134(g_tTex3du4) DescriptorSet 0 + Decorate 147(g_tTexcdf4) DescriptorSet 0 + Decorate 156(g_tTexcdi4) DescriptorSet 0 + Decorate 165(g_tTexcdu4) DescriptorSet 0 + MemberDecorate 171(PS_OUTPUT) 1 BuiltIn FragDepth + Decorate 180(g_sSamp2d) DescriptorSet 0 + Decorate 181(g_sSamp2D_b) DescriptorSet 0 + Decorate 182(g_tTex1df4a) DescriptorSet 0 + Decorate 182(g_tTex1df4a) Binding 1 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 1 + 7(MemberTest): TypeStruct 6(int) 6(int) 6(int) 6(int) 6(int) 6(int) 6(int) 6(int) 6(int) 6(int) 6(int) 6(int) + 8: TypePointer Function 7(MemberTest) + 10: 6(int) Constant 1 + 11: TypePointer Function 6(int) + 13: 6(int) Constant 2 + 15: 6(int) Constant 3 + 17: 6(int) Constant 4 + 19: 6(int) Constant 5 + 21: 6(int) Constant 6 + 23: 6(int) Constant 0 + 25: 6(int) Constant 7 + 27: 6(int) Constant 8 + 29: 6(int) Constant 9 + 31: 6(int) Constant 10 + 33: 6(int) Constant 11 + 35: TypeFloat 32 + 36: TypeVector 35(float) 4 + 37: TypePointer Function 36(fvec4) + 39: TypeImage 35(float) 1D sampled format:Unknown + 40: TypePointer UniformConstant 39 + 41(g_tTex1df4): 40(ptr) Variable UniformConstant + 43: TypeSampler + 44: TypePointer UniformConstant 43 + 45(g_sSamp): 44(ptr) Variable UniformConstant + 47: TypeSampledImage 39 + 49: 35(float) Constant 1036831949 + 51: TypeVector 6(int) 4 + 52: TypePointer Function 51(ivec4) + 54: TypeImage 6(int) 1D sampled format:Unknown + 55: TypePointer UniformConstant 54 + 56(g_tTex1di4): 55(ptr) Variable UniformConstant + 59: TypeSampledImage 54 + 61: 35(float) Constant 1045220557 + 63: TypeInt 32 0 + 64: TypeVector 63(int) 4 + 65: TypePointer Function 64(ivec4) + 67: TypeImage 63(int) 1D sampled format:Unknown + 68: TypePointer UniformConstant 67 + 69(g_tTex1du4): 68(ptr) Variable UniformConstant + 72: TypeSampledImage 67 + 74: 35(float) Constant 1050253722 + 77: TypeImage 35(float) 2D sampled format:Unknown + 78: TypePointer UniformConstant 77 + 79(g_tTex2df4): 78(ptr) Variable UniformConstant + 82: TypeSampledImage 77 + 84: TypeVector 35(float) 2 + 85: 84(fvec2) ConstantComposite 49 61 + 88: TypeImage 6(int) 2D sampled format:Unknown + 89: TypePointer UniformConstant 88 + 90(g_tTex2di4): 89(ptr) Variable UniformConstant + 93: TypeSampledImage 88 + 95: 35(float) Constant 1053609165 + 96: 84(fvec2) ConstantComposite 74 95 + 99: TypeImage 63(int) 2D sampled format:Unknown + 100: TypePointer UniformConstant 99 + 101(g_tTex2du4): 100(ptr) Variable UniformConstant + 104: TypeSampledImage 99 + 106: 35(float) Constant 1056964608 + 107: 35(float) Constant 1058642330 + 108: 84(fvec2) ConstantComposite 106 107 + 111: TypeImage 35(float) 3D sampled format:Unknown + 112: TypePointer UniformConstant 111 + 113(g_tTex3df4): 112(ptr) Variable UniformConstant + 116: TypeSampledImage 111 + 118: TypeVector 35(float) 3 + 119: 118(fvec3) ConstantComposite 49 61 74 + 122: TypeImage 6(int) 3D sampled format:Unknown + 123: TypePointer UniformConstant 122 + 124(g_tTex3di4): 123(ptr) Variable UniformConstant + 127: TypeSampledImage 122 + 129: 118(fvec3) ConstantComposite 95 106 107 + 132: TypeImage 63(int) 3D sampled format:Unknown + 133: TypePointer UniformConstant 132 + 134(g_tTex3du4): 133(ptr) Variable UniformConstant + 137: TypeSampledImage 132 + 139: 35(float) Constant 1060320051 + 140: 35(float) Constant 1061997773 + 141: 35(float) Constant 1063675494 + 142: 118(fvec3) ConstantComposite 139 140 141 + 145: TypeImage 35(float) Cube sampled format:Unknown + 146: TypePointer UniformConstant 145 + 147(g_tTexcdf4): 146(ptr) Variable UniformConstant + 150: TypeSampledImage 145 + 154: TypeImage 6(int) Cube sampled format:Unknown + 155: TypePointer UniformConstant 154 + 156(g_tTexcdi4): 155(ptr) Variable UniformConstant + 159: TypeSampledImage 154 + 163: TypeImage 63(int) Cube sampled format:Unknown + 164: TypePointer UniformConstant 163 + 165(g_tTexcdu4): 164(ptr) Variable UniformConstant + 168: TypeSampledImage 163 + 171(PS_OUTPUT): TypeStruct 36(fvec4) 35(float) + 172: TypePointer Function 171(PS_OUTPUT) + 174: 35(float) Constant 1065353216 + 175: 36(fvec4) ConstantComposite 174 174 174 174 + 177: TypePointer Function 35(float) + 180(g_sSamp2d): 44(ptr) Variable UniformConstant +181(g_sSamp2D_b): 44(ptr) Variable UniformConstant +182(g_tTex1df4a): 40(ptr) Variable UniformConstant + 4(main): 2 Function None 3 + 5: Label + 9(mtest): 8(ptr) Variable Function + 38(txval10): 37(ptr) Variable Function + 53(txval11): 52(ptr) Variable Function + 66(txval12): 65(ptr) Variable Function + 76(txval20): 37(ptr) Variable Function + 87(txval21): 52(ptr) Variable Function + 98(txval22): 65(ptr) Variable Function + 110(txval30): 37(ptr) Variable Function + 121(txval31): 52(ptr) Variable Function + 131(txval32): 65(ptr) Variable Function + 144(txval40): 37(ptr) Variable Function + 153(txval41): 52(ptr) Variable Function + 162(txval42): 65(ptr) Variable Function + 173(psout): 172(ptr) Variable Function + 12: 11(ptr) AccessChain 9(mtest) 10 + Store 12 10 + 14: 11(ptr) AccessChain 9(mtest) 13 + Store 14 10 + 16: 11(ptr) AccessChain 9(mtest) 15 + Store 16 10 + 18: 11(ptr) AccessChain 9(mtest) 17 + Store 18 10 + 20: 11(ptr) AccessChain 9(mtest) 19 + Store 20 10 + 22: 11(ptr) AccessChain 9(mtest) 21 + Store 22 10 + 24: 11(ptr) AccessChain 9(mtest) 23 + Store 24 10 + 26: 11(ptr) AccessChain 9(mtest) 25 + Store 26 10 + 28: 11(ptr) AccessChain 9(mtest) 27 + Store 28 10 + 30: 11(ptr) AccessChain 9(mtest) 29 + Store 30 10 + 32: 11(ptr) AccessChain 9(mtest) 31 + Store 32 10 + 34: 11(ptr) AccessChain 9(mtest) 33 + Store 34 10 + 42: 39 Load 41(g_tTex1df4) + 46: 43 Load 45(g_sSamp) + 48: 47 SampledImage 42 46 + 50: 36(fvec4) ImageSampleImplicitLod 48 49 + Store 38(txval10) 50 + 57: 54 Load 56(g_tTex1di4) + 58: 43 Load 45(g_sSamp) + 60: 59 SampledImage 57 58 + 62: 51(ivec4) ImageSampleImplicitLod 60 61 + Store 53(txval11) 62 + 70: 67 Load 69(g_tTex1du4) + 71: 43 Load 45(g_sSamp) + 73: 72 SampledImage 70 71 + 75: 64(ivec4) ImageSampleImplicitLod 73 74 + Store 66(txval12) 75 + 80: 77 Load 79(g_tTex2df4) + 81: 43 Load 45(g_sSamp) + 83: 82 SampledImage 80 81 + 86: 36(fvec4) ImageSampleImplicitLod 83 85 + Store 76(txval20) 86 + 91: 88 Load 90(g_tTex2di4) + 92: 43 Load 45(g_sSamp) + 94: 93 SampledImage 91 92 + 97: 51(ivec4) ImageSampleImplicitLod 94 96 + Store 87(txval21) 97 + 102: 99 Load 101(g_tTex2du4) + 103: 43 Load 45(g_sSamp) + 105: 104 SampledImage 102 103 + 109: 64(ivec4) ImageSampleImplicitLod 105 108 + Store 98(txval22) 109 + 114: 111 Load 113(g_tTex3df4) + 115: 43 Load 45(g_sSamp) + 117: 116 SampledImage 114 115 + 120: 36(fvec4) ImageSampleImplicitLod 117 119 + Store 110(txval30) 120 + 125: 122 Load 124(g_tTex3di4) + 126: 43 Load 45(g_sSamp) + 128: 127 SampledImage 125 126 + 130: 51(ivec4) ImageSampleImplicitLod 128 129 + Store 121(txval31) 130 + 135: 132 Load 134(g_tTex3du4) + 136: 43 Load 45(g_sSamp) + 138: 137 SampledImage 135 136 + 143: 64(ivec4) ImageSampleImplicitLod 138 142 + Store 131(txval32) 143 + 148: 145 Load 147(g_tTexcdf4) + 149: 43 Load 45(g_sSamp) + 151: 150 SampledImage 148 149 + 152: 36(fvec4) ImageSampleImplicitLod 151 119 + Store 144(txval40) 152 + 157: 154 Load 156(g_tTexcdi4) + 158: 43 Load 45(g_sSamp) + 160: 159 SampledImage 157 158 + 161: 51(ivec4) ImageSampleImplicitLod 160 129 + Store 153(txval41) 161 + 166: 163 Load 165(g_tTexcdu4) + 167: 43 Load 45(g_sSamp) + 169: 168 SampledImage 166 167 + 170: 64(ivec4) ImageSampleImplicitLod 169 142 + Store 162(txval42) 170 + 176: 37(ptr) AccessChain 173(psout) 23 + Store 176 175 + 178: 177(ptr) AccessChain 173(psout) 10 + Store 178 174 + 179:171(PS_OUTPUT) Load 173(psout) + ReturnValue 179 + FunctionEnd diff --git a/Test/baseResults/remap.hlsl.sample.basic.strip.frag.out b/Test/baseResults/remap.hlsl.sample.basic.strip.frag.out new file mode 100644 index 0000000000..a0f896c397 --- /dev/null +++ b/Test/baseResults/remap.hlsl.sample.basic.strip.frag.out @@ -0,0 +1,246 @@ +remap.hlsl.sample.basic.strip.frag +WARNING: 0:4: 'immediate sampler state' : unimplemented + + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 183 + + Capability Shader + Capability Sampled1D + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" + ExecutionMode 4 OriginUpperLeft + Decorate 41 DescriptorSet 0 + Decorate 41 Binding 0 + Decorate 45 DescriptorSet 0 + Decorate 45 Binding 0 + Decorate 56 DescriptorSet 0 + Decorate 69 DescriptorSet 0 + Decorate 79 DescriptorSet 0 + Decorate 90 DescriptorSet 0 + Decorate 101 DescriptorSet 0 + Decorate 113 DescriptorSet 0 + Decorate 124 DescriptorSet 0 + Decorate 134 DescriptorSet 0 + Decorate 147 DescriptorSet 0 + Decorate 156 DescriptorSet 0 + Decorate 165 DescriptorSet 0 + MemberDecorate 171 1 BuiltIn FragDepth + Decorate 180 DescriptorSet 0 + Decorate 181 DescriptorSet 0 + Decorate 182 DescriptorSet 0 + Decorate 182 Binding 1 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 1 + 7: TypeStruct 6(int) 6(int) 6(int) 6(int) 6(int) 6(int) 6(int) 6(int) 6(int) 6(int) 6(int) 6(int) + 8: TypePointer Function 7(struct) + 10: 6(int) Constant 1 + 11: TypePointer Function 6(int) + 13: 6(int) Constant 2 + 15: 6(int) Constant 3 + 17: 6(int) Constant 4 + 19: 6(int) Constant 5 + 21: 6(int) Constant 6 + 23: 6(int) Constant 0 + 25: 6(int) Constant 7 + 27: 6(int) Constant 8 + 29: 6(int) Constant 9 + 31: 6(int) Constant 10 + 33: 6(int) Constant 11 + 35: TypeFloat 32 + 36: TypeVector 35(float) 4 + 37: TypePointer Function 36(fvec4) + 39: TypeImage 35(float) 1D sampled format:Unknown + 40: TypePointer UniformConstant 39 + 41: 40(ptr) Variable UniformConstant + 43: TypeSampler + 44: TypePointer UniformConstant 43 + 45: 44(ptr) Variable UniformConstant + 47: TypeSampledImage 39 + 49: 35(float) Constant 1036831949 + 51: TypeVector 6(int) 4 + 52: TypePointer Function 51(ivec4) + 54: TypeImage 6(int) 1D sampled format:Unknown + 55: TypePointer UniformConstant 54 + 56: 55(ptr) Variable UniformConstant + 59: TypeSampledImage 54 + 61: 35(float) Constant 1045220557 + 63: TypeInt 32 0 + 64: TypeVector 63(int) 4 + 65: TypePointer Function 64(ivec4) + 67: TypeImage 63(int) 1D sampled format:Unknown + 68: TypePointer UniformConstant 67 + 69: 68(ptr) Variable UniformConstant + 72: TypeSampledImage 67 + 74: 35(float) Constant 1050253722 + 77: TypeImage 35(float) 2D sampled format:Unknown + 78: TypePointer UniformConstant 77 + 79: 78(ptr) Variable UniformConstant + 82: TypeSampledImage 77 + 84: TypeVector 35(float) 2 + 85: 84(fvec2) ConstantComposite 49 61 + 88: TypeImage 6(int) 2D sampled format:Unknown + 89: TypePointer UniformConstant 88 + 90: 89(ptr) Variable UniformConstant + 93: TypeSampledImage 88 + 95: 35(float) Constant 1053609165 + 96: 84(fvec2) ConstantComposite 74 95 + 99: TypeImage 63(int) 2D sampled format:Unknown + 100: TypePointer UniformConstant 99 + 101: 100(ptr) Variable UniformConstant + 104: TypeSampledImage 99 + 106: 35(float) Constant 1056964608 + 107: 35(float) Constant 1058642330 + 108: 84(fvec2) ConstantComposite 106 107 + 111: TypeImage 35(float) 3D sampled format:Unknown + 112: TypePointer UniformConstant 111 + 113: 112(ptr) Variable UniformConstant + 116: TypeSampledImage 111 + 118: TypeVector 35(float) 3 + 119: 118(fvec3) ConstantComposite 49 61 74 + 122: TypeImage 6(int) 3D sampled format:Unknown + 123: TypePointer UniformConstant 122 + 124: 123(ptr) Variable UniformConstant + 127: TypeSampledImage 122 + 129: 118(fvec3) ConstantComposite 95 106 107 + 132: TypeImage 63(int) 3D sampled format:Unknown + 133: TypePointer UniformConstant 132 + 134: 133(ptr) Variable UniformConstant + 137: TypeSampledImage 132 + 139: 35(float) Constant 1060320051 + 140: 35(float) Constant 1061997773 + 141: 35(float) Constant 1063675494 + 142: 118(fvec3) ConstantComposite 139 140 141 + 145: TypeImage 35(float) Cube sampled format:Unknown + 146: TypePointer UniformConstant 145 + 147: 146(ptr) Variable UniformConstant + 150: TypeSampledImage 145 + 154: TypeImage 6(int) Cube sampled format:Unknown + 155: TypePointer UniformConstant 154 + 156: 155(ptr) Variable UniformConstant + 159: TypeSampledImage 154 + 163: TypeImage 63(int) Cube sampled format:Unknown + 164: TypePointer UniformConstant 163 + 165: 164(ptr) Variable UniformConstant + 168: TypeSampledImage 163 + 171: TypeStruct 36(fvec4) 35(float) + 172: TypePointer Function 171(struct) + 174: 35(float) Constant 1065353216 + 175: 36(fvec4) ConstantComposite 174 174 174 174 + 177: TypePointer Function 35(float) + 180: 44(ptr) Variable UniformConstant + 181: 44(ptr) Variable UniformConstant + 182: 40(ptr) Variable UniformConstant + 4: 2 Function None 3 + 5: Label + 9: 8(ptr) Variable Function + 38: 37(ptr) Variable Function + 53: 52(ptr) Variable Function + 66: 65(ptr) Variable Function + 76: 37(ptr) Variable Function + 87: 52(ptr) Variable Function + 98: 65(ptr) Variable Function + 110: 37(ptr) Variable Function + 121: 52(ptr) Variable Function + 131: 65(ptr) Variable Function + 144: 37(ptr) Variable Function + 153: 52(ptr) Variable Function + 162: 65(ptr) Variable Function + 173: 172(ptr) Variable Function + 12: 11(ptr) AccessChain 9 10 + Store 12 10 + 14: 11(ptr) AccessChain 9 13 + Store 14 10 + 16: 11(ptr) AccessChain 9 15 + Store 16 10 + 18: 11(ptr) AccessChain 9 17 + Store 18 10 + 20: 11(ptr) AccessChain 9 19 + Store 20 10 + 22: 11(ptr) AccessChain 9 21 + Store 22 10 + 24: 11(ptr) AccessChain 9 23 + Store 24 10 + 26: 11(ptr) AccessChain 9 25 + Store 26 10 + 28: 11(ptr) AccessChain 9 27 + Store 28 10 + 30: 11(ptr) AccessChain 9 29 + Store 30 10 + 32: 11(ptr) AccessChain 9 31 + Store 32 10 + 34: 11(ptr) AccessChain 9 33 + Store 34 10 + 42: 39 Load 41 + 46: 43 Load 45 + 48: 47 SampledImage 42 46 + 50: 36(fvec4) ImageSampleImplicitLod 48 49 + Store 38 50 + 57: 54 Load 56 + 58: 43 Load 45 + 60: 59 SampledImage 57 58 + 62: 51(ivec4) ImageSampleImplicitLod 60 61 + Store 53 62 + 70: 67 Load 69 + 71: 43 Load 45 + 73: 72 SampledImage 70 71 + 75: 64(ivec4) ImageSampleImplicitLod 73 74 + Store 66 75 + 80: 77 Load 79 + 81: 43 Load 45 + 83: 82 SampledImage 80 81 + 86: 36(fvec4) ImageSampleImplicitLod 83 85 + Store 76 86 + 91: 88 Load 90 + 92: 43 Load 45 + 94: 93 SampledImage 91 92 + 97: 51(ivec4) ImageSampleImplicitLod 94 96 + Store 87 97 + 102: 99 Load 101 + 103: 43 Load 45 + 105: 104 SampledImage 102 103 + 109: 64(ivec4) ImageSampleImplicitLod 105 108 + Store 98 109 + 114: 111 Load 113 + 115: 43 Load 45 + 117: 116 SampledImage 114 115 + 120: 36(fvec4) ImageSampleImplicitLod 117 119 + Store 110 120 + 125: 122 Load 124 + 126: 43 Load 45 + 128: 127 SampledImage 125 126 + 130: 51(ivec4) ImageSampleImplicitLod 128 129 + Store 121 130 + 135: 132 Load 134 + 136: 43 Load 45 + 138: 137 SampledImage 135 136 + 143: 64(ivec4) ImageSampleImplicitLod 138 142 + Store 131 143 + 148: 145 Load 147 + 149: 43 Load 45 + 151: 150 SampledImage 148 149 + 152: 36(fvec4) ImageSampleImplicitLod 151 119 + Store 144 152 + 157: 154 Load 156 + 158: 43 Load 45 + 160: 159 SampledImage 157 158 + 161: 51(ivec4) ImageSampleImplicitLod 160 129 + Store 153 161 + 166: 163 Load 165 + 167: 43 Load 45 + 169: 168 SampledImage 166 167 + 170: 64(ivec4) ImageSampleImplicitLod 169 142 + Store 162 170 + 176: 37(ptr) AccessChain 173 23 + Store 176 175 + 178: 177(ptr) AccessChain 173 10 + Store 178 174 + 179: 171(struct) Load 173 + ReturnValue 179 + FunctionEnd diff --git a/Test/baseResults/remap.hlsl.templatetypes.everything.frag.out b/Test/baseResults/remap.hlsl.templatetypes.everything.frag.out new file mode 100644 index 0000000000..a483986eac --- /dev/null +++ b/Test/baseResults/remap.hlsl.templatetypes.everything.frag.out @@ -0,0 +1,23 @@ +remap.hlsl.templatetypes.everything.frag + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 16123 + + Capability Shader + Capability Float64 + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 5663 "main" + ExecutionMode 5663 OriginUpperLeft + 8: TypeVoid + 1282: TypeFunction 8 + 13: TypeFloat 32 + 2572: 13(float) Constant 0 + 5663: 8 Function None 1282 + 16122: Label + ReturnValue 2572 + FunctionEnd diff --git a/Test/baseResults/remap.hlsl.templatetypes.none.frag.out b/Test/baseResults/remap.hlsl.templatetypes.none.frag.out new file mode 100644 index 0000000000..1878c64d73 --- /dev/null +++ b/Test/baseResults/remap.hlsl.templatetypes.none.frag.out @@ -0,0 +1,216 @@ +remap.hlsl.templatetypes.none.frag + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 144 + + Capability Shader + Capability Float64 + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" + ExecutionMode 4 OriginUpperLeft + Name 4 "main" + Name 9 "r00" + Name 15 "r01" + Name 20 "r12" + Name 24 "r13" + Name 27 "r14" + Name 30 "r15" + Name 34 "r16" + Name 38 "r20" + Name 43 "r21" + Name 48 "r22" + Name 52 "r23" + Name 57 "r24" + Name 62 "r30" + Name 66 "r31" + Name 71 "r32" + Name 75 "r33" + Name 80 "r34" + Name 85 "r40" + Name 89 "r41" + Name 92 "r42" + Name 95 "r43" + Name 100 "r44" + Name 105 "r50" + Name 122 "r51" + Name 125 "r61" + Name 131 "r62" + Name 136 "r65" + Name 141 "r66" + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypePointer Function 7(fvec4) + 10: 6(float) Constant 1065353216 + 11: 6(float) Constant 1073741824 + 12: 6(float) Constant 1077936128 + 13: 6(float) Constant 1082130432 + 14: 7(fvec4) ConstantComposite 10 11 12 13 + 16: 6(float) Constant 1084227584 + 17: 7(fvec4) ConstantComposite 11 12 13 16 + 18: TypeBool + 19: TypePointer Function 18(bool) + 21: 18(bool) ConstantFalse + 22: TypeInt 32 1 + 23: TypePointer Function 22(int) + 25: 22(int) Constant 1 + 26: TypePointer Function 6(float) + 28: TypeFloat 64 + 29: TypePointer Function 28(float) + 31: 28(float) Constant 0 1072693248 + 32: TypeInt 32 0 + 33: TypePointer Function 32(int) + 35: 32(int) Constant 1 + 36: TypeVector 18(bool) 2 + 37: TypePointer Function 36(bvec2) + 39: 18(bool) ConstantTrue + 40: 36(bvec2) ConstantComposite 21 39 + 41: TypeVector 22(int) 2 + 42: TypePointer Function 41(ivec2) + 44: 22(int) Constant 2 + 45: 41(ivec2) ConstantComposite 25 44 + 46: TypeVector 6(float) 2 + 47: TypePointer Function 46(fvec2) + 49: 46(fvec2) ConstantComposite 10 11 + 50: TypeVector 28(float) 2 + 51: TypePointer Function 50(fvec2) + 53: 28(float) Constant 0 1073741824 + 54: 50(fvec2) ConstantComposite 31 53 + 55: TypeVector 32(int) 2 + 56: TypePointer Function 55(ivec2) + 58: 32(int) Constant 2 + 59: 55(ivec2) ConstantComposite 35 58 + 60: TypeVector 18(bool) 3 + 61: TypePointer Function 60(bvec3) + 63: 60(bvec3) ConstantComposite 21 39 39 + 64: TypeVector 22(int) 3 + 65: TypePointer Function 64(ivec3) + 67: 22(int) Constant 3 + 68: 64(ivec3) ConstantComposite 25 44 67 + 69: TypeVector 6(float) 3 + 70: TypePointer Function 69(fvec3) + 72: 69(fvec3) ConstantComposite 10 11 12 + 73: TypeVector 28(float) 3 + 74: TypePointer Function 73(fvec3) + 76: 28(float) Constant 0 1074266112 + 77: 73(fvec3) ConstantComposite 31 53 76 + 78: TypeVector 32(int) 3 + 79: TypePointer Function 78(ivec3) + 81: 32(int) Constant 3 + 82: 78(ivec3) ConstantComposite 35 58 81 + 83: TypeVector 18(bool) 4 + 84: TypePointer Function 83(bvec4) + 86: 83(bvec4) ConstantComposite 21 39 39 21 + 87: TypeVector 22(int) 4 + 88: TypePointer Function 87(ivec4) + 90: 22(int) Constant 4 + 91: 87(ivec4) ConstantComposite 25 44 67 90 + 93: TypeVector 28(float) 4 + 94: TypePointer Function 93(fvec4) + 96: 28(float) Constant 0 1074790400 + 97: 93(fvec4) ConstantComposite 31 53 76 96 + 98: TypeVector 32(int) 4 + 99: TypePointer Function 98(ivec4) + 101: 32(int) Constant 4 + 102: 98(ivec4) ConstantComposite 35 58 81 101 + 103: TypeMatrix 7(fvec4) 4 + 104: TypePointer Function 103 + 106: 6(float) Constant 0 + 107: 7(fvec4) ConstantComposite 106 10 11 12 + 108: 6(float) Constant 1086324736 + 109: 6(float) Constant 1088421888 + 110: 7(fvec4) ConstantComposite 13 16 108 109 + 111: 6(float) Constant 1090519040 + 112: 6(float) Constant 1091567616 + 113: 6(float) Constant 1092616192 + 114: 6(float) Constant 1093664768 + 115: 7(fvec4) ConstantComposite 111 112 113 114 + 116: 6(float) Constant 1094713344 + 117: 6(float) Constant 1095761920 + 118: 6(float) Constant 1096810496 + 119: 6(float) Constant 1097859072 + 120: 7(fvec4) ConstantComposite 116 117 118 119 + 121: 103 ConstantComposite 107 110 115 120 + 123: TypeMatrix 46(fvec2) 3 + 124: TypePointer Function 123 + 126: 46(fvec2) ConstantComposite 12 13 + 127: 46(fvec2) ConstantComposite 16 108 + 128: 123 ConstantComposite 49 126 127 + 129: TypeMatrix 69(fvec3) 2 + 130: TypePointer Function 129 + 132: 69(fvec3) ConstantComposite 13 16 108 + 133: 129 ConstantComposite 72 132 + 134: TypeMatrix 7(fvec4) 2 + 135: TypePointer Function 134 + 137: 7(fvec4) ConstantComposite 16 108 109 111 + 138: 134 ConstantComposite 14 137 + 139: TypeMatrix 7(fvec4) 3 + 140: TypePointer Function 139 + 142: 7(fvec4) ConstantComposite 112 113 114 116 + 143: 139 ConstantComposite 14 137 142 + 4(main): 2 Function None 3 + 5: Label + 9(r00): 8(ptr) Variable Function + 15(r01): 8(ptr) Variable Function + 20(r12): 19(ptr) Variable Function + 24(r13): 23(ptr) Variable Function + 27(r14): 26(ptr) Variable Function + 30(r15): 29(ptr) Variable Function + 34(r16): 33(ptr) Variable Function + 38(r20): 37(ptr) Variable Function + 43(r21): 42(ptr) Variable Function + 48(r22): 47(ptr) Variable Function + 52(r23): 51(ptr) Variable Function + 57(r24): 56(ptr) Variable Function + 62(r30): 61(ptr) Variable Function + 66(r31): 65(ptr) Variable Function + 71(r32): 70(ptr) Variable Function + 75(r33): 74(ptr) Variable Function + 80(r34): 79(ptr) Variable Function + 85(r40): 84(ptr) Variable Function + 89(r41): 88(ptr) Variable Function + 92(r42): 8(ptr) Variable Function + 95(r43): 94(ptr) Variable Function + 100(r44): 99(ptr) Variable Function + 105(r50): 104(ptr) Variable Function + 122(r51): 104(ptr) Variable Function + 125(r61): 124(ptr) Variable Function + 131(r62): 130(ptr) Variable Function + 136(r65): 135(ptr) Variable Function + 141(r66): 140(ptr) Variable Function + Store 9(r00) 14 + Store 15(r01) 17 + Store 20(r12) 21 + Store 24(r13) 25 + Store 27(r14) 10 + Store 30(r15) 31 + Store 34(r16) 35 + Store 38(r20) 40 + Store 43(r21) 45 + Store 48(r22) 49 + Store 52(r23) 54 + Store 57(r24) 59 + Store 62(r30) 63 + Store 66(r31) 68 + Store 71(r32) 72 + Store 75(r33) 77 + Store 80(r34) 82 + Store 85(r40) 86 + Store 89(r41) 91 + Store 92(r42) 14 + Store 95(r43) 97 + Store 100(r44) 102 + Store 105(r50) 121 + Store 122(r51) 121 + Store 125(r61) 128 + Store 131(r62) 133 + Store 136(r65) 138 + Store 141(r66) 143 + ReturnValue 106 + FunctionEnd diff --git a/Test/baseResults/remap.if.everything.frag.out b/Test/baseResults/remap.if.everything.frag.out new file mode 100644 index 0000000000..9f98c18438 --- /dev/null +++ b/Test/baseResults/remap.if.everything.frag.out @@ -0,0 +1,47 @@ +remap.if.everything.frag +Warning, version 450 is not yet complete; most version-specific features are present, but some are missing. + + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 22855 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 5663 "main" 3773 4539 + ExecutionMode 5663 OriginUpperLeft + 8: TypeVoid + 1282: TypeFunction 8 + 13: TypeFloat 32 + 650: TypePointer Input 13(float) + 3773: 650(ptr) Variable Input + 24: 13(float) Constant 1073741824 + 9: TypeBool + 29: TypeVector 13(float) 4 + 666: TypePointer Output 29(fvec4) + 4539: 666(ptr) Variable Output + 947: 13(float) Constant 3204448256 + 5663: 8 Function None 1282 + 7911: Label + 21734: 13(float) Load 3773 + 13508: 9(bool) FOrdGreaterThan 21734 24 + SelectionMerge 19578 None + BranchConditional 13508 13182 10142 + 13182: Label + 9496: 13(float) Load 3773 + 17615: 29(fvec4) CompositeConstruct 9496 9496 9496 9496 + Store 4539 17615 + Branch 19578 + 10142: Label + 22854: 13(float) Load 3773 + 9982: 13(float) FAdd 22854 947 + 12421: 29(fvec4) CompositeConstruct 9982 9982 9982 9982 + Store 4539 12421 + Branch 19578 + 19578: Label + Return + FunctionEnd diff --git a/Test/baseResults/remap.if.none.frag.out b/Test/baseResults/remap.if.none.frag.out new file mode 100644 index 0000000000..f3113a36a7 --- /dev/null +++ b/Test/baseResults/remap.if.none.frag.out @@ -0,0 +1,51 @@ +remap.if.none.frag +Warning, version 450 is not yet complete; most version-specific features are present, but some are missing. + + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 25 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 8 17 + ExecutionMode 4 OriginUpperLeft + Source GLSL 450 + Name 4 "main" + Name 8 "inf" + Name 17 "outf4" + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypePointer Input 6(float) + 8(inf): 7(ptr) Variable Input + 10: 6(float) Constant 1073741824 + 11: TypeBool + 15: TypeVector 6(float) 4 + 16: TypePointer Output 15(fvec4) + 17(outf4): 16(ptr) Variable Output + 22: 6(float) Constant 3204448256 + 4(main): 2 Function None 3 + 5: Label + 9: 6(float) Load 8(inf) + 12: 11(bool) FOrdGreaterThan 9 10 + SelectionMerge 14 None + BranchConditional 12 13 20 + 13: Label + 18: 6(float) Load 8(inf) + 19: 15(fvec4) CompositeConstruct 18 18 18 18 + Store 17(outf4) 19 + Branch 14 + 20: Label + 21: 6(float) Load 8(inf) + 23: 6(float) FAdd 21 22 + 24: 15(fvec4) CompositeConstruct 23 23 23 23 + Store 17(outf4) 24 + Branch 14 + 14: Label + Return + FunctionEnd diff --git a/Test/baseResults/remap.literal64.everything.spv.out b/Test/baseResults/remap.literal64.everything.spv.out new file mode 100644 index 0000000000..7a4f37ba1e --- /dev/null +++ b/Test/baseResults/remap.literal64.everything.spv.out @@ -0,0 +1,7 @@ +remap.literal64.everything.spv +// Module Version 10100 +// Generated by (magic number): 70000 +// Id's are bound by 0 + + Capability Shader + MemoryModel Logical GLSL450 diff --git a/Test/baseResults/remap.literal64.none.spv.out b/Test/baseResults/remap.literal64.none.spv.out new file mode 100644 index 0000000000..792b13a612 --- /dev/null +++ b/Test/baseResults/remap.literal64.none.spv.out @@ -0,0 +1,25 @@ +remap.literal64.none.spv +// Module Version 10100 +// Generated by (magic number): 70000 +// Id's are bound by 10 + + Capability Shader + MemoryModel Logical GLSL450 + 1: TypeVoid + 2: TypeInt 64 1 + 3: TypeFunction 1 + 4: 2(int) Constant 0 0 + 5: 1 Function None 3 + 6: Label + SelectionMerge 7 None + Switch 4 7 + case 0: 0 + case 8: 1 + case 0: 9 + 8: Label + Branch 7 + 9: Label + Branch 7 + 7: Label + Return + FunctionEnd diff --git a/Test/baseResults/remap.similar_1a.everything.frag.out b/Test/baseResults/remap.similar_1a.everything.frag.out new file mode 100644 index 0000000000..09589f57f3 --- /dev/null +++ b/Test/baseResults/remap.similar_1a.everything.frag.out @@ -0,0 +1,121 @@ +remap.similar_1a.everything.frag +Warning, version 450 is not yet complete; most version-specific features are present, but some are missing. + + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 24916 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 5663 "main" 4201 4539 3773 + ExecutionMode 5663 OriginUpperLeft + Decorate 4201 Flat + 8: TypeVoid + 1282: TypeFunction 8 + 12: TypeInt 32 1 + 649: TypePointer Function 12(int) + 13: TypeFloat 32 + 204: TypeFunction 13(float) 649(ptr) + 650: TypePointer Function 13(float) + 2572: 13(float) Constant 0 + 2571: 12(int) Constant 0 + 9: TypeBool + 252: 13(float) Constant 1056964608 + 2574: 12(int) Constant 1 + 2577: 12(int) Constant 2 + 26: TypeVector 12(int) 4 + 663: TypePointer Input 26(ivec4) + 4201: 663(ptr) Variable Input + 11: TypeInt 32 0 + 2573: 11(int) Constant 1 + 651: TypePointer Input 12(int) + 2576: 11(int) Constant 2 + 2570: 11(int) Constant 0 + 29: TypeVector 13(float) 4 + 666: TypePointer Output 29(fvec4) + 4539: 666(ptr) Variable Output + 652: TypePointer Input 13(float) + 3773: 652(ptr) Variable Input + 5663: 8 Function None 1282 + 24915: Label + 18415: 649(ptr) Variable Function + 5786: 649(ptr) Variable Function + 8366: 13(float) Load 3773 + 8654: 12(int) ConvertFToS 8366 + Store 18415 8654 + 17256: 13(float) FunctionCall 3782 18415 + 14512: 13(float) Load 3773 + 7041: 12(int) ConvertFToS 14512 + Store 5786 7041 + 23993: 13(float) FunctionCall 3836 5786 + 9180: 13(float) FAdd 17256 23993 + 15728: 29(fvec4) CompositeConstruct 9180 9180 9180 9180 + Store 4539 15728 + Return + FunctionEnd + 3782: 13(float) Function None 204 + 6931: 649(ptr) FunctionParameter + 12220: Label + 4292: 650(ptr) Variable Function + 4298: 649(ptr) Variable Function + Store 4292 2572 + Store 4298 2571 + Branch 14924 + 14924: Label + LoopMerge 8882 6488 None + Branch 11857 + 11857: Label + 13755: 12(int) Load 4298 + 22731: 12(int) Load 6931 + 20007: 9(bool) SLessThan 13755 22731 + BranchConditional 20007 24750 8882 + 24750: Label + 22912: 13(float) Load 4292 + 19471: 13(float) FAdd 22912 252 + Store 4292 19471 + Branch 6488 + 6488: Label + 19050: 12(int) Load 4298 + 8593: 12(int) IAdd 19050 2574 + Store 4298 8593 + Branch 14924 + 8882: Label + 11601: 13(float) Load 4292 + ReturnValue 11601 + FunctionEnd + 3836: 13(float) Function None 204 + 4408: 649(ptr) FunctionParameter + 12143: Label + 22102: 649(ptr) Variable Function + 24151: 12(int) Load 4408 + 13868: 9(bool) SGreaterThan 24151 2577 + SelectionMerge 22309 None + BranchConditional 13868 9492 17416 + 9492: Label + 15624: 12(int) Load 4408 + Store 22102 15624 + 17278: 13(float) FunctionCall 3782 22102 + ReturnValue 17278 + 17416: Label + 19506: 12(int) Load 4408 + 22773: 12(int) IMul 19506 2577 + 13472: 651(ptr) AccessChain 4201 2573 + 15280: 12(int) Load 13472 + 18079: 651(ptr) AccessChain 4201 2576 + 15199: 12(int) Load 18079 + 9343: 12(int) IMul 15280 15199 + 11462: 12(int) IAdd 22773 9343 + 11885: 651(ptr) AccessChain 4201 2570 + 21176: 12(int) Load 11885 + 10505: 12(int) IAdd 11462 21176 + 14626: 13(float) ConvertSToF 10505 + ReturnValue 14626 + 22309: Label + 6429: 13(float) Undef + ReturnValue 6429 + FunctionEnd diff --git a/Test/baseResults/remap.similar_1a.none.frag.out b/Test/baseResults/remap.similar_1a.none.frag.out new file mode 100644 index 0000000000..1748451227 --- /dev/null +++ b/Test/baseResults/remap.similar_1a.none.frag.out @@ -0,0 +1,135 @@ +remap.similar_1a.none.frag +Warning, version 450 is not yet complete; most version-specific features are present, but some are missing. + + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 82 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 50 69 71 + ExecutionMode 4 OriginUpperLeft + Source GLSL 450 + Name 4 "main" + Name 11 "Test1(i1;" + Name 10 "bound" + Name 14 "Test2(i1;" + Name 13 "bound" + Name 17 "r" + Name 19 "x" + Name 42 "param" + Name 50 "ini4" + Name 69 "outf4" + Name 71 "inf" + Name 74 "param" + Name 78 "param" + Decorate 50(ini4) Flat + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 1 + 7: TypePointer Function 6(int) + 8: TypeFloat 32 + 9: TypeFunction 8(float) 7(ptr) + 16: TypePointer Function 8(float) + 18: 8(float) Constant 0 + 20: 6(int) Constant 0 + 28: TypeBool + 30: 8(float) Constant 1056964608 + 34: 6(int) Constant 1 + 38: 6(int) Constant 2 + 48: TypeVector 6(int) 4 + 49: TypePointer Input 48(ivec4) + 50(ini4): 49(ptr) Variable Input + 51: TypeInt 32 0 + 52: 51(int) Constant 1 + 53: TypePointer Input 6(int) + 56: 51(int) Constant 2 + 61: 51(int) Constant 0 + 67: TypeVector 8(float) 4 + 68: TypePointer Output 67(fvec4) + 69(outf4): 68(ptr) Variable Output + 70: TypePointer Input 8(float) + 71(inf): 70(ptr) Variable Input + 4(main): 2 Function None 3 + 5: Label + 74(param): 7(ptr) Variable Function + 78(param): 7(ptr) Variable Function + 72: 8(float) Load 71(inf) + 73: 6(int) ConvertFToS 72 + Store 74(param) 73 + 75: 8(float) FunctionCall 11(Test1(i1;) 74(param) + 76: 8(float) Load 71(inf) + 77: 6(int) ConvertFToS 76 + Store 78(param) 77 + 79: 8(float) FunctionCall 14(Test2(i1;) 78(param) + 80: 8(float) FAdd 75 79 + 81: 67(fvec4) CompositeConstruct 80 80 80 80 + Store 69(outf4) 81 + Return + FunctionEnd + 11(Test1(i1;): 8(float) Function None 9 + 10(bound): 7(ptr) FunctionParameter + 12: Label + 17(r): 16(ptr) Variable Function + 19(x): 7(ptr) Variable Function + Store 17(r) 18 + Store 19(x) 20 + Branch 21 + 21: Label + LoopMerge 23 24 None + Branch 25 + 25: Label + 26: 6(int) Load 19(x) + 27: 6(int) Load 10(bound) + 29: 28(bool) SLessThan 26 27 + BranchConditional 29 22 23 + 22: Label + 31: 8(float) Load 17(r) + 32: 8(float) FAdd 31 30 + Store 17(r) 32 + Branch 24 + 24: Label + 33: 6(int) Load 19(x) + 35: 6(int) IAdd 33 34 + Store 19(x) 35 + Branch 21 + 23: Label + 36: 8(float) Load 17(r) + ReturnValue 36 + FunctionEnd + 14(Test2(i1;): 8(float) Function None 9 + 13(bound): 7(ptr) FunctionParameter + 15: Label + 42(param): 7(ptr) Variable Function + 37: 6(int) Load 13(bound) + 39: 28(bool) SGreaterThan 37 38 + SelectionMerge 41 None + BranchConditional 39 40 45 + 40: Label + 43: 6(int) Load 13(bound) + Store 42(param) 43 + 44: 8(float) FunctionCall 11(Test1(i1;) 42(param) + ReturnValue 44 + 45: Label + 46: 6(int) Load 13(bound) + 47: 6(int) IMul 46 38 + 54: 53(ptr) AccessChain 50(ini4) 52 + 55: 6(int) Load 54 + 57: 53(ptr) AccessChain 50(ini4) 56 + 58: 6(int) Load 57 + 59: 6(int) IMul 55 58 + 60: 6(int) IAdd 47 59 + 62: 53(ptr) AccessChain 50(ini4) 61 + 63: 6(int) Load 62 + 64: 6(int) IAdd 60 63 + 65: 8(float) ConvertSToF 64 + ReturnValue 65 + 41: Label + 66: 8(float) Undef + ReturnValue 66 + FunctionEnd diff --git a/Test/baseResults/remap.similar_1b.everything.frag.out b/Test/baseResults/remap.similar_1b.everything.frag.out new file mode 100644 index 0000000000..d05be11729 --- /dev/null +++ b/Test/baseResults/remap.similar_1b.everything.frag.out @@ -0,0 +1,127 @@ +remap.similar_1b.everything.frag +Warning, version 450 is not yet complete; most version-specific features are present, but some are missing. + + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 24916 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 5663 "main" 4201 4539 3773 + ExecutionMode 5663 OriginUpperLeft + Decorate 4201 Flat + 8: TypeVoid + 1282: TypeFunction 8 + 12: TypeInt 32 1 + 649: TypePointer Function 12(int) + 13: TypeFloat 32 + 204: TypeFunction 13(float) 649(ptr) + 650: TypePointer Function 13(float) + 2572: 13(float) Constant 0 + 2571: 12(int) Constant 0 + 9: TypeBool + 252: 13(float) Constant 1056964608 + 2574: 12(int) Constant 1 + 2821: 13(float) Constant 1045220557 + 2577: 12(int) Constant 2 + 2583: 12(int) Constant 4 + 26: TypeVector 12(int) 4 + 663: TypePointer Input 26(ivec4) + 4201: 663(ptr) Variable Input + 11: TypeInt 32 0 + 2573: 11(int) Constant 1 + 651: TypePointer Input 12(int) + 2576: 11(int) Constant 2 + 2570: 11(int) Constant 0 + 29: TypeVector 13(float) 4 + 666: TypePointer Output 29(fvec4) + 4539: 666(ptr) Variable Output + 652: TypePointer Input 13(float) + 3773: 652(ptr) Variable Input + 5663: 8 Function None 1282 + 24915: Label + 18415: 649(ptr) Variable Function + 5786: 649(ptr) Variable Function + 8366: 13(float) Load 3773 + 8654: 12(int) ConvertFToS 8366 + Store 18415 8654 + 17256: 13(float) FunctionCall 3782 18415 + 14512: 13(float) Load 3773 + 7041: 12(int) ConvertFToS 14512 + Store 5786 7041 + 23993: 13(float) FunctionCall 3836 5786 + 9180: 13(float) FAdd 17256 23993 + 15728: 29(fvec4) CompositeConstruct 9180 9180 9180 9180 + Store 4539 15728 + Return + FunctionEnd + 3782: 13(float) Function None 204 + 6931: 649(ptr) FunctionParameter + 12220: Label + 4292: 650(ptr) Variable Function + 4298: 649(ptr) Variable Function + Store 4292 2572 + Store 4298 2571 + Branch 14924 + 14924: Label + LoopMerge 6507 6488 None + Branch 11857 + 11857: Label + 13755: 12(int) Load 4298 + 22731: 12(int) Load 6931 + 20007: 9(bool) SLessThan 13755 22731 + BranchConditional 20007 24750 6507 + 24750: Label + 22912: 13(float) Load 4292 + 19471: 13(float) FAdd 22912 252 + Store 4292 19471 + Branch 6488 + 6488: Label + 19050: 12(int) Load 4298 + 8593: 12(int) IAdd 19050 2574 + Store 4298 8593 + Branch 14924 + 6507: Label + 18877: 13(float) Load 4292 + 15899: 13(float) FAdd 18877 2821 + Store 4292 15899 + 20342: 13(float) Load 4292 + ReturnValue 20342 + FunctionEnd + 3836: 13(float) Function None 204 + 4408: 649(ptr) FunctionParameter + 12143: Label + 22102: 649(ptr) Variable Function + 24151: 12(int) Load 4408 + 13868: 9(bool) SGreaterThan 24151 2577 + SelectionMerge 22309 None + BranchConditional 13868 10822 17416 + 10822: Label + 22680: 12(int) Load 4408 + 23216: 12(int) IMul 22680 2577 + Store 22102 23216 + 7042: 13(float) FunctionCall 3782 22102 + ReturnValue 7042 + 17416: Label + 19506: 12(int) Load 4408 + 22773: 12(int) IMul 19506 2583 + 13472: 651(ptr) AccessChain 4201 2573 + 15280: 12(int) Load 13472 + 18079: 651(ptr) AccessChain 4201 2576 + 15199: 12(int) Load 18079 + 9343: 12(int) IMul 15280 15199 + 11462: 12(int) IAdd 22773 9343 + 11885: 651(ptr) AccessChain 4201 2570 + 21176: 12(int) Load 11885 + 10505: 12(int) IAdd 11462 21176 + 14626: 13(float) ConvertSToF 10505 + ReturnValue 14626 + 22309: Label + 6429: 13(float) Undef + ReturnValue 6429 + FunctionEnd diff --git a/Test/baseResults/remap.similar_1b.none.frag.out b/Test/baseResults/remap.similar_1b.none.frag.out new file mode 100644 index 0000000000..f9bf0847b0 --- /dev/null +++ b/Test/baseResults/remap.similar_1b.none.frag.out @@ -0,0 +1,141 @@ +remap.similar_1b.none.frag +Warning, version 450 is not yet complete; most version-specific features are present, but some are missing. + + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 87 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 55 74 76 + ExecutionMode 4 OriginUpperLeft + Source GLSL 450 + Name 4 "main" + Name 11 "Test1(i1;" + Name 10 "bound" + Name 14 "Test2(i1;" + Name 13 "bound" + Name 17 "r" + Name 19 "x" + Name 47 "param" + Name 55 "ini4" + Name 74 "outf4" + Name 76 "inf" + Name 79 "param" + Name 83 "param" + Decorate 55(ini4) Flat + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 1 + 7: TypePointer Function 6(int) + 8: TypeFloat 32 + 9: TypeFunction 8(float) 7(ptr) + 16: TypePointer Function 8(float) + 18: 8(float) Constant 0 + 20: 6(int) Constant 0 + 28: TypeBool + 30: 8(float) Constant 1056964608 + 34: 6(int) Constant 1 + 36: 8(float) Constant 1045220557 + 41: 6(int) Constant 2 + 51: 6(int) Constant 4 + 53: TypeVector 6(int) 4 + 54: TypePointer Input 53(ivec4) + 55(ini4): 54(ptr) Variable Input + 56: TypeInt 32 0 + 57: 56(int) Constant 1 + 58: TypePointer Input 6(int) + 61: 56(int) Constant 2 + 66: 56(int) Constant 0 + 72: TypeVector 8(float) 4 + 73: TypePointer Output 72(fvec4) + 74(outf4): 73(ptr) Variable Output + 75: TypePointer Input 8(float) + 76(inf): 75(ptr) Variable Input + 4(main): 2 Function None 3 + 5: Label + 79(param): 7(ptr) Variable Function + 83(param): 7(ptr) Variable Function + 77: 8(float) Load 76(inf) + 78: 6(int) ConvertFToS 77 + Store 79(param) 78 + 80: 8(float) FunctionCall 11(Test1(i1;) 79(param) + 81: 8(float) Load 76(inf) + 82: 6(int) ConvertFToS 81 + Store 83(param) 82 + 84: 8(float) FunctionCall 14(Test2(i1;) 83(param) + 85: 8(float) FAdd 80 84 + 86: 72(fvec4) CompositeConstruct 85 85 85 85 + Store 74(outf4) 86 + Return + FunctionEnd + 11(Test1(i1;): 8(float) Function None 9 + 10(bound): 7(ptr) FunctionParameter + 12: Label + 17(r): 16(ptr) Variable Function + 19(x): 7(ptr) Variable Function + Store 17(r) 18 + Store 19(x) 20 + Branch 21 + 21: Label + LoopMerge 23 24 None + Branch 25 + 25: Label + 26: 6(int) Load 19(x) + 27: 6(int) Load 10(bound) + 29: 28(bool) SLessThan 26 27 + BranchConditional 29 22 23 + 22: Label + 31: 8(float) Load 17(r) + 32: 8(float) FAdd 31 30 + Store 17(r) 32 + Branch 24 + 24: Label + 33: 6(int) Load 19(x) + 35: 6(int) IAdd 33 34 + Store 19(x) 35 + Branch 21 + 23: Label + 37: 8(float) Load 17(r) + 38: 8(float) FAdd 37 36 + Store 17(r) 38 + 39: 8(float) Load 17(r) + ReturnValue 39 + FunctionEnd + 14(Test2(i1;): 8(float) Function None 9 + 13(bound): 7(ptr) FunctionParameter + 15: Label + 47(param): 7(ptr) Variable Function + 40: 6(int) Load 13(bound) + 42: 28(bool) SGreaterThan 40 41 + SelectionMerge 44 None + BranchConditional 42 43 49 + 43: Label + 45: 6(int) Load 13(bound) + 46: 6(int) IMul 45 41 + Store 47(param) 46 + 48: 8(float) FunctionCall 11(Test1(i1;) 47(param) + ReturnValue 48 + 49: Label + 50: 6(int) Load 13(bound) + 52: 6(int) IMul 50 51 + 59: 58(ptr) AccessChain 55(ini4) 57 + 60: 6(int) Load 59 + 62: 58(ptr) AccessChain 55(ini4) 61 + 63: 6(int) Load 62 + 64: 6(int) IMul 60 63 + 65: 6(int) IAdd 52 64 + 67: 58(ptr) AccessChain 55(ini4) 66 + 68: 6(int) Load 67 + 69: 6(int) IAdd 65 68 + 70: 8(float) ConvertSToF 69 + ReturnValue 70 + 44: Label + 71: 8(float) Undef + ReturnValue 71 + FunctionEnd diff --git a/Test/baseResults/remap.switch.everything.frag.out b/Test/baseResults/remap.switch.everything.frag.out new file mode 100644 index 0000000000..a1d9b0d921 --- /dev/null +++ b/Test/baseResults/remap.switch.everything.frag.out @@ -0,0 +1,81 @@ +remap.switch.everything.frag +Warning, version 450 is not yet complete; most version-specific features are present, but some are missing. +WARNING: 0:5: '' : all default precisions are highp; use precision statements to quiet warning, e.g.: + "precision mediump int; precision highp float;" + + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 23990 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 5663 "main" 3719 3994 + ExecutionMode 5663 OriginUpperLeft + Decorate 3719 Location 0 + Decorate 3994 RelaxedPrecision + Decorate 3994 Location 0 + Decorate 12421 RelaxedPrecision + Decorate 12422 RelaxedPrecision + Decorate 12423 RelaxedPrecision + 8: TypeVoid + 1282: TypeFunction 8 + 13: TypeFloat 32 + 29: TypeVector 13(float) 4 + 666: TypePointer Input 29(fvec4) + 3719: 666(ptr) Variable Input + 11: TypeInt 32 0 + 2579: 11(int) Constant 3 + 650: TypePointer Input 13(float) + 12: TypeInt 32 1 + 667: TypePointer Output 29(fvec4) + 3994: 667(ptr) Variable Output + 2570: 11(int) Constant 0 + 2572: 13(float) Constant 0 + 2573: 11(int) Constant 1 + 138: 13(float) Constant 1065353216 + 2576: 11(int) Constant 2 + 24: 13(float) Constant 1073741824 + 833: 13(float) Constant 3212836864 + 1284: 29(fvec4) ConstantComposite 833 833 833 833 + 5663: 8 Function None 1282 + 23915: Label + 7984: 650(ptr) AccessChain 3719 2579 + 11376: 13(float) Load 7984 + 16859: 12(int) ConvertFToS 11376 + SelectionMerge 19578 None + Switch 16859 15971 + case 0: 8158 + case 1: 8159 + case 2: 8160 + 15971: Label + Store 3994 1284 + Branch 19578 + 8158: Label + 21848: 650(ptr) AccessChain 3719 2570 + 23987: 13(float) Load 21848 + 19989: 13(float) FAdd 23987 2572 + 12421: 29(fvec4) CompositeConstruct 19989 19989 19989 19989 + Store 3994 12421 + Branch 19578 + 8159: Label + 21849: 650(ptr) AccessChain 3719 2573 + 23988: 13(float) Load 21849 + 19990: 13(float) FAdd 23988 138 + 12422: 29(fvec4) CompositeConstruct 19990 19990 19990 19990 + Store 3994 12422 + Branch 19578 + 8160: Label + 21850: 650(ptr) AccessChain 3719 2576 + 23989: 13(float) Load 21850 + 19991: 13(float) FAdd 23989 24 + 12423: 29(fvec4) CompositeConstruct 19991 19991 19991 19991 + Store 3994 12423 + Branch 19578 + 19578: Label + Return + FunctionEnd diff --git a/Test/baseResults/remap.switch.none.frag.out b/Test/baseResults/remap.switch.none.frag.out new file mode 100644 index 0000000000..7fc8f04b1e --- /dev/null +++ b/Test/baseResults/remap.switch.none.frag.out @@ -0,0 +1,85 @@ +remap.switch.none.frag +Warning, version 450 is not yet complete; most version-specific features are present, but some are missing. +WARNING: 0:5: '' : all default precisions are highp; use precision statements to quiet warning, e.g.: + "precision mediump int; precision highp float;" + + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 44 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 9 23 + ExecutionMode 4 OriginUpperLeft + Source GLSL 450 + Name 4 "main" + Name 9 "in0" + Name 23 "FragColor" + Decorate 9(in0) Location 0 + Decorate 23(FragColor) RelaxedPrecision + Decorate 23(FragColor) Location 0 + Decorate 29 RelaxedPrecision + Decorate 35 RelaxedPrecision + Decorate 41 RelaxedPrecision + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypePointer Input 7(fvec4) + 9(in0): 8(ptr) Variable Input + 10: TypeInt 32 0 + 11: 10(int) Constant 3 + 12: TypePointer Input 6(float) + 15: TypeInt 32 1 + 22: TypePointer Output 7(fvec4) + 23(FragColor): 22(ptr) Variable Output + 24: 10(int) Constant 0 + 27: 6(float) Constant 0 + 30: 10(int) Constant 1 + 33: 6(float) Constant 1065353216 + 36: 10(int) Constant 2 + 39: 6(float) Constant 1073741824 + 42: 6(float) Constant 3212836864 + 43: 7(fvec4) ConstantComposite 42 42 42 42 + 4(main): 2 Function None 3 + 5: Label + 13: 12(ptr) AccessChain 9(in0) 11 + 14: 6(float) Load 13 + 16: 15(int) ConvertFToS 14 + SelectionMerge 21 None + Switch 16 20 + case 0: 17 + case 1: 18 + case 2: 19 + 20: Label + Store 23(FragColor) 43 + Branch 21 + 17: Label + 25: 12(ptr) AccessChain 9(in0) 24 + 26: 6(float) Load 25 + 28: 6(float) FAdd 26 27 + 29: 7(fvec4) CompositeConstruct 28 28 28 28 + Store 23(FragColor) 29 + Branch 21 + 18: Label + 31: 12(ptr) AccessChain 9(in0) 30 + 32: 6(float) Load 31 + 34: 6(float) FAdd 32 33 + 35: 7(fvec4) CompositeConstruct 34 34 34 34 + Store 23(FragColor) 35 + Branch 21 + 19: Label + 37: 12(ptr) AccessChain 9(in0) 36 + 38: 6(float) Load 37 + 40: 6(float) FAdd 38 39 + 41: 7(fvec4) CompositeConstruct 40 40 40 40 + Store 23(FragColor) 41 + Branch 21 + 21: Label + Return + FunctionEnd diff --git a/Test/baseResults/remap.uniformarray.everything.frag.out b/Test/baseResults/remap.uniformarray.everything.frag.out new file mode 100644 index 0000000000..18defecbc4 --- /dev/null +++ b/Test/baseResults/remap.uniformarray.everything.frag.out @@ -0,0 +1,67 @@ +remap.uniformarray.everything.frag + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 25030 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 5663 "main" 3608 4957 4339 5139 + ExecutionMode 5663 OriginUpperLeft + 8: TypeVoid + 1282: TypeFunction 8 + 13: TypeFloat 32 + 29: TypeVector 13(float) 4 + 666: TypePointer Function 29(fvec4) + 11: TypeInt 32 0 + 2588: 11(int) Constant 6 + 740: TypeArray 29(fvec4) 2588 + 1377: TypePointer Input 740 + 3608: 1377(ptr) Variable Input + 12: TypeInt 32 1 + 2574: 12(int) Constant 1 + 667: TypePointer Input 29(fvec4) + 24: TypeVector 13(float) 3 + 661: TypePointer Input 24(fvec3) + 4957: 661(ptr) Variable Input + 2618: 11(int) Constant 16 + 669: TypeArray 13(float) 2618 + 1306: TypePointer Input 669 + 4339: 1306(ptr) Variable Input + 2607: 12(int) Constant 12 + 650: TypePointer Input 13(float) + 2579: 11(int) Constant 3 + 651: TypePointer Function 13(float) + 668: TypePointer Output 29(fvec4) + 5139: 668(ptr) Variable Output + 5663: 8 Function None 1282 + 25029: Label + 4902: 666(ptr) Variable Function + 10645: 667(ptr) AccessChain 3608 2574 + 8181: 29(fvec4) Load 10645 + 21370: 667(ptr) AccessChain 3608 2574 + 11355: 29(fvec4) Load 21370 + 23084: 29(fvec4) FAdd 8181 11355 + Store 4902 23084 + 21218: 24(fvec3) Load 4957 + 13695: 29(fvec4) Load 4902 + 23883: 24(fvec3) VectorShuffle 13695 13695 0 1 2 + 15591: 24(fvec3) FAdd 23883 21218 + 17086: 29(fvec4) Load 4902 + 7051: 29(fvec4) VectorShuffle 17086 15591 4 5 6 3 + Store 4902 7051 + 18282: 650(ptr) AccessChain 4339 2607 + 7372: 13(float) Load 18282 + 21371: 651(ptr) AccessChain 4902 2579 + 11412: 13(float) Load 21371 + 22584: 13(float) FAdd 11412 7372 + 17318: 651(ptr) AccessChain 4902 2579 + Store 17318 22584 + 17934: 29(fvec4) Load 4902 + Store 5139 17934 + Return + FunctionEnd diff --git a/Test/baseResults/remap.uniformarray.none.frag.out b/Test/baseResults/remap.uniformarray.none.frag.out new file mode 100644 index 0000000000..ff2489e366 --- /dev/null +++ b/Test/baseResults/remap.uniformarray.none.frag.out @@ -0,0 +1,80 @@ +remap.uniformarray.none.frag + +Linked fragment stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 53 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 14 25 35 47 + ExecutionMode 4 OriginUpperLeft + Source GLSL 140 + Name 4 "main" + Name 9 "texColor" + Name 14 "color" + Name 25 "inColor" + Name 35 "alpha" + Name 47 "gl_FragColor" + Name 52 "texSampler2D" + Decorate 52(texSampler2D) DescriptorSet 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypePointer Function 7(fvec4) + 10: TypeInt 32 0 + 11: 10(int) Constant 6 + 12: TypeArray 7(fvec4) 11 + 13: TypePointer Input 12 + 14(color): 13(ptr) Variable Input + 15: TypeInt 32 1 + 16: 15(int) Constant 1 + 17: TypePointer Input 7(fvec4) + 23: TypeVector 6(float) 3 + 24: TypePointer Input 23(fvec3) + 25(inColor): 24(ptr) Variable Input + 32: 10(int) Constant 16 + 33: TypeArray 6(float) 32 + 34: TypePointer Input 33 + 35(alpha): 34(ptr) Variable Input + 36: 15(int) Constant 12 + 37: TypePointer Input 6(float) + 40: 10(int) Constant 3 + 41: TypePointer Function 6(float) + 46: TypePointer Output 7(fvec4) +47(gl_FragColor): 46(ptr) Variable Output + 49: TypeImage 6(float) 2D sampled format:Unknown + 50: TypeSampledImage 49 + 51: TypePointer UniformConstant 50 +52(texSampler2D): 51(ptr) Variable UniformConstant + 4(main): 2 Function None 3 + 5: Label + 9(texColor): 8(ptr) Variable Function + 18: 17(ptr) AccessChain 14(color) 16 + 19: 7(fvec4) Load 18 + 20: 17(ptr) AccessChain 14(color) 16 + 21: 7(fvec4) Load 20 + 22: 7(fvec4) FAdd 19 21 + Store 9(texColor) 22 + 26: 23(fvec3) Load 25(inColor) + 27: 7(fvec4) Load 9(texColor) + 28: 23(fvec3) VectorShuffle 27 27 0 1 2 + 29: 23(fvec3) FAdd 28 26 + 30: 7(fvec4) Load 9(texColor) + 31: 7(fvec4) VectorShuffle 30 29 4 5 6 3 + Store 9(texColor) 31 + 38: 37(ptr) AccessChain 35(alpha) 36 + 39: 6(float) Load 38 + 42: 41(ptr) AccessChain 9(texColor) 40 + 43: 6(float) Load 42 + 44: 6(float) FAdd 43 39 + 45: 41(ptr) AccessChain 9(texColor) 40 + Store 45 44 + 48: 7(fvec4) Load 9(texColor) + Store 47(gl_FragColor) 48 + Return + FunctionEnd diff --git a/Test/remap.basic.dcefunc.frag b/Test/remap.basic.dcefunc.frag new file mode 100644 index 0000000000..714120ab85 --- /dev/null +++ b/Test/remap.basic.dcefunc.frag @@ -0,0 +1,11 @@ +#version 450 + +in float inf; +out vec4 outf4; + +vec3 dead_fn() { return vec3(0); } + +void main() +{ + outf4 = vec4(inf); +} diff --git a/Test/remap.basic.everything.frag b/Test/remap.basic.everything.frag new file mode 100644 index 0000000000..714120ab85 --- /dev/null +++ b/Test/remap.basic.everything.frag @@ -0,0 +1,11 @@ +#version 450 + +in float inf; +out vec4 outf4; + +vec3 dead_fn() { return vec3(0); } + +void main() +{ + outf4 = vec4(inf); +} diff --git a/Test/remap.basic.none.frag b/Test/remap.basic.none.frag new file mode 100644 index 0000000000..714120ab85 --- /dev/null +++ b/Test/remap.basic.none.frag @@ -0,0 +1,11 @@ +#version 450 + +in float inf; +out vec4 outf4; + +vec3 dead_fn() { return vec3(0); } + +void main() +{ + outf4 = vec4(inf); +} diff --git a/Test/remap.basic.strip.frag b/Test/remap.basic.strip.frag new file mode 100644 index 0000000000..714120ab85 --- /dev/null +++ b/Test/remap.basic.strip.frag @@ -0,0 +1,11 @@ +#version 450 + +in float inf; +out vec4 outf4; + +vec3 dead_fn() { return vec3(0); } + +void main() +{ + outf4 = vec4(inf); +} diff --git a/Test/remap.hlsl.sample.basic.everything.frag b/Test/remap.hlsl.sample.basic.everything.frag new file mode 100644 index 0000000000..03e83ef9bc --- /dev/null +++ b/Test/remap.hlsl.sample.basic.everything.frag @@ -0,0 +1,90 @@ +SamplerState g_sSamp : register(s0); +uniform sampler2D g_sSamp2d +{ + AddressU = MIRROR; + AddressV = WRAP; + MinLOD = 0; + MaxLOD = 10; + MaxAnisotropy = 2; + MipLodBias = 0.2; +}, g_sSamp2D_b; + +Texture1D g_tTex1df4a : register(t1); + +uniform Texture1D g_tTex1df4 : register(t0); +Texture1D g_tTex1di4; +Texture1D g_tTex1du4; + +Texture2D g_tTex2df4; +Texture2D g_tTex2di4; +Texture2D g_tTex2du4; + +Texture3D g_tTex3df4; +Texture3D g_tTex3di4; +Texture3D g_tTex3du4; + +TextureCube g_tTexcdf4; +TextureCube g_tTexcdi4; +TextureCube g_tTexcdu4; + +struct MemberTest +{ + int Sample; // in HLSL, method names are valid struct members. + int CalculateLevelOfDetail; // ... + int CalculateLevelOfDetailUnclamped; // ... + int Gather; // ... + int GetDimensions; // ... + int GetSamplePosition; // ... + int Load; // ... + int SampleBias; // ... + int SampleCmp; // ... + int SampleCmpLevelZero; // ... + int SampleGrad; // ... + int SampleLevel; // ... +}; + +struct PS_OUTPUT +{ + float4 Color : SV_Target0; + float Depth : SV_Depth; +}; + +PS_OUTPUT main() +{ + PS_OUTPUT psout; + + MemberTest mtest; + mtest.CalculateLevelOfDetail = 1; // in HLSL, method names are valid struct members. + mtest.CalculateLevelOfDetailUnclamped = 1; // ... + mtest.Gather = 1; // ... + mtest.GetDimensions = 1; // ... + mtest.GetSamplePosition = 1; // ... + mtest.Load = 1; // ... + mtest.Sample = 1; // ... + mtest.SampleBias = 1; // ... + mtest.SampleCmp = 1; // ... + mtest.SampleCmpLevelZero = 1; // ... + mtest.SampleGrad = 1; // ... + mtest.SampleLevel = 1; // ... + + float4 txval10 = g_tTex1df4 . Sample(g_sSamp, 0.1); + int4 txval11 = g_tTex1di4 . Sample(g_sSamp, 0.2); + uint4 txval12 = g_tTex1du4 . Sample(g_sSamp, 0.3); + + float4 txval20 = g_tTex2df4 . Sample(g_sSamp, float2(0.1, 0.2)); + int4 txval21 = g_tTex2di4 . Sample(g_sSamp, float2(0.3, 0.4)); + uint4 txval22 = g_tTex2du4 . Sample(g_sSamp, float2(0.5, 0.6)); + + float4 txval30 = g_tTex3df4 . Sample(g_sSamp, float3(0.1, 0.2, 0.3)); + int4 txval31 = g_tTex3di4 . Sample(g_sSamp, float3(0.4, 0.5, 0.6)); + uint4 txval32 = g_tTex3du4 . Sample(g_sSamp, float3(0.7, 0.8, 0.9)); + + float4 txval40 = g_tTexcdf4 . Sample(g_sSamp, float3(0.1, 0.2, 0.3)); + int4 txval41 = g_tTexcdi4 . Sample(g_sSamp, float3(0.4, 0.5, 0.6)); + uint4 txval42 = g_tTexcdu4 . Sample(g_sSamp, float3(0.7, 0.8, 0.9)); + + psout.Color = 1.0; + psout.Depth = 1.0; + + return psout; +} diff --git a/Test/remap.hlsl.sample.basic.none.frag b/Test/remap.hlsl.sample.basic.none.frag new file mode 100644 index 0000000000..03e83ef9bc --- /dev/null +++ b/Test/remap.hlsl.sample.basic.none.frag @@ -0,0 +1,90 @@ +SamplerState g_sSamp : register(s0); +uniform sampler2D g_sSamp2d +{ + AddressU = MIRROR; + AddressV = WRAP; + MinLOD = 0; + MaxLOD = 10; + MaxAnisotropy = 2; + MipLodBias = 0.2; +}, g_sSamp2D_b; + +Texture1D g_tTex1df4a : register(t1); + +uniform Texture1D g_tTex1df4 : register(t0); +Texture1D g_tTex1di4; +Texture1D g_tTex1du4; + +Texture2D g_tTex2df4; +Texture2D g_tTex2di4; +Texture2D g_tTex2du4; + +Texture3D g_tTex3df4; +Texture3D g_tTex3di4; +Texture3D g_tTex3du4; + +TextureCube g_tTexcdf4; +TextureCube g_tTexcdi4; +TextureCube g_tTexcdu4; + +struct MemberTest +{ + int Sample; // in HLSL, method names are valid struct members. + int CalculateLevelOfDetail; // ... + int CalculateLevelOfDetailUnclamped; // ... + int Gather; // ... + int GetDimensions; // ... + int GetSamplePosition; // ... + int Load; // ... + int SampleBias; // ... + int SampleCmp; // ... + int SampleCmpLevelZero; // ... + int SampleGrad; // ... + int SampleLevel; // ... +}; + +struct PS_OUTPUT +{ + float4 Color : SV_Target0; + float Depth : SV_Depth; +}; + +PS_OUTPUT main() +{ + PS_OUTPUT psout; + + MemberTest mtest; + mtest.CalculateLevelOfDetail = 1; // in HLSL, method names are valid struct members. + mtest.CalculateLevelOfDetailUnclamped = 1; // ... + mtest.Gather = 1; // ... + mtest.GetDimensions = 1; // ... + mtest.GetSamplePosition = 1; // ... + mtest.Load = 1; // ... + mtest.Sample = 1; // ... + mtest.SampleBias = 1; // ... + mtest.SampleCmp = 1; // ... + mtest.SampleCmpLevelZero = 1; // ... + mtest.SampleGrad = 1; // ... + mtest.SampleLevel = 1; // ... + + float4 txval10 = g_tTex1df4 . Sample(g_sSamp, 0.1); + int4 txval11 = g_tTex1di4 . Sample(g_sSamp, 0.2); + uint4 txval12 = g_tTex1du4 . Sample(g_sSamp, 0.3); + + float4 txval20 = g_tTex2df4 . Sample(g_sSamp, float2(0.1, 0.2)); + int4 txval21 = g_tTex2di4 . Sample(g_sSamp, float2(0.3, 0.4)); + uint4 txval22 = g_tTex2du4 . Sample(g_sSamp, float2(0.5, 0.6)); + + float4 txval30 = g_tTex3df4 . Sample(g_sSamp, float3(0.1, 0.2, 0.3)); + int4 txval31 = g_tTex3di4 . Sample(g_sSamp, float3(0.4, 0.5, 0.6)); + uint4 txval32 = g_tTex3du4 . Sample(g_sSamp, float3(0.7, 0.8, 0.9)); + + float4 txval40 = g_tTexcdf4 . Sample(g_sSamp, float3(0.1, 0.2, 0.3)); + int4 txval41 = g_tTexcdi4 . Sample(g_sSamp, float3(0.4, 0.5, 0.6)); + uint4 txval42 = g_tTexcdu4 . Sample(g_sSamp, float3(0.7, 0.8, 0.9)); + + psout.Color = 1.0; + psout.Depth = 1.0; + + return psout; +} diff --git a/Test/remap.hlsl.sample.basic.strip.frag b/Test/remap.hlsl.sample.basic.strip.frag new file mode 100644 index 0000000000..03e83ef9bc --- /dev/null +++ b/Test/remap.hlsl.sample.basic.strip.frag @@ -0,0 +1,90 @@ +SamplerState g_sSamp : register(s0); +uniform sampler2D g_sSamp2d +{ + AddressU = MIRROR; + AddressV = WRAP; + MinLOD = 0; + MaxLOD = 10; + MaxAnisotropy = 2; + MipLodBias = 0.2; +}, g_sSamp2D_b; + +Texture1D g_tTex1df4a : register(t1); + +uniform Texture1D g_tTex1df4 : register(t0); +Texture1D g_tTex1di4; +Texture1D g_tTex1du4; + +Texture2D g_tTex2df4; +Texture2D g_tTex2di4; +Texture2D g_tTex2du4; + +Texture3D g_tTex3df4; +Texture3D g_tTex3di4; +Texture3D g_tTex3du4; + +TextureCube g_tTexcdf4; +TextureCube g_tTexcdi4; +TextureCube g_tTexcdu4; + +struct MemberTest +{ + int Sample; // in HLSL, method names are valid struct members. + int CalculateLevelOfDetail; // ... + int CalculateLevelOfDetailUnclamped; // ... + int Gather; // ... + int GetDimensions; // ... + int GetSamplePosition; // ... + int Load; // ... + int SampleBias; // ... + int SampleCmp; // ... + int SampleCmpLevelZero; // ... + int SampleGrad; // ... + int SampleLevel; // ... +}; + +struct PS_OUTPUT +{ + float4 Color : SV_Target0; + float Depth : SV_Depth; +}; + +PS_OUTPUT main() +{ + PS_OUTPUT psout; + + MemberTest mtest; + mtest.CalculateLevelOfDetail = 1; // in HLSL, method names are valid struct members. + mtest.CalculateLevelOfDetailUnclamped = 1; // ... + mtest.Gather = 1; // ... + mtest.GetDimensions = 1; // ... + mtest.GetSamplePosition = 1; // ... + mtest.Load = 1; // ... + mtest.Sample = 1; // ... + mtest.SampleBias = 1; // ... + mtest.SampleCmp = 1; // ... + mtest.SampleCmpLevelZero = 1; // ... + mtest.SampleGrad = 1; // ... + mtest.SampleLevel = 1; // ... + + float4 txval10 = g_tTex1df4 . Sample(g_sSamp, 0.1); + int4 txval11 = g_tTex1di4 . Sample(g_sSamp, 0.2); + uint4 txval12 = g_tTex1du4 . Sample(g_sSamp, 0.3); + + float4 txval20 = g_tTex2df4 . Sample(g_sSamp, float2(0.1, 0.2)); + int4 txval21 = g_tTex2di4 . Sample(g_sSamp, float2(0.3, 0.4)); + uint4 txval22 = g_tTex2du4 . Sample(g_sSamp, float2(0.5, 0.6)); + + float4 txval30 = g_tTex3df4 . Sample(g_sSamp, float3(0.1, 0.2, 0.3)); + int4 txval31 = g_tTex3di4 . Sample(g_sSamp, float3(0.4, 0.5, 0.6)); + uint4 txval32 = g_tTex3du4 . Sample(g_sSamp, float3(0.7, 0.8, 0.9)); + + float4 txval40 = g_tTexcdf4 . Sample(g_sSamp, float3(0.1, 0.2, 0.3)); + int4 txval41 = g_tTexcdi4 . Sample(g_sSamp, float3(0.4, 0.5, 0.6)); + uint4 txval42 = g_tTexcdu4 . Sample(g_sSamp, float3(0.7, 0.8, 0.9)); + + psout.Color = 1.0; + psout.Depth = 1.0; + + return psout; +} diff --git a/Test/remap.hlsl.templatetypes.everything.frag b/Test/remap.hlsl.templatetypes.everything.frag new file mode 100644 index 0000000000..bacd6f56d9 --- /dev/null +++ b/Test/remap.hlsl.templatetypes.everything.frag @@ -0,0 +1,47 @@ + +float4 main(float4 input) : COLOR0 +{ + vector r00 = float4(1,2,3,4); // vector means float4 + float4 r01 = vector(2,3,4,5); // vector means float4 + + vector r12 = bool1(false); + vector r13 = int1(1); + vector r14 = float1(1); + vector r15 = double1(1); + vector r16 = uint1(1); + + vector r20 = bool2(false, true); + vector r21 = int2(1,2); + vector r22 = float2(1,2); + vector r23 = double2(1,2); + vector r24 = uint2(1,2); + + vector r30 = bool3(false, true, true); + vector r31 = int3(1,2,3); + vector r32 = float3(1,2,3); + vector r33 = double3(1,2,3); + vector r34 = uint3(1,2,3); + + vector r40 = bool4(false, true, true, false); + vector r41 = int4(1,2,3,4); + vector r42 = float4(1,2,3,4); + vector r43 = double4(1,2,3,4); + vector r44 = uint4(1,2,3,4); + + matrix r50 = float4x4(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); // matrix means float4x4 + float4x4 r51 = matrix(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); // matrix means float4x4 + + // matrix r60 = bool2x3(false, true, false, true, false, true); // TODO: + matrix r61 = float2x3(1,2,3,4,5,6); + matrix r62 = float3x2(1,2,3,4,5,6); + // matrix r63 = float4x1(1,2,3,4); // TODO: + // matrix r64 = float1x4(1,2,3,4); // TODO: + matrix r65 = float4x2(1,2,3,4,5,6,7,8); + matrix r66 = float4x3(1,2,3,4,5,6,7,8,9,10,11,12); + + // TODO: bool mats + // TODO: int mats + + return 0.0; +} + diff --git a/Test/remap.hlsl.templatetypes.none.frag b/Test/remap.hlsl.templatetypes.none.frag new file mode 100644 index 0000000000..bacd6f56d9 --- /dev/null +++ b/Test/remap.hlsl.templatetypes.none.frag @@ -0,0 +1,47 @@ + +float4 main(float4 input) : COLOR0 +{ + vector r00 = float4(1,2,3,4); // vector means float4 + float4 r01 = vector(2,3,4,5); // vector means float4 + + vector r12 = bool1(false); + vector r13 = int1(1); + vector r14 = float1(1); + vector r15 = double1(1); + vector r16 = uint1(1); + + vector r20 = bool2(false, true); + vector r21 = int2(1,2); + vector r22 = float2(1,2); + vector r23 = double2(1,2); + vector r24 = uint2(1,2); + + vector r30 = bool3(false, true, true); + vector r31 = int3(1,2,3); + vector r32 = float3(1,2,3); + vector r33 = double3(1,2,3); + vector r34 = uint3(1,2,3); + + vector r40 = bool4(false, true, true, false); + vector r41 = int4(1,2,3,4); + vector r42 = float4(1,2,3,4); + vector r43 = double4(1,2,3,4); + vector r44 = uint4(1,2,3,4); + + matrix r50 = float4x4(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); // matrix means float4x4 + float4x4 r51 = matrix(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); // matrix means float4x4 + + // matrix r60 = bool2x3(false, true, false, true, false, true); // TODO: + matrix r61 = float2x3(1,2,3,4,5,6); + matrix r62 = float3x2(1,2,3,4,5,6); + // matrix r63 = float4x1(1,2,3,4); // TODO: + // matrix r64 = float1x4(1,2,3,4); // TODO: + matrix r65 = float4x2(1,2,3,4,5,6,7,8); + matrix r66 = float4x3(1,2,3,4,5,6,7,8,9,10,11,12); + + // TODO: bool mats + // TODO: int mats + + return 0.0; +} + diff --git a/Test/remap.if.everything.frag b/Test/remap.if.everything.frag new file mode 100644 index 0000000000..3fedfc437a --- /dev/null +++ b/Test/remap.if.everything.frag @@ -0,0 +1,12 @@ +#version 450 + +in float inf; +out vec4 outf4; + +void main() +{ + if (inf > 2.0) + outf4 = vec4(inf); + else + outf4 = vec4(inf + -.5); +} diff --git a/Test/remap.if.none.frag b/Test/remap.if.none.frag new file mode 100644 index 0000000000..3fedfc437a --- /dev/null +++ b/Test/remap.if.none.frag @@ -0,0 +1,12 @@ +#version 450 + +in float inf; +out vec4 outf4; + +void main() +{ + if (inf > 2.0) + outf4 = vec4(inf); + else + outf4 = vec4(inf + -.5); +} diff --git a/Test/remap.literal64.everything.spv b/Test/remap.literal64.everything.spv new file mode 100644 index 0000000000..88103c4948 Binary files /dev/null and b/Test/remap.literal64.everything.spv differ diff --git a/Test/remap.literal64.none.spv b/Test/remap.literal64.none.spv new file mode 100644 index 0000000000..88103c4948 Binary files /dev/null and b/Test/remap.literal64.none.spv differ diff --git a/Test/remap.similar_1a.everything.frag b/Test/remap.similar_1a.everything.frag new file mode 100644 index 0000000000..6eddbc51a9 --- /dev/null +++ b/Test/remap.similar_1a.everything.frag @@ -0,0 +1,29 @@ +#version 450 + +in float inf; +in flat ivec4 ini4; +out vec4 outf4; + +float Test1(int bound) +{ + float r = 0; + for (int x=0; x 2) + return Test1(bound); + else + return float(bound * 2 + + ini4.y * ini4.z + + ini4.x); +} + +void main() +{ + outf4 = vec4(Test1(int(inf)) + + Test2(int(inf))); +} diff --git a/Test/remap.similar_1a.none.frag b/Test/remap.similar_1a.none.frag new file mode 100644 index 0000000000..6eddbc51a9 --- /dev/null +++ b/Test/remap.similar_1a.none.frag @@ -0,0 +1,29 @@ +#version 450 + +in float inf; +in flat ivec4 ini4; +out vec4 outf4; + +float Test1(int bound) +{ + float r = 0; + for (int x=0; x 2) + return Test1(bound); + else + return float(bound * 2 + + ini4.y * ini4.z + + ini4.x); +} + +void main() +{ + outf4 = vec4(Test1(int(inf)) + + Test2(int(inf))); +} diff --git a/Test/remap.similar_1b.everything.frag b/Test/remap.similar_1b.everything.frag new file mode 100644 index 0000000000..460094515c --- /dev/null +++ b/Test/remap.similar_1b.everything.frag @@ -0,0 +1,30 @@ +#version 450 + +out vec4 outf4; +in flat ivec4 ini4; +in float inf; + +float Test1(int bound) +{ + float r = 0; + for (int x=0; x 2) { + return Test1(bound * 2); + } else + return float(bound * 4 + + ini4.y * ini4.z + + ini4.x); +} + +void main() +{ + outf4 = vec4(Test1(int(inf)) + + Test2(int(inf))); +} diff --git a/Test/remap.similar_1b.none.frag b/Test/remap.similar_1b.none.frag new file mode 100644 index 0000000000..460094515c --- /dev/null +++ b/Test/remap.similar_1b.none.frag @@ -0,0 +1,30 @@ +#version 450 + +out vec4 outf4; +in flat ivec4 ini4; +in float inf; + +float Test1(int bound) +{ + float r = 0; + for (int x=0; x 2) { + return Test1(bound * 2); + } else + return float(bound * 4 + + ini4.y * ini4.z + + ini4.x); +} + +void main() +{ + outf4 = vec4(Test1(int(inf)) + + Test2(int(inf))); +} diff --git a/Test/remap.switch.everything.frag b/Test/remap.switch.everything.frag new file mode 100644 index 0000000000..140c0792b0 --- /dev/null +++ b/Test/remap.switch.everything.frag @@ -0,0 +1,16 @@ +#version 450 + +precision highp float; + +layout(location = 0) out mediump vec4 FragColor; +layout(location = 0) in vec4 in0; + +void main() +{ + switch(int(in0.w)) { + case 0: FragColor = vec4(in0.x + 0); break; + case 1: FragColor = vec4(in0.y + 1); break; + case 2: FragColor = vec4(in0.z + 2); break; + default: FragColor = vec4(-1); + } +} diff --git a/Test/remap.switch.none.frag b/Test/remap.switch.none.frag new file mode 100644 index 0000000000..140c0792b0 --- /dev/null +++ b/Test/remap.switch.none.frag @@ -0,0 +1,16 @@ +#version 450 + +precision highp float; + +layout(location = 0) out mediump vec4 FragColor; +layout(location = 0) in vec4 in0; + +void main() +{ + switch(int(in0.w)) { + case 0: FragColor = vec4(in0.x + 0); break; + case 1: FragColor = vec4(in0.y + 1); break; + case 2: FragColor = vec4(in0.z + 2); break; + default: FragColor = vec4(-1); + } +} diff --git a/Test/remap.uniformarray.everything.frag b/Test/remap.uniformarray.everything.frag new file mode 100644 index 0000000000..4f642e6e97 --- /dev/null +++ b/Test/remap.uniformarray.everything.frag @@ -0,0 +1,17 @@ +#version 140 + +uniform sampler2D texSampler2D; +in vec3 inColor; +in vec4 color[6]; +in float alpha[16]; + +void main() +{ + vec4 texColor = color[1] + color[1]; + + texColor.xyz += inColor; + + texColor.a += alpha[12]; + + gl_FragColor = texColor; +} diff --git a/Test/remap.uniformarray.none.frag b/Test/remap.uniformarray.none.frag new file mode 100644 index 0000000000..4f642e6e97 --- /dev/null +++ b/Test/remap.uniformarray.none.frag @@ -0,0 +1,17 @@ +#version 140 + +uniform sampler2D texSampler2D; +in vec3 inColor; +in vec4 color[6]; +in float alpha[16]; + +void main() +{ + vec4 texColor = color[1] + color[1]; + + texColor.xyz += inColor; + + texColor.a += alpha[12]; + + gl_FragColor = texColor; +} diff --git a/gtests/CMakeLists.txt b/gtests/CMakeLists.txt index 4aafd11f31..2b3018360a 100644 --- a/gtests/CMakeLists.txt +++ b/gtests/CMakeLists.txt @@ -37,4 +37,37 @@ if (TARGET gmock) glslang OSDependent OGLCompiler HLSL glslang SPIRV glslang-default-resource-limits gmock) add_test(NAME glslang-gtests COMMAND glslangtests) + + # -- Remapper tests + set(REMAPPER_TEST_SOURCES + # Framework related source files + ${CMAKE_CURRENT_SOURCE_DIR}/Initializer.h + ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Settings.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Settings.h + ${CMAKE_CURRENT_SOURCE_DIR}/TestFixture.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/TestFixture.h + + # Test related source files + ${CMAKE_CURRENT_SOURCE_DIR}/Remap.FromFile.cpp + ) + + add_executable(remappertests ${REMAPPER_TEST_SOURCES}) + set_property(TARGET remappertests PROPERTY FOLDER tests) + glslang_set_link_args(remappertests) + install(TARGETS remappertests + RUNTIME DESTINATION bin) + + target_compile_definitions(remappertests + PRIVATE GLSLANG_TEST_DIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}/../Test") + target_include_directories(remappertests PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR} + ${gmock_SOURCE_DIR}/include + ${gtest_SOURCE_DIR}/include) + target_link_libraries(remappertests PRIVATE + SPVRemapper + glslang OSDependent OGLCompiler HLSL glslang + SPIRV glslang-default-resource-limits gmock) + add_test(NAME remapper-gtests COMMAND remappertests) endif() diff --git a/gtests/Remap.FromFile.cpp b/gtests/Remap.FromFile.cpp new file mode 100644 index 0000000000..cd246ea2f6 --- /dev/null +++ b/gtests/Remap.FromFile.cpp @@ -0,0 +1,117 @@ +// +// Copyright (C) 2016 LunarG, Inc. +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// +// Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +#include + +#include "TestFixture.h" + +namespace glslangtest { +namespace { + +struct RemapTestArgs { + const char* fileName; + const char* entryPoint; + Source sourceLanguage; + unsigned int remapOpts; +}; + +// We are using FileNameEntryPointPair objects as parameters for instantiating +// the template, so the global FileNameAsCustomTestSuffix() won't work since +// it assumes std::string as parameters. Thus, an overriding one here. +std::string FileNameAsCustomTestSuffix( + const ::testing::TestParamInfo& info) { + std::string name = info.param.fileName; + // A valid test case suffix cannot have '.' and '-' inside. + std::replace(name.begin(), name.end(), '.', '_'); + std::replace(name.begin(), name.end(), '-', '_'); + return name; +} + +using RemapTest = GlslangTest<::testing::TestWithParam>; + +// Remapping SPIR-V modules. +TEST_P(RemapTest, FromFile) +{ + if (GetSuffix(GetParam().fileName) == "spv") { + loadFileRemapAndCheck(GLSLANG_TEST_DIRECTORY, GetParam().fileName, + GetParam().sourceLanguage, + Semantics::Vulkan, + Target::Spv, + GetParam().remapOpts); + } else { + loadFileCompileRemapAndCheck(GLSLANG_TEST_DIRECTORY, GetParam().fileName, + GetParam().sourceLanguage, + Semantics::Vulkan, + Target::Spv, + GetParam().entryPoint, + GetParam().remapOpts); + } +} + +// clang-format off +INSTANTIATE_TEST_CASE_P( + ToSpirv, RemapTest, + ::testing::ValuesIn(std::vector{ + // GLSL remapper tests + // testname entry language remapper_options + { "remap.basic.none.frag", "main", Source::GLSL, spv::spirvbin_t::NONE }, + { "remap.basic.everything.frag", "main", Source::GLSL, spv::spirvbin_t::DO_EVERYTHING }, + { "remap.basic.dcefunc.frag", "main", Source::GLSL, spv::spirvbin_t::DCE_FUNCS }, + { "remap.basic.strip.frag", "main", Source::GLSL, spv::spirvbin_t::STRIP }, + { "remap.switch.none.frag", "main", Source::GLSL, spv::spirvbin_t::NONE }, + { "remap.switch.everything.frag", "main", Source::GLSL, spv::spirvbin_t::DO_EVERYTHING }, + { "remap.literal64.none.spv", "main", Source::GLSL, spv::spirvbin_t::NONE }, + { "remap.literal64.everything.spv", "main", Source::GLSL, spv::spirvbin_t::DO_EVERYTHING }, + { "remap.if.none.frag", "main", Source::GLSL, spv::spirvbin_t::NONE }, + { "remap.if.everything.frag", "main", Source::GLSL, spv::spirvbin_t::DO_EVERYTHING }, + { "remap.similar_1a.none.frag", "main", Source::GLSL, spv::spirvbin_t::NONE }, + { "remap.similar_1b.none.frag", "main", Source::GLSL, spv::spirvbin_t::NONE }, + { "remap.similar_1a.everything.frag", "main", Source::GLSL, spv::spirvbin_t::DO_EVERYTHING }, + { "remap.similar_1b.everything.frag", "main", Source::GLSL, spv::spirvbin_t::DO_EVERYTHING }, + { "remap.uniformarray.none.frag", "main", Source::GLSL, spv::spirvbin_t::NONE }, + { "remap.uniformarray.everything.frag", "main", Source::GLSL, spv::spirvbin_t::DO_EVERYTHING }, + + // HLSL remapper tests + { "remap.hlsl.sample.basic.strip.frag", "main", Source::HLSL, spv::spirvbin_t::STRIP }, + { "remap.hlsl.sample.basic.everything.frag", "main", Source::HLSL, spv::spirvbin_t::DO_EVERYTHING }, + { "remap.hlsl.sample.basic.none.frag", "main", Source::HLSL, spv::spirvbin_t::NONE }, + { "remap.hlsl.templatetypes.none.frag", "main", Source::HLSL, spv::spirvbin_t::NONE }, + { "remap.hlsl.templatetypes.everything.frag", "main", Source::HLSL, spv::spirvbin_t::DO_EVERYTHING }, + }), + FileNameAsCustomTestSuffix +); +// clang-format on + +} // anonymous namespace +} // namespace glslangtest diff --git a/gtests/TestFixture.cpp b/gtests/TestFixture.cpp index f170f368db..1dff65aca0 100644 --- a/gtests/TestFixture.cpp +++ b/gtests/TestFixture.cpp @@ -116,6 +116,32 @@ std::pair ReadFile(const std::string& path) return std::make_pair(false, ""); } +std::pair > ReadSpvBinaryFile(const std::string& path) +{ + std::ifstream fstream(path, std::fstream::in | std::fstream::binary); + + if (!fstream) + return std::make_pair(false, std::vector()); + + std::vector contents; + + // Reserve space (for efficiency, not for correctness) + fstream.seekg(0, fstream.end); + contents.reserve(size_t(fstream.tellg()) / sizeof(std::uint32_t)); + fstream.seekg(0, fstream.beg); + + // There is no istream iterator traversing by uint32_t, so we must loop. + while (!fstream.eof()) { + std::uint32_t inWord; + fstream.read((char *)&inWord, sizeof(inWord)); + + if (!fstream.eof()) + contents.push_back(inWord); + } + + return std::make_pair(true, contents); // hopefully, c++11 move semantics optimizes the copy away. +} + bool WriteFile(const std::string& path, const std::string& contents) { std::ofstream fstream(path, std::ios::out); diff --git a/gtests/TestFixture.h b/gtests/TestFixture.h index 4f916e7e50..81930125b2 100644 --- a/gtests/TestFixture.h +++ b/gtests/TestFixture.h @@ -40,12 +40,14 @@ #include #include #include +#include #include #include "SPIRV/GlslangToSpv.h" #include "SPIRV/disassemble.h" #include "SPIRV/doc.h" +#include "SPIRV/SPVRemapper.h" #include "StandAlone/ResourceLimits.h" #include "glslang/Public/ShaderLang.h" @@ -93,6 +95,7 @@ EShMessages DeriveOptions(Source, Semantics, Target); // Reads the content of the file at the given |path|. On success, returns true // and the contents; otherwise, returns false and an empty string. std::pair ReadFile(const std::string& path); +std::pair > ReadSpvBinaryFile(const std::string& path); // Writes the given |contents| into the file at the given |path|. Returns true // on successful output. @@ -128,6 +131,16 @@ class GlslangTest : public GT { ASSERT_TRUE(fileReadOk) << "Cannot open " << tag << " file: " << path; } + // Tries to load the contents from the file at the given |path|. On success, + // writes the contents into |contents|. On failure, errors out. + void tryLoadSpvFile(const std::string& path, const std::string& tag, + std::vector& contents) + { + bool fileReadOk; + std::tie(fileReadOk, contents) = ReadSpvBinaryFile(path); + ASSERT_TRUE(fileReadOk) << "Cannot open " << tag << " file: " << path; + } + // Checks the equality of |expected| and |real|. If they are not equal, // write |real| to the given file named as |fname| if update mode is on. void checkEqAndUpdateIfRequested(const std::string& expected, @@ -221,6 +234,68 @@ class GlslangTest : public GT { } } + // This is like compileAndLink but with remapping of the SPV binary + // through spirvbin_t::remap(). While technically this could be merged + // with compileAndLink() above (with the remap step optionally being a no-op) + // it is given separately here for ease of future extraction. + GlslangResult compileLinkRemap( + const std::string shaderName, const std::string& code, + const std::string& entryPointName, EShMessages controls, + const unsigned int remapOptions = spv::spirvbin_t::NONE) + { + const EShLanguage kind = GetShaderStage(GetSuffix(shaderName)); + + glslang::TShader shader(kind); + bool success = compile(&shader, code, entryPointName, controls); + + glslang::TProgram program; + program.addShader(&shader); + success &= program.link(controls); + + spv::SpvBuildLogger logger; + + if (success && (controls & EShMsgSpvRules)) { + std::vector spirv_binary; + glslang::GlslangToSpv(*program.getIntermediate(kind), + spirv_binary, &logger); + + spv::spirvbin_t(0 /*verbosity*/).remap(spirv_binary, remapOptions); + + std::ostringstream disassembly_stream; + spv::Parameterize(); + spv::Disassemble(disassembly_stream, spirv_binary); + return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},}, + program.getInfoLog(), program.getInfoDebugLog(), + logger.getAllMessages(), disassembly_stream.str()}; + } else { + return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},}, + program.getInfoLog(), program.getInfoDebugLog(), "", ""}; + } + } + + // remap the binary in 'code' with the options in remapOptions + GlslangResult remap( + const std::string shaderName, const std::vector& code, + EShMessages controls, + const unsigned int remapOptions = spv::spirvbin_t::NONE) + { + if ((controls & EShMsgSpvRules)) { + std::vector spirv_binary(code); // scratch copy + + spv::spirvbin_t(0 /*verbosity*/).remap(spirv_binary, remapOptions); + + std::ostringstream disassembly_stream; + spv::Parameterize(); + spv::Disassemble(disassembly_stream, spirv_binary); + + return {{{shaderName, "", ""},}, + "", "", + "", disassembly_stream.str()}; + } else { + return {{{shaderName, "", ""},}, "", "", "", ""}; + } + } + void outputResultToStream(std::ostringstream* stream, const GlslangResult& result, EShMessages controls) @@ -272,6 +347,60 @@ class GlslangTest : public GT { expectedOutputFname); } + void loadFileCompileRemapAndCheck(const std::string& testDir, + const std::string& testName, + Source source, + Semantics semantics, + Target target, + const std::string& entryPointName="", + const unsigned int remapOptions = spv::spirvbin_t::NONE) + { + const std::string inputFname = testDir + "/" + testName; + const std::string expectedOutputFname = + testDir + "/baseResults/" + testName + ".out"; + std::string input, expectedOutput; + + tryLoadFile(inputFname, "input", &input); + tryLoadFile(expectedOutputFname, "expected output", &expectedOutput); + + const EShMessages controls = DeriveOptions(source, semantics, target); + GlslangResult result = compileLinkRemap(testName, input, entryPointName, controls, remapOptions); + + // Generate the hybrid output in the way of glslangValidator. + std::ostringstream stream; + outputResultToStream(&stream, result, controls); + + checkEqAndUpdateIfRequested(expectedOutput, stream.str(), + expectedOutputFname); + } + + void loadFileRemapAndCheck(const std::string& testDir, + const std::string& testName, + Source source, + Semantics semantics, + Target target, + const unsigned int remapOptions = spv::spirvbin_t::NONE) + { + const std::string inputFname = testDir + "/" + testName; + const std::string expectedOutputFname = + testDir + "/baseResults/" + testName + ".out"; + std::vector input; + std::string expectedOutput; + + tryLoadSpvFile(inputFname, "input", input); + tryLoadFile(expectedOutputFname, "expected output", &expectedOutput); + + const EShMessages controls = DeriveOptions(source, semantics, target); + GlslangResult result = remap(testName, input, controls, remapOptions); + + // Generate the hybrid output in the way of glslangValidator. + std::ostringstream stream; + outputResultToStream(&stream, result, controls); + + checkEqAndUpdateIfRequested(expectedOutput, stream.str(), + expectedOutputFname); + } + // Preprocesses the given |source| code. On success, returns true, the // preprocessed shader, and warning messages. Otherwise, returns false, an // empty string, and error messages.