Merge pull request #3102 from jeremy-lunarg/hayes-fix-debuginfo-disassembly
[platform/upstream/glslang.git] / gtests / Spv.FromFile.cpp
1  //
2 // Copyright (C) 2016 Google, Inc.
3 // Copyright (C) 2019 ARM Limited.
4 // Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
5 //
6 // All rights reserved.
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions
10 // are met:
11 //
12 //    Redistributions of source code must retain the above copyright
13 //    notice, this list of conditions and the following disclaimer.
14 //
15 //    Redistributions in binary form must reproduce the above
16 //    copyright notice, this list of conditions and the following
17 //    disclaimer in the documentation and/or other materials provided
18 //    with the distribution.
19 //
20 //    Neither the name of Google Inc. nor the names of its
21 //    contributors may be used to endorse or promote products derived
22 //    from this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 // POSSIBILITY OF SUCH DAMAGE.
36
37 #include <algorithm>
38
39 #include <gtest/gtest.h>
40
41 #include "TestFixture.h"
42
43 namespace glslangtest {
44 namespace {
45
46 struct IoMapData {
47     const char* fileName;
48     const char* entryPoint;
49     int baseSamplerBinding;
50     int baseTextureBinding;
51     int baseImageBinding;
52     int baseUboBinding;
53     int baseSsboBinding;
54     bool autoMapBindings;
55     bool flattenUniforms;
56 };
57
58 std::string FileNameAsCustomTestSuffixIoMap(
59     const ::testing::TestParamInfo<IoMapData>& info) {
60     std::string name = info.param.fileName;
61     // A valid test case suffix cannot have '.' and '-' inside.
62     std::replace(name.begin(), name.end(), '.', '_');
63     std::replace(name.begin(), name.end(), '-', '_');
64     return name;
65 }
66
67 using CompileVulkanToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
68 using CompileVulkanToSpirvDeadCodeElimTest = GlslangTest<::testing::TestWithParam<std::string>>;
69 using CompileVulkanToDebugSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
70 using CompileVulkan1_1ToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
71 using CompileToSpirv14Test = GlslangTest<::testing::TestWithParam<std::string>>;
72 using CompileToSpirv16Test = GlslangTest<::testing::TestWithParam<std::string>>;
73 using CompileOpenGLToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
74 using VulkanSemantics = GlslangTest<::testing::TestWithParam<std::string>>;
75 using OpenGLSemantics = GlslangTest<::testing::TestWithParam<std::string>>;
76 using VulkanAstSemantics = GlslangTest<::testing::TestWithParam<std::string>>;
77 using HlslIoMap = GlslangTest<::testing::TestWithParam<IoMapData>>;
78 using GlslIoMap = GlslangTest<::testing::TestWithParam<IoMapData>>;
79 using CompileVulkanToSpirvTestAMD = GlslangTest<::testing::TestWithParam<std::string>>;
80 using CompileVulkanToSpirvTestNV = GlslangTest<::testing::TestWithParam<std::string>>;
81 using CompileVulkanToSpirv14TestNV = GlslangTest<::testing::TestWithParam<std::string>>;
82 using CompileUpgradeTextureToSampledTextureAndDropSamplersTest = GlslangTest<::testing::TestWithParam<std::string>>;
83 using CompileVulkanToNonSemanticShaderDebugInfoTest = GlslangTest<::testing::TestWithParam<std::string>>;
84
85 // Compiling GLSL to SPIR-V under Vulkan semantics. Expected to successfully
86 // generate SPIR-V.
87 TEST_P(CompileVulkanToSpirvTest, FromFile)
88 {
89     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
90                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
91                             Target::Spv);
92 }
93
94 TEST_P(CompileVulkanToSpirvDeadCodeElimTest, FromFile)
95 {
96     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
97                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
98                             Target::Spv);
99 }
100
101 // Compiling GLSL to SPIR-V with debug info under Vulkan semantics. Expected
102 // to successfully generate SPIR-V.
103 TEST_P(CompileVulkanToDebugSpirvTest, FromFile)
104 {
105     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
106                             Source::GLSL, Semantics::Vulkan,
107                             glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
108                             Target::Spv, true, "",
109                             "/baseResults/", false, true);
110 }
111
112
113 TEST_P(CompileVulkan1_1ToSpirvTest, FromFile)
114 {
115     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
116                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_1, glslang::EShTargetSpv_1_3,
117                             Target::Spv);
118 }
119
120 TEST_P(CompileToSpirv14Test, FromFile)
121 {
122     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
123                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_1, glslang::EShTargetSpv_1_4,
124                             Target::Spv);
125 }
126
127 TEST_P(CompileToSpirv16Test, FromFile)
128 {
129     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
130                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_3, glslang::EShTargetSpv_1_6,
131                             Target::Spv);
132 }
133
134 // Compiling GLSL to SPIR-V under OpenGL semantics. Expected to successfully
135 // generate SPIR-V.
136 TEST_P(CompileOpenGLToSpirvTest, FromFile)
137 {
138     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
139                             Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
140                             Target::Spv);
141 }
142
143 // GLSL-level Vulkan semantics test. Expected to error out before generating
144 // SPIR-V.
145 TEST_P(VulkanSemantics, FromFile)
146 {
147     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
148                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
149                             Target::Spv, false);
150 }
151
152 // GLSL-level Vulkan semantics test. Expected to error out before generating
153 // SPIR-V.
154 TEST_P(OpenGLSemantics, FromFile)
155 {
156     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
157                             Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
158                             Target::Spv, false);
159 }
160
161 // GLSL-level Vulkan semantics test that need to see the AST for validation.
162 TEST_P(VulkanAstSemantics, FromFile)
163 {
164     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
165                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
166                             Target::AST);
167 }
168
169 // HLSL-level Vulkan semantics tests.
170 TEST_P(HlslIoMap, FromFile)
171 {
172     loadFileCompileIoMapAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
173                                  Source::HLSL, Semantics::Vulkan,
174                                  Target::Spv, GetParam().entryPoint,
175                                  GetParam().baseSamplerBinding,
176                                  GetParam().baseTextureBinding,
177                                  GetParam().baseImageBinding,
178                                  GetParam().baseUboBinding,
179                                  GetParam().baseSsboBinding,
180                                  GetParam().autoMapBindings,
181                                  GetParam().flattenUniforms);
182 }
183
184 // GLSL-level Vulkan semantics tests.
185 TEST_P(GlslIoMap, FromFile)
186 {
187     loadFileCompileIoMapAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
188                                  Source::GLSL, Semantics::Vulkan,
189                                  Target::Spv, GetParam().entryPoint,
190                                  GetParam().baseSamplerBinding,
191                                  GetParam().baseTextureBinding,
192                                  GetParam().baseImageBinding,
193                                  GetParam().baseUboBinding,
194                                  GetParam().baseSsboBinding,
195                                  GetParam().autoMapBindings,
196                                  GetParam().flattenUniforms);
197 }
198
199 // Compiling GLSL to SPIR-V under Vulkan semantics (AMD extensions enabled).
200 // Expected to successfully generate SPIR-V.
201 TEST_P(CompileVulkanToSpirvTestAMD, FromFile)
202 {
203     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
204                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
205                             Target::Spv);
206 }
207
208 // Compiling GLSL to SPIR-V under Vulkan semantics (NV extensions enabled).
209 // Expected to successfully generate SPIR-V.
210 TEST_P(CompileVulkanToSpirvTestNV, FromFile)
211 {
212     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
213                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
214                             Target::Spv);
215 }
216
217 TEST_P(CompileVulkanToSpirv14TestNV, FromFile)
218 {
219     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
220                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_1, glslang::EShTargetSpv_1_4,
221                             Target::Spv);
222 }
223
224 TEST_P(CompileUpgradeTextureToSampledTextureAndDropSamplersTest, FromFile)
225 {
226     loadCompileUpgradeTextureToSampledTextureAndDropSamplersAndCheck(GlobalTestSettings.testRoot,
227                                                                      GetParam(),
228                                                                      Source::GLSL,
229                                                                      Semantics::Vulkan,
230                                                                      Target::Spv);
231 }
232
233 TEST_P(CompileVulkanToNonSemanticShaderDebugInfoTest, FromFile)
234 {
235     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
236                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
237                             Target::Spv, true, "", "/baseResults/", false, false, true);
238 }
239
240 // clang-format off
241 INSTANTIATE_TEST_SUITE_P(
242     Glsl, CompileVulkanToSpirvTest,
243     ::testing::ValuesIn(std::vector<std::string>({
244         // Test looping constructs.
245         // No tests yet for making sure break and continue from a nested loop
246         // goes to the innermost target.
247         "spv.barrier.vert",
248         "spv.do-simple.vert",
249         "spv.do-while-continue-break.vert",
250         "spv.for-complex-condition.vert",
251         "spv.for-continue-break.vert",
252         "spv.for-simple.vert",
253         "spv.for-notest.vert",
254         "spv.for-nobody.vert",
255         "spv.while-continue-break.vert",
256         "spv.while-simple.vert",
257         // vulkan-specific tests
258         "rayQuery.rgen",
259         "rayQuery-no-cse.rgen",
260         "rayQuery-initialize.rgen",
261         "rayQuery-allOps.rgen",
262         "rayQuery-allOps.Error.rgen",
263         "rayQuery-committed.Error.rgen",
264         "rayQuery-allOps.comp",
265         "rayQuery-allOps.frag",
266         "rayQuery-initialization.Error.comp",
267         "rayQuery-global.rgen",
268         "rayQuery-types.comp",
269         "rayQuery-OpConvertUToAccelerationStructureKHR.comp",
270         "spv.set.vert",
271         "spv.double.comp",
272         "spv.100ops.frag",
273         "spv.130.frag",
274         "spv.140.frag",
275         "spv.150.geom",
276         "spv.150.vert",
277         "spv.16bitstorage.frag",
278         "spv.16bitstorage_Error.frag",
279         "spv.16bitstorage-int.frag",
280         "spv.16bitstorage_Error-int.frag",
281         "spv.16bitstorage-uint.frag",
282         "spv.16bitstorage_Error-uint.frag",
283         "spv.300BuiltIns.vert",
284         "spv.300layout.frag",
285         "spv.300layout.vert",
286         "spv.300layoutp.vert",
287         "spv.310.comp",
288         "spv.310.bitcast.frag",
289         "spv.330.geom",
290         "spv.400.frag",
291         "spv.400.tesc",
292         "spv.400.tese",
293         "spv.420.geom",
294         "spv.430.frag",
295         "spv.430.vert",
296         "spv.450.tesc",
297         "spv.450.geom",
298         "spv.450.noRedecl.tesc",
299         "spv.8bitstorage-int.frag",
300         "spv.8bitstorage_Error-int.frag",
301         "spv.8bitstorage-uint.frag",
302         "spv.8bitstorage_Error-uint.frag",
303         "spv.8bitstorage-ubo.vert",
304         "spv.8bitstorage-ssbo.vert",
305         "spv.8bit-16bit-construction.frag",
306         "spv.accessChain.frag",
307         "spv.aggOps.frag",
308         "spv.always-discard.frag",
309         "spv.always-discard2.frag",
310         "spv.arbPostDepthCoverage.frag",
311         "spv.arbPostDepthCoverage_Error.frag",
312         "spv.atomicCounter.comp",
313         "spv.bitCast.frag",
314         "spv.bool.vert",
315         "spv.boolInBlock.frag",
316         "spv.branch-return.vert",
317         "spv.bufferhandle1.frag",
318         "spv.bufferhandle10.frag",
319         "spv.bufferhandle11.frag",
320         "spv.bufferhandle12.frag",
321         "spv.bufferhandle13.frag",
322         "spv.bufferhandle14.frag",
323         "spv.bufferhandle15.frag",
324         "spv.bufferhandle16.frag",
325         "spv.bufferhandle17_Errors.frag",
326         "spv.bufferhandle18.frag",
327         "spv.bufferhandle19_Errors.frag",
328         "spv.bufferhandle2.frag",
329         "spv.bufferhandle3.frag",
330         "spv.bufferhandle4.frag",
331         "spv.bufferhandle5.frag",
332         "spv.bufferhandle6.frag",
333         "spv.bufferhandle7.frag",
334         "spv.bufferhandle8.frag",
335         "spv.bufferhandle9.frag",
336         "spv.bufferhandleUvec2.frag",
337         "spv.bufferhandle_Error.frag",
338         "spv.builtInXFB.vert",
339         "spv.conditionalDemote.frag",
340         "spv.conditionalDiscard.frag",
341         "spv.constructComposite.comp",
342         "spv.constStruct.vert",
343         "spv.constConstruct.vert",
344         "spv.controlFlowAttributes.frag",
345         "spv.conversion.frag",
346         "spv.coopmat.comp",
347         "spv.coopmat_Error.comp",
348         "spv.dataOut.frag",
349         "spv.dataOutIndirect.frag",
350         "spv.dataOutIndirect.vert",
351         "spv.debugPrintf.frag",
352         "spv.debugPrintf_Error.frag",
353         "spv.demoteDisabled.frag",
354         "spv.deepRvalue.frag",
355         "spv.depthOut.frag",
356         "spv.depthUnchanged.frag",
357         "spv.discard-dce.frag",
358         "spv.doWhileLoop.frag",
359         "spv.earlyReturnDiscard.frag",
360         "spv.extPostDepthCoverage.frag",
361         "spv.extPostDepthCoverage_Error.frag",
362         "spv.float16convertonlyarith.comp",
363         "spv.float16convertonlystorage.comp",
364         "spv.flowControl.frag",
365         "spv.forLoop.frag",
366         "spv.forwardFun.frag",
367         "spv.fragmentDensity.frag",
368         "spv.fragmentDensity.vert",
369         "spv.fragmentDensity-es.frag",
370         "spv.fragmentDensity-neg.frag",
371         "spv.fsi.frag",
372         "spv.fsi_Error.frag",
373         "spv.fullyCovered.frag",
374         "spv.functionCall.frag",
375         "spv.functionNestedOpaque.vert",
376         "spv.functionSemantics.frag",
377         "spv.functionParameterTypes.frag",
378         "spv.GeometryShaderPassthrough.geom",
379         "spv.funcall.array.frag",
380         "spv.load.bool.array.interface.block.frag",
381         "spv.interpOps.frag",
382         "spv.int64.frag",
383         "spv.intcoopmat.comp",
384         "spv.intOps.vert",
385         "spv.intrinsicsSpirvByReference.vert",
386         "spv.intrinsicsSpirvDecorate.frag",
387         "spv.intrinsicsSpirvExecutionMode.frag",
388         "spv.intrinsicsSpirvInstruction.vert",
389         "spv.intrinsicsSpirvLiteral.vert",
390         "spv.intrinsicsSpirvStorageClass.rchit",
391         "spv.intrinsicsSpirvType.rgen",
392         "spv.intrinsicsSpirvTypeLocalVar.vert",
393         "spv.invariantAll.vert",
394         "spv.layer.tese",
395         "spv.layoutNested.vert",
396         "spv.length.frag",
397         "spv.localAggregates.frag",
398         "spv.loops.frag",
399         "spv.loopsArtificial.frag",
400         "spv.matFun.vert",
401         "spv.matrix.frag",
402         "spv.matrix2.frag",
403         "spv.memoryQualifier.frag",
404         "spv.merge-unreachable.frag",
405         "spv.multiStruct.comp",
406         "spv.multiStructFuncall.frag",
407         "spv.newTexture.frag",
408         "spv.noDeadDecorations.vert",
409         "spv.nonSquare.vert",
410         "spv.nonuniform.frag",
411         "spv.nonuniform2.frag",
412         "spv.nonuniform3.frag",
413         "spv.nonuniform4.frag",
414         "spv.nonuniform5.frag",
415         "spv.noWorkgroup.comp",
416         "spv.nullInit.comp",
417         "spv.offsets.frag",
418         "spv.Operations.frag",
419         "spv.paramMemory.frag",
420         "spv.paramMemory.420.frag",
421         "spv.precision.frag",
422         "spv.precisionArgs.frag",
423         "spv.precisionNonESSamp.frag",
424         "spv.precisionTexture.frag",
425         "spv.prepost.frag",
426         "spv.privateVariableTypes.frag",
427         "spv.qualifiers.vert",
428         "spv.sample.frag",
429         "spv.sampleId.frag",
430         "spv.samplePosition.frag",
431         "spv.sampleMaskOverrideCoverage.frag",
432         "spv.scalarlayout.frag",
433         "spv.scalarlayoutfloat16.frag",
434         "spv.shaderBallot.comp",
435         "spv.shaderDrawParams.vert",
436         "spv.shaderGroupVote.comp",
437         "spv.shaderStencilExport.frag",
438         "spv.shiftOps.frag",
439         "spv.simpleFunctionCall.frag",
440         "spv.simpleMat.vert",
441         "spv.sparseTexture.frag",
442         "spv.sparseTextureClamp.frag",
443         "spv.structAssignment.frag",
444         "spv.structDeref.frag",
445         "spv.structure.frag",
446         "spv.switch.frag",
447         "spv.swizzle.frag",
448         "spv.swizzleInversion.frag",
449         "spv.test.frag",
450         "spv.test.vert",
451         "spv.texture.frag",
452         "spv.texture.vert",
453         "spv.textureBuffer.vert",
454         "spv.image.frag",
455         "spv.imageAtomic64.frag",
456         "spv.imageAtomic64.comp",
457         "spv.types.frag",
458         "spv.uint.frag",
459         "spv.uniformArray.frag",
460         "spv.variableArrayIndex.frag",
461         "spv.varyingArray.frag",
462         "spv.varyingArrayIndirect.frag",
463         "spv.vecMatConstruct.frag",
464         "spv.voidFunction.frag",
465         "spv.whileLoop.frag",
466         "spv.AofA.frag",
467         "spv.queryL.frag",
468         "spv.separate.frag",
469         "spv.shortCircuit.frag",
470         "spv.pushConstant.vert",
471         "spv.pushConstantAnon.vert",
472         "spv.subpass.frag",
473         "spv.specConstant.vert",
474         "spv.specConstant.comp",
475         "spv.specConstantComposite.vert",
476         "spv.specConstantOperations.vert",
477         "spv.specConstant.float16.comp",
478         "spv.specConstant.int16.comp",
479         "spv.specConstant.int8.comp",
480         "spv.storageBuffer.vert",
481         "spv.terminate.frag",
482         "spv.subgroupUniformControlFlow.vert",
483         "spv.subgroupSizeARB.frag",
484         "spv.precise.tese",
485         "spv.precise.tesc",
486         "spv.viewportindex.tese",
487         "spv.volatileAtomic.comp",
488         "spv.vulkan100.subgroupArithmetic.comp",
489         "spv.vulkan100.subgroupPartitioned.comp",
490         "spv.xfb.vert",
491         "spv.xfb2.vert",
492         "spv.xfb3.vert",
493         "spv.samplerlessTextureFunctions.frag",
494         "spv.smBuiltins.vert",
495         "spv.smBuiltins.frag",
496         "spv.ARMCoreBuiltIns.vert",
497         "spv.ARMCoreBuiltIns.frag",
498         "spv.builtin.PrimitiveShadingRateEXT.vert",
499         "spv.builtin.ShadingRateEXT.frag",
500         "spv.atomicAdd.bufferReference.comp",
501         "spv.fragmentShaderBarycentric3.frag",
502         "spv.fragmentShaderBarycentric4.frag",
503     })),
504     FileNameAsCustomTestSuffix
505 );
506
507 // Cases with deliberately unreachable code.
508 // By default the compiler will aggressively eliminate
509 // unreachable merges and continues.
510 INSTANTIATE_TEST_SUITE_P(
511     GlslWithDeadCode, CompileVulkanToSpirvDeadCodeElimTest,
512     ::testing::ValuesIn(std::vector<std::string>({
513         "spv.dead-after-continue.vert",
514         "spv.dead-after-discard.frag",
515         "spv.dead-after-return.vert",
516         "spv.dead-after-loop-break.vert",
517         "spv.dead-after-switch-break.vert",
518         "spv.dead-complex-continue-after-return.vert",
519         "spv.dead-complex-merge-after-return.vert",
520     })),
521     FileNameAsCustomTestSuffix
522 );
523
524 // clang-format off
525 INSTANTIATE_TEST_SUITE_P(
526     Glsl, CompileVulkanToDebugSpirvTest,
527     ::testing::ValuesIn(std::vector<std::string>({
528         "spv.pp.line.frag",
529     })),
530     FileNameAsCustomTestSuffix
531 );
532
533 // clang-format off
534 INSTANTIATE_TEST_SUITE_P(
535     Glsl, CompileVulkan1_1ToSpirvTest,
536     ::testing::ValuesIn(std::vector<std::string>({
537         "spv.1.3.8bitstorage-ubo.vert",
538         "spv.1.3.8bitstorage-ssbo.vert",
539         "spv.1.3.coopmat.comp",
540         "spv.deviceGroup.frag",
541         "spv.drawParams.vert",
542         "spv.int8.frag",
543         "spv.vulkan110.int16.frag",
544         "spv.int32.frag",
545         "spv.explicittypes.frag",
546         "spv.float16NoRelaxed.vert",
547         "spv.float32.frag",
548         "spv.float64.frag",
549         "spv.memoryScopeSemantics.comp",
550         "spv.memoryScopeSemantics_Error.comp",
551         "spv.multiView.frag",
552         "spv.queueFamilyScope.comp",
553         "spv.RayGenShader11.rgen",
554         "spv.subgroup.frag",
555         "spv.subgroup.geom",
556         "spv.subgroup.tesc",
557         "spv.subgroup.tese",
558         "spv.subgroup.vert",
559         "spv.subgroupArithmetic.comp",
560         "spv.subgroupBasic.comp",
561         "spv.subgroupBallot.comp",
562         "spv.subgroupBallotNeg.comp",
563         "spv.subgroupClustered.comp",
564         "spv.subgroupClusteredNeg.comp",
565         "spv.subgroupPartitioned.comp",
566         "spv.subgroupShuffle.comp",
567         "spv.subgroupShuffleRelative.comp",
568         "spv.subgroupQuad.comp",
569         "spv.subgroupVote.comp",
570         "spv.subgroupExtendedTypesArithmetic.comp",
571         "spv.subgroupExtendedTypesArithmeticNeg.comp",
572         "spv.subgroupExtendedTypesBallot.comp",
573         "spv.subgroupExtendedTypesBallotNeg.comp",
574         "spv.subgroupExtendedTypesClustered.comp",
575         "spv.subgroupExtendedTypesClusteredNeg.comp",
576         "spv.subgroupExtendedTypesPartitioned.comp",
577         "spv.subgroupExtendedTypesPartitionedNeg.comp",
578         "spv.subgroupExtendedTypesShuffle.comp",
579         "spv.subgroupExtendedTypesShuffleNeg.comp",
580         "spv.subgroupExtendedTypesShuffleRelative.comp",
581         "spv.subgroupExtendedTypesShuffleRelativeNeg.comp",
582         "spv.subgroupExtendedTypesQuad.comp",
583         "spv.subgroupExtendedTypesQuadNeg.comp",
584         "spv.subgroupExtendedTypesVote.comp",
585         "spv.subgroupExtendedTypesVoteNeg.comp",
586         "spv.vulkan110.storageBuffer.vert",
587     })),
588     FileNameAsCustomTestSuffix
589 );
590
591 // clang-format off
592 INSTANTIATE_TEST_SUITE_P(
593     Glsl, CompileToSpirv14Test,
594     ::testing::ValuesIn(std::vector<std::string>({
595         "spv.1.4.LoopControl.frag",
596         "spv.1.4.NonWritable.frag",
597         "spv.1.4.OpEntryPoint.frag",
598         "spv.1.4.OpEntryPoint.opaqueParams.vert",
599         "spv.1.4.OpSelect.frag",
600         "spv.1.4.OpCopyLogical.comp",
601         "spv.1.4.OpCopyLogicalBool.comp",
602         "spv.1.4.OpCopyLogical.funcall.frag",
603         "spv.1.4.funcall.array.frag",
604         "spv.1.4.load.bool.array.interface.block.frag",
605         "spv.1.4.image.frag",
606         "spv.1.4.sparseTexture.frag",
607         "spv.1.4.texture.frag",
608         "spv.1.4.constructComposite.comp",
609         "spv.ext.AnyHitShader.rahit",
610         "spv.ext.AnyHitShader_Errors.rahit",
611         "spv.ext.ClosestHitShader.rchit",
612         "spv.ext.ClosestHitShader_Subgroup.rchit",
613         "spv.ext.ClosestHitShader_Errors.rchit",
614         "spv.ext.IntersectShader.rint",
615         "spv.ext.IntersectShader_Errors.rint",
616         "spv.ext.MissShader.rmiss",
617         "spv.ext.MissShader_Errors.rmiss",
618         "spv.ext.RayPrimCull_Errors.rgen",
619         "spv.ext.RayCallable.rcall",
620         "spv.ext.RayCallable_Errors.rcall",
621         "spv.ext.RayConstants.rgen",
622         "spv.ext.RayGenShader.rgen",
623         "spv.ext.RayGenShader_Errors.rgen",
624         "spv.ext.RayGenShader11.rgen",
625         "spv.ext.RayGenShaderArray.rgen",
626         "spv.ext.RayGenSBTlayout.rgen",
627         "spv.ext.RayGenSBTlayout140.rgen",
628         "spv.ext.RayGenSBTlayout430.rgen",
629         "spv.ext.RayGenSBTlayoutscalar.rgen",
630         "spv.ext.World3x4.rahit",
631         "spv.ext.AccelDecl.frag",
632         "spv.ext.RayQueryDecl.frag",
633
634         // SPV_KHR_workgroup_memory_explicit_layout depends on SPIR-V 1.4.
635         "spv.WorkgroupMemoryExplicitLayout.SingleBlock.comp",
636         "spv.WorkgroupMemoryExplicitLayout.MultiBlock.comp",
637         "spv.WorkgroupMemoryExplicitLayout.8BitAccess.comp",
638         "spv.WorkgroupMemoryExplicitLayout.16BitAccess.comp",
639         "spv.WorkgroupMemoryExplicitLayout.NonBlock.comp",
640         "spv.WorkgroupMemoryExplicitLayout.MixBlockNonBlock_Errors.comp",
641         "spv.WorkgroupMemoryExplicitLayout.std140.comp",
642         "spv.WorkgroupMemoryExplicitLayout.std430.comp",
643         "spv.WorkgroupMemoryExplicitLayout.scalar.comp",
644
645         // SPV_EXT_mesh_shader
646         "spv.ext.meshShaderBuiltins.mesh",
647         "spv.ext.meshShaderRedeclBuiltins.mesh",
648         "spv.ext.meshShaderTaskMem.mesh",
649         "spv.ext.meshShaderUserDefined.mesh",
650         "spv.ext.meshTaskShader.task",
651         "spv.atomiAddEXT.error.mesh",
652         "spv.atomiAddEXT.task",
653         "spv.460.subgroupEXT.task",
654         "spv.460.subgroupEXT.mesh",
655
656         // SPV_NV_shader_execution_reorder
657
658         "spv.nv.hitobject-allops.rgen",
659         "spv.nv.hitobject-allops.rchit",
660         "spv.nv.hitobject-allops.rmiss",
661     })),
662     FileNameAsCustomTestSuffix
663 );
664
665 // clang-format off
666 INSTANTIATE_TEST_SUITE_P(
667     Glsl, CompileToSpirv16Test,
668     ::testing::ValuesIn(std::vector<std::string>({
669         "spv.1.6.conditionalDiscard.frag",
670         "spv.1.6.helperInvocation.frag",
671         "spv.1.6.helperInvocation.memmodel.frag",
672         "spv.1.6.specConstant.comp",
673         "spv.1.6.samplerBuffer.frag",
674         "spv.1.6.separate.frag",
675     })),
676     FileNameAsCustomTestSuffix
677 );
678
679
680 // clang-format off
681 INSTANTIATE_TEST_SUITE_P(
682     Hlsl, HlslIoMap,
683     ::testing::ValuesIn(std::vector<IoMapData>{
684         { "spv.register.autoassign.frag", "main_ep", 5, 10, 0, 20, 30, true, false },
685         { "spv.register.noautoassign.frag", "main_ep", 5, 10, 0, 15, 30, false, false },
686         { "spv.register.autoassign-2.frag", "main", 5, 10, 0, 15, 30, true, true },
687         { "spv.register.subpass.frag", "main", 0, 20, 0, 0, 0, true, true },
688         { "spv.buffer.autoassign.frag", "main", 5, 10, 0, 15, 30, true, true },
689         { "spv.ssbo.autoassign.frag", "main", 5, 10, 0, 15, 30, true, true },
690         { "spv.ssboAlias.frag", "main", 0, 0, 0, 0, 83, true, false },
691         { "spv.rw.autoassign.frag", "main", 5, 10, 20, 15, 30, true, true },
692         { "spv.register.autoassign.rangetest.frag", "main",
693                 glslang::TQualifier::layoutBindingEnd-2,
694                 glslang::TQualifier::layoutBindingEnd+5,
695                 20, 30, true, false },
696     }),
697     FileNameAsCustomTestSuffixIoMap
698 );
699
700 // clang-format off
701 INSTANTIATE_TEST_SUITE_P(
702     Hlsl, GlslIoMap,
703     ::testing::ValuesIn(std::vector<IoMapData>{
704         { "spv.glsl.register.autoassign.frag", "main", 5, 10, 0, 20, 30, true, false },
705         { "spv.glsl.register.noautoassign.frag", "main", 5, 10, 0, 15, 30, false, false },
706     }),
707     FileNameAsCustomTestSuffixIoMap
708 );
709
710 // clang-format off
711 INSTANTIATE_TEST_SUITE_P(
712     Glsl, CompileOpenGLToSpirvTest,
713     ::testing::ValuesIn(std::vector<std::string>({
714         "spv.460.frag",
715         "spv.460.vert",
716         "spv.460.comp",
717         "spv.atomic.comp",
718         "spv.atomicFloat.comp",
719         "spv.atomicFloat_Error.comp",
720         "spv.glFragColor.frag",
721         "spv.rankShift.comp",
722         "spv.specConst.vert",
723         "spv.specTexture.frag",
724         "spv.OVR_multiview.vert",
725         "spv.uniformInitializer.frag",
726         "spv.uniformInitializerSpecConstant.frag",
727         "spv.uniformInitializerStruct.frag",
728         "spv.xfbOffsetOnBlockMembersAssignment.vert",
729         "spv.xfbOffsetOnStructMembersAssignment.vert",
730         "spv.xfbOverlapOffsetCheckWithBlockAndMember.vert",
731         "spv.xfbStrideJustOnce.vert",
732     })),
733     FileNameAsCustomTestSuffix
734 );
735
736 INSTANTIATE_TEST_SUITE_P(
737     Glsl, VulkanSemantics,
738     ::testing::ValuesIn(std::vector<std::string>({
739         "vulkan.frag",
740         "vulkan.vert",
741         "vulkan.comp",
742         "samplerlessTextureFunctions.frag",
743         "spv.specConstArrayCheck.vert",
744     })),
745     FileNameAsCustomTestSuffix
746 );
747
748 INSTANTIATE_TEST_SUITE_P(
749     Glsl, OpenGLSemantics,
750     ::testing::ValuesIn(std::vector<std::string>({
751         "glspv.esversion.vert",
752         "glspv.version.frag",
753         "glspv.version.vert",
754         "glspv.frag",
755         "glspv.vert",
756     })),
757     FileNameAsCustomTestSuffix
758 );
759
760 INSTANTIATE_TEST_SUITE_P(
761     Glsl, VulkanAstSemantics,
762     ::testing::ValuesIn(std::vector<std::string>({
763         "vulkan.ast.vert",
764     })),
765     FileNameAsCustomTestSuffix
766 );
767
768 INSTANTIATE_TEST_SUITE_P(
769     Glsl, CompileVulkanToSpirvTestAMD,
770     ::testing::ValuesIn(std::vector<std::string>({
771         "spv.16bitxfb.vert",
772         "spv.float16.frag",
773         "spv.float16Fetch.frag",
774         "spv.imageLoadStoreLod.frag",
775         "spv.int16.frag",
776         "spv.int16.amd.frag",
777         "spv.shaderBallotAMD.comp",
778         "spv.shaderFragMaskAMD.frag",
779         "spv.textureGatherBiasLod.frag",
780     })),
781     FileNameAsCustomTestSuffix
782 );
783
784 INSTANTIATE_TEST_SUITE_P(
785     Glsl, CompileVulkanToSpirvTestNV,
786     ::testing::ValuesIn(std::vector<std::string>({
787     "spv.sampleMaskOverrideCoverage.frag",
788     "spv.GeometryShaderPassthrough.geom",
789     "spv.viewportArray2.vert",
790     "spv.viewportArray2.tesc",
791     "spv.stereoViewRendering.vert",
792     "spv.stereoViewRendering.tesc",
793     "spv.multiviewPerViewAttributes.vert",
794     "spv.multiviewPerViewAttributes.tesc",
795     "spv.atomicInt64.comp",
796     "spv.atomicStoreInt64.comp",
797     "spv.shadingRate.frag",
798     "spv.RayGenShader.rgen",
799     "spv.RayGenShaderArray.rgen",
800     "spv.RayGenShader_Errors.rgen",
801     "spv.RayConstants.rgen",
802     "spv.IntersectShader.rint",
803     "spv.IntersectShader_Errors.rint",
804     "spv.AnyHitShader.rahit",
805     "spv.AnyHitShader_Errors.rahit",
806     "spv.ClosestHitShader.rchit",
807     "spv.ClosestHitShader_Errors.rchit",
808     "spv.MissShader.rmiss",
809     "spv.MissShader_Errors.rmiss",
810     "spv.RayCallable.rcall",
811     "spv.RayCallable_Errors.rcall",
812     "spv.fragmentShaderBarycentric.frag",
813     "spv.fragmentShaderBarycentric2.frag",
814     "spv.computeShaderDerivatives.comp",
815     "spv.computeShaderDerivatives2.comp",
816     "spv.shaderImageFootprint.frag",
817     "spv.meshShaderBuiltins.mesh",
818     "spv.meshShaderUserDefined.mesh",
819     "spv.meshShaderPerViewBuiltins.mesh",
820     "spv.meshShaderPerViewUserDefined.mesh",
821     "spv.meshShaderPerView_Errors.mesh",
822     "spv.meshShaderSharedMem.mesh",
823     "spv.meshShaderTaskMem.mesh",
824     "spv.320.meshShaderUserDefined.mesh",
825     "spv.meshShaderRedeclBuiltins.mesh",
826     "spv.meshShaderRedeclPerViewBuiltins.mesh",
827     "spv.meshTaskShader.task",
828     "spv.perprimitiveNV.frag",
829 })),
830 FileNameAsCustomTestSuffix
831 );
832
833 INSTANTIATE_TEST_SUITE_P(
834     Glsl, CompileVulkanToSpirv14TestNV,
835     ::testing::ValuesIn(std::vector<std::string>({
836     "spv.RayGenShaderMotion.rgen",
837     "spv.IntersectShaderMotion.rint",
838     "spv.AnyHitShaderMotion.rahit",
839     "spv.ClosestHitShaderMotion.rchit",
840     "spv.MissShaderMotion.rmiss",
841 })),
842 FileNameAsCustomTestSuffix
843 );
844
845 INSTANTIATE_TEST_SUITE_P(
846     Glsl, CompileUpgradeTextureToSampledTextureAndDropSamplersTest,
847     ::testing::ValuesIn(std::vector<std::string>({
848       "spv.texture.sampler.transform.frag",
849     })),
850     FileNameAsCustomTestSuffix
851 );
852
853 INSTANTIATE_TEST_SUITE_P(
854     Glsl, CompileVulkanToNonSemanticShaderDebugInfoTest,
855     ::testing::ValuesIn(std::vector<std::string>({
856         "spv.debuginfo.glsl.vert",
857         "spv.debuginfo.glsl.frag",
858         "spv.debuginfo.glsl.comp",
859         "spv.debuginfo.glsl.geom",
860         "spv.debuginfo.glsl.tesc",
861         "spv.debuginfo.glsl.tese",
862         "spv.debuginfo.const_params.glsl.comp"
863     })),
864     FileNameAsCustomTestSuffix
865 );
866 // clang-format on
867
868 }  // anonymous namespace
869 }  // namespace glslangtest