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 "qpDebugOut.h"
29 #include "tcuPlatform.hpp"
30 #include "tcuTestCase.hpp"
31 #include "tcuTestLog.hpp"
32 #include "tcuCommandLine.hpp"
33 #include "tcuWaiverUtil.hpp"
35 #include "vkPlatform.hpp"
36 #include "vkPrograms.hpp"
37 #include "vkBinaryRegistry.hpp"
38 #include "vkShaderToSpirV.hpp"
39 #include "vkDebugReportUtil.hpp"
40 #include "vkQueryUtil.hpp"
41 #include "vkApiVersion.hpp"
42 #include "vkRenderDocUtil.hpp"
43 #include "vkResourceInterface.hpp"
45 #include "deUniquePtr.hpp"
46 #include "deSharedPtr.hpp"
47 #ifdef CTS_USES_VULKANSC
48 #include "deProcess.h"
49 #include "vksClient.hpp"
51 #endif // CTS_USES_VULKANSC
53 #include "vktTestGroupUtil.hpp"
54 #include "vktApiTests.hpp"
55 #include "vktPipelineTests.hpp"
56 #include "vktBindingModelTests.hpp"
57 #include "vktSpvAsmTests.hpp"
58 #include "vktShaderLibrary.hpp"
59 #include "vktRenderPassTests.hpp"
60 #include "vktMemoryTests.hpp"
61 #include "vktShaderRenderBuiltinVarTests.hpp"
62 #include "vktShaderRenderDerivateTests.hpp"
63 #include "vktShaderRenderDiscardTests.hpp"
64 #include "vktShaderRenderIndexingTests.hpp"
65 #include "vktShaderRenderInvarianceTests.hpp"
66 #include "vktShaderRenderLimitTests.hpp"
67 #include "vktShaderRenderLoopTests.hpp"
68 #include "vktShaderRenderMatrixTests.hpp"
69 #include "vktShaderRenderOperatorTests.hpp"
70 #include "vktShaderRenderReturnTests.hpp"
71 #include "vktShaderRenderStructTests.hpp"
72 #include "vktShaderRenderSwitchTests.hpp"
73 #include "vktShaderRenderTextureFunctionTests.hpp"
74 #include "vktShaderRenderTextureGatherTests.hpp"
75 #include "vktShaderBuiltinTests.hpp"
76 #include "vktOpaqueTypeIndexingTests.hpp"
77 #include "vktAtomicOperationTests.hpp"
78 #include "vktUniformBlockTests.hpp"
79 #include "vktDynamicStateTests.hpp"
80 #include "vktSSBOLayoutTests.hpp"
81 #include "vktQueryPoolTests.hpp"
82 #include "vktDrawTests.hpp"
83 #include "vktComputeTests.hpp"
84 #include "vktConditionalTests.hpp"
85 #include "vktImageTests.hpp"
86 #include "vktInfoTests.hpp"
87 #include "vktWsiTests.hpp"
88 #include "vktSynchronizationTests.hpp"
89 #include "vktSparseResourcesTests.hpp"
90 #include "vktTessellationTests.hpp"
91 #include "vktRasterizationTests.hpp"
92 #include "vktClippingTests.hpp"
93 #include "vktFragmentOperationsTests.hpp"
94 #include "vktTextureTests.hpp"
95 #include "vktGeometryTests.hpp"
96 #include "vktRobustnessTests.hpp"
97 #include "vktMultiViewTests.hpp"
98 #include "vktSubgroupsTests.hpp"
99 #include "vktYCbCrTests.hpp"
100 #include "vktProtectedMemTests.hpp"
101 #include "vktDeviceGroupTests.hpp"
102 #include "vktMemoryModelTests.hpp"
103 #include "vktAmberGraphicsFuzzTests.hpp"
104 #include "vktAmberGlslTests.hpp"
105 #include "vktImagelessFramebufferTests.hpp"
106 #include "vktTransformFeedbackTests.hpp"
107 #include "vktDescriptorIndexingTests.hpp"
108 #include "vktImagelessFramebufferTests.hpp"
109 #include "vktFragmentShaderInterlockTests.hpp"
110 #include "vktShaderClockTests.hpp"
111 #include "vktModifiersTests.hpp"
112 #include "vktRayTracingTests.hpp"
113 #include "vktRayQueryTests.hpp"
114 #include "vktPostmortemTests.hpp"
115 #include "vktFragmentShadingRateTests.hpp"
116 #include "vktReconvergenceTests.hpp"
117 #include "vktMeshShaderTests.hpp"
118 #include "vktFragmentShadingBarycentricTests.hpp"
119 #ifdef CTS_USES_VULKANSC
120 #include "vktSafetyCriticalTests.hpp"
121 #endif // CTS_USES_VULKANSC
139 #ifdef CTS_USES_VULKANSC
140 struct DetailedSubprocessTestCount
142 std::string testPattern;
145 #endif // CTS_USES_VULKANSC
147 class TestCaseExecutor : public tcu::TestCaseExecutor
150 TestCaseExecutor (tcu::TestContext& testCtx);
151 ~TestCaseExecutor (void);
153 void init (tcu::TestCase* testCase, const std::string& path) override;
154 void deinit (tcu::TestCase* testCase) override;
156 tcu::TestNode::IterateResult iterate (tcu::TestCase* testCase) override;
158 void deinitTestPackage (tcu::TestContext& testCtx) override;
159 bool usesLocalStatus () override;
160 void updateGlobalStatus (tcu::TestRunStatus& status) override;
161 void reportDurations (tcu::TestContext& testCtx, const std::string& packageName, const deInt64& duration, const std::map<std::string, deUint64>& groupsDurationTime) override;
162 int getCurrentSubprocessCount (const std::string& casePath, int defaultSubprocessCount);
165 void logUnusedShaders (tcu::TestCase* testCase);
167 void runTestsInSubprocess (tcu::TestContext& testCtx);
169 bool spirvVersionSupported (vk::SpirvVersion);
171 vk::BinaryCollection m_progCollection;
172 vk::BinaryRegistryReader m_prebuiltBinRegistry;
174 const UniquePtr<vk::Library> m_library;
175 MovePtr<Context> m_context;
177 const UniquePtr<vk::RenderDocUtil> m_renderDoc;
178 SharedPtr<vk::ResourceInterface> m_resourceInterface;
179 vk::VkPhysicalDeviceProperties m_deviceProperties;
180 tcu::WaiverUtil m_waiverMechanism;
182 TestInstance* m_instance; //!< Current test case instance
183 std::vector<std::string> m_testsForSubprocess;
184 tcu::TestRunStatus m_status;
186 #ifdef CTS_USES_VULKANSC
187 int m_subprocessCount;
189 std::unique_ptr<vksc_server::ipc::Parent> m_parentIPC;
190 std::vector<DetailedSubprocessTestCount> m_detailedSubprocessTestCount;
191 #endif // CTS_USES_VULKANSC
194 #ifdef CTS_USES_VULKANSC
195 static deBool supressedWrite (int, const char*) { return false; }
196 static deBool supressedWriteFtm (int, const char*, va_list) { return false; }
197 static deBool openWrite (int type, const char* message) { DE_UNREF(type); DE_UNREF(message); return true; }
198 static deBool openWriteFtm (int type, const char* format, va_list args) { DE_UNREF(type); DE_UNREF(format); DE_UNREF(args); return true; }
199 static void suppressStandardOutput () { qpRedirectOut(supressedWrite, supressedWriteFtm); }
200 static void restoreStandardOutput () { qpRedirectOut(openWrite, openWriteFtm); }
201 #endif // CTS_USES_VULKANSC
203 static MovePtr<vk::Library> createLibrary (tcu::TestContext& testCtx)
205 return MovePtr<vk::Library>(testCtx.getPlatform().getVulkanPlatform().createLibrary(testCtx.getCommandLine().getVkLibraryPath()));
208 static vk::VkPhysicalDeviceProperties getPhysicalDeviceProperties(vkt::Context& context)
210 const vk::InstanceInterface& vki = context.getInstanceInterface();
211 const vk::VkPhysicalDevice physicalDevice = context.getPhysicalDevice();
213 vk::VkPhysicalDeviceProperties properties;
214 vki.getPhysicalDeviceProperties(physicalDevice, &properties);
218 std::string trim (const std::string& original)
220 static const std::string whiteSigns = " \t";
221 const auto beg = original.find_first_not_of(whiteSigns);
222 if (beg == std::string::npos)
223 return std::string();
224 const auto end = original.find_last_not_of(whiteSigns);
225 return original.substr(beg, end - beg + 1);
228 TestCaseExecutor::TestCaseExecutor (tcu::TestContext& testCtx)
229 : m_prebuiltBinRegistry (testCtx.getArchive(), "vulkan/prebuilt")
230 , m_library (createLibrary(testCtx))
231 , m_renderDoc (testCtx.getCommandLine().isRenderDocEnabled()
232 ? MovePtr<vk::RenderDocUtil>(new vk::RenderDocUtil())
233 : MovePtr<vk::RenderDocUtil>(DE_NULL))
234 #if defined CTS_USES_VULKANSC
235 , m_resourceInterface (new vk::ResourceInterfaceVKSC(testCtx))
237 , m_resourceInterface (new vk::ResourceInterfaceStandard(testCtx))
238 #endif // CTS_USES_VULKANSC
239 , m_instance (DE_NULL)
240 #if defined CTS_USES_VULKANSC
241 , m_subprocessCount (0)
242 #endif // CTS_USES_VULKANSC
244 #ifdef CTS_USES_VULKANSC
245 std::vector<int> caseFraction = testCtx.getCommandLine().getCaseFraction();
246 std::string jsonFileName;
248 if (caseFraction.empty())
250 jsonFileName = "pipeline_data.txt";
255 jsonFileName = "pipeline_data_" + std::to_string(caseFraction[0]) + ".txt";
256 portOffset = caseFraction[0];
259 if (testCtx.getCommandLine().isSubProcess())
261 std::vector<deUint8> input = vksc_server::ipc::Child{portOffset}.GetFile(jsonFileName);
262 m_resourceInterface->importData(input);
266 m_parentIPC.reset( new vksc_server::ipc::Parent{portOffset} );
269 // Load information about test tree branches that use subprocess test count other than default
270 // Expected file format:
271 if (!testCtx.getCommandLine().isSubProcess() && !std::string(testCtx.getCommandLine().getSubprocessConfigFile()).empty())
273 std::ifstream iFile(testCtx.getCommandLine().getSubprocessConfigFile(), std::ios::in);
275 TCU_THROW(InternalError, (std::string("Missing config file defining number of tests: ") + testCtx.getCommandLine().getSubprocessConfigFile()).c_str());
277 while (std::getline(iFile, line))
281 std::size_t pos = line.find_first_of(',');
282 if (pos == std::string::npos)
284 std::string testPattern, testNumber;
285 std::copy(line.begin(), line.begin() + pos, std::back_inserter(testPattern));
286 testPattern = trim(testPattern);
287 std::copy(line.begin() + pos + 1, line.end(), std::back_inserter(testNumber));
288 testNumber = trim(testNumber);
289 if (testPattern.empty() || testNumber.empty())
291 std::istringstream is(testNumber);
293 if ((is >> testCount).fail())
295 m_detailedSubprocessTestCount.push_back(DetailedSubprocessTestCount{ testPattern, testCount });
297 // sort test patterns
298 std::sort(m_detailedSubprocessTestCount.begin(), m_detailedSubprocessTestCount.end(), [](const DetailedSubprocessTestCount& lhs, const DetailedSubprocessTestCount& rhs)
300 return lhs.testCount < rhs.testCount;
304 // If we are provided with remote location
305 if (!std::string(testCtx.getCommandLine().getServerAddress()).empty())
307 // Open connection with the server dedicated for standard output
308 vksc_server::OpenRemoteStandardOutput(testCtx.getCommandLine().getServerAddress());
309 restoreStandardOutput();
311 #endif // CTS_USES_VULKANSC
313 m_context = MovePtr<Context>(new Context(testCtx, m_library->getPlatformInterface(), m_progCollection, m_resourceInterface));
314 m_deviceProperties = getPhysicalDeviceProperties(*m_context);
316 tcu::SessionInfo sessionInfo(m_deviceProperties.vendorID,
317 m_deviceProperties.deviceID,
318 testCtx.getCommandLine().getInitialCmdLine());
319 m_waiverMechanism.setup(testCtx.getCommandLine().getWaiverFileName(),
321 m_deviceProperties.vendorID,
322 m_deviceProperties.deviceID,
325 #ifdef CTS_USES_VULKANSC
326 if (!std::string(testCtx.getCommandLine().getServerAddress()).empty())
328 vksc_server::AppendRequest request;
329 request.fileName = testCtx.getCommandLine().getLogFileName();
331 std::ostringstream str;
332 str << "#sessionInfo releaseName " << qpGetReleaseName() << std::endl;
333 str << "#sessionInfo releaseId 0x" << std::hex << std::setw(8) << std::setfill('0') << qpGetReleaseId() << std::endl;
334 str << "#sessionInfo targetName \"" << qpGetTargetName() << "\"" << std::endl;
335 str << sessionInfo.get() << std::endl;
336 str << "#beginSession" << std::endl;
338 std::string output = str.str();
339 request.data.assign(output.begin(), output.end());
340 request.clear = true;
341 vksc_server::StandardOutputServerSingleton()->SendRequest(request);
344 #endif // CTS_USES_VULKANSC
346 testCtx.getLog().writeSessionInfo(sessionInfo.get());
349 #ifdef CTS_USES_VULKANSC
350 m_resourceInterface->initApiVersion(m_context->getUsedApiVersion());
352 // Real Vulkan SC tests are performed in subprocess.
353 // Tests run in main process are only used to collect data required by Vulkan SC.
354 // That's why we turn off any output in main process and copy output from subprocess when subprocess tests are performed
355 if (!testCtx.getCommandLine().isSubProcess())
357 suppressStandardOutput();
358 m_context->getTestContext().getLog().supressLogging(true);
360 #endif // CTS_USES_VULKANSC
363 TestCaseExecutor::~TestCaseExecutor (void)
368 void TestCaseExecutor::init (tcu::TestCase* testCase, const std::string& casePath)
370 if (m_waiverMechanism.isOnWaiverList(casePath))
371 throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER);
373 TestCase* vktCase = dynamic_cast<TestCase*>(testCase);
374 tcu::TestLog& log = m_context->getTestContext().getLog();
375 const deUint32 usedVulkanVersion = m_context->getUsedApiVersion();
376 const vk::SpirvVersion baselineSpirvVersion = vk::getBaselineSpirvVersion(usedVulkanVersion);
377 vk::ShaderBuildOptions defaultGlslBuildOptions (usedVulkanVersion, baselineSpirvVersion, 0u);
378 vk::ShaderBuildOptions defaultHlslBuildOptions (usedVulkanVersion, baselineSpirvVersion, 0u);
379 vk::SpirVAsmBuildOptions defaultSpirvAsmBuildOptions (usedVulkanVersion, baselineSpirvVersion);
380 vk::SourceCollections sourceProgs (usedVulkanVersion, defaultGlslBuildOptions, defaultHlslBuildOptions, defaultSpirvAsmBuildOptions);
381 const tcu::CommandLine& commandLine = m_context->getTestContext().getCommandLine();
382 const bool doShaderLog = commandLine.isLogDecompiledSpirvEnabled() && log.isShaderLoggingEnabled();
385 TCU_THROW(InternalError, "Test node not an instance of vkt::TestCase");
388 #ifdef CTS_USES_VULKANSC
389 int currentSubprocessCount = getCurrentSubprocessCount(casePath, m_context->getTestContext().getCommandLine().getSubprocessTestCount());
390 if (m_subprocessCount && currentSubprocessCount != m_subprocessCount)
392 runTestsInSubprocess(m_context->getTestContext());
394 // Clean up data after performing tests in subprocess and prepare system for another batch of tests
395 m_testsForSubprocess.clear();
396 const vk::DeviceInterface& vkd = m_context->getDeviceInterface();
397 const vk::DeviceDriverSC* dds = dynamic_cast<const vk::DeviceDriverSC*>(&vkd);
399 TCU_THROW(InternalError, "Undefined device driver for Vulkan SC");
401 m_resourceInterface->resetObjects();
403 suppressStandardOutput();
404 m_context->getTestContext().getLog().supressLogging(true);
406 m_subprocessCount = currentSubprocessCount;
407 #endif // CTS_USES_VULKANSC
408 m_testsForSubprocess.push_back(casePath);
411 m_resourceInterface->initTestCase(casePath);
413 if (m_waiverMechanism.isOnWaiverList(casePath))
414 throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER);
416 vktCase->checkSupport(*m_context);
418 vktCase->delayedInit();
420 m_progCollection.clear();
421 vktCase->initPrograms(sourceProgs);
423 for (vk::GlslSourceCollection::Iterator progIter = sourceProgs.glslSources.begin(); progIter != sourceProgs.glslSources.end(); ++progIter)
425 if (!spirvVersionSupported(progIter.getProgram().buildOptions.targetVersion))
426 TCU_THROW(NotSupportedError, "Shader requires SPIR-V higher than available");
428 const vk::ProgramBinary* const binProg = m_resourceInterface->buildProgram<glu::ShaderProgramInfo, vk::GlslSourceCollection::Iterator>(casePath, progIter, m_prebuiltBinRegistry, &m_progCollection);
434 std::ostringstream disasm;
436 vk::disassembleProgram(*binProg, &disasm);
438 log << vk::SpirVAsmSource(disasm.str());
440 catch (const tcu::NotSupportedError& err)
447 for (vk::HlslSourceCollection::Iterator progIter = sourceProgs.hlslSources.begin(); progIter != sourceProgs.hlslSources.end(); ++progIter)
449 if (!spirvVersionSupported(progIter.getProgram().buildOptions.targetVersion))
450 TCU_THROW(NotSupportedError, "Shader requires SPIR-V higher than available");
452 const vk::ProgramBinary* const binProg = m_resourceInterface->buildProgram<glu::ShaderProgramInfo, vk::HlslSourceCollection::Iterator>(casePath, progIter, m_prebuiltBinRegistry, &m_progCollection);
458 std::ostringstream disasm;
460 vk::disassembleProgram(*binProg, &disasm);
462 log << vk::SpirVAsmSource(disasm.str());
464 catch (const tcu::NotSupportedError& err)
471 for (vk::SpirVAsmCollection::Iterator asmIterator = sourceProgs.spirvAsmSources.begin(); asmIterator != sourceProgs.spirvAsmSources.end(); ++asmIterator)
473 if (!spirvVersionSupported(asmIterator.getProgram().buildOptions.targetVersion))
474 TCU_THROW(NotSupportedError, "Shader requires SPIR-V higher than available");
476 m_resourceInterface->buildProgram<vk::SpirVProgramInfo, vk::SpirVAsmCollection::Iterator>(casePath, asmIterator, m_prebuiltBinRegistry, &m_progCollection);
479 if (m_renderDoc) m_renderDoc->startFrame(m_context->getInstance());
481 DE_ASSERT(!m_instance);
482 m_instance = vktCase->createInstance(*m_context);
483 m_context->resultSetOnValidation(false);
486 void TestCaseExecutor::deinit (tcu::TestCase* testCase)
489 m_instance = DE_NULL;
491 if (m_renderDoc) m_renderDoc->endFrame(m_context->getInstance());
493 // Collect and report any debug messages
494 #ifndef CTS_USES_VULKANSC
495 if (m_context->hasDebugReportRecorder())
496 collectAndReportDebugMessages(m_context->getDebugReportRecorder(), *m_context);
497 #endif // CTS_USES_VULKANSC
499 if (testCase != DE_NULL)
500 logUnusedShaders(testCase);
502 #ifdef CTS_USES_VULKANSC
503 if (!m_context->getTestContext().getCommandLine().isSubProcess())
505 int currentSubprocessCount = getCurrentSubprocessCount(m_context->getResourceInterface()->getCasePath(), m_context->getTestContext().getCommandLine().getSubprocessTestCount());
506 if (m_testsForSubprocess.size() >= std::size_t(currentSubprocessCount))
508 runTestsInSubprocess(m_context->getTestContext());
510 // Clean up data after performing tests in subprocess and prepare system for another batch of tests
511 m_testsForSubprocess.clear();
512 const vk::DeviceInterface& vkd = m_context->getDeviceInterface();
513 const vk::DeviceDriverSC* dds = dynamic_cast<const vk::DeviceDriverSC*>(&vkd);
515 TCU_THROW(InternalError, "Undefined device driver for Vulkan SC");
517 m_resourceInterface->resetObjects();
519 suppressStandardOutput();
520 m_context->getTestContext().getLog().supressLogging(true);
523 #endif // CTS_USES_VULKANSC
526 void TestCaseExecutor::logUnusedShaders (tcu::TestCase* testCase)
528 const qpTestResult testResult = testCase->getTestContext().getTestResult();
530 if (testResult == QP_TEST_RESULT_PASS || testResult == QP_TEST_RESULT_QUALITY_WARNING || testResult == QP_TEST_RESULT_COMPATIBILITY_WARNING)
532 bool unusedShaders = false;
534 for (vk::BinaryCollection::Iterator it = m_progCollection.begin(); it != m_progCollection.end(); ++it)
536 if (!it.getProgram().getUsed())
538 unusedShaders = true;
548 for (vk::BinaryCollection::Iterator it = m_progCollection.begin(); it != m_progCollection.end(); ++it)
550 if (!it.getProgram().getUsed())
551 message += it.getName() + ",";
554 message.resize(message.size() - 1);
556 message = std::string("Unused shaders: ") + message;
558 m_context->getTestContext().getLog() << TestLog::Message << message << TestLog::EndMessage;
563 tcu::TestNode::IterateResult TestCaseExecutor::iterate (tcu::TestCase*)
565 DE_ASSERT(m_instance);
567 const tcu::TestStatus result = m_instance->iterate();
569 if (result.isComplete())
571 // Vulkan tests shouldn't set result directly except when using a debug report messenger to catch validation errors.
572 DE_ASSERT(m_context->getTestContext().getTestResult() == QP_TEST_RESULT_LAST || m_context->resultSetOnValidation());
574 // Override result if not set previously by a debug report messenger.
575 if (!m_context->resultSetOnValidation())
576 m_context->getTestContext().setTestResult(result.getCode(), result.getDescription().c_str());
577 return tcu::TestNode::STOP;
580 return tcu::TestNode::CONTINUE;
583 void TestCaseExecutor::deinitTestPackage (tcu::TestContext& testCtx)
585 #ifdef CTS_USES_VULKANSC
586 if (!testCtx.getCommandLine().isSubProcess())
588 if (!m_testsForSubprocess.empty())
590 runTestsInSubprocess(testCtx);
592 // Clean up data after performing tests in subprocess and prepare system for another batch of tests
593 m_testsForSubprocess.clear();
594 const vk::DeviceInterface& vkd = m_context->getDeviceInterface();
595 const vk::DeviceDriverSC* dds = dynamic_cast<const vk::DeviceDriverSC*>(&vkd);
597 TCU_THROW(InternalError, "Undefined device driver for Vulkan SC");
599 m_resourceInterface->resetObjects();
602 // Tests are finished. Next tests ( if any ) will come from other test package and test executor
603 restoreStandardOutput();
604 m_context->getTestContext().getLog().supressLogging(false);
606 m_resourceInterface->resetPipelineCaches();
609 #endif // CTS_USES_VULKANSC
612 bool TestCaseExecutor::usesLocalStatus ()
614 #ifdef CTS_USES_VULKANSC
615 return !m_context->getTestContext().getCommandLine().isSubProcess();
621 void TestCaseExecutor::updateGlobalStatus (tcu::TestRunStatus& status)
623 status.numExecuted += m_status.numExecuted;
624 status.numPassed += m_status.numPassed;
625 status.numNotSupported += m_status.numNotSupported;
626 status.numWarnings += m_status.numWarnings;
627 status.numWaived += m_status.numWaived;
628 status.numFailed += m_status.numFailed;
632 void TestCaseExecutor::reportDurations(tcu::TestContext& testCtx, const std::string& packageName, const deInt64& duration, const std::map<std::string, deUint64>& groupsDurationTime)
634 #ifdef CTS_USES_VULKANSC
635 // Send it to server to append to its log
636 vksc_server::AppendRequest request;
637 request.fileName = testCtx.getCommandLine().getLogFileName();
639 std::ostringstream str;
642 str << "#beginTestsCasesTime" << std::endl;
644 str << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
645 str << "<TestsCasesTime>" << std::endl;
647 str << " <Number Name=\"" << packageName << "\" Description=\"Total tests case duration in microseconds\" Tag=\"Time\" Unit=\"us\">" << duration << "</Number>" << std::endl;
648 for (std::map<std::string, deUint64>::const_iterator it = groupsDurationTime.begin(); it != groupsDurationTime.end(); ++it)
649 str << " <Number Name=\"" << it->first << "\" Description=\"The test group case duration in microseconds\" Tag=\"Time\" Unit=\"us\">" << it->second << "</Number>" << std::endl;
650 str << "</TestsCasesTime>" << std::endl;
652 str << "#endTestsCasesTime" << std::endl;
654 str << "#endSession" << std::endl;
656 std::string output = str.str();
657 request.data.assign(output.begin(), output.end());
658 vksc_server::StandardOutputServerSingleton()->SendRequest(request);
661 DE_UNREF(packageName);
663 DE_UNREF(groupsDurationTime);
664 #endif // CTS_USES_VULKANSC
668 int TestCaseExecutor::getCurrentSubprocessCount(const std::string& casePath, int defaultSubprocessCount)
670 #ifdef CTS_USES_VULKANSC
671 for (const auto& detailed : m_detailedSubprocessTestCount)
672 if (tcu::matchWildcards(detailed.testPattern.begin(), detailed.testPattern.end(), casePath.begin(), casePath.end(), false))
673 return detailed.testCount;
676 #endif // CTS_USES_VULKANSC
677 return defaultSubprocessCount;
680 void TestCaseExecutor::runTestsInSubprocess (tcu::TestContext& testCtx)
682 #ifdef CTS_USES_VULKANSC
683 if (testCtx.getCommandLine().isSubProcess())
684 TCU_THROW(InternalError, "Cannot run subprocess inside subprocess : ");
686 if (m_testsForSubprocess.empty())
689 std::vector<int> caseFraction = testCtx.getCommandLine().getCaseFraction();
690 std::ostringstream jsonFileName, qpaFileName, pipelineCompilerOutFileName, pipelineCompilerLogFileName, pipelineCompilerPrefix;
691 if (caseFraction.empty())
693 jsonFileName << "pipeline_data.txt";
694 qpaFileName << "sub.qpa";
695 if (!std::string(testCtx.getCommandLine().getPipelineCompilerPath()).empty())
697 pipelineCompilerOutFileName << "pipeline_cache.bin";
698 pipelineCompilerLogFileName << "compiler.log";
699 pipelineCompilerPrefix << "";
704 jsonFileName << "pipeline_data_" << caseFraction[0] << ".txt";
705 qpaFileName << "sub_" << caseFraction[0] << ".qpa";
706 if (!std::string(testCtx.getCommandLine().getPipelineCompilerPath()).empty())
708 pipelineCompilerOutFileName << "pipeline_cache_" << caseFraction[0] <<".bin";
709 pipelineCompilerLogFileName << "compiler_" << caseFraction[0] << ".log";
710 pipelineCompilerPrefix << "sub_" << caseFraction[0] << "_";
714 // export data collected during statistics gathering to JSON file ( VkDeviceObjectReservationCreateInfo, SPIR-V shaders, pipelines )
716 m_resourceInterface->removeRedundantObjects();
717 m_resourceInterface->finalizeCommandBuffers();
718 std::vector<deUint8> data = m_resourceInterface->exportData();
719 m_parentIPC->SetFile(jsonFileName.str(), data);
722 // collect current application name, add it to new commandline with subprocess parameters
723 std::string newCmdLine;
725 std::string appName = testCtx.getCommandLine().getApplicationName();
727 TCU_THROW(InternalError, "Application name is not defined");
728 // add --deqp-subprocess option to inform deqp-vksc process that it works as slave process
729 newCmdLine = appName + " --deqp-subprocess=enable --deqp-log-filename=" + qpaFileName.str();
731 // add offline pipeline compiler parameters if present
732 if (!std::string(testCtx.getCommandLine().getPipelineCompilerPath()).empty())
734 newCmdLine += " --deqp-pipeline-compiler=" + std::string(testCtx.getCommandLine().getPipelineCompilerPath());
735 newCmdLine += " --deqp-pipeline-file=" + pipelineCompilerOutFileName.str();
736 if (!std::string(testCtx.getCommandLine().getPipelineCompilerDataDir()).empty())
737 newCmdLine += " --deqp-pipeline-dir=" + std::string(testCtx.getCommandLine().getPipelineCompilerDataDir());
738 newCmdLine += " --deqp-pipeline-logfile=" + pipelineCompilerLogFileName.str();
739 if(!pipelineCompilerPrefix.str().empty())
740 newCmdLine += " --deqp-pipeline-prefix=" + pipelineCompilerPrefix.str();
741 if (!std::string(testCtx.getCommandLine().getPipelineCompilerArgs()).empty())
742 newCmdLine += " --deqp-pipeline-args=\"" + std::string( testCtx.getCommandLine().getPipelineCompilerArgs() ) + "\"";
746 // collect parameters, remove parameters associated with case filter and case fraction. We will provide our own case list
748 std::string originalCmdLine = testCtx.getCommandLine().getInitialCmdLine();
750 // brave ( but working ) assumption that each CTS parameter starts with "--deqp"
752 std::string paramStr ("--deqp");
753 std::vector<std::string> skipElements =
756 "--deqp-stdin-caselist",
757 "--deqp-log-filename",
758 "--deqp-pipeline-compiler",
759 "--deqp-pipeline-dir",
760 "--deqp-pipeline-args",
761 "--deqp-pipeline-file",
762 "--deqp-pipeline-logfile",
763 "--deqp-pipeline-prefix"
767 std::vector<std::size_t> argPos;
768 while ((pos = originalCmdLine.find(paramStr, pos)) != std::string::npos)
769 argPos.push_back(pos++);
771 argPos.push_back(originalCmdLine.size());
773 std::vector<std::string> args;
774 for (std::size_t i = 0; i < argPos.size()-1; ++i)
776 std::string s = originalCmdLine.substr(argPos[i], argPos[i + 1] - argPos[i]);
777 std::size_t found = s.find_last_not_of(' ');
778 if (found != std::string::npos)
784 for (std::size_t i = 0; i < args.size(); ++i)
786 bool skipElement = false;
787 for (const auto& elem : skipElements)
788 if (args[i].find(elem) == 0)
795 newCmdLine = newCmdLine + " " + args[i];
799 // create --deqp-case list from tests collected in m_testsForSubprocess
800 std::string subprocessTestList;
801 for (auto it = begin(m_testsForSubprocess); it != end(m_testsForSubprocess); ++it)
803 auto nit = it; ++nit;
805 subprocessTestList += *it;
806 if (nit != end(m_testsForSubprocess))
807 subprocessTestList += "\n";
810 std::string caseListName = "subcaselist" + (caseFraction.empty() ? std::string("") : de::toString(caseFraction[0])) + ".txt";
812 deFile* exportFile = deFile_create(caseListName.c_str(), DE_FILEMODE_CREATE | DE_FILEMODE_OPEN | DE_FILEMODE_WRITE | DE_FILEMODE_TRUNCATE);
813 deInt64 numWritten = 0;
814 deFile_write(exportFile, subprocessTestList.c_str(), subprocessTestList.size(), &numWritten);
815 deFile_destroy(exportFile);
816 newCmdLine = newCmdLine + " --deqp-caselist-file=" + caseListName;
818 // restore cout and cerr
819 restoreStandardOutput();
821 // create subprocess which will perform real tests
822 std::string subProcessExitCodeInfo;
824 deProcess* process = deProcess_create();
825 if (deProcess_start(process, newCmdLine.c_str(), ".") != DE_TRUE)
827 std::string err = deProcess_getLastError(process);
828 deProcess_destroy(process);
830 TCU_THROW(InternalError, "Error while running subprocess : " + err);
833 whole.reserve(1024 * 4);
835 // create a separate thread that captures std::err output
836 de::MovePtr<std::thread> errThread(new std::thread([&process]
838 deFile* subErr = deProcess_getStdErr(process);
839 char errBuffer[128] = { 0 };
840 deInt64 errNumRead = 0;
841 while (deFile_read(subErr, errBuffer, sizeof(errBuffer) - 1, &errNumRead) == DE_FILERESULT_SUCCESS)
843 errBuffer[errNumRead] = 0;
847 deFile* subOutput = deProcess_getStdOut(process);
848 char outBuffer[128] = { 0 };
850 while (deFile_read(subOutput, outBuffer, sizeof(outBuffer) - 1, &numRead) == DE_FILERESULT_SUCCESS)
852 outBuffer[numRead] = 0;
857 if (deProcess_waitForFinish(process))
859 const int exitCode = deProcess_getExitCode(process);
862 s << " Subprocess failed with exit code " << exitCode << "(" << std::hex << exitCode << ")";
864 subProcessExitCodeInfo = s.str();
866 deProcess_destroy(process);
868 vksc_server::RemoteWrite(0, whole.c_str());
871 // copy test information from sub.qpa to main log
873 std::ifstream subQpa(qpaFileName.str(), std::ios::binary);
874 std::string subQpaText{std::istreambuf_iterator<char>(subQpa),
875 std::istreambuf_iterator<char>()};
877 std::string beginText ("#beginTestCaseResult");
878 std::string endText ("#endTestCaseResult");
879 std::size_t beginPos = subQpaText.find(beginText);
880 std::size_t endPos = subQpaText.rfind(endText);
881 if (beginPos == std::string::npos || endPos == std::string::npos)
882 TCU_THROW(InternalError, "Couldn't match tags from " + qpaFileName.str() + subProcessExitCodeInfo);
884 std::string subQpaCopy = "\n" + std::string(subQpaText.begin() + beginPos, subQpaText.begin() + endPos + endText.size()) + "\n";
886 if (!std::string(testCtx.getCommandLine().getServerAddress()).empty())
888 // Send it to server to append to its log
889 vksc_server::AppendRequest request;
890 request.fileName = testCtx.getCommandLine().getLogFileName();
891 request.data.assign(subQpaCopy.begin(), subQpaCopy.end());
892 vksc_server::StandardOutputServerSingleton()->SendRequest(request);
896 // Write it to parent's log
899 testCtx.getLog().supressLogging(false);
900 testCtx.getLog().writeRaw(subQpaCopy.c_str());
904 testCtx.getLog().supressLogging(true);
907 testCtx.getLog().supressLogging(true);
912 std::string beginStat ("#SubProcessStatus");
913 std::size_t beginPos = subQpaText.find(beginStat);
914 if (beginPos == std::string::npos)
915 TCU_THROW(InternalError, "Couldn't match #SubProcessStatus tag from " + qpaFileName.str() + subProcessExitCodeInfo);
917 std::string subQpaStat (subQpaText.begin() + beginPos + beginStat.size(), subQpaText.end());
919 std::istringstream str(subQpaStat);
920 int numExecuted, numPassed, numFailed, numNotSupported, numWarnings, numWaived;
921 str >> numExecuted >> numPassed >> numFailed >> numNotSupported >> numWarnings >> numWaived;
923 m_status.numExecuted += numExecuted;
924 m_status.numPassed += numPassed;
925 m_status.numNotSupported += numNotSupported;
926 m_status.numWarnings += numWarnings;
927 m_status.numWaived += numWaived;
928 m_status.numFailed += numFailed;
931 deDeleteFile(qpaFileName.str().c_str());
935 #endif // CTS_USES_VULKANSC
938 bool TestCaseExecutor::spirvVersionSupported (vk::SpirvVersion spirvVersion)
940 if (spirvVersion <= vk::getMaxSpirvVersionForVulkan(m_context->getUsedApiVersion()))
943 if (spirvVersion <= vk::SPIRV_VERSION_1_4)
944 return m_context->isDeviceFunctionalitySupported("VK_KHR_spirv_1_4");
951 void createGlslTests (tcu::TestCaseGroup* glslTests)
953 tcu::TestContext& testCtx = glslTests->getTestContext();
955 // ShaderLibrary-based tests
959 const char* description;
962 { "arrays", "Arrays" },
963 { "conditionals", "Conditional statements" },
964 { "constant_expressions", "Constant expressions" },
965 { "constants", "Constants" },
966 { "conversions", "Type conversions" },
967 { "functions", "Functions" },
968 { "linkage", "Linking" },
969 { "scoping", "Scoping" },
970 { "swizzles", "Swizzles" },
973 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_es310Tests); ndx++)
974 glslTests->addChild(createShaderLibraryGroup(testCtx,
975 s_es310Tests[ndx].name,
976 s_es310Tests[ndx].description,
977 std::string("vulkan/glsl/es310/") + s_es310Tests[ndx].name + ".test").release());
982 const char* description;
985 { "linkage", "Linking" },
988 de::MovePtr<tcu::TestCaseGroup> glsl440Tests = de::MovePtr<tcu::TestCaseGroup>(new tcu::TestCaseGroup(testCtx, "440", ""));
990 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_440Tests); ndx++)
991 glsl440Tests->addChild(createShaderLibraryGroup(testCtx,
992 s_440Tests[ndx].name,
993 s_440Tests[ndx].description,
994 std::string("vulkan/glsl/440/") + s_440Tests[ndx].name + ".test").release());
996 glslTests->addChild(glsl440Tests.release());
998 // ShaderRenderCase-based tests
999 glslTests->addChild(sr::createDerivateTests (testCtx));
1000 glslTests->addChild(sr::createDiscardTests (testCtx));
1001 #ifndef CTS_USES_VULKANSC
1002 glslTests->addChild(sr::createDemoteTests (testCtx));
1003 #endif // CTS_USES_VULKANSC
1004 glslTests->addChild(sr::createIndexingTests (testCtx));
1005 glslTests->addChild(sr::createShaderInvarianceTests (testCtx));
1006 glslTests->addChild(sr::createLimitTests (testCtx));
1007 glslTests->addChild(sr::createLoopTests (testCtx));
1008 glslTests->addChild(sr::createMatrixTests (testCtx));
1009 glslTests->addChild(sr::createOperatorTests (testCtx));
1010 glslTests->addChild(sr::createReturnTests (testCtx));
1011 glslTests->addChild(sr::createStructTests (testCtx));
1012 glslTests->addChild(sr::createSwitchTests (testCtx));
1013 glslTests->addChild(sr::createTextureFunctionTests (testCtx));
1014 glslTests->addChild(sr::createTextureGatherTests (testCtx));
1015 glslTests->addChild(sr::createBuiltinVarTests (testCtx));
1017 // ShaderExecutor-based tests
1018 glslTests->addChild(shaderexecutor::createBuiltinTests (testCtx));
1019 glslTests->addChild(shaderexecutor::createOpaqueTypeIndexingTests (testCtx));
1020 glslTests->addChild(shaderexecutor::createAtomicOperationTests (testCtx));
1021 glslTests->addChild(shaderexecutor::createShaderClockTests (testCtx));
1023 #ifndef CTS_USES_VULKANSC
1024 // Amber GLSL tests.
1025 glslTests->addChild(cts_amber::createCombinedOperationsGroup (testCtx));
1026 glslTests->addChild(cts_amber::createCrashTestGroup (testCtx));
1027 #endif // CTS_USES_VULKANSC
1032 BaseTestPackage::BaseTestPackage (tcu::TestContext& testCtx, const char* name, const char* desc)
1033 : tcu::TestPackage(testCtx, name, desc)
1037 BaseTestPackage::~BaseTestPackage (void)
1041 #ifdef CTS_USES_VULKAN
1043 TestPackage::TestPackage (tcu::TestContext& testCtx)
1044 : BaseTestPackage(testCtx, "dEQP-VK", "dEQP Vulkan Tests")
1048 TestPackage::~TestPackage (void)
1052 ExperimentalTestPackage::ExperimentalTestPackage (tcu::TestContext& testCtx)
1053 : BaseTestPackage(testCtx, "dEQP-VK-experimental", "dEQP Vulkan Experimental Tests")
1057 ExperimentalTestPackage::~ExperimentalTestPackage (void)
1063 #ifdef CTS_USES_VULKANSC
1065 TestPackageSC::TestPackageSC (tcu::TestContext& testCtx)
1066 : BaseTestPackage(testCtx, "dEQP-VKSC", "dEQP Vulkan SC Tests")
1070 TestPackageSC::~TestPackageSC (void)
1074 #endif // CTS_USES_VULKANSC
1076 tcu::TestCaseExecutor* BaseTestPackage::createExecutor (void) const
1078 return new TestCaseExecutor(m_testCtx);
1081 #ifdef CTS_USES_VULKAN
1083 void TestPackage::init (void)
1085 addChild(createTestGroup (m_testCtx, "info", "Build and Device Info Tests", createInfoTests));
1086 addChild(api::createTests (m_testCtx));
1087 addChild(memory::createTests (m_testCtx));
1088 addChild(pipeline::createTests (m_testCtx));
1089 addChild(BindingModel::createTests (m_testCtx));
1090 addChild(SpirVAssembly::createTests (m_testCtx));
1091 addChild(createTestGroup (m_testCtx, "glsl", "GLSL shader execution tests", createGlslTests));
1092 addChild(createRenderPassTests (m_testCtx));
1093 addChild(createRenderPass2Tests (m_testCtx));
1094 addChild(createDynamicRenderingTests (m_testCtx));
1095 addChild(ubo::createTests (m_testCtx));
1096 addChild(DynamicState::createTests (m_testCtx));
1097 addChild(ssbo::createTests (m_testCtx));
1098 addChild(QueryPool::createTests (m_testCtx));
1099 addChild(Draw::createTests (m_testCtx));
1100 addChild(compute::createTests (m_testCtx));
1101 addChild(image::createTests (m_testCtx));
1102 addChild(wsi::createTests (m_testCtx));
1103 addChild(createSynchronizationTests (m_testCtx));
1104 addChild(createSynchronization2Tests (m_testCtx));
1105 addChild(sparse::createTests (m_testCtx));
1106 addChild(tessellation::createTests (m_testCtx));
1107 addChild(rasterization::createTests (m_testCtx));
1108 addChild(clipping::createTests (m_testCtx));
1109 addChild(FragmentOperations::createTests (m_testCtx));
1110 addChild(texture::createTests (m_testCtx));
1111 addChild(geometry::createTests (m_testCtx));
1112 addChild(robustness::createTests (m_testCtx));
1113 addChild(MultiView::createTests (m_testCtx));
1114 addChild(subgroups::createTests (m_testCtx));
1115 addChild(ycbcr::createTests (m_testCtx));
1116 addChild(ProtectedMem::createTests (m_testCtx));
1117 addChild(DeviceGroup::createTests (m_testCtx));
1118 addChild(MemoryModel::createTests (m_testCtx));
1119 addChild(conditional::createTests (m_testCtx));
1120 addChild(cts_amber::createGraphicsFuzzTests (m_testCtx));
1121 addChild(imageless::createTests (m_testCtx));
1122 addChild(TransformFeedback::createTests (m_testCtx));
1123 addChild(DescriptorIndexing::createTests (m_testCtx));
1124 addChild(FragmentShaderInterlock::createTests(m_testCtx));
1125 addChild(modifiers::createTests (m_testCtx));
1126 addChild(RayTracing::createTests (m_testCtx));
1127 addChild(RayQuery::createTests (m_testCtx));
1128 addChild(FragmentShadingRate::createTests (m_testCtx));
1129 addChild(Reconvergence::createTests (m_testCtx, false));
1130 addChild(MeshShader::createTests (m_testCtx));
1131 addChild(FragmentShadingBarycentric::createTests(m_testCtx));
1134 void ExperimentalTestPackage::init (void)
1136 addChild(postmortem::createTests (m_testCtx));
1137 addChild(Reconvergence::createTests (m_testCtx, true));
1142 #ifdef CTS_USES_VULKANSC
1144 void TestPackageSC::init (void)
1146 addChild(createTestGroup (m_testCtx, "info", "Build and Device Info Tests", createInfoTests));
1147 addChild(api::createTests (m_testCtx));
1148 addChild(memory::createTests (m_testCtx));
1149 addChild(pipeline::createTests (m_testCtx));
1150 addChild(BindingModel::createTests (m_testCtx));
1151 addChild(SpirVAssembly::createTests (m_testCtx));
1152 addChild(createTestGroup (m_testCtx, "glsl", "GLSL shader execution tests", createGlslTests));
1153 addChild(createRenderPassTests (m_testCtx));
1154 addChild(createRenderPass2Tests (m_testCtx));
1155 addChild(ubo::createTests (m_testCtx));
1156 addChild(DynamicState::createTests (m_testCtx));
1157 addChild(ssbo::createTests (m_testCtx));
1158 addChild(QueryPool::createTests (m_testCtx));
1159 addChild(Draw::createTests (m_testCtx));
1160 addChild(compute::createTests (m_testCtx));
1161 addChild(image::createTests (m_testCtx));
1162 // addChild(wsi::createTests (m_testCtx));
1163 addChild(createSynchronizationTests (m_testCtx));
1164 addChild(createSynchronization2Tests (m_testCtx));
1165 // addChild(sparse::createTests (m_testCtx));
1166 addChild(tessellation::createTests (m_testCtx));
1167 addChild(rasterization::createTests (m_testCtx));
1168 addChild(clipping::createTests (m_testCtx));
1169 addChild(FragmentOperations::createTests (m_testCtx));
1170 addChild(texture::createTests (m_testCtx));
1171 addChild(geometry::createTests (m_testCtx));
1172 addChild(robustness::createTests (m_testCtx));
1173 addChild(MultiView::createTests (m_testCtx));
1174 addChild(subgroups::createTests (m_testCtx));
1175 addChild(ycbcr::createTests (m_testCtx));
1176 addChild(ProtectedMem::createTests (m_testCtx));
1177 addChild(DeviceGroup::createTests (m_testCtx));
1178 addChild(MemoryModel::createTests (m_testCtx));
1179 // addChild(conditional::createTests (m_testCtx));
1180 // addChild(cts_amber::createGraphicsFuzzTests (m_testCtx));
1181 addChild(imageless::createTests (m_testCtx));
1182 // addChild(TransformFeedback::createTests (m_testCtx));
1183 addChild(DescriptorIndexing::createTests (m_testCtx));
1184 addChild(FragmentShaderInterlock::createTests(m_testCtx));
1185 // addChild(modifiers::createTests (m_testCtx));
1186 // addChild(RayTracing::createTests (m_testCtx));
1187 // addChild(RayQuery::createTests (m_testCtx));
1188 addChild(FragmentShadingRate::createTests(m_testCtx));
1189 addChild(sc::createTests(m_testCtx));
1192 #endif // CTS_USES_VULKANSC