1 /*-------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
5 * Copyright (c) 2015 Google Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Vulkan Test Package
22 *//*--------------------------------------------------------------------*/
24 #include "vktTestPackage.hpp"
26 #include "tcuPlatform.hpp"
27 #include "tcuTestCase.hpp"
28 #include "tcuTestLog.hpp"
29 #include "tcuCommandLine.hpp"
30 #include "tcuWaiverUtil.hpp"
32 #include "vkPlatform.hpp"
33 #include "vkPrograms.hpp"
34 #include "vkBinaryRegistry.hpp"
35 #include "vkShaderToSpirV.hpp"
36 #include "vkDebugReportUtil.hpp"
37 #include "vkQueryUtil.hpp"
38 #include "vkApiVersion.hpp"
39 #include "vkRenderDocUtil.hpp"
41 #include "deUniquePtr.hpp"
43 #include "vktTestGroupUtil.hpp"
44 #include "vktApiTests.hpp"
45 #include "vktPipelineTests.hpp"
46 #include "vktBindingModelTests.hpp"
47 #include "vktSpvAsmTests.hpp"
48 #include "vktShaderLibrary.hpp"
49 #include "vktRenderPassTests.hpp"
50 #include "vktMemoryTests.hpp"
51 #include "vktShaderRenderBuiltinVarTests.hpp"
52 #include "vktShaderRenderDerivateTests.hpp"
53 #include "vktShaderRenderDiscardTests.hpp"
54 #include "vktShaderRenderIndexingTests.hpp"
55 #include "vktShaderRenderInvarianceTests.hpp"
56 #include "vktShaderRenderLimitTests.hpp"
57 #include "vktShaderRenderLoopTests.hpp"
58 #include "vktShaderRenderMatrixTests.hpp"
59 #include "vktShaderRenderOperatorTests.hpp"
60 #include "vktShaderRenderReturnTests.hpp"
61 #include "vktShaderRenderStructTests.hpp"
62 #include "vktShaderRenderSwitchTests.hpp"
63 #include "vktShaderRenderTextureFunctionTests.hpp"
64 #include "vktShaderRenderTextureGatherTests.hpp"
65 #include "vktShaderBuiltinTests.hpp"
66 #include "vktOpaqueTypeIndexingTests.hpp"
67 #include "vktAtomicOperationTests.hpp"
68 #include "vktUniformBlockTests.hpp"
69 #include "vktDynamicStateTests.hpp"
70 #include "vktSSBOLayoutTests.hpp"
71 #include "vktQueryPoolTests.hpp"
72 #include "vktDrawTests.hpp"
73 #include "vktComputeTests.hpp"
74 #include "vktConditionalTests.hpp"
75 #include "vktImageTests.hpp"
76 #include "vktInfoTests.hpp"
77 #include "vktWsiTests.hpp"
78 #include "vktSynchronizationTests.hpp"
79 #include "vktSparseResourcesTests.hpp"
80 #include "vktTessellationTests.hpp"
81 #include "vktRasterizationTests.hpp"
82 #include "vktClippingTests.hpp"
83 #include "vktFragmentOperationsTests.hpp"
84 #include "vktTextureTests.hpp"
85 #include "vktGeometryTests.hpp"
86 #include "vktRobustnessTests.hpp"
87 #include "vktMultiViewTests.hpp"
88 #include "vktSubgroupsTests.hpp"
89 #include "vktYCbCrTests.hpp"
90 #include "vktProtectedMemTests.hpp"
91 #include "vktDeviceGroupTests.hpp"
92 #include "vktMemoryModelTests.hpp"
93 #include "vktAmberGraphicsFuzzTests.hpp"
94 #include "vktAmberGlslTests.hpp"
95 #include "vktImagelessFramebufferTests.hpp"
96 #include "vktTransformFeedbackTests.hpp"
97 #include "vktDescriptorIndexingTests.hpp"
98 #include "vktImagelessFramebufferTests.hpp"
99 #include "vktFragmentShaderInterlockTests.hpp"
100 #include "vktShaderClockTests.hpp"
101 #include "vktModifiersTests.hpp"
102 #include "vktRayTracingTests.hpp"
103 #include "vktRayQueryTests.hpp"
104 #include "vktPostmortemTests.hpp"
105 #include "vktFragmentShadingRateTests.hpp"
106 #include "vktReconvergenceTests.hpp"
111 namespace // compilation
114 vk::ProgramBinary* compileProgram (const vk::GlslSource& source, glu::ShaderProgramInfo* buildInfo, const tcu::CommandLine& commandLine)
116 return vk::buildProgram(source, buildInfo, commandLine);
119 vk::ProgramBinary* compileProgram (const vk::HlslSource& source, glu::ShaderProgramInfo* buildInfo, const tcu::CommandLine& commandLine)
121 return vk::buildProgram(source, buildInfo, commandLine);
124 vk::ProgramBinary* compileProgram (const vk::SpirVAsmSource& source, vk::SpirVProgramInfo* buildInfo, const tcu::CommandLine& commandLine)
126 return vk::assembleProgram(source, buildInfo, commandLine);
129 template <typename InfoType, typename IteratorType>
130 vk::ProgramBinary* buildProgram (const std::string& casePath,
132 const vk::BinaryRegistryReader& prebuiltBinRegistry,
134 vk::BinaryCollection* progCollection,
135 const tcu::CommandLine& commandLine)
137 const vk::ProgramIdentifier progId (casePath, iter.getName());
138 const tcu::ScopedLogSection progSection (log, iter.getName(), "Program: " + iter.getName());
139 de::MovePtr<vk::ProgramBinary> binProg;
144 binProg = de::MovePtr<vk::ProgramBinary>(compileProgram(iter.getProgram(), &buildInfo, commandLine));
147 catch (const tcu::NotSupportedError& err)
149 // Try to load from cache
150 log << err << tcu::TestLog::Message << "Building from source not supported, loading stored binary instead" << tcu::TestLog::EndMessage;
152 binProg = de::MovePtr<vk::ProgramBinary>(prebuiltBinRegistry.loadProgram(progId));
154 log << iter.getProgram();
156 catch (const tcu::Exception&)
158 // Build failed for other reason
163 TCU_CHECK_INTERNAL(binProg);
166 vk::ProgramBinary* const returnBinary = binProg.get();
168 progCollection->add(progId.programName, binProg);
174 } // anonymous(compilation)
186 class TestCaseExecutor : public tcu::TestCaseExecutor
189 TestCaseExecutor (tcu::TestContext& testCtx);
190 ~TestCaseExecutor (void);
192 virtual void init (tcu::TestCase* testCase, const std::string& path);
193 virtual void deinit (tcu::TestCase* testCase);
195 virtual tcu::TestNode::IterateResult iterate (tcu::TestCase* testCase);
198 void logUnusedShaders (tcu::TestCase* testCase);
200 bool spirvVersionSupported(vk::SpirvVersion);
201 vk::BinaryCollection m_progCollection;
202 vk::BinaryRegistryReader m_prebuiltBinRegistry;
204 const UniquePtr<vk::Library> m_library;
207 const UniquePtr<vk::RenderDocUtil> m_renderDoc;
208 vk::VkPhysicalDeviceProperties m_deviceProperties;
209 tcu::WaiverUtil m_waiverMechanism;
211 TestInstance* m_instance; //!< Current test case instance
214 static MovePtr<vk::Library> createLibrary (tcu::TestContext& testCtx)
216 return MovePtr<vk::Library>(testCtx.getPlatform().getVulkanPlatform().createLibrary());
219 static vk::VkPhysicalDeviceProperties getPhysicalDeviceProperties(vkt::Context& context)
221 const vk::InstanceInterface& vki = context.getInstanceInterface();
222 const vk::VkPhysicalDevice physicalDevice = context.getPhysicalDevice();
224 vk::VkPhysicalDeviceProperties properties;
225 vki.getPhysicalDeviceProperties(physicalDevice, &properties);
229 TestCaseExecutor::TestCaseExecutor (tcu::TestContext& testCtx)
230 : m_prebuiltBinRegistry (testCtx.getArchive(), "vulkan/prebuilt")
231 , m_library (createLibrary(testCtx))
232 , m_context (testCtx, m_library->getPlatformInterface(), m_progCollection)
233 , m_renderDoc (testCtx.getCommandLine().isRenderDocEnabled()
234 ? MovePtr<vk::RenderDocUtil>(new vk::RenderDocUtil())
235 : MovePtr<vk::RenderDocUtil>(DE_NULL))
236 , m_deviceProperties (getPhysicalDeviceProperties(m_context))
237 , m_instance (DE_NULL)
239 tcu::SessionInfo sessionInfo(m_deviceProperties.vendorID,
240 m_deviceProperties.deviceID,
241 testCtx.getCommandLine().getInitialCmdLine());
242 m_waiverMechanism.setup(testCtx.getCommandLine().getWaiverFileName(),
244 m_deviceProperties.vendorID,
245 m_deviceProperties.deviceID,
247 testCtx.getLog().writeSessionInfo(sessionInfo.get());
250 TestCaseExecutor::~TestCaseExecutor (void)
255 void TestCaseExecutor::init (tcu::TestCase* testCase, const std::string& casePath)
257 TestCase* vktCase = dynamic_cast<TestCase*>(testCase);
258 tcu::TestLog& log = m_context.getTestContext().getLog();
259 const deUint32 usedVulkanVersion = m_context.getUsedApiVersion();
260 const vk::SpirvVersion baselineSpirvVersion = vk::getBaselineSpirvVersion(usedVulkanVersion);
261 vk::ShaderBuildOptions defaultGlslBuildOptions (usedVulkanVersion, baselineSpirvVersion, 0u);
262 vk::ShaderBuildOptions defaultHlslBuildOptions (usedVulkanVersion, baselineSpirvVersion, 0u);
263 vk::SpirVAsmBuildOptions defaultSpirvAsmBuildOptions (usedVulkanVersion, baselineSpirvVersion);
264 vk::SourceCollections sourceProgs (usedVulkanVersion, defaultGlslBuildOptions, defaultHlslBuildOptions, defaultSpirvAsmBuildOptions);
265 const tcu::CommandLine& commandLine = m_context.getTestContext().getCommandLine();
266 const bool doShaderLog = commandLine.isLogDecompiledSpirvEnabled() && log.isShaderLoggingEnabled();
269 TCU_THROW(InternalError, "Test node not an instance of vkt::TestCase");
271 if (m_waiverMechanism.isOnWaiverList(casePath))
272 throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER);
274 vktCase->checkSupport(m_context);
276 vktCase->delayedInit();
278 m_progCollection.clear();
279 vktCase->initPrograms(sourceProgs);
281 for (vk::GlslSourceCollection::Iterator progIter = sourceProgs.glslSources.begin(); progIter != sourceProgs.glslSources.end(); ++progIter)
283 if (!spirvVersionSupported(progIter.getProgram().buildOptions.targetVersion))
284 TCU_THROW(NotSupportedError, "Shader requires SPIR-V higher than available");
286 const vk::ProgramBinary* const binProg = buildProgram<glu::ShaderProgramInfo, vk::GlslSourceCollection::Iterator>(casePath, progIter, m_prebuiltBinRegistry, log, &m_progCollection, commandLine);
292 std::ostringstream disasm;
294 vk::disassembleProgram(*binProg, &disasm);
296 log << vk::SpirVAsmSource(disasm.str());
298 catch (const tcu::NotSupportedError& err)
305 for (vk::HlslSourceCollection::Iterator progIter = sourceProgs.hlslSources.begin(); progIter != sourceProgs.hlslSources.end(); ++progIter)
307 if (!spirvVersionSupported(progIter.getProgram().buildOptions.targetVersion))
308 TCU_THROW(NotSupportedError, "Shader requires SPIR-V higher than available");
310 const vk::ProgramBinary* const binProg = buildProgram<glu::ShaderProgramInfo, vk::HlslSourceCollection::Iterator>(casePath, progIter, m_prebuiltBinRegistry, log, &m_progCollection, commandLine);
316 std::ostringstream disasm;
318 vk::disassembleProgram(*binProg, &disasm);
320 log << vk::SpirVAsmSource(disasm.str());
322 catch (const tcu::NotSupportedError& err)
329 for (vk::SpirVAsmCollection::Iterator asmIterator = sourceProgs.spirvAsmSources.begin(); asmIterator != sourceProgs.spirvAsmSources.end(); ++asmIterator)
331 if (!spirvVersionSupported(asmIterator.getProgram().buildOptions.targetVersion))
332 TCU_THROW(NotSupportedError, "Shader requires SPIR-V higher than available");
334 buildProgram<vk::SpirVProgramInfo, vk::SpirVAsmCollection::Iterator>(casePath, asmIterator, m_prebuiltBinRegistry, log, &m_progCollection, commandLine);
337 if (m_renderDoc) m_renderDoc->startFrame(m_context.getInstance());
339 DE_ASSERT(!m_instance);
340 m_instance = vktCase->createInstance(m_context);
341 m_context.resultSetOnValidation(false);
344 void TestCaseExecutor::deinit (tcu::TestCase* testCase)
347 m_instance = DE_NULL;
349 if (m_renderDoc) m_renderDoc->endFrame(m_context.getInstance());
351 // Collect and report any debug messages
352 if (m_context.hasDebugReportRecorder())
353 collectAndReportDebugMessages(m_context.getDebugReportRecorder(), m_context);
355 if (testCase != DE_NULL)
356 logUnusedShaders(testCase);
359 void TestCaseExecutor::logUnusedShaders (tcu::TestCase* testCase)
361 const qpTestResult testResult = testCase->getTestContext().getTestResult();
363 if (testResult == QP_TEST_RESULT_PASS || testResult == QP_TEST_RESULT_QUALITY_WARNING || testResult == QP_TEST_RESULT_COMPATIBILITY_WARNING)
365 bool unusedShaders = false;
367 for (vk::BinaryCollection::Iterator it = m_progCollection.begin(); it != m_progCollection.end(); ++it)
369 if (!it.getProgram().getUsed())
371 unusedShaders = true;
381 for (vk::BinaryCollection::Iterator it = m_progCollection.begin(); it != m_progCollection.end(); ++it)
383 if (!it.getProgram().getUsed())
384 message += it.getName() + ",";
387 message.resize(message.size() - 1);
389 message = std::string("Unused shaders: ") + message;
391 m_context.getTestContext().getLog() << TestLog::Message << message << TestLog::EndMessage;
396 tcu::TestNode::IterateResult TestCaseExecutor::iterate (tcu::TestCase*)
398 DE_ASSERT(m_instance);
400 const tcu::TestStatus result = m_instance->iterate();
402 if (result.isComplete())
404 // Vulkan tests shouldn't set result directly except when using a debug report messenger to catch validation errors.
405 DE_ASSERT(m_context.getTestContext().getTestResult() == QP_TEST_RESULT_LAST || m_context.resultSetOnValidation());
407 // Override result if not set previously by a debug report messenger.
408 if (!m_context.resultSetOnValidation())
409 m_context.getTestContext().setTestResult(result.getCode(), result.getDescription().c_str());
410 return tcu::TestNode::STOP;
413 return tcu::TestNode::CONTINUE;
416 bool TestCaseExecutor::spirvVersionSupported (vk::SpirvVersion spirvVersion)
418 if (spirvVersion <= vk::getMaxSpirvVersionForVulkan(m_context.getUsedApiVersion()))
421 if (spirvVersion <= vk::SPIRV_VERSION_1_4)
422 return m_context.isDeviceFunctionalitySupported("VK_KHR_spirv_1_4");
429 void createGlslTests (tcu::TestCaseGroup* glslTests)
431 tcu::TestContext& testCtx = glslTests->getTestContext();
433 // ShaderLibrary-based tests
437 const char* description;
440 { "arrays", "Arrays" },
441 { "conditionals", "Conditional statements" },
442 { "constant_expressions", "Constant expressions" },
443 { "constants", "Constants" },
444 { "conversions", "Type conversions" },
445 { "functions", "Functions" },
446 { "linkage", "Linking" },
447 { "scoping", "Scoping" },
448 { "swizzles", "Swizzles" },
451 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_es310Tests); ndx++)
452 glslTests->addChild(createShaderLibraryGroup(testCtx,
453 s_es310Tests[ndx].name,
454 s_es310Tests[ndx].description,
455 std::string("vulkan/glsl/es310/") + s_es310Tests[ndx].name + ".test").release());
460 const char* description;
463 { "linkage", "Linking" },
466 de::MovePtr<tcu::TestCaseGroup> glsl440Tests = de::MovePtr<tcu::TestCaseGroup>(new tcu::TestCaseGroup(testCtx, "440", ""));
468 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_440Tests); ndx++)
469 glsl440Tests->addChild(createShaderLibraryGroup(testCtx,
470 s_440Tests[ndx].name,
471 s_440Tests[ndx].description,
472 std::string("vulkan/glsl/440/") + s_440Tests[ndx].name + ".test").release());
474 glslTests->addChild(glsl440Tests.release());
476 // ShaderRenderCase-based tests
477 glslTests->addChild(sr::createDerivateTests (testCtx));
478 glslTests->addChild(sr::createDiscardTests (testCtx));
479 glslTests->addChild(sr::createDemoteTests (testCtx));
480 glslTests->addChild(sr::createIndexingTests (testCtx));
481 glslTests->addChild(sr::createShaderInvarianceTests (testCtx));
482 glslTests->addChild(sr::createLimitTests (testCtx));
483 glslTests->addChild(sr::createLoopTests (testCtx));
484 glslTests->addChild(sr::createMatrixTests (testCtx));
485 glslTests->addChild(sr::createOperatorTests (testCtx));
486 glslTests->addChild(sr::createReturnTests (testCtx));
487 glslTests->addChild(sr::createStructTests (testCtx));
488 glslTests->addChild(sr::createSwitchTests (testCtx));
489 glslTests->addChild(sr::createTextureFunctionTests (testCtx));
490 glslTests->addChild(sr::createTextureGatherTests (testCtx));
491 glslTests->addChild(sr::createBuiltinVarTests (testCtx));
493 // ShaderExecutor-based tests
494 glslTests->addChild(shaderexecutor::createBuiltinTests (testCtx));
495 glslTests->addChild(shaderexecutor::createOpaqueTypeIndexingTests (testCtx));
496 glslTests->addChild(shaderexecutor::createAtomicOperationTests (testCtx));
497 glslTests->addChild(shaderexecutor::createShaderClockTests (testCtx));
500 glslTests->addChild(cts_amber::createCombinedOperationsGroup (testCtx));
505 BaseTestPackage::BaseTestPackage (tcu::TestContext& testCtx, const char* name, const char* desc)
506 : tcu::TestPackage(testCtx, name, desc)
510 BaseTestPackage::~BaseTestPackage (void)
514 TestPackage::TestPackage (tcu::TestContext& testCtx)
515 : BaseTestPackage(testCtx, "dEQP-VK", "dEQP Vulkan Tests")
519 TestPackage::~TestPackage (void)
523 ExperimentalTestPackage::ExperimentalTestPackage (tcu::TestContext& testCtx)
524 : BaseTestPackage(testCtx, "dEQP-VK-experimental", "dEQP Vulkan Experimental Tests")
528 ExperimentalTestPackage::~ExperimentalTestPackage (void)
532 tcu::TestCaseExecutor* BaseTestPackage::createExecutor (void) const
534 return new TestCaseExecutor(m_testCtx);
537 void TestPackage::init (void)
539 addChild(createTestGroup (m_testCtx, "info", "Build and Device Info Tests", createInfoTests));
540 addChild(api::createTests (m_testCtx));
541 addChild(memory::createTests (m_testCtx));
542 addChild(pipeline::createTests (m_testCtx));
543 addChild(BindingModel::createTests (m_testCtx));
544 addChild(SpirVAssembly::createTests (m_testCtx));
545 addChild(createTestGroup (m_testCtx, "glsl", "GLSL shader execution tests", createGlslTests));
546 addChild(createRenderPassTests (m_testCtx));
547 addChild(createRenderPass2Tests (m_testCtx));
548 addChild(createDynamicRenderingTests (m_testCtx));
549 addChild(ubo::createTests (m_testCtx));
550 addChild(DynamicState::createTests (m_testCtx));
551 addChild(ssbo::createTests (m_testCtx));
552 addChild(QueryPool::createTests (m_testCtx));
553 addChild(Draw::createTests (m_testCtx));
554 addChild(compute::createTests (m_testCtx));
555 addChild(image::createTests (m_testCtx));
556 addChild(wsi::createTests (m_testCtx));
557 addChild(createSynchronizationTests (m_testCtx));
558 addChild(createSynchronization2Tests (m_testCtx));
559 addChild(sparse::createTests (m_testCtx));
560 addChild(tessellation::createTests (m_testCtx));
561 addChild(rasterization::createTests (m_testCtx));
562 addChild(clipping::createTests (m_testCtx));
563 addChild(FragmentOperations::createTests (m_testCtx));
564 addChild(texture::createTests (m_testCtx));
565 addChild(geometry::createTests (m_testCtx));
566 addChild(robustness::createTests (m_testCtx));
567 addChild(MultiView::createTests (m_testCtx));
568 addChild(subgroups::createTests (m_testCtx));
569 addChild(ycbcr::createTests (m_testCtx));
570 addChild(ProtectedMem::createTests (m_testCtx));
571 addChild(DeviceGroup::createTests (m_testCtx));
572 addChild(MemoryModel::createTests (m_testCtx));
573 addChild(conditional::createTests (m_testCtx));
574 addChild(cts_amber::createGraphicsFuzzTests (m_testCtx));
575 addChild(imageless::createTests (m_testCtx));
576 addChild(TransformFeedback::createTests (m_testCtx));
577 addChild(DescriptorIndexing::createTests (m_testCtx));
578 addChild(FragmentShaderInterlock::createTests(m_testCtx));
579 addChild(modifiers::createTests (m_testCtx));
580 addChild(RayTracing::createTests (m_testCtx));
581 addChild(RayQuery::createTests (m_testCtx));
582 addChild(FragmentShadingRate::createTests (m_testCtx));
583 addChild(Reconvergence::createTests (m_testCtx, false));
586 void ExperimentalTestPackage::init (void)
588 addChild(postmortem::createTests (m_testCtx));
589 addChild(Reconvergence::createTests (m_testCtx, true));