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