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.coopmatKHR_arithmetic.comp",
371 "spv.coopmatKHR_arithmeticError.comp",
372 "spv.coopmatKHR_Error.comp",
373 "spv.coopmatKHR_constructor.comp",
374 "spv.coopmatKHR_constructorError.comp",
375 "spv.dataOut.frag",
376 "spv.dataOutIndirect.frag",
377 "spv.dataOutIndirect.vert",
378 "spv.debugPrintf.frag",
379 "spv.debugPrintf_Error.frag",
380 "spv.demoteDisabled.frag",
381 "spv.deepRvalue.frag",
382 "spv.depthOut.frag",
383 "spv.depthUnchanged.frag",
384 "spv.discard-dce.frag",
385 "spv.doWhileLoop.frag",
386 "spv.earlyReturnDiscard.frag",
387 "spv.expect_assume.assumeEXT.comp",
388 "spv.expect_assume.expectEXT.comp",
389 "spv.expect_assume.expectEXT.exttypes.comp",
390 "spv.ext.ShaderTileImage.color.frag",
391 "spv.ext.ShaderTileImage.depth_stencil.frag",
392 "spv.ext.ShaderTileImage.subpassinput.frag",
393 "spv.ext.ShaderTileImage.typemismatch.frag",
394 "spv.ext.ShaderTileImage.overlap.frag",
395 "spv.ext.ShaderTileImage.wronglayout.frag",
396 "spv.extPostDepthCoverage.frag",
397 "spv.extPostDepthCoverage_Error.frag",
398 "spv.float16convertonlyarith.comp",
399 "spv.float16convertonlystorage.comp",
400 "spv.flowControl.frag",
401 "spv.forLoop.frag",
402 "spv.forwardFun.frag",
403 "spv.fragmentDensity.frag",
404 "spv.fragmentDensity.vert",
405 "spv.fragmentDensity-es.frag",
406 "spv.fragmentDensity-neg.frag",
407 "spv.fsi.frag",
408 "spv.fsi_Error.frag",
409 "spv.fullyCovered.frag",
410 "spv.functionCall.frag",
411 "spv.functionNestedOpaque.vert",
412 "spv.functionSemantics.frag",
413 "spv.functionParameterTypes.frag",
414 "spv.GeometryShaderPassthrough.geom",
415 "spv.funcall.array.frag",
416 "spv.load.bool.array.interface.block.frag",
417 "spv.interpOps.frag",
418 "spv.int64.frag",
419 "spv.intcoopmat.comp",
420 "spv.intOps.vert",
421 "spv.intrinsicsSpirvByReference.vert",
422 "spv.intrinsicsSpirvDecorate.frag",
423 "spv.intrinsicsSpirvDecorateId.comp",
424 "spv.intrinsicsSpirvDecorateString.comp",
425 "spv.intrinsicsSpirvExecutionMode.frag",
426 "spv.intrinsicsSpirvInstruction.vert",
427 "spv.intrinsicsSpirvLiteral.vert",
428 "spv.intrinsicsSpirvStorageClass.rchit",
429 "spv.intrinsicsSpirvType.rgen",
430 "spv.intrinsicsSpirvTypeLocalVar.vert",
431 "spv.intrinsicsSpirvTypeWithTypeSpecifier.vert",
432 "spv.invariantAll.vert",
433 "spv.layer.tese",
434 "spv.layoutNested.vert",
435 "spv.length.frag",
436 "spv.localAggregates.frag",
437 "spv.loops.frag",
438 "spv.loopsArtificial.frag",
439 "spv.matFun.vert",
440 "spv.matrix.frag",
441 "spv.matrix2.frag",
442 "spv.maximalReconvergence.vert",
443 "spv.memoryQualifier.frag",
444 "spv.merge-unreachable.frag",
445 "spv.multiStruct.comp",
446 "spv.multiStructFuncall.frag",
447 "spv.newTexture.frag",
448 "spv.noDeadDecorations.vert",
449 "spv.nonSquare.vert",
450 "spv.nonuniform.frag",
451 "spv.nonuniform2.frag",
452 "spv.nonuniform3.frag",
453 "spv.nonuniform4.frag",
454 "spv.nonuniform5.frag",
455 "spv.noWorkgroup.comp",
456 "spv.nvAtomicFp16Vec.frag",
457 "spv.nullInit.comp",
458 "spv.offsets.frag",
459 "spv.Operations.frag",
460 "spv.paramMemory.frag",
461 "spv.paramMemory.420.frag",
462 "spv.precision.frag",
463 "spv.precisionArgs.frag",
464 "spv.precisionNonESSamp.frag",
465 "spv.precisionTexture.frag",
466 "spv.prepost.frag",
467 "spv.privateVariableTypes.frag",
468 "spv.qualifiers.vert",
469 "spv.sample.frag",
470 "spv.sampleId.frag",
471 "spv.samplePosition.frag",
472 "spv.sampleMaskOverrideCoverage.frag",
473 "spv.scalarlayout.frag",
474 "spv.scalarlayoutfloat16.frag",
475 "spv.shaderBallot.comp",
476 "spv.shaderDrawParams.vert",
477 "spv.shaderGroupVote.comp",
478 "spv.shaderStencilExport.frag",
479 "spv.shiftOps.frag",
480 "spv.simpleFunctionCall.frag",
481 "spv.simpleMat.vert",
482 "spv.sparseTexture.frag",
483 "spv.sparseTextureClamp.frag",
484 "spv.structAssignment.frag",
485 "spv.structCopy.comp",
486 "spv.structDeref.frag",
487 "spv.structure.frag",
488 "spv.switch.frag",
489 "spv.swizzle.frag",
490 "spv.swizzleInversion.frag",
491 "spv.test.frag",
492 "spv.test.vert",
493 "spv.texture.frag",
494 "spv.texture.vert",
495 "spv.textureBuffer.vert",
496 "spv.image.frag",
497 "spv.imageAtomic64.frag",
498 "spv.imageAtomic64.comp",
499 "spv.types.frag",
500 "spv.uint.frag",
501 "spv.uniformArray.frag",
502 "spv.variableArrayIndex.frag",
503 "spv.varyingArray.frag",
504 "spv.varyingArrayIndirect.frag",
505 "spv.vecMatConstruct.frag",
506 "spv.voidFunction.frag",
507 "spv.whileLoop.frag",
508 "spv.AofA.frag",
509 "spv.queryL.frag",
510 "spv.separate.frag",
511 "spv.shortCircuit.frag",
512 "spv.pushConstant.vert",
513 "spv.pushConstantAnon.vert",
514 "spv.subpass.frag",
515 "spv.specConstant.vert",
516 "spv.specConstant.comp",
517 "spv.specConstantComposite.vert",
518 "spv.specConstantOperations.vert",
519 "spv.specConstant.float16.comp",
520 "spv.specConstant.int16.comp",
521 "spv.specConstant.int8.comp",
522 "spv.specConstantOp.int16.comp",
523 "spv.specConstantOp.int8.comp",
524 "spv.specConstantOp.float16.comp",
525 "spv.storageBuffer.vert",
526 "spv.terminate.frag",
527 "spv.subgroupUniformControlFlow.vert",
528 "spv.subgroupSizeARB.frag",
529 "spv.precise.tese",
530 "spv.precise.tesc",
531 "spv.viewportindex.tese",
532 "spv.volatileAtomic.comp",
533 "spv.vulkan100.subgroupArithmetic.comp",
534 "spv.vulkan100.subgroupPartitioned.comp",
535 "spv.xfb.vert",
536 "spv.xfb2.vert",
537 "spv.xfb3.vert",
538 "spv.samplerlessTextureFunctions.frag",
539 "spv.smBuiltins.vert",
540 "spv.smBuiltins.frag",
541 "spv.ARMCoreBuiltIns.vert",
542 "spv.ARMCoreBuiltIns.frag",
543 "spv.builtin.PrimitiveShadingRateEXT.vert",
544 "spv.builtin.ShadingRateEXT.frag",
545 "spv.atomicAdd.bufferReference.comp",
546 "spv.fragmentShaderBarycentric3.frag",
547 "spv.fragmentShaderBarycentric4.frag",
548 "spv.ext.textureShadowLod.frag",
549 "spv.ext.textureShadowLod.error.frag",
550 "spv.floatFetch.frag",
551 "spv.atomicRvalue.error.vert",
552 })),
553 FileNameAsCustomTestSuffix
554 );
555
556 INSTANTIATE_TEST_SUITE_P(
557 Glsl, CompileVulkanToSpirvTestNoLink,
558 ::testing::ValuesIn(std::vector<std::string>({
559 "spv.exportFunctions.comp",
560 })),
561 FileNameAsCustomTestSuffix
562 );
563
564 // Cases with deliberately unreachable code.
565 // By default the compiler will aggressively eliminate
566 // unreachable merges and continues.
567 INSTANTIATE_TEST_SUITE_P(
568 GlslWithDeadCode, CompileVulkanToSpirvDeadCodeElimTest,
569 ::testing::ValuesIn(std::vector<std::string>({
570 "spv.dead-after-continue.vert",
571 "spv.dead-after-discard.frag",
572 "spv.dead-after-return.vert",
573 "spv.dead-after-loop-break.vert",
574 "spv.dead-after-switch-break.vert",
575 "spv.dead-complex-continue-after-return.vert",
576 "spv.dead-complex-merge-after-return.vert",
577 })),
578 FileNameAsCustomTestSuffix
579 );
580
581 // clang-format off
582 INSTANTIATE_TEST_SUITE_P(
583 Glsl, CompileVulkanToDebugSpirvTest,
584 ::testing::ValuesIn(std::vector<std::string>({
585 "spv.pp.line.frag",
586 })),
587 FileNameAsCustomTestSuffix
588 );
589
590 // clang-format off
591 INSTANTIATE_TEST_SUITE_P(
592 Glsl, CompileVulkan1_1ToSpirvTest,
593 ::testing::ValuesIn(std::vector<std::string>({
594 "spv.1.3.8bitstorage-ubo.vert",
595 "spv.1.3.8bitstorage-ssbo.vert",
596 "spv.1.3.coopmat.comp",
597 "spv.deviceGroup.frag",
598 "spv.drawParams.vert",
599 "spv.int8.frag",
600 "spv.vulkan110.int16.frag",
601 "spv.int32.frag",
602 "spv.explicittypes.frag",
603 "spv.float16NoRelaxed.vert",
604 "spv.float32.frag",
605 "spv.float64.frag",
606 "spv.memoryScopeSemantics.comp",
607 "spv.memoryScopeSemantics_Error.comp",
608 "spv.multiView.frag",
609 "spv.queueFamilyScope.comp",
610 "spv.RayGenShader11.rgen",
611 "spv.subgroup.frag",
612 "spv.subgroup.geom",
613 "spv.subgroup.tesc",
614 "spv.subgroup.tese",
615 "spv.subgroup.vert",
616 "spv.subgroupArithmetic.comp",
617 "spv.subgroupBasic.comp",
618 "spv.subgroupBallot.comp",
619 "spv.subgroupBallotNeg.comp",
620 "spv.subgroupClustered.comp",
621 "spv.subgroupClusteredNeg.comp",
622 "spv.subgroupPartitioned.comp",
623 "spv.subgroupRotate.comp",
624 "spv.subgroupShuffle.comp",
625 "spv.subgroupShuffleRelative.comp",
626 "spv.subgroupQuad.comp",
627 "spv.subgroupVote.comp",
628 "spv.subgroupExtendedTypesArithmetic.comp",
629 "spv.subgroupExtendedTypesArithmeticNeg.comp",
630 "spv.subgroupExtendedTypesBallot.comp",
631 "spv.subgroupExtendedTypesBallotNeg.comp",
632 "spv.subgroupExtendedTypesClustered.comp",
633 "spv.subgroupExtendedTypesClusteredNeg.comp",
634 "spv.subgroupExtendedTypesPartitioned.comp",
635 "spv.subgroupExtendedTypesPartitionedNeg.comp",
636 "spv.subgroupExtendedTypesRotate.comp",
637 "spv.subgroupExtendedTypesRotateNeg.comp",
638 "spv.subgroupExtendedTypesShuffle.comp",
639 "spv.subgroupExtendedTypesShuffleNeg.comp",
640 "spv.subgroupExtendedTypesShuffleRelative.comp",
641 "spv.subgroupExtendedTypesShuffleRelativeNeg.comp",
642 "spv.subgroupExtendedTypesQuad.comp",
643 "spv.subgroupExtendedTypesQuadNeg.comp",
644 "spv.subgroupExtendedTypesVote.comp",
645 "spv.subgroupExtendedTypesVoteNeg.comp",
646 "spv.vulkan110.storageBuffer.vert",
647 })),
648 FileNameAsCustomTestSuffix
649 );
650
651 // clang-format off
652 INSTANTIATE_TEST_SUITE_P(
653 Glsl, CompileToSpirv14Test,
654 ::testing::ValuesIn(std::vector<std::string>({
655 "spv.1.4.LoopControl.frag",
656 "spv.1.4.NonWritable.frag",
657 "spv.1.4.OpEntryPoint.frag",
658 "spv.1.4.OpEntryPoint.opaqueParams.vert",
659 "spv.1.4.OpSelect.frag",
660 "spv.1.4.OpCopyLogical.comp",
661 "spv.1.4.OpCopyLogicalBool.comp",
662 "spv.1.4.OpCopyLogical.funcall.frag",
663 "spv.1.4.funcall.array.frag",
664 "spv.1.4.load.bool.array.interface.block.frag",
665 "spv.1.4.image.frag",
666 "spv.1.4.sparseTexture.frag",
667 "spv.1.4.texture.frag",
668 "spv.1.4.constructComposite.comp",
669 "spv.ext.AnyHitShader.rahit",
670 "spv.ext.AnyHitShader_Errors.rahit",
671 "spv.ext.ClosestHitShader.rchit",
672 "spv.ext.ClosestHitShader_Subgroup.rchit",
673 "spv.ext.ClosestHitShader_Errors.rchit",
674 "spv.ext.IntersectShader.rint",
675 "spv.ext.IntersectShader_Errors.rint",
676 "spv.ext.MissShader.rmiss",
677 "spv.ext.MissShader_Errors.rmiss",
678 "spv.ext.RayPrimCull_Errors.rgen",
679 "spv.ext.RayCallable.rcall",
680 "spv.ext.RayCallable_Errors.rcall",
681 "spv.ext.RayConstants.rgen",
682 "spv.ext.RayGenShader.rgen",
683 "spv.ext.RayGenShader_Errors.rgen",
684 "spv.ext.RayGenShader11.rgen",
685 "spv.ext.RayGenShaderArray.rgen",
686 "spv.ext.RayGenSBTlayout.rgen",
687 "spv.ext.RayGenSBTlayout140.rgen",
688 "spv.ext.RayGenSBTlayout430.rgen",
689 "spv.ext.RayGenSBTlayoutscalar.rgen",
690 "spv.ext.World3x4.rahit",
691 "spv.ext.AccelDecl.frag",
692 "spv.ext.RayQueryDecl.frag",
693
694 // SPV_KHR_workgroup_memory_explicit_layout depends on SPIR-V 1.4.
695 "spv.WorkgroupMemoryExplicitLayout.SingleBlock.comp",
696 "spv.WorkgroupMemoryExplicitLayout.MultiBlock.comp",
697 "spv.WorkgroupMemoryExplicitLayout.8BitAccess.comp",
698 "spv.WorkgroupMemoryExplicitLayout.16BitAccess.comp",
699 "spv.WorkgroupMemoryExplicitLayout.NonBlock.comp",
700 "spv.WorkgroupMemoryExplicitLayout.MixBlockNonBlock_Errors.comp",
701 "spv.WorkgroupMemoryExplicitLayout.std140.comp",
702 "spv.WorkgroupMemoryExplicitLayout.std430.comp",
703 "spv.WorkgroupMemoryExplicitLayout.scalar.comp",
704
705 // SPV_EXT_mesh_shader
706 "spv.ext.meshShaderBuiltins.mesh",
707 "spv.ext.meshShaderBuiltinsShadingRate.mesh",
708 "spv.ext.meshShaderRedeclBuiltins.mesh",
709 "spv.ext.meshShaderTaskMem.mesh",
710 "spv.ext.meshShaderUserDefined.mesh",
711 "spv.ext.meshTaskShader.task",
712 "spv.atomiAddEXT.error.mesh",
713 "spv.atomiAddEXT.task",
714 "spv.460.subgroupEXT.task",
715 "spv.460.subgroupEXT.mesh",
716
717 // SPV_NV_shader_execution_reorder
718
719 "spv.nv.hitobject-allops.rgen",
720 "spv.nv.hitobject-allops.rchit",
721 "spv.nv.hitobject-allops.rmiss",
722
723
724 // SPV_NV_displacment_micromap
725
726 "spv.nv.dmm-allops.rgen",
727 "spv.nv.dmm-allops.rchit",
728 "spv.nv.dmm-allops.rahit",
729 "spv.nv.dmm-allops.mesh",
730 "spv.nv.dmm-allops.comp",
731 })),
732 FileNameAsCustomTestSuffix
733 );
734
735 // clang-format off
736 INSTANTIATE_TEST_SUITE_P(
737 Glsl, CompileToSpirv16Test,
738 ::testing::ValuesIn(std::vector<std::string>({
739 "spv.1.6.conditionalDiscard.frag",
740 "spv.1.6.helperInvocation.frag",
741 "spv.1.6.helperInvocation.memmodel.frag",
742 "spv.1.6.specConstant.comp",
743 "spv.1.6.samplerBuffer.frag",
744 "spv.1.6.separate.frag",
745 "spv.1.6.quad.frag",
746 })),
747 FileNameAsCustomTestSuffix
748 );
749
750
751 // clang-format off
752 INSTANTIATE_TEST_SUITE_P(
753 Hlsl, HlslIoMap,
754 ::testing::ValuesIn(std::vector<IoMapData>{
755 { "spv.register.autoassign.frag", "main_ep", 5, 10, 0, 20, 30, true, false },
756 { "spv.register.noautoassign.frag", "main_ep", 5, 10, 0, 15, 30, false, false },
757 { "spv.register.autoassign-2.frag", "main", 5, 10, 0, 15, 30, true, true },
758 { "spv.register.subpass.frag", "main", 0, 20, 0, 0, 0, true, true },
759 { "spv.buffer.autoassign.frag", "main", 5, 10, 0, 15, 30, true, true },
760 { "spv.ssbo.autoassign.frag", "main", 5, 10, 0, 15, 30, true, true },
761 { "spv.ssboAlias.frag", "main", 0, 0, 0, 0, 83, true, false },
762 { "spv.rw.autoassign.frag", "main", 5, 10, 20, 15, 30, true, true },
763 { "spv.register.autoassign.rangetest.frag", "main",
764 glslang::TQualifier::layoutBindingEnd-2,
765 glslang::TQualifier::layoutBindingEnd+5,
766 0, 20, 30, true, false },
767 }),
768 FileNameAsCustomTestSuffixIoMap
769 );
770
771 // clang-format off
772 INSTANTIATE_TEST_SUITE_P(
773 Hlsl, GlslIoMap,
774 ::testing::ValuesIn(std::vector<IoMapData>{
775 { "spv.glsl.register.autoassign.frag", "main", 5, 10, 0, 20, 30, true, false },
776 { "spv.glsl.register.noautoassign.frag", "main", 5, 10, 0, 15, 30, false, false },
777 }),
778 FileNameAsCustomTestSuffixIoMap
779 );
780
781 // clang-format off
782 INSTANTIATE_TEST_SUITE_P(
783 Glsl, CompileOpenGLToSpirvTest,
784 ::testing::ValuesIn(std::vector<std::string>({
785 "spv.460.frag",
786 "spv.460.vert",
787 "spv.460.comp",
788 "spv.atomic.comp",
789 "spv.atomicFloat.comp",
790 "spv.atomicFloat_Error.comp",
791 "spv.glFragColor.frag",
792 "spv.rankShift.comp",
793 "spv.specConst.vert",
794 "spv.specTexture.frag",
795 "spv.OVR_multiview.vert",
796 "spv.uniformInitializer.frag",
797 "spv.uniformInitializerSpecConstant.frag",
798 "spv.uniformInitializerStruct.frag",
799 "spv.xfbOffsetOnBlockMembersAssignment.vert",
800 "spv.xfbOffsetOnStructMembersAssignment.vert",
801 "spv.xfbOverlapOffsetCheckWithBlockAndMember.vert",
802 "spv.xfbStrideJustOnce.vert",
803 })),
804 FileNameAsCustomTestSuffix
805 );
806
807 INSTANTIATE_TEST_SUITE_P(
808 Glsl, VulkanSemantics,
809 ::testing::ValuesIn(std::vector<std::string>({
810 "vulkan.frag",
811 "vulkan.vert",
812 "vulkan.comp",
813 "samplerlessTextureFunctions.frag",
814 "spv.intrinsicsFakeEnable.vert",
815 "spv.specConstArrayCheck.vert",
816 })),
817 FileNameAsCustomTestSuffix
818 );
819
820 INSTANTIATE_TEST_SUITE_P(
821 Glsl, OpenGLSemantics,
822 ::testing::ValuesIn(std::vector<std::string>({
823 "glspv.esversion.vert",
824 "glspv.version.frag",
825 "glspv.version.vert",
826 "glspv.frag",
827 "glspv.vert",
828 })),
829 FileNameAsCustomTestSuffix
830 );
831
832 INSTANTIATE_TEST_SUITE_P(
833 Glsl, VulkanAstSemantics,
834 ::testing::ValuesIn(std::vector<std::string>({
835 "vulkan.ast.vert",
836 })),
837 FileNameAsCustomTestSuffix
838 );
839
840 INSTANTIATE_TEST_SUITE_P(
841 Glsl, CompileVulkanToSpirvTestQCOM,
842 ::testing::ValuesIn(std::vector<std::string>({
843 "spv.tpipSampleWeighted.frag",
844 "spv.tpipBoxFilter.frag",
845 "spv.tpipBlockMatchSSD.frag",
846 "spv.tpipBlockMatchSAD.frag",
847 "spv.tpipTextureArrays.frag",
848 })),
849 FileNameAsCustomTestSuffix
850 );
851
852 INSTANTIATE_TEST_SUITE_P(
853 Glsl, CompileVulkanToSpirvTestAMD,
854 ::testing::ValuesIn(std::vector<std::string>({
855 "spv.16bitxfb.vert",
856 "spv.float16.frag",
857 "spv.float16Fetch.frag",
858 "spv.imageLoadStoreLod.frag",
859 "spv.int16.frag",
860 "spv.int16.amd.frag",
861 "spv.shaderBallotAMD.comp",
862 "spv.shaderFragMaskAMD.frag",
863 "spv.textureGatherBiasLod.frag",
864 })),
865 FileNameAsCustomTestSuffix
866 );
867
868 INSTANTIATE_TEST_SUITE_P(
869 Glsl, CompileVulkanToSpirvTestNV,
870 ::testing::ValuesIn(std::vector<std::string>({
871 "spv.sampleMaskOverrideCoverage.frag",
872 "spv.GeometryShaderPassthrough.geom",
873 "spv.viewportArray2.vert",
874 "spv.viewportArray2.tesc",
875 "spv.stereoViewRendering.vert",
876 "spv.stereoViewRendering.tesc",
877 "spv.multiviewPerViewAttributes.vert",
878 "spv.multiviewPerViewAttributes.tesc",
879 "spv.atomicInt64.comp",
880 "spv.atomicStoreInt64.comp",
881 "spv.shadingRate.frag",
882 "spv.RayGenShader.rgen",
883 "spv.RayGenShaderArray.rgen",
884 "spv.RayGenShader_Errors.rgen",
885 "spv.RayConstants.rgen",
886 "spv.IntersectShader.rint",
887 "spv.IntersectShader_Errors.rint",
888 "spv.AnyHitShader.rahit",
889 "spv.AnyHitShader_Errors.rahit",
890 "spv.ClosestHitShader.rchit",
891 "spv.ClosestHitShader_Errors.rchit",
892 "spv.MissShader.rmiss",
893 "spv.MissShader_Errors.rmiss",
894 "spv.RayCallable.rcall",
895 "spv.RayCallable_Errors.rcall",
896 "spv.fragmentShaderBarycentric.frag",
897 "spv.fragmentShaderBarycentric2.frag",
898 "spv.computeShaderDerivatives.comp",
899 "spv.computeShaderDerivatives2.comp",
900 "spv.shaderImageFootprint.frag",
901 "spv.meshShaderBuiltins.mesh",
902 "spv.meshShaderUserDefined.mesh",
903 "spv.meshShaderPerViewBuiltins.mesh",
904 "spv.meshShaderPerViewUserDefined.mesh",
905 "spv.meshShaderPerView_Errors.mesh",
906 "spv.meshShaderSharedMem.mesh",
907 "spv.meshShaderTaskMem.mesh",
908 "spv.320.meshShaderUserDefined.mesh",
909 "spv.meshShaderRedeclBuiltins.mesh",
910 "spv.meshShaderRedeclPerViewBuiltins.mesh",
911 "spv.meshTaskShader.task",
912 "spv.perprimitiveNV.frag",
913 })),
914 FileNameAsCustomTestSuffix
915 );
916
917 INSTANTIATE_TEST_SUITE_P(
918 Glsl, CompileVulkanToSpirv14TestNV,
919 ::testing::ValuesIn(std::vector<std::string>({
920 "spv.RayGenShaderMotion.rgen",
921 "spv.IntersectShaderMotion.rint",
922 "spv.AnyHitShaderMotion.rahit",
923 "spv.ClosestHitShaderMotion.rchit",
924 "spv.MissShaderMotion.rmiss",
925 })),
926 FileNameAsCustomTestSuffix
927 );
928
929 INSTANTIATE_TEST_SUITE_P(
930 Glsl, CompileUpgradeTextureToSampledTextureAndDropSamplersTest,
931 ::testing::ValuesIn(std::vector<std::string>({
932 "spv.texture.sampler.transform.frag",
933 })),
934 FileNameAsCustomTestSuffix
935 );
936
937 INSTANTIATE_TEST_SUITE_P(
938 Glsl, CompileVulkanToNonSemanticShaderDebugInfoTest,
939 ::testing::ValuesIn(std::vector<std::string>({
940 "spv.debuginfo.glsl.vert",
941 "spv.debuginfo.glsl.frag",
942 "spv.debuginfo.glsl.comp",
943 "spv.debuginfo.glsl.geom",
944 "spv.debuginfo.glsl.tesc",
945 "spv.debuginfo.glsl.tese",
946 "spv.debuginfo.bufferref.glsl.frag",
947 "spv.debuginfo.const_params.glsl.comp",
948 "spv.debuginfo.scalar_types.glsl.frag",
949 "spv.debuginfo.rt_types.glsl.rgen",
950 })),
951 FileNameAsCustomTestSuffix
952 );
953 // clang-format on
954
955 } // anonymous namespace
956 } // namespace glslangtest
957