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