Merge pull request #2826 from amdrexu/bugfix
[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.intrinsicsSpecConst.vert",
369         "spv.intrinsicsSpirvByReference.vert",
370         "spv.intrinsicsSpirvDecorate.frag",
371         "spv.intrinsicsSpirvExecutionMode.frag",
372         "spv.intrinsicsSpirvInstruction.vert",
373         "spv.intrinsicsSpirvLiteral.vert",
374         "spv.intrinsicsSpirvStorageClass.rchit",
375         "spv.intrinsicsSpirvType.rgen",
376         "spv.intrinsicsSpirvTypeLocalVar.vert",
377         "spv.invariantAll.vert",
378         "spv.layer.tese",
379         "spv.layoutNested.vert",
380         "spv.length.frag",
381         "spv.localAggregates.frag",
382         "spv.loops.frag",
383         "spv.loopsArtificial.frag",
384         "spv.matFun.vert",
385         "spv.matrix.frag",
386         "spv.matrix2.frag",
387         "spv.memoryQualifier.frag",
388         "spv.merge-unreachable.frag",
389         "spv.multiStruct.comp",
390         "spv.multiStructFuncall.frag",
391         "spv.newTexture.frag",
392         "spv.noDeadDecorations.vert",
393         "spv.nonSquare.vert",
394         "spv.nonuniform.frag",
395         "spv.nonuniform2.frag",
396         "spv.nonuniform3.frag",
397         "spv.nonuniform4.frag",
398         "spv.nonuniform5.frag",
399         "spv.noWorkgroup.comp",
400         "spv.nullInit.comp",
401         "spv.offsets.frag",
402         "spv.Operations.frag",
403         "spv.paramMemory.frag",
404         "spv.paramMemory.420.frag",
405         "spv.precision.frag",
406         "spv.precisionArgs.frag",
407         "spv.precisionNonESSamp.frag",
408         "spv.precisionTexture.frag",
409         "spv.prepost.frag",
410         "spv.privateVariableTypes.frag",
411         "spv.qualifiers.vert",
412         "spv.sample.frag",
413         "spv.sampleId.frag",
414         "spv.samplePosition.frag",
415         "spv.sampleMaskOverrideCoverage.frag",
416         "spv.scalarlayout.frag",
417         "spv.scalarlayoutfloat16.frag",
418         "spv.shaderBallot.comp",
419         "spv.shaderDrawParams.vert",
420         "spv.shaderGroupVote.comp",
421         "spv.shaderStencilExport.frag",
422         "spv.shiftOps.frag",
423         "spv.simpleFunctionCall.frag",
424         "spv.simpleMat.vert",
425         "spv.sparseTexture.frag",
426         "spv.sparseTextureClamp.frag",
427         "spv.structAssignment.frag",
428         "spv.structDeref.frag",
429         "spv.structure.frag",
430         "spv.switch.frag",
431         "spv.swizzle.frag",
432         "spv.swizzleInversion.frag",
433         "spv.test.frag",
434         "spv.test.vert",
435         "spv.texture.frag",
436         "spv.texture.vert",
437         "spv.textureBuffer.vert",
438         "spv.image.frag",
439         "spv.imageAtomic64.frag",
440         "spv.types.frag",
441         "spv.uint.frag",
442         "spv.uniformArray.frag",
443         "spv.variableArrayIndex.frag",
444         "spv.varyingArray.frag",
445         "spv.varyingArrayIndirect.frag",
446         "spv.vecMatConstruct.frag",
447         "spv.voidFunction.frag",
448         "spv.whileLoop.frag",
449         "spv.AofA.frag",
450         "spv.queryL.frag",
451         "spv.separate.frag",
452         "spv.shortCircuit.frag",
453         "spv.pushConstant.vert",
454         "spv.pushConstantAnon.vert",
455         "spv.subpass.frag",
456         "spv.specConstant.vert",
457         "spv.specConstant.comp",
458         "spv.specConstantComposite.vert",
459         "spv.specConstantOperations.vert",
460         "spv.specConstant.float16.comp",
461         "spv.specConstant.int16.comp",
462         "spv.specConstant.int8.comp",
463         "spv.storageBuffer.vert",
464         "spv.terminate.frag",
465         "spv.subgroupUniformControlFlow.vert",
466         "spv.precise.tese",
467         "spv.precise.tesc",
468         "spv.viewportindex.tese",
469         "spv.volatileAtomic.comp",
470         "spv.vulkan100.subgroupArithmetic.comp",
471         "spv.vulkan100.subgroupPartitioned.comp",
472         "spv.xfb.vert",
473         "spv.xfb2.vert",
474         "spv.xfb3.vert",
475         "spv.samplerlessTextureFunctions.frag",
476         "spv.smBuiltins.vert",
477         "spv.smBuiltins.frag",
478         "spv.builtin.PrimitiveShadingRateEXT.vert",
479         "spv.builtin.ShadingRateEXT.frag",
480         "spv.atomicAdd.bufferReference.comp"
481     })),
482     FileNameAsCustomTestSuffix
483 );
484
485 // Cases with deliberately unreachable code.
486 // By default the compiler will aggressively eliminate
487 // unreachable merges and continues.
488 INSTANTIATE_TEST_SUITE_P(
489     GlslWithDeadCode, CompileVulkanToSpirvDeadCodeElimTest,
490     ::testing::ValuesIn(std::vector<std::string>({
491         "spv.dead-after-continue.vert",
492         "spv.dead-after-discard.frag",
493         "spv.dead-after-return.vert",
494         "spv.dead-after-loop-break.vert",
495         "spv.dead-after-switch-break.vert",
496         "spv.dead-complex-continue-after-return.vert",
497         "spv.dead-complex-merge-after-return.vert",
498     })),
499     FileNameAsCustomTestSuffix
500 );
501
502 // clang-format off
503 INSTANTIATE_TEST_SUITE_P(
504     Glsl, CompileVulkanToDebugSpirvTest,
505     ::testing::ValuesIn(std::vector<std::string>({
506         "spv.pp.line.frag",
507     })),
508     FileNameAsCustomTestSuffix
509 );
510
511 // clang-format off
512 INSTANTIATE_TEST_SUITE_P(
513     Glsl, CompileVulkan1_1ToSpirvTest,
514     ::testing::ValuesIn(std::vector<std::string>({
515         "spv.1.3.8bitstorage-ubo.vert",
516         "spv.1.3.8bitstorage-ssbo.vert",
517         "spv.1.3.coopmat.comp",
518         "spv.deviceGroup.frag",
519         "spv.drawParams.vert",
520         "spv.int8.frag",
521         "spv.vulkan110.int16.frag",
522         "spv.int32.frag",
523         "spv.explicittypes.frag",
524         "spv.float32.frag",
525         "spv.float64.frag",
526         "spv.memoryScopeSemantics.comp",
527         "spv.memoryScopeSemantics_Error.comp",
528         "spv.multiView.frag",
529         "spv.queueFamilyScope.comp",
530         "spv.RayGenShader11.rgen",
531         "spv.subgroup.frag",
532         "spv.subgroup.geom",
533         "spv.subgroup.tesc",
534         "spv.subgroup.tese",
535         "spv.subgroup.vert",
536         "spv.subgroupArithmetic.comp",
537         "spv.subgroupBasic.comp",
538         "spv.subgroupBallot.comp",
539         "spv.subgroupBallotNeg.comp",
540         "spv.subgroupClustered.comp",
541         "spv.subgroupClusteredNeg.comp",
542         "spv.subgroupPartitioned.comp",
543         "spv.subgroupShuffle.comp",
544         "spv.subgroupShuffleRelative.comp",
545         "spv.subgroupQuad.comp",
546         "spv.subgroupVote.comp",
547         "spv.subgroupExtendedTypesArithmetic.comp",
548         "spv.subgroupExtendedTypesArithmeticNeg.comp",
549         "spv.subgroupExtendedTypesBallot.comp",
550         "spv.subgroupExtendedTypesBallotNeg.comp",
551         "spv.subgroupExtendedTypesClustered.comp",
552         "spv.subgroupExtendedTypesClusteredNeg.comp",
553         "spv.subgroupExtendedTypesPartitioned.comp",
554         "spv.subgroupExtendedTypesPartitionedNeg.comp",
555         "spv.subgroupExtendedTypesShuffle.comp",
556         "spv.subgroupExtendedTypesShuffleNeg.comp",
557         "spv.subgroupExtendedTypesShuffleRelative.comp",
558         "spv.subgroupExtendedTypesShuffleRelativeNeg.comp",
559         "spv.subgroupExtendedTypesQuad.comp",
560         "spv.subgroupExtendedTypesQuadNeg.comp",
561         "spv.subgroupExtendedTypesVote.comp",
562         "spv.subgroupExtendedTypesVoteNeg.comp",
563         "spv.vulkan110.storageBuffer.vert",
564     })),
565     FileNameAsCustomTestSuffix
566 );
567
568 // clang-format off
569 INSTANTIATE_TEST_SUITE_P(
570     Glsl, CompileToSpirv14Test,
571     ::testing::ValuesIn(std::vector<std::string>({
572         "spv.1.4.LoopControl.frag",
573         "spv.1.4.NonWritable.frag",
574         "spv.1.4.OpEntryPoint.frag",
575         "spv.1.4.OpEntryPoint.opaqueParams.vert",
576         "spv.1.4.OpSelect.frag",
577         "spv.1.4.OpCopyLogical.comp",
578         "spv.1.4.OpCopyLogicalBool.comp",
579         "spv.1.4.OpCopyLogical.funcall.frag",
580         "spv.1.4.funcall.array.frag",
581         "spv.1.4.load.bool.array.interface.block.frag",
582         "spv.1.4.image.frag",
583         "spv.1.4.sparseTexture.frag",
584         "spv.1.4.texture.frag",
585         "spv.1.4.constructComposite.comp",
586         "spv.ext.AnyHitShader.rahit",
587         "spv.ext.AnyHitShader_Errors.rahit",
588         "spv.ext.ClosestHitShader.rchit",
589         "spv.ext.ClosestHitShader_Subgroup.rchit",
590         "spv.ext.ClosestHitShader_Errors.rchit",
591         "spv.ext.IntersectShader.rint",
592         "spv.ext.IntersectShader_Errors.rint",
593         "spv.ext.MissShader.rmiss",
594         "spv.ext.MissShader_Errors.rmiss",
595         "spv.ext.RayPrimCull_Errors.rgen",
596         "spv.ext.RayCallable.rcall",
597         "spv.ext.RayCallable_Errors.rcall",
598         "spv.ext.RayConstants.rgen",
599         "spv.ext.RayGenShader.rgen",
600         "spv.ext.RayGenShader_Errors.rgen",
601         "spv.ext.RayGenShader11.rgen",
602         "spv.ext.RayGenShaderArray.rgen",
603         "spv.ext.RayGenSBTlayout.rgen",
604         "spv.ext.RayGenSBTlayout140.rgen",
605         "spv.ext.RayGenSBTlayout430.rgen",
606         "spv.ext.RayGenSBTlayoutscalar.rgen",
607         "spv.ext.World3x4.rahit",
608         "spv.ext.AccelDecl.frag",
609         "spv.ext.RayQueryDecl.frag",
610
611         // SPV_KHR_workgroup_memory_explicit_layout depends on SPIR-V 1.4.
612         "spv.WorkgroupMemoryExplicitLayout.SingleBlock.comp",
613         "spv.WorkgroupMemoryExplicitLayout.MultiBlock.comp",
614         "spv.WorkgroupMemoryExplicitLayout.8BitAccess.comp",
615         "spv.WorkgroupMemoryExplicitLayout.16BitAccess.comp",
616         "spv.WorkgroupMemoryExplicitLayout.NonBlock.comp",
617         "spv.WorkgroupMemoryExplicitLayout.MixBlockNonBlock_Errors.comp",
618         "spv.WorkgroupMemoryExplicitLayout.std140.comp",
619         "spv.WorkgroupMemoryExplicitLayout.std430.comp",
620         "spv.WorkgroupMemoryExplicitLayout.scalar.comp",
621     })),
622     FileNameAsCustomTestSuffix
623 );
624
625 // clang-format off
626 INSTANTIATE_TEST_SUITE_P(
627     Hlsl, HlslIoMap,
628     ::testing::ValuesIn(std::vector<IoMapData>{
629         { "spv.register.autoassign.frag", "main_ep", 5, 10, 0, 20, 30, true, false },
630         { "spv.register.noautoassign.frag", "main_ep", 5, 10, 0, 15, 30, false, false },
631         { "spv.register.autoassign-2.frag", "main", 5, 10, 0, 15, 30, true, true },
632         { "spv.register.subpass.frag", "main", 0, 20, 0, 0, 0, true, true },
633         { "spv.buffer.autoassign.frag", "main", 5, 10, 0, 15, 30, true, true },
634         { "spv.ssbo.autoassign.frag", "main", 5, 10, 0, 15, 30, true, true },
635         { "spv.ssboAlias.frag", "main", 0, 0, 0, 0, 83, true, false },
636         { "spv.rw.autoassign.frag", "main", 5, 10, 20, 15, 30, true, true },
637         { "spv.register.autoassign.rangetest.frag", "main",
638                 glslang::TQualifier::layoutBindingEnd-2,
639                 glslang::TQualifier::layoutBindingEnd+5,
640                 20, 30, true, false },
641     }),
642     FileNameAsCustomTestSuffixIoMap
643 );
644
645 // clang-format off
646 INSTANTIATE_TEST_SUITE_P(
647     Hlsl, GlslIoMap,
648     ::testing::ValuesIn(std::vector<IoMapData>{
649         { "spv.glsl.register.autoassign.frag", "main", 5, 10, 0, 20, 30, true, false },
650         { "spv.glsl.register.noautoassign.frag", "main", 5, 10, 0, 15, 30, false, false },
651     }),
652     FileNameAsCustomTestSuffixIoMap
653 );
654
655 // clang-format off
656 INSTANTIATE_TEST_SUITE_P(
657     Glsl, CompileOpenGLToSpirvTest,
658     ::testing::ValuesIn(std::vector<std::string>({
659         "spv.460.frag",
660         "spv.460.vert",
661         "spv.460.comp",
662         "spv.atomic.comp",
663         "spv.atomicFloat.comp",
664         "spv.atomicFloat_Error.comp",
665         "spv.glFragColor.frag",
666         "spv.rankShift.comp",
667         "spv.specConst.vert",
668         "spv.specTexture.frag",
669         "spv.OVR_multiview.vert",
670         "spv.uniformInitializer.frag",
671         "spv.uniformInitializerSpecConstant.frag",
672         "spv.uniformInitializerStruct.frag",
673         "spv.xfbOffsetOnBlockMembersAssignment.vert",
674         "spv.xfbOffsetOnStructMembersAssignment.vert",
675         "spv.xfbOverlapOffsetCheckWithBlockAndMember.vert",
676         "spv.xfbStrideJustOnce.vert",
677     })),
678     FileNameAsCustomTestSuffix
679 );
680
681 INSTANTIATE_TEST_SUITE_P(
682     Glsl, VulkanSemantics,
683     ::testing::ValuesIn(std::vector<std::string>({
684         "vulkan.frag",
685         "vulkan.vert",
686         "vulkan.comp",
687         "samplerlessTextureFunctions.frag",
688         "spv.specConstArrayCheck.vert",
689     })),
690     FileNameAsCustomTestSuffix
691 );
692
693 INSTANTIATE_TEST_SUITE_P(
694     Glsl, OpenGLSemantics,
695     ::testing::ValuesIn(std::vector<std::string>({
696         "glspv.esversion.vert",
697         "glspv.version.frag",
698         "glspv.version.vert",
699         "glspv.frag",
700         "glspv.vert",
701     })),
702     FileNameAsCustomTestSuffix
703 );
704
705 INSTANTIATE_TEST_SUITE_P(
706     Glsl, VulkanAstSemantics,
707     ::testing::ValuesIn(std::vector<std::string>({
708         "vulkan.ast.vert",
709     })),
710     FileNameAsCustomTestSuffix
711 );
712
713 INSTANTIATE_TEST_SUITE_P(
714     Glsl, CompileVulkanToSpirvTestAMD,
715     ::testing::ValuesIn(std::vector<std::string>({
716         "spv.16bitxfb.vert",
717         "spv.float16.frag",
718         "spv.float16Fetch.frag",
719         "spv.imageLoadStoreLod.frag",
720         "spv.int16.frag",
721         "spv.int16.amd.frag",
722         "spv.shaderBallotAMD.comp",
723         "spv.shaderFragMaskAMD.frag",
724         "spv.textureGatherBiasLod.frag",
725     })),
726     FileNameAsCustomTestSuffix
727 );
728
729 INSTANTIATE_TEST_SUITE_P(
730     Glsl, CompileVulkanToSpirvTestNV,
731     ::testing::ValuesIn(std::vector<std::string>({
732     "spv.sampleMaskOverrideCoverage.frag",
733     "spv.GeometryShaderPassthrough.geom",
734     "spv.viewportArray2.vert",
735     "spv.viewportArray2.tesc",
736     "spv.stereoViewRendering.vert",
737     "spv.stereoViewRendering.tesc",
738     "spv.multiviewPerViewAttributes.vert",
739     "spv.multiviewPerViewAttributes.tesc",
740     "spv.atomicInt64.comp",
741     "spv.atomicStoreInt64.comp",
742     "spv.shadingRate.frag",
743     "spv.RayGenShader.rgen",
744     "spv.RayGenShaderArray.rgen",
745     "spv.RayGenShader_Errors.rgen",
746     "spv.RayConstants.rgen",
747     "spv.IntersectShader.rint",
748     "spv.IntersectShader_Errors.rint",
749     "spv.AnyHitShader.rahit",
750     "spv.AnyHitShader_Errors.rahit",
751     "spv.ClosestHitShader.rchit",
752     "spv.ClosestHitShader_Errors.rchit",
753     "spv.MissShader.rmiss",
754     "spv.MissShader_Errors.rmiss",
755     "spv.RayCallable.rcall",
756     "spv.RayCallable_Errors.rcall",
757     "spv.fragmentShaderBarycentric.frag",
758     "spv.fragmentShaderBarycentric2.frag",
759     "spv.computeShaderDerivatives.comp",
760     "spv.computeShaderDerivatives2.comp",
761     "spv.shaderImageFootprint.frag",
762     "spv.meshShaderBuiltins.mesh",
763     "spv.meshShaderUserDefined.mesh",
764     "spv.meshShaderPerViewBuiltins.mesh",
765     "spv.meshShaderPerViewUserDefined.mesh",
766     "spv.meshShaderPerView_Errors.mesh",
767     "spv.meshShaderSharedMem.mesh",
768     "spv.meshShaderTaskMem.mesh",
769     "spv.320.meshShaderUserDefined.mesh",
770     "spv.meshShaderRedeclBuiltins.mesh",
771     "spv.meshShaderRedeclPerViewBuiltins.mesh",
772     "spv.meshTaskShader.task",
773     "spv.perprimitiveNV.frag",
774 })),
775 FileNameAsCustomTestSuffix
776 );
777
778 INSTANTIATE_TEST_SUITE_P(
779     Glsl, CompileVulkanToSpirv14TestNV,
780     ::testing::ValuesIn(std::vector<std::string>({
781     "spv.RayGenShaderMotion.rgen",
782     "spv.IntersectShaderMotion.rint",
783     "spv.AnyHitShaderMotion.rahit",
784     "spv.ClosestHitShaderMotion.rchit",
785     "spv.MissShaderMotion.rmiss",
786 })),
787 FileNameAsCustomTestSuffix
788 );
789 INSTANTIATE_TEST_SUITE_P(
790     Glsl, CompileUpgradeTextureToSampledTextureAndDropSamplersTest,
791     ::testing::ValuesIn(std::vector<std::string>({
792       "spv.texture.sampler.transform.frag",
793     })),
794     FileNameAsCustomTestSuffix
795 );
796 // clang-format on
797
798 }  // anonymous namespace
799 }  // namespace glslangtest