diff --git a/Test/baseResults/spv.debugInfo.1.1.frag.out b/Test/baseResults/spv.debugInfo.1.1.frag.out new file mode 100644 index 00000000..12726756 --- /dev/null +++ b/Test/baseResults/spv.debugInfo.1.1.frag.out @@ -0,0 +1,422 @@ +spv.debugInfo.frag +// Module Version 10300 +// Generated by (magic number): 8000b +// Id's are bound by 187 + + Capability Shader + 2: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 5 "main" 30 104 + ExecutionMode 5 OriginUpperLeft + 1: String "spv.debugInfo.frag" + Source GLSL 450 1 "#version 450 + +struct S { + int a; +}; + +uniform ubuf { + S s; +}; + +uniform sampler2D s2d; + +layout(location = 0) in vec4 inv; +layout(location = 0) out vec4 outv; + +vec4 foo(S s) +{ + vec4 r = s.a * inv; + ++r; + if (r.x > 3.0) + --r; + else + r *= 2; + + return r; +} + +float testBranch(float x, float y) +{ + float result = 0; + bool b = x > 0; + + // branch with load + if (b) { + result += 1; + } + else { + result -= 1; + } + + // branch with expression + if (x > y) { + result += x - y; + } + + // selection with load + result += b ? + 1 : -1; + + // selection with expression + result += x < y ? + y : + float(b); + + return result; +} + +void main() +{ + outv = foo(s); + outv += testBranch(inv.x, inv.y); + outv += texture(s2d, vec2(0.5)); + + switch (s.a) { + case 10: + ++outv; + break; + case 20: + outv = 2 * outv; + ++outv; + break; + default: + --outv; + break; + } + + for (int i = 0; i < 10; ++i) + outv *= 3.0; + + outv.x < 10.0 ? + outv = sin(outv) : + outv = cos(outv); +}" + Name 5 "main" + Name 8 "S" + MemberName 8(S) 0 "a" + Name 14 "foo(struct-S-i11;" + Name 13 "s" + Name 20 "testBranch(f1;f1;" + Name 18 "x" + Name 19 "y" + Name 23 "r" + Name 30 "inv" + Name 56 "result" + Name 59 "b" + Name 104 "outv" + Name 105 "S" + MemberName 105(S) 0 "a" + Name 106 "ubuf" + MemberName 106(ubuf) 0 "s" + Name 108 "" + Name 109 "param" + Name 116 "param" + Name 120 "param" + Name 131 "s2d" + Name 161 "i" + ModuleProcessed "no-storage-format" + ModuleProcessed "resource-set-binding 3" + ModuleProcessed "auto-map-bindings" + ModuleProcessed "auto-map-locations" + ModuleProcessed "client vulkan100" + ModuleProcessed "target-env spirv1.3" + ModuleProcessed "target-env vulkan1.1" + ModuleProcessed "relaxed-errors" + ModuleProcessed "suppress-warnings" + ModuleProcessed "hlsl-offsets" + ModuleProcessed "entry-point main" + Decorate 30(inv) Location 0 + Decorate 104(outv) Location 0 + MemberDecorate 105(S) 0 Offset 0 + MemberDecorate 106(ubuf) 0 Offset 0 + Decorate 106(ubuf) Block + Decorate 108 DescriptorSet 3 + Decorate 108 Binding 0 + Decorate 131(s2d) DescriptorSet 3 + Decorate 131(s2d) Binding 1 + 3: TypeVoid + 4: TypeFunction 3 + 7: TypeInt 32 1 + 8(S): TypeStruct 7(int) + 9: TypePointer Function 8(S) + 10: TypeFloat 32 + 11: TypeVector 10(float) 4 + 12: TypeFunction 11(fvec4) 9(ptr) + 16: TypePointer Function 10(float) + 17: TypeFunction 10(float) 16(ptr) 16(ptr) + 22: TypePointer Function 11(fvec4) + 24: 7(int) Constant 0 + 25: TypePointer Function 7(int) + 29: TypePointer Input 11(fvec4) + 30(inv): 29(ptr) Variable Input + 34: 10(float) Constant 1065353216 + 37: TypeInt 32 0 + 38: 37(int) Constant 0 + 41: 10(float) Constant 1077936128 + 42: TypeBool + 50: 10(float) Constant 1073741824 + 57: 10(float) Constant 0 + 58: TypePointer Function 42(bool) + 81: 7(int) Constant 1 + 82: 7(int) Constant 4294967295 + 103: TypePointer Output 11(fvec4) + 104(outv): 103(ptr) Variable Output + 105(S): TypeStruct 7(int) + 106(ubuf): TypeStruct 105(S) + 107: TypePointer Uniform 106(ubuf) + 108: 107(ptr) Variable Uniform + 110: TypePointer Uniform 105(S) + 117: TypePointer Input 10(float) + 121: 37(int) Constant 1 + 128: TypeImage 10(float) 2D sampled format:Unknown + 129: TypeSampledImage 128 + 130: TypePointer UniformConstant 129 + 131(s2d): 130(ptr) Variable UniformConstant + 133: TypeVector 10(float) 2 + 134: 10(float) Constant 1056964608 + 135: 133(fvec2) ConstantComposite 134 134 + 139: TypePointer Uniform 7(int) + 168: 7(int) Constant 10 + 174: TypePointer Output 10(float) + 177: 10(float) Constant 1092616192 + Line 1 58 11 + 5(main): 3 Function None 4 + 6: Label + 109(param): 9(ptr) Variable Function + 116(param): 16(ptr) Variable Function + 120(param): 16(ptr) Variable Function + 161(i): 25(ptr) Variable Function + 179: 22(ptr) Variable Function + Line 1 60 0 + 111: 110(ptr) AccessChain 108 24 + 112: 105(S) Load 111 + 113: 7(int) CompositeExtract 112 0 + 114: 25(ptr) AccessChain 109(param) 24 + Store 114 113 + 115: 11(fvec4) FunctionCall 14(foo(struct-S-i11;) 109(param) + Store 104(outv) 115 + Line 1 61 0 + 118: 117(ptr) AccessChain 30(inv) 38 + 119: 10(float) Load 118 + Store 116(param) 119 + 122: 117(ptr) AccessChain 30(inv) 121 + 123: 10(float) Load 122 + Store 120(param) 123 + 124: 10(float) FunctionCall 20(testBranch(f1;f1;) 116(param) 120(param) + 125: 11(fvec4) Load 104(outv) + 126: 11(fvec4) CompositeConstruct 124 124 124 124 + 127: 11(fvec4) FAdd 125 126 + Store 104(outv) 127 + Line 1 62 0 + 132: 129 Load 131(s2d) + 136: 11(fvec4) ImageSampleImplicitLod 132 135 + 137: 11(fvec4) Load 104(outv) + 138: 11(fvec4) FAdd 137 136 + Store 104(outv) 138 + Line 1 64 0 + 140: 139(ptr) AccessChain 108 24 24 + 141: 7(int) Load 140 + SelectionMerge 145 None + Switch 141 144 + case 10: 142 + case 20: 143 + 144: Label + Line 1 73 0 + 156: 11(fvec4) Load 104(outv) + 157: 11(fvec4) CompositeConstruct 34 34 34 34 + 158: 11(fvec4) FSub 156 157 + Store 104(outv) 158 + Line 1 74 0 + Branch 145 + 142: Label + Line 1 66 0 + 146: 11(fvec4) Load 104(outv) + 147: 11(fvec4) CompositeConstruct 34 34 34 34 + 148: 11(fvec4) FAdd 146 147 + Store 104(outv) 148 + Line 1 67 0 + Branch 145 + 143: Label + Line 1 69 0 + 150: 11(fvec4) Load 104(outv) + 151: 11(fvec4) VectorTimesScalar 150 50 + Store 104(outv) 151 + Line 1 70 0 + 152: 11(fvec4) Load 104(outv) + 153: 11(fvec4) CompositeConstruct 34 34 34 34 + 154: 11(fvec4) FAdd 152 153 + Store 104(outv) 154 + Line 1 71 0 + Branch 145 + 145: Label + Line 1 77 0 + Store 161(i) 24 + Branch 162 + 162: Label + Line 1 77 0 + LoopMerge 164 165 None + Branch 166 + 166: Label + Line 1 77 0 + 167: 7(int) Load 161(i) + 169: 42(bool) SLessThan 167 168 + BranchConditional 169 163 164 + 163: Label + Line 1 78 0 + 170: 11(fvec4) Load 104(outv) + 171: 11(fvec4) VectorTimesScalar 170 41 + Store 104(outv) 171 + Branch 165 + 165: Label + Line 1 77 0 + 172: 7(int) Load 161(i) + 173: 7(int) IAdd 172 81 + Store 161(i) 173 + Branch 162 + 164: Label + Line 1 80 0 + 175: 174(ptr) AccessChain 104(outv) 38 + 176: 10(float) Load 175 + 178: 42(bool) FOrdLessThan 176 177 + SelectionMerge 181 None + BranchConditional 178 180 184 + 180: Label + Line 1 81 0 + 182: 11(fvec4) Load 104(outv) + 183: 11(fvec4) ExtInst 2(GLSL.std.450) 13(Sin) 182 + Store 104(outv) 183 + Store 179 183 + Branch 181 + 184: Label + Line 1 82 0 + 185: 11(fvec4) Load 104(outv) + 186: 11(fvec4) ExtInst 2(GLSL.std.450) 14(Cos) 185 + Store 104(outv) 186 + Store 179 186 + Branch 181 + 181: Label + Return + FunctionEnd + Line 1 16 13 +14(foo(struct-S-i11;): 11(fvec4) Function None 12 + 13(s): 9(ptr) FunctionParameter + 15: Label + 23(r): 22(ptr) Variable Function + Line 1 18 0 + 26: 25(ptr) AccessChain 13(s) 24 + 27: 7(int) Load 26 + 28: 10(float) ConvertSToF 27 + 31: 11(fvec4) Load 30(inv) + 32: 11(fvec4) VectorTimesScalar 31 28 + Store 23(r) 32 + Line 1 19 0 + 33: 11(fvec4) Load 23(r) + 35: 11(fvec4) CompositeConstruct 34 34 34 34 + 36: 11(fvec4) FAdd 33 35 + Store 23(r) 36 + Line 1 20 0 + 39: 16(ptr) AccessChain 23(r) 38 + 40: 10(float) Load 39 + 43: 42(bool) FOrdGreaterThan 40 41 + SelectionMerge 45 None + BranchConditional 43 44 49 + 44: Label + Line 1 21 0 + 46: 11(fvec4) Load 23(r) + 47: 11(fvec4) CompositeConstruct 34 34 34 34 + 48: 11(fvec4) FSub 46 47 + Store 23(r) 48 + Branch 45 + 49: Label + Line 1 23 0 + 51: 11(fvec4) Load 23(r) + 52: 11(fvec4) VectorTimesScalar 51 50 + Store 23(r) 52 + Branch 45 + 45: Label + Line 1 25 0 + 53: 11(fvec4) Load 23(r) + ReturnValue 53 + FunctionEnd + Line 1 28 34 +20(testBranch(f1;f1;): 10(float) Function None 17 + 18(x): 16(ptr) FunctionParameter + 19(y): 16(ptr) FunctionParameter + 21: Label + 56(result): 16(ptr) Variable Function + 59(b): 58(ptr) Variable Function + 90: 16(ptr) Variable Function + Line 1 30 0 + Store 56(result) 57 + Line 1 31 0 + 60: 10(float) Load 18(x) + 61: 42(bool) FOrdGreaterThan 60 57 + Store 59(b) 61 + Line 1 34 0 + 62: 42(bool) Load 59(b) + SelectionMerge 64 None + BranchConditional 62 63 67 + 63: Label + Line 1 35 0 + 65: 10(float) Load 56(result) + 66: 10(float) FAdd 65 34 + Store 56(result) 66 + Branch 64 + 67: Label + Line 1 38 0 + 68: 10(float) Load 56(result) + 69: 10(float) FSub 68 34 + Store 56(result) 69 + Branch 64 + 64: Label + Line 1 42 0 + 70: 10(float) Load 18(x) + 71: 10(float) Load 19(y) + 72: 42(bool) FOrdGreaterThan 70 71 + SelectionMerge 74 None + BranchConditional 72 73 74 + 73: Label + Line 1 43 0 + 75: 10(float) Load 18(x) + 76: 10(float) Load 19(y) + 77: 10(float) FSub 75 76 + 78: 10(float) Load 56(result) + 79: 10(float) FAdd 78 77 + Store 56(result) 79 + Branch 74 + 74: Label + Line 1 47 0 + 80: 42(bool) Load 59(b) + 83: 7(int) Select 80 81 82 + 84: 10(float) ConvertSToF 83 + 85: 10(float) Load 56(result) + 86: 10(float) FAdd 85 84 + Store 56(result) 86 + Line 1 51 0 + 87: 10(float) Load 18(x) + 88: 10(float) Load 19(y) + 89: 42(bool) FOrdLessThan 87 88 + SelectionMerge 92 None + BranchConditional 89 91 94 + 91: Label + Line 1 52 0 + 93: 10(float) Load 19(y) + Store 90 93 + Branch 92 + 94: Label + Line 1 53 0 + 95: 42(bool) Load 59(b) + 96: 10(float) Select 95 34 57 + Store 90 96 + Branch 92 + 92: Label + 97: 10(float) Load 90 + Line 1 51 0 + 98: 10(float) Load 56(result) + 99: 10(float) FAdd 98 97 + Store 56(result) 99 + Line 1 55 0 + 100: 10(float) Load 56(result) + ReturnValue 100 + FunctionEnd diff --git a/Test/baseResults/spv.debugInfo.frag.out b/Test/baseResults/spv.debugInfo.frag.out index 475187d9..8bacd74d 100644 --- a/Test/baseResults/spv.debugInfo.frag.out +++ b/Test/baseResults/spv.debugInfo.frag.out @@ -7,13 +7,17 @@ spv.debugInfo.frag 2: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint Fragment 5 "main" 30 104 - ExecutionMode 5 OriginUpperLeft + ExecutionMode 5 OriginLowerLeft 1: String "spv.debugInfo.frag" - Source GLSL 450 1 "// OpModuleProcessed auto-map-locations + Source GLSL 450 1 "// OpModuleProcessed no-storage-format +// OpModuleProcessed resource-set-binding 3 // OpModuleProcessed auto-map-bindings -// OpModuleProcessed client vulkan100 -// OpModuleProcessed target-env vulkan1.0 -// OpModuleProcessed keep-uncalled +// OpModuleProcessed auto-map-locations +// OpModuleProcessed client opengl100 +// OpModuleProcessed target-env opengl +// OpModuleProcessed relaxed-errors +// OpModuleProcessed suppress-warnings +// OpModuleProcessed hlsl-offsets // OpModuleProcessed entry-point main #line 1 #version 450 @@ -127,9 +131,10 @@ void main() MemberDecorate 105(S) 0 Offset 0 MemberDecorate 106(ubuf) 0 Offset 0 Decorate 106(ubuf) Block - Decorate 108 DescriptorSet 0 + Decorate 108 DescriptorSet 3 Decorate 108 Binding 0 - Decorate 131(s2d) DescriptorSet 0 + Decorate 131(s2d) Location 0 + Decorate 131(s2d) DescriptorSet 3 Decorate 131(s2d) Binding 1 3: TypeVoid 4: TypeFunction 3 diff --git a/Test/runtests b/Test/runtests index 52898e06..00c2babd 100755 --- a/Test/runtests +++ b/Test/runtests @@ -169,6 +169,12 @@ diff -b $BASEDIR/spv.looseUniformNoLoc.vert.out "$TARGETDIR/spv.looseUniformNoLo # Testing debug information # echo Testing SPV Debug Information +run -g --relaxed-errors --suppress-warnings --aml --amb --hlsl-offsets --nsf --spirv-val \ + -G -H spv.debugInfo.frag --rsb frag 3 > "$TARGETDIR/spv.debugInfo.frag.out" +diff -b $BASEDIR/spv.debugInfo.frag.out "$TARGETDIR/spv.debugInfo.frag.out" || HASERROR=1 +run -g -Od --target-env vulkan1.1 --relaxed-errors --suppress-warnings --aml --amb --hlsl-offsets --nsf --spirv-val \ + -V -H spv.debugInfo.frag --rsb frag 3 > "$TARGETDIR/spv.debugInfo.1.1.frag.out" +diff -b $BASEDIR/spv.debugInfo.1.1.frag.out "$TARGETDIR/spv.debugInfo.1.1.frag.out" || HASERROR=1 run -g -D -Od -e newMain -g --amb --aml --fua --hlsl-iomap --nsf --spirv-val --sib 1 --ssb 2 --sbb 3 --stb 4 --suavb 5 --sub 6 \ --sep origMain -H -Od spv.hlslDebugInfo.vert --rsb vert t0 0 0 > "$TARGETDIR/spv.hlslDebugInfo.frag.out" diff -b $BASEDIR/spv.hlslDebugInfo.frag.out "$TARGETDIR/spv.hlslDebugInfo.frag.out" || HASERROR=1 diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index 627b3aa4..77e9cccf 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -935,7 +935,6 @@ INSTANTIATE_TEST_SUITE_P( Glsl, GlslSpirvDebugInfoTest, ::testing::ValuesIn(std::vector({ "spv.pp.line.frag", - "spv.debugInfo.frag", })), FileNameAsCustomTestSuffix );