Merge pull request #2829 from amdrexu/bugfix2
[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 CompileOpenGLToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
73 using VulkanSemantics = GlslangTest<::testing::TestWithParam<std::string>>;
74 using OpenGLSemantics = GlslangTest<::testing::TestWithParam<std::string>>;
75 using VulkanAstSemantics = GlslangTest<::testing::TestWithParam<std::string>>;
76 using HlslIoMap = GlslangTest<::testing::TestWithParam<IoMapData>>;
77 using GlslIoMap = GlslangTest<::testing::TestWithParam<IoMapData>>;
78 using CompileVulkanToSpirvTestAMD = GlslangTest<::testing::TestWithParam<std::string>>;
79 using CompileVulkanToSpirvTestNV = GlslangTest<::testing::TestWithParam<std::string>>;
80 using CompileVulkanToSpirv14TestNV = GlslangTest<::testing::TestWithParam<std::string>>;
81 using CompileUpgradeTextureToSampledTextureAndDropSamplersTest = GlslangTest<::testing::TestWithParam<std::string>>;
82
83 // Compiling GLSL to SPIR-V under Vulkan semantics. Expected to successfully
84 // generate SPIR-V.
85 TEST_P(CompileVulkanToSpirvTest, FromFile)
86 {
87     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
88                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
89                             Target::Spv);
90 }
91
92 TEST_P(CompileVulkanToSpirvDeadCodeElimTest, FromFile)
93 {
94     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
95                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
96                             Target::Spv);
97 }
98
99 // Compiling GLSL to SPIR-V with debug info under Vulkan semantics. Expected
100 // to successfully generate SPIR-V.
101 TEST_P(CompileVulkanToDebugSpirvTest, FromFile)
102 {
103     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
104                             Source::GLSL, Semantics::Vulkan,
105                             glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
106                             Target::Spv, true, "",
107                             "/baseResults/", false, true);
108 }
109
110
111 TEST_P(CompileVulkan1_1ToSpirvTest, FromFile)
112 {
113     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
114                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_1, glslang::EShTargetSpv_1_3,
115                             Target::Spv);
116 }
117
118 TEST_P(CompileToSpirv14Test, FromFile)
119 {
120     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
121                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_1, glslang::EShTargetSpv_1_4,
122                             Target::Spv);
123 }
124
125 // Compiling GLSL to SPIR-V under OpenGL semantics. Expected to successfully
126 // generate SPIR-V.
127 TEST_P(CompileOpenGLToSpirvTest, FromFile)
128 {
129     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
130                             Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
131                             Target::Spv);
132 }
133
134 // GLSL-level Vulkan semantics test. Expected to error out before generating
135 // SPIR-V.
136 TEST_P(VulkanSemantics, FromFile)
137 {
138     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
139                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
140                             Target::Spv, false);
141 }
142
143 // GLSL-level Vulkan semantics test. Expected to error out before generating
144 // SPIR-V.
145 TEST_P(OpenGLSemantics, FromFile)
146 {
147     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
148                             Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
149                             Target::Spv, false);
150 }
151
152 // GLSL-level Vulkan semantics test that need to see the AST for validation.
153 TEST_P(VulkanAstSemantics, FromFile)
154 {
155     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
156                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
157                             Target::AST);
158 }
159
160 // HLSL-level Vulkan semantics tests.
161 TEST_P(HlslIoMap, FromFile)
162 {
163     loadFileCompileIoMapAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
164                                  Source::HLSL, Semantics::Vulkan,
165                                  Target::Spv, GetParam().entryPoint,
166                                  GetParam().baseSamplerBinding,
167                                  GetParam().baseTextureBinding,
168                                  GetParam().baseImageBinding,
169                                  GetParam().baseUboBinding,
170                                  GetParam().baseSsboBinding,
171                                  GetParam().autoMapBindings,
172                                  GetParam().flattenUniforms);
173 }
174
175 // GLSL-level Vulkan semantics tests.
176 TEST_P(GlslIoMap, FromFile)
177 {
178     loadFileCompileIoMapAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
179                                  Source::GLSL, Semantics::Vulkan,
180                                  Target::Spv, GetParam().entryPoint,
181                                  GetParam().baseSamplerBinding,
182                                  GetParam().baseTextureBinding,
183                                  GetParam().baseImageBinding,
184                                  GetParam().baseUboBinding,
185                                  GetParam().baseSsboBinding,
186                                  GetParam().autoMapBindings,
187                                  GetParam().flattenUniforms);
188 }
189
190 // Compiling GLSL to SPIR-V under Vulkan semantics (AMD extensions enabled).
191 // Expected to successfully generate SPIR-V.
192 TEST_P(CompileVulkanToSpirvTestAMD, FromFile)
193 {
194     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
195                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_0, glslang::EShTargetSpv_1_0,
196                             Target::Spv);
197 }
198
199 // Compiling GLSL to SPIR-V under Vulkan semantics (NV extensions enabled).
200 // Expected to successfully generate SPIR-V.
201 TEST_P(CompileVulkanToSpirvTestNV, 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 TEST_P(CompileVulkanToSpirv14TestNV, FromFile)
209 {
210     loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
211                             Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_1, glslang::EShTargetSpv_1_4,
212                             Target::Spv);
213 }
214
215 TEST_P(CompileUpgradeTextureToSampledTextureAndDropSamplersTest, FromFile)
216 {
217     loadCompileUpgradeTextureToSampledTextureAndDropSamplersAndCheck(GlobalTestSettings.testRoot,
218                                                                      GetParam(),
219                                                                      Source::GLSL,
220                                                                      Semantics::Vulkan,
221                                                                      Target::Spv);
222 }
223
224 // clang-format off
225 INSTANTIATE_TEST_SUITE_P(
226     Glsl, CompileVulkanToSpirvTest,
227     ::testing::ValuesIn(std::vector<std::string>({
228         // Test looping constructs.
229         // No tests yet for making sure break and continue from a nested loop
230         // goes to the innermost target.
231         "spv.barrier.vert",
232         "spv.do-simple.vert",
233         "spv.do-while-continue-break.vert",
234         "spv.for-complex-condition.vert",
235         "spv.for-continue-break.vert",
236         "spv.for-simple.vert",
237         "spv.for-notest.vert",
238         "spv.for-nobody.vert",
239         "spv.while-continue-break.vert",
240         "spv.while-simple.vert",
241         // vulkan-specific tests
242         "rayQuery.rgen",
243         "rayQuery-no-cse.rgen",
244         "rayQuery-initialize.rgen",
245         "rayQuery-allOps.rgen",
246         "rayQuery-allOps.Error.rgen",
247         "rayQuery-committed.Error.rgen",
248         "rayQuery-allOps.comp",
249         "rayQuery-allOps.frag",
250         "rayQuery-initialization.Error.comp",
251         "rayQuery-global.rgen",
252         "rayQuery-types.comp",
253         "spv.set.vert",
254         "spv.double.comp",
255         "spv.100ops.frag",
256         "spv.130.frag",
257         "spv.140.frag",
258         "spv.150.geom",
259         "spv.150.vert",
260         "spv.16bitstorage.frag",
261         "spv.16bitstorage_Error.frag",
262         "spv.16bitstorage-int.frag",
263         "spv.16bitstorage_Error-int.frag",
264         "spv.16bitstorage-uint.frag",
265         "spv.16bitstorage_Error-uint.frag",
266         "spv.300BuiltIns.vert",
267         "spv.300layout.frag",
268         "spv.300layout.vert",
269         "spv.300layoutp.vert",
270         "spv.310.comp",
271         "spv.310.bitcast.frag",
272         "spv.330.geom",
273         "spv.400.frag",
274         "spv.400.tesc",
275         "spv.400.tese",
276         "spv.420.geom",
277         "spv.430.frag",
278         "spv.430.vert",
279         "spv.450.tesc",
280         "spv.450.geom",
281         "spv.450.noRedecl.tesc",
282         "spv.8bitstorage-int.frag",
283         "spv.8bitstorage_Error-int.frag",
284         "spv.8bitstorage-uint.frag",
285         "spv.8bitstorage_Error-uint.frag",
286         "spv.8bitstorage-ubo.vert",
287         "spv.8bitstorage-ssbo.vert",
288         "spv.8bit-16bit-construction.frag",
289         "spv.accessChain.frag",
290         "spv.aggOps.frag",
291         "spv.always-discard.frag",
292         "spv.always-discard2.frag",
293         "spv.arbPostDepthCoverage.frag",
294         "spv.arbPostDepthCoverage_Error.frag",
295         "spv.atomicCounter.comp",
296         "spv.bitCast.frag",
297         "spv.bool.vert",
298         "spv.boolInBlock.frag",
299         "spv.branch-return.vert",
300         "spv.bufferhandle1.frag",
301         "spv.bufferhandle10.frag",
302         "spv.bufferhandle11.frag",
303         "spv.bufferhandle12.frag",
304         "spv.bufferhandle13.frag",
305         "spv.bufferhandle14.frag",
306         "spv.bufferhandle15.frag",
307         "spv.bufferhandle16.frag",
308         "spv.bufferhandle17_Errors.frag",
309         "spv.bufferhandle18.frag",
310         "spv.bufferhandle19_Errors.frag",
311         "spv.bufferhandle2.frag",
312         "spv.bufferhandle3.frag",
313         "spv.bufferhandle4.frag",
314         "spv.bufferhandle5.frag",
315         "spv.bufferhandle6.frag",
316         "spv.bufferhandle7.frag",
317         "spv.bufferhandle8.frag",
318         "spv.bufferhandle9.frag",
319         "spv.bufferhandleUvec2.frag",
320         "spv.bufferhandle_Error.frag",
321         "spv.builtInXFB.vert",
322         "spv.conditionalDemote.frag",
323         "spv.conditionalDiscard.frag",
324         "spv.constructComposite.comp",
325         "spv.constStruct.vert",
326         "spv.constConstruct.vert",
327         "spv.controlFlowAttributes.frag",
328         "spv.conversion.frag",
329         "spv.coopmat.comp",
330         "spv.coopmat_Error.comp",
331         "spv.dataOut.frag",
332         "spv.dataOutIndirect.frag",
333         "spv.dataOutIndirect.vert",
334         "spv.debugPrintf.frag",
335         "spv.debugPrintf_Error.frag",
336         "spv.demoteDisabled.frag",
337         "spv.deepRvalue.frag",
338         "spv.depthOut.frag",
339         "spv.depthUnchanged.frag",
340         "spv.discard-dce.frag",
341         "spv.doWhileLoop.frag",
342         "spv.earlyReturnDiscard.frag",
343         "spv.extPostDepthCoverage.frag",
344         "spv.extPostDepthCoverage_Error.frag",
345         "spv.float16convertonlyarith.comp",
346         "spv.float16convertonlystorage.comp",
347         "spv.flowControl.frag",
348         "spv.forLoop.frag",
349         "spv.forwardFun.frag",
350         "spv.fragmentDensity.frag",
351         "spv.fragmentDensity.vert",
352         "spv.fragmentDensity-es.frag",
353         "spv.fragmentDensity-neg.frag",
354         "spv.fsi.frag",
355         "spv.fsi_Error.frag",
356         "spv.fullyCovered.frag",
357         "spv.functionCall.frag",
358         "spv.functionNestedOpaque.vert",
359         "spv.functionSemantics.frag",
360         "spv.functionParameterTypes.frag",
361         "spv.GeometryShaderPassthrough.geom",
362         "spv.funcall.array.frag",
363         "spv.load.bool.array.interface.block.frag",
364         "spv.interpOps.frag",
365         "spv.int64.frag",
366         "spv.intcoopmat.comp",
367         "spv.intOps.vert",
368         "spv.intrinsicsSpirvByReference.vert",
369         "spv.intrinsicsSpirvDecorate.frag",
370         "spv.intrinsicsSpirvExecutionMode.frag",
371         "spv.intrinsicsSpirvInstruction.vert",
372         "spv.intrinsicsSpirvLiteral.vert",
373         "spv.intrinsicsSpirvStorageClass.rchit",
374         "spv.intrinsicsSpirvType.rgen",
375         "spv.intrinsicsSpirvTypeLocalVar.vert",
376         "spv.invariantAll.vert",
377         "spv.layer.tese",
378         "spv.layoutNested.vert",
379         "spv.length.frag",
380         "spv.localAggregates.frag",
381         "spv.loops.frag",
382         "spv.loopsArtificial.frag",
383         "spv.matFun.vert",
384         "spv.matrix.frag",
385         "spv.matrix2.frag",
386         "spv.memoryQualifier.frag",
387         "spv.merge-unreachable.frag",
388         "spv.multiStruct.comp",
389         "spv.multiStructFuncall.frag",
390         "spv.newTexture.frag",
391         "spv.noDeadDecorations.vert",
392         "spv.nonSquare.vert",
393         "spv.nonuniform.frag",
394         "spv.nonuniform2.frag",
395         "spv.nonuniform3.frag",
396         "spv.nonuniform4.frag",
397         "spv.nonuniform5.frag",
398         "spv.noWorkgroup.comp",
399         "spv.nullInit.comp",
400         "spv.offsets.frag",
401         "spv.Operations.frag",
402         "spv.paramMemory.frag",
403         "spv.paramMemory.420.frag",
404         "spv.precision.frag",
405         "spv.precisionArgs.frag",
406         "spv.precisionNonESSamp.frag",
407         "spv.precisionTexture.frag",
408         "spv.prepost.frag",
409         "spv.privateVariableTypes.frag",
410         "spv.qualifiers.vert",
411         "spv.sample.frag",
412         "spv.sampleId.frag",
413         "spv.samplePosition.frag",
414         "spv.sampleMaskOverrideCoverage.frag",
415         "spv.scalarlayout.frag",
416         "spv.scalarlayoutfloat16.frag",
417         "spv.shaderBallot.comp",
418         "spv.shaderDrawParams.vert",
419         "spv.shaderGroupVote.comp",
420         "spv.shaderStencilExport.frag",
421         "spv.shiftOps.frag",
422         "spv.simpleFunctionCall.frag",
423         "spv.simpleMat.vert",
424         "spv.sparseTexture.frag",
425         "spv.sparseTextureClamp.frag",
426         "spv.structAssignment.frag",
427         "spv.structDeref.frag",
428         "spv.structure.frag",
429         "spv.switch.frag",
430         "spv.swizzle.frag",
431         "spv.swizzleInversion.frag",
432         "spv.test.frag",
433         "spv.test.vert",
434         "spv.texture.frag",
435         "spv.texture.vert",
436         "spv.textureBuffer.vert",
437         "spv.image.frag",
438         "spv.imageAtomic64.frag",
439         "spv.types.frag",
440         "spv.uint.frag",
441         "spv.uniformArray.frag",
442         "spv.variableArrayIndex.frag",
443         "spv.varyingArray.frag",
444         "spv.varyingArrayIndirect.frag",
445         "spv.vecMatConstruct.frag",
446         "spv.voidFunction.frag",
447         "spv.whileLoop.frag",
448         "spv.AofA.frag",
449         "spv.queryL.frag",
450         "spv.separate.frag",
451         "spv.shortCircuit.frag",
452         "spv.pushConstant.vert",
453         "spv.pushConstantAnon.vert",
454         "spv.subpass.frag",
455         "spv.specConstant.vert",
456         "spv.specConstant.comp",
457         "spv.specConstantComposite.vert",
458         "spv.specConstantOperations.vert",
459         "spv.specConstant.float16.comp",
460         "spv.specConstant.int16.comp",
461         "spv.specConstant.int8.comp",
462         "spv.storageBuffer.vert",
463         "spv.terminate.frag",
464         "spv.subgroupUniformControlFlow.vert",
465         "spv.precise.tese",
466         "spv.precise.tesc",
467         "spv.viewportindex.tese",
468         "spv.volatileAtomic.comp",
469         "spv.vulkan100.subgroupArithmetic.comp",
470         "spv.vulkan100.subgroupPartitioned.comp",
471         "spv.xfb.vert",
472         "spv.xfb2.vert",
473         "spv.xfb3.vert",
474         "spv.samplerlessTextureFunctions.frag",
475         "spv.smBuiltins.vert",
476         "spv.smBuiltins.frag",
477         "spv.builtin.PrimitiveShadingRateEXT.vert",
478         "spv.builtin.ShadingRateEXT.frag",
479         "spv.atomicAdd.bufferReference.comp"
480     })),
481     FileNameAsCustomTestSuffix
482 );
483
484 // Cases with deliberately unreachable code.
485 // By default the compiler will aggressively eliminate
486 // unreachable merges and continues.
487 INSTANTIATE_TEST_SUITE_P(
488     GlslWithDeadCode, CompileVulkanToSpirvDeadCodeElimTest,
489     ::testing::ValuesIn(std::vector<std::string>({
490         "spv.dead-after-continue.vert",
491         "spv.dead-after-discard.frag",
492         "spv.dead-after-return.vert",
493         "spv.dead-after-loop-break.vert",
494         "spv.dead-after-switch-break.vert",
495         "spv.dead-complex-continue-after-return.vert",
496         "spv.dead-complex-merge-after-return.vert",
497     })),
498     FileNameAsCustomTestSuffix
499 );
500
501 // clang-format off
502 INSTANTIATE_TEST_SUITE_P(
503     Glsl, CompileVulkanToDebugSpirvTest,
504     ::testing::ValuesIn(std::vector<std::string>({
505         "spv.pp.line.frag",
506     })),
507     FileNameAsCustomTestSuffix
508 );
509
510 // clang-format off
511 INSTANTIATE_TEST_SUITE_P(
512     Glsl, CompileVulkan1_1ToSpirvTest,
513     ::testing::ValuesIn(std::vector<std::string>({
514         "spv.1.3.8bitstorage-ubo.vert",
515         "spv.1.3.8bitstorage-ssbo.vert",
516         "spv.1.3.coopmat.comp",
517         "spv.deviceGroup.frag",
518         "spv.drawParams.vert",
519         "spv.int8.frag",
520         "spv.vulkan110.int16.frag",
521         "spv.int32.frag",
522         "spv.explicittypes.frag",
523         "spv.float32.frag",
524         "spv.float64.frag",
525         "spv.memoryScopeSemantics.comp",
526         "spv.memoryScopeSemantics_Error.comp",
527         "spv.multiView.frag",
528         "spv.queueFamilyScope.comp",
529         "spv.RayGenShader11.rgen",
530         "spv.subgroup.frag",
531         "spv.subgroup.geom",
532         "spv.subgroup.tesc",
533         "spv.subgroup.tese",
534         "spv.subgroup.vert",
535         "spv.subgroupArithmetic.comp",
536         "spv.subgroupBasic.comp",
537         "spv.subgroupBallot.comp",
538         "spv.subgroupBallotNeg.comp",
539         "spv.subgroupClustered.comp",
540         "spv.subgroupClusteredNeg.comp",
541         "spv.subgroupPartitioned.comp",
542         "spv.subgroupShuffle.comp",
543         "spv.subgroupShuffleRelative.comp",
544         "spv.subgroupQuad.comp",
545         "spv.subgroupVote.comp",
546         "spv.subgroupExtendedTypesArithmetic.comp",
547         "spv.subgroupExtendedTypesArithmeticNeg.comp",
548         "spv.subgroupExtendedTypesBallot.comp",
549         "spv.subgroupExtendedTypesBallotNeg.comp",
550         "spv.subgroupExtendedTypesClustered.comp",
551         "spv.subgroupExtendedTypesClusteredNeg.comp",
552         "spv.subgroupExtendedTypesPartitioned.comp",
553         "spv.subgroupExtendedTypesPartitionedNeg.comp",
554         "spv.subgroupExtendedTypesShuffle.comp",
555         "spv.subgroupExtendedTypesShuffleNeg.comp",
556         "spv.subgroupExtendedTypesShuffleRelative.comp",
557         "spv.subgroupExtendedTypesShuffleRelativeNeg.comp",
558         "spv.subgroupExtendedTypesQuad.comp",
559         "spv.subgroupExtendedTypesQuadNeg.comp",
560         "spv.subgroupExtendedTypesVote.comp",
561         "spv.subgroupExtendedTypesVoteNeg.comp",
562         "spv.vulkan110.storageBuffer.vert",
563     })),
564     FileNameAsCustomTestSuffix
565 );
566
567 // clang-format off
568 INSTANTIATE_TEST_SUITE_P(
569     Glsl, CompileToSpirv14Test,
570     ::testing::ValuesIn(std::vector<std::string>({
571         "spv.1.4.LoopControl.frag",
572         "spv.1.4.NonWritable.frag",
573         "spv.1.4.OpEntryPoint.frag",
574         "spv.1.4.OpEntryPoint.opaqueParams.vert",
575         "spv.1.4.OpSelect.frag",
576         "spv.1.4.OpCopyLogical.comp",
577         "spv.1.4.OpCopyLogicalBool.comp",
578         "spv.1.4.OpCopyLogical.funcall.frag",
579         "spv.1.4.funcall.array.frag",
580         "spv.1.4.load.bool.array.interface.block.frag",
581         "spv.1.4.image.frag",
582         "spv.1.4.sparseTexture.frag",
583         "spv.1.4.texture.frag",
584         "spv.1.4.constructComposite.comp",
585         "spv.ext.AnyHitShader.rahit",
586         "spv.ext.AnyHitShader_Errors.rahit",
587         "spv.ext.ClosestHitShader.rchit",
588         "spv.ext.ClosestHitShader_Subgroup.rchit",
589         "spv.ext.ClosestHitShader_Errors.rchit",
590         "spv.ext.IntersectShader.rint",
591         "spv.ext.IntersectShader_Errors.rint",
592         "spv.ext.MissShader.rmiss",
593         "spv.ext.MissShader_Errors.rmiss",
594         "spv.ext.RayPrimCull_Errors.rgen",
595         "spv.ext.RayCallable.rcall",
596         "spv.ext.RayCallable_Errors.rcall",
597         "spv.ext.RayConstants.rgen",
598         "spv.ext.RayGenShader.rgen",
599         "spv.ext.RayGenShader_Errors.rgen",
600         "spv.ext.RayGenShader11.rgen",
601         "spv.ext.RayGenShaderArray.rgen",
602         "spv.ext.RayGenSBTlayout.rgen",
603         "spv.ext.RayGenSBTlayout140.rgen",
604         "spv.ext.RayGenSBTlayout430.rgen",
605         "spv.ext.RayGenSBTlayoutscalar.rgen",
606         "spv.ext.World3x4.rahit",
607         "spv.ext.AccelDecl.frag",
608         "spv.ext.RayQueryDecl.frag",
609
610         // SPV_KHR_workgroup_memory_explicit_layout depends on SPIR-V 1.4.
611         "spv.WorkgroupMemoryExplicitLayout.SingleBlock.comp",
612         "spv.WorkgroupMemoryExplicitLayout.MultiBlock.comp",
613         "spv.WorkgroupMemoryExplicitLayout.8BitAccess.comp",
614         "spv.WorkgroupMemoryExplicitLayout.16BitAccess.comp",
615         "spv.WorkgroupMemoryExplicitLayout.NonBlock.comp",
616         "spv.WorkgroupMemoryExplicitLayout.MixBlockNonBlock_Errors.comp",
617         "spv.WorkgroupMemoryExplicitLayout.std140.comp",
618         "spv.WorkgroupMemoryExplicitLayout.std430.comp",
619         "spv.WorkgroupMemoryExplicitLayout.scalar.comp",
620     })),
621     FileNameAsCustomTestSuffix
622 );
623
624 // clang-format off
625 INSTANTIATE_TEST_SUITE_P(
626     Hlsl, HlslIoMap,
627     ::testing::ValuesIn(std::vector<IoMapData>{
628         { "spv.register.autoassign.frag", "main_ep", 5, 10, 0, 20, 30, true, false },
629         { "spv.register.noautoassign.frag", "main_ep", 5, 10, 0, 15, 30, false, false },
630         { "spv.register.autoassign-2.frag", "main", 5, 10, 0, 15, 30, true, true },
631         { "spv.register.subpass.frag", "main", 0, 20, 0, 0, 0, true, true },
632         { "spv.buffer.autoassign.frag", "main", 5, 10, 0, 15, 30, true, true },
633         { "spv.ssbo.autoassign.frag", "main", 5, 10, 0, 15, 30, true, true },
634         { "spv.ssboAlias.frag", "main", 0, 0, 0, 0, 83, true, false },
635         { "spv.rw.autoassign.frag", "main", 5, 10, 20, 15, 30, true, true },
636         { "spv.register.autoassign.rangetest.frag", "main",
637                 glslang::TQualifier::layoutBindingEnd-2,
638                 glslang::TQualifier::layoutBindingEnd+5,
639                 20, 30, true, false },
640     }),
641     FileNameAsCustomTestSuffixIoMap
642 );
643
644 // clang-format off
645 INSTANTIATE_TEST_SUITE_P(
646     Hlsl, GlslIoMap,
647     ::testing::ValuesIn(std::vector<IoMapData>{
648         { "spv.glsl.register.autoassign.frag", "main", 5, 10, 0, 20, 30, true, false },
649         { "spv.glsl.register.noautoassign.frag", "main", 5, 10, 0, 15, 30, false, false },
650     }),
651     FileNameAsCustomTestSuffixIoMap
652 );
653
654 // clang-format off
655 INSTANTIATE_TEST_SUITE_P(
656     Glsl, CompileOpenGLToSpirvTest,
657     ::testing::ValuesIn(std::vector<std::string>({
658         "spv.460.frag",
659         "spv.460.vert",
660         "spv.460.comp",
661         "spv.atomic.comp",
662         "spv.atomicFloat.comp",
663         "spv.atomicFloat_Error.comp",
664         "spv.glFragColor.frag",
665         "spv.rankShift.comp",
666         "spv.specConst.vert",
667         "spv.specTexture.frag",
668         "spv.OVR_multiview.vert",
669         "spv.uniformInitializer.frag",
670         "spv.uniformInitializerSpecConstant.frag",
671         "spv.uniformInitializerStruct.frag",
672         "spv.xfbOffsetOnBlockMembersAssignment.vert",
673         "spv.xfbOffsetOnStructMembersAssignment.vert",
674         "spv.xfbOverlapOffsetCheckWithBlockAndMember.vert",
675         "spv.xfbStrideJustOnce.vert",
676     })),
677     FileNameAsCustomTestSuffix
678 );
679
680 INSTANTIATE_TEST_SUITE_P(
681     Glsl, VulkanSemantics,
682     ::testing::ValuesIn(std::vector<std::string>({
683         "vulkan.frag",
684         "vulkan.vert",
685         "vulkan.comp",
686         "samplerlessTextureFunctions.frag",
687         "spv.specConstArrayCheck.vert",
688     })),
689     FileNameAsCustomTestSuffix
690 );
691
692 INSTANTIATE_TEST_SUITE_P(
693     Glsl, OpenGLSemantics,
694     ::testing::ValuesIn(std::vector<std::string>({
695         "glspv.esversion.vert",
696         "glspv.version.frag",
697         "glspv.version.vert",
698         "glspv.frag",
699         "glspv.vert",
700     })),
701     FileNameAsCustomTestSuffix
702 );
703
704 INSTANTIATE_TEST_SUITE_P(
705     Glsl, VulkanAstSemantics,
706     ::testing::ValuesIn(std::vector<std::string>({
707         "vulkan.ast.vert",
708     })),
709     FileNameAsCustomTestSuffix
710 );
711
712 INSTANTIATE_TEST_SUITE_P(
713     Glsl, CompileVulkanToSpirvTestAMD,
714     ::testing::ValuesIn(std::vector<std::string>({
715         "spv.16bitxfb.vert",
716         "spv.float16.frag",
717         "spv.float16Fetch.frag",
718         "spv.imageLoadStoreLod.frag",
719         "spv.int16.frag",
720         "spv.int16.amd.frag",
721         "spv.shaderBallotAMD.comp",
722         "spv.shaderFragMaskAMD.frag",
723         "spv.textureGatherBiasLod.frag",
724     })),
725     FileNameAsCustomTestSuffix
726 );
727
728 INSTANTIATE_TEST_SUITE_P(
729     Glsl, CompileVulkanToSpirvTestNV,
730     ::testing::ValuesIn(std::vector<std::string>({
731     "spv.sampleMaskOverrideCoverage.frag",
732     "spv.GeometryShaderPassthrough.geom",
733     "spv.viewportArray2.vert",
734     "spv.viewportArray2.tesc",
735     "spv.stereoViewRendering.vert",
736     "spv.stereoViewRendering.tesc",
737     "spv.multiviewPerViewAttributes.vert",
738     "spv.multiviewPerViewAttributes.tesc",
739     "spv.atomicInt64.comp",
740     "spv.atomicStoreInt64.comp",
741     "spv.shadingRate.frag",
742     "spv.RayGenShader.rgen",
743     "spv.RayGenShaderArray.rgen",
744     "spv.RayGenShader_Errors.rgen",
745     "spv.RayConstants.rgen",
746     "spv.IntersectShader.rint",
747     "spv.IntersectShader_Errors.rint",
748     "spv.AnyHitShader.rahit",
749     "spv.AnyHitShader_Errors.rahit",
750     "spv.ClosestHitShader.rchit",
751     "spv.ClosestHitShader_Errors.rchit",
752     "spv.MissShader.rmiss",
753     "spv.MissShader_Errors.rmiss",
754     "spv.RayCallable.rcall",
755     "spv.RayCallable_Errors.rcall",
756     "spv.fragmentShaderBarycentric.frag",
757     "spv.fragmentShaderBarycentric2.frag",
758     "spv.computeShaderDerivatives.comp",
759     "spv.computeShaderDerivatives2.comp",
760     "spv.shaderImageFootprint.frag",
761     "spv.meshShaderBuiltins.mesh",
762     "spv.meshShaderUserDefined.mesh",
763     "spv.meshShaderPerViewBuiltins.mesh",
764     "spv.meshShaderPerViewUserDefined.mesh",
765     "spv.meshShaderPerView_Errors.mesh",
766     "spv.meshShaderSharedMem.mesh",
767     "spv.meshShaderTaskMem.mesh",
768     "spv.320.meshShaderUserDefined.mesh",
769     "spv.meshShaderRedeclBuiltins.mesh",
770     "spv.meshShaderRedeclPerViewBuiltins.mesh",
771     "spv.meshTaskShader.task",
772     "spv.perprimitiveNV.frag",
773 })),
774 FileNameAsCustomTestSuffix
775 );
776
777 INSTANTIATE_TEST_SUITE_P(
778     Glsl, CompileVulkanToSpirv14TestNV,
779     ::testing::ValuesIn(std::vector<std::string>({
780     "spv.RayGenShaderMotion.rgen",
781     "spv.IntersectShaderMotion.rint",
782     "spv.AnyHitShaderMotion.rahit",
783     "spv.ClosestHitShaderMotion.rchit",
784     "spv.MissShaderMotion.rmiss",
785 })),
786 FileNameAsCustomTestSuffix
787 );
788 INSTANTIATE_TEST_SUITE_P(
789     Glsl, CompileUpgradeTextureToSampledTextureAndDropSamplersTest,
790     ::testing::ValuesIn(std::vector<std::string>({
791       "spv.texture.sampler.transform.frag",
792     })),
793     FileNameAsCustomTestSuffix
794 );
795 // clang-format on
796
797 }  // anonymous namespace
798 }  // namespace glslangtest