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