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 Object management tests
22 *//*--------------------------------------------------------------------*/
24 #include "vktApiObjectManagementTests.hpp"
25 #include "vktTestCaseUtil.hpp"
26 #include "vktCustomInstancesDevices.hpp"
30 #include "vkRefUtil.hpp"
31 #include "vkQueryUtil.hpp"
32 #include "vkMemUtil.hpp"
33 #include "vkPrograms.hpp"
34 #include "vkTypeUtil.hpp"
35 #include "vkPlatform.hpp"
36 #include "vkStrUtil.hpp"
37 #include "vkAllocationCallbackUtil.hpp"
38 #include "vkObjTypeImpl.inl"
39 #include "vkObjUtil.hpp"
40 #include "vkBuilderUtil.hpp"
41 #include "vkSafetyCriticalUtil.hpp"
43 #include "vktTestGroupUtil.hpp"
45 #include "tcuVector.hpp"
46 #include "tcuResultCollector.hpp"
47 #include "tcuCommandLine.hpp"
48 #include "tcuTestLog.hpp"
49 #include "tcuPlatform.hpp"
51 #include "deUniquePtr.hpp"
52 #include "deSharedPtr.hpp"
53 #include "deArrayUtil.hpp"
54 #include "deSpinBarrier.hpp"
55 #include "deThread.hpp"
61 #define VK_DESCRIPTOR_TYPE_LAST (VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT + 1)
79 using tcu::ResultCollector;
80 using tcu::TestStatus;
86 typedef SharedPtr<Move<VkPipeline> > VkPipelineSp; // Move so it's possible to disown the handle
87 typedef SharedPtr<Move<VkDescriptorSet> > VkDescriptorSetSp;
88 typedef SharedPtr<Move<VkCommandBuffer> > VkCommandBufferSp;
90 class ThreadGroupThread;
92 /*--------------------------------------------------------------------*//*!
95 * Thread group manages collection of threads that are expected to be
96 * launched simultaneously as a group.
98 * Shared barrier is provided for synchronizing execution. Terminating thread
99 * early either by returning from ThreadGroupThread::runThread() or throwing
100 * an exception is safe, and other threads will continue execution. The
101 * thread that has been terminated is simply removed from the synchronization
104 * TestException-based exceptions are collected and translated into a
105 * tcu::TestStatus by using tcu::ResultCollector.
107 * Use cases for ThreadGroup include for example testing thread-safety of
108 * certain API operations by poking API simultaneously from multiple
110 *//*--------------------------------------------------------------------*/
118 void add (de::MovePtr<ThreadGroupThread> thread);
119 TestStatus run (void);
122 typedef std::vector<de::SharedPtr<ThreadGroupThread> > ThreadVector;
124 ThreadVector m_threads;
125 de::SpinBarrier m_barrier;
126 } DE_WARN_UNUSED_TYPE;
128 class ThreadGroupThread : private de::Thread
131 ThreadGroupThread (void);
132 virtual ~ThreadGroupThread (void);
134 void start (de::SpinBarrier* groupBarrier);
136 ResultCollector& getResultCollector (void) { return m_resultCollector; }
138 using de::Thread::join;
141 virtual void runThread (void) = 0;
146 ThreadGroupThread (const ThreadGroupThread&);
147 ThreadGroupThread& operator= (const ThreadGroupThread&);
151 ResultCollector m_resultCollector;
152 de::SpinBarrier* m_barrier;
157 ThreadGroup::ThreadGroup (void)
162 ThreadGroup::~ThreadGroup (void)
166 void ThreadGroup::add (de::MovePtr<ThreadGroupThread> thread)
168 m_threads.push_back(de::SharedPtr<ThreadGroupThread>(thread.release()));
171 tcu::TestStatus ThreadGroup::run (void)
173 tcu::ResultCollector resultCollector;
175 m_barrier.reset((int)m_threads.size());
177 for (ThreadVector::iterator threadIter = m_threads.begin(); threadIter != m_threads.end(); ++threadIter)
178 (*threadIter)->start(&m_barrier);
180 for (ThreadVector::iterator threadIter = m_threads.begin(); threadIter != m_threads.end(); ++threadIter)
182 tcu::ResultCollector& threadResult = (*threadIter)->getResultCollector();
183 (*threadIter)->join();
184 resultCollector.addResult(threadResult.getResult(), threadResult.getMessage());
187 return tcu::TestStatus(resultCollector.getResult(), resultCollector.getMessage());
192 ThreadGroupThread::ThreadGroupThread (void)
197 ThreadGroupThread::~ThreadGroupThread (void)
201 void ThreadGroupThread::start (de::SpinBarrier* groupBarrier)
203 m_barrier = groupBarrier;
207 void ThreadGroupThread::run (void)
213 catch (const tcu::TestException& e)
215 getResultCollector().addResult(e.getTestResult(), e.getMessage());
217 catch (const std::exception& e)
219 getResultCollector().addResult(QP_TEST_RESULT_FAIL, e.what());
223 getResultCollector().addResult(QP_TEST_RESULT_FAIL, "Exception");
226 m_barrier->removeThread(de::SpinBarrier::WAIT_MODE_AUTO);
229 inline void ThreadGroupThread::barrier (void)
231 m_barrier->sync(de::SpinBarrier::WAIT_MODE_AUTO);
234 deUint32 getDefaultTestThreadCount (void)
236 #ifndef CTS_USES_VULKANSC
237 return de::clamp(deGetNumAvailableLogicalCores(), 2u, 8u);
240 #endif // CTS_USES_VULKANSC
248 const PlatformInterface& vkp;
250 const InstanceInterface& instanceInterface;
252 const DeviceInterface& vkd;
254 deUint32 queueFamilyIndex;
255 const BinaryCollection& programBinaries;
256 const VkAllocationCallbacks* allocationCallbacks;
257 deUint32 maxResourceConsumers; // Maximum number of objects using same Object::Resources concurrently
258 #ifdef CTS_USES_VULKANSC
259 de::SharedPtr<ResourceInterface> resourceInterface;
260 VkPhysicalDeviceVulkanSC10Properties vulkanSC10Properties;
261 VkPhysicalDeviceProperties properties;
262 #endif // CTS_USES_VULKANSC
263 const tcu::CommandLine& commandLine;
265 Environment (Context& context, deUint32 maxResourceConsumers_)
266 : vkp (context.getPlatformInterface())
267 , apiVersion (context.getUsedApiVersion())
268 , instanceInterface (context.getInstanceInterface())
269 , instance (context.getInstance())
270 , vkd (context.getDeviceInterface())
271 , device (context.getDevice())
272 , queueFamilyIndex (context.getUniversalQueueFamilyIndex())
273 , programBinaries (context.getBinaryCollection())
274 , allocationCallbacks (DE_NULL)
275 , maxResourceConsumers (maxResourceConsumers_)
276 #ifdef CTS_USES_VULKANSC
277 , resourceInterface (context.getResourceInterface())
278 , vulkanSC10Properties (context.getDeviceVulkanSC10Properties())
279 , properties (context.getDeviceProperties())
280 #endif // CTS_USES_VULKANSC
281 , commandLine (context.getTestContext().getCommandLine())
285 Environment (const PlatformInterface& vkp_,
286 deUint32 apiVersion_,
287 const InstanceInterface& instanceInterface_,
288 VkInstance instance_,
289 const DeviceInterface& vkd_,
291 deUint32 queueFamilyIndex_,
292 const BinaryCollection& programBinaries_,
293 const VkAllocationCallbacks* allocationCallbacks_,
294 deUint32 maxResourceConsumers_,
295 #ifdef CTS_USES_VULKANSC
296 de::SharedPtr<ResourceInterface> resourceInterface_,
297 const VkPhysicalDeviceVulkanSC10Properties& vulkanSC10Properties_,
298 #endif // CTS_USES_VULKANSC
299 const tcu::CommandLine& commandLine_)
301 , apiVersion (apiVersion_)
302 , instanceInterface (instanceInterface_)
303 , instance (instance_)
306 , queueFamilyIndex (queueFamilyIndex_)
307 , programBinaries (programBinaries_)
308 #ifdef CTS_USES_VULKANSC
309 , allocationCallbacks(DE_NULL)
311 , allocationCallbacks(allocationCallbacks_)
312 #endif // CTS_USES_VULKANSC
313 , maxResourceConsumers (maxResourceConsumers_)
314 #ifdef CTS_USES_VULKANSC
315 , resourceInterface (resourceInterface_)
316 , vulkanSC10Properties (vulkanSC10Properties_)
317 #endif // CTS_USES_VULKANSC
318 , commandLine (commandLine_)
320 #ifdef CTS_USES_VULKANSC
321 DE_UNREF(allocationCallbacks_);
322 #endif // CTS_USES_VULKANSC
326 template<typename Case>
329 typename Case::Resources resources;
330 Unique<typename Case::Type> object;
332 Dependency (const Environment& env, const typename Case::Parameters& params)
333 : resources (env, params)
334 , object (Case::create(env, resources, params))
339 T roundUpToNextMultiple (T value, T multiple)
341 if (value % multiple == 0)
344 return value + multiple - (value % multiple);
347 #if defined(DE_DEBUG)
349 bool isPowerOfTwo (T value)
351 return ((value & (value - T(1))) == 0);
356 T alignToPowerOfTwo (T value, T align)
358 DE_ASSERT(isPowerOfTwo(align));
359 return (value + align - T(1)) & ~(align - T(1));
361 #ifndef CTS_USES_VULKANSC
362 inline bool hasDeviceExtension (Context& context, const string name)
364 return context.isDeviceFunctionalitySupported(name);
368 VkDeviceSize getPageTableSize (const tcu::PlatformMemoryLimits& limits, VkDeviceSize allocationSize)
370 VkDeviceSize totalSize = 0;
372 for (size_t levelNdx = 0; levelNdx < limits.devicePageTableHierarchyLevels; ++levelNdx)
374 const VkDeviceSize coveredAddressSpaceSize = limits.devicePageSize<<levelNdx;
375 const VkDeviceSize numPagesNeeded = alignToPowerOfTwo(allocationSize, coveredAddressSpaceSize) / coveredAddressSpaceSize;
377 totalSize += numPagesNeeded*limits.devicePageTableEntrySize;
383 size_t getCurrentSystemMemoryUsage (const AllocationCallbackRecorder& allocRecoder)
385 const size_t systemAllocationOverhead = sizeof(void*)*2;
386 AllocationCallbackValidationResults validationResults;
388 validateAllocationCallbacks(allocRecoder, &validationResults);
389 TCU_CHECK(validationResults.violations.empty());
391 return getLiveSystemAllocationTotal(validationResults) + systemAllocationOverhead*validationResults.liveAllocations.size();
394 template<typename Object>
395 size_t computeSystemMemoryUsage (Context& context, const typename Object::Parameters& params)
397 AllocationCallbackRecorder allocRecorder (getSystemAllocator());
398 const Environment env (context.getPlatformInterface(),
399 context.getUsedApiVersion(),
400 context.getInstanceInterface(),
401 context.getInstance(),
402 context.getDeviceInterface(),
404 context.getUniversalQueueFamilyIndex(),
405 context.getBinaryCollection(),
406 allocRecorder.getCallbacks(),
408 #ifdef CTS_USES_VULKANSC
409 context.getResourceInterface(),
410 context.getDeviceVulkanSC10Properties(),
411 #endif // CTS_USES_VULKANSC
412 context.getTestContext().getCommandLine());
413 const typename Object::Resources res (env, params);
414 const size_t resourceMemoryUsage = getCurrentSystemMemoryUsage(allocRecorder);
417 Unique<typename Object::Type> obj (Object::create(env, res, params));
418 const size_t totalMemoryUsage = getCurrentSystemMemoryUsage(allocRecorder);
420 return totalMemoryUsage - resourceMemoryUsage;
424 size_t getSafeObjectCount (const tcu::PlatformMemoryLimits& memoryLimits,
425 size_t objectSystemMemoryUsage,
426 VkDeviceSize objectDeviceMemoryUsage = 0)
428 const VkDeviceSize roundedUpDeviceMemory = roundUpToNextMultiple(objectDeviceMemoryUsage, memoryLimits.deviceMemoryAllocationGranularity);
430 if (memoryLimits.totalDeviceLocalMemory > 0 && roundedUpDeviceMemory > 0)
432 if (objectSystemMemoryUsage > 0)
433 return de::min(memoryLimits.totalSystemMemory / objectSystemMemoryUsage,
434 (size_t)(memoryLimits.totalDeviceLocalMemory / roundedUpDeviceMemory));
436 return (size_t)(memoryLimits.totalDeviceLocalMemory / roundedUpDeviceMemory);
438 else if (objectSystemMemoryUsage + roundedUpDeviceMemory > 0)
440 DE_ASSERT(roundedUpDeviceMemory <= std::numeric_limits<size_t>::max() - objectSystemMemoryUsage);
441 return memoryLimits.totalSystemMemory / (objectSystemMemoryUsage + (size_t)roundedUpDeviceMemory);
445 // Warning: at this point driver has probably not implemented allocation callbacks correctly
446 return std::numeric_limits<size_t>::max();
450 tcu::PlatformMemoryLimits getPlatformMemoryLimits (Context& context)
452 tcu::PlatformMemoryLimits memoryLimits;
454 context.getTestContext().getPlatform().getMemoryLimits(memoryLimits);
459 size_t getSafeObjectCount (Context& context, size_t objectSystemMemoryUsage, VkDeviceSize objectDeviceMemorySize = 0)
461 return getSafeObjectCount(getPlatformMemoryLimits(context), objectSystemMemoryUsage, objectDeviceMemorySize);
464 VkDeviceSize getPageTableSize (Context& context, VkDeviceSize allocationSize)
466 return getPageTableSize(getPlatformMemoryLimits(context), allocationSize);
469 template<typename Object>
470 deUint32 getSafeObjectCount (Context& context,
471 const typename Object::Parameters& params,
472 deUint32 hardCountLimit,
473 VkDeviceSize deviceMemoryUsage = 0)
475 return (deUint32)de::min((size_t)hardCountLimit,
476 getSafeObjectCount(context,
477 computeSystemMemoryUsage<Object>(context, params),
481 // Object definitions
485 MAX_CONCURRENT_INSTANCES = 32,
486 MAX_CONCURRENT_DEVICES = 32,
487 MAX_CONCURRENT_SYNC_PRIMITIVES = 100,
488 MAX_CONCURRENT_PIPELINE_CACHES = 128,
489 MAX_CONCURRENT_QUERY_POOLS = 8192,
490 DEFAULT_MAX_CONCURRENT_OBJECTS = 16*1024,
495 typedef VkInstance Type;
499 const vector<string> instanceExtensions;
503 Parameters (vector<string>& extensions)
504 : instanceExtensions (extensions)
510 Resources (const Environment&, const Parameters&) {}
513 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
515 return getSafeObjectCount<Instance>(context, params, MAX_CONCURRENT_INSTANCES);
518 static Move<VkInstance> create (const Environment& env, const Resources&, const Parameters& params)
520 vector<const char*> extensionNamePtrs;
521 const vector<VkExtensionProperties> instanceExts = enumerateInstanceExtensionProperties(env.vkp, DE_NULL);
522 for (const auto& extName : params.instanceExtensions)
524 bool extNotInCore = !isCoreInstanceExtension(env.apiVersion, extName);
525 if (extNotInCore && !isExtensionStructSupported(instanceExts.begin(), instanceExts.end(), RequiredExtension(extName)))
526 TCU_THROW(NotSupportedError, (extName + " is not supported").c_str());
529 extensionNamePtrs.push_back(extName.c_str());
532 const VkApplicationInfo appInfo =
534 VK_STRUCTURE_TYPE_APPLICATION_INFO,
536 DE_NULL, // pApplicationName
537 0u, // applicationVersion
538 DE_NULL, // pEngineName
543 const VkInstanceCreateInfo instanceInfo =
545 VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
547 (VkInstanceCreateFlags)0,
549 0u, // enabledLayerNameCount
550 DE_NULL, // ppEnabledLayerNames
551 (deUint32)extensionNamePtrs.size(), // enabledExtensionNameCount
552 extensionNamePtrs.empty() ? DE_NULL : &extensionNamePtrs[0], // ppEnabledExtensionNames
555 return createInstance(env.vkp, &instanceInfo, env.allocationCallbacks);
561 typedef VkDevice Type;
565 deUint32 deviceIndex;
566 VkQueueFlags queueFlags;
568 Parameters (deUint32 deviceIndex_, VkQueueFlags queueFlags_)
569 : deviceIndex (deviceIndex_)
570 , queueFlags (queueFlags_)
576 Dependency<Instance> instance;
577 #ifndef CTS_USES_VULKANSC
580 InstanceDriverSC vki;
581 #endif // CTS_USES_VULKANSC
583 VkPhysicalDevice physicalDevice;
584 deUint32 queueFamilyIndex;
586 Resources (const Environment& env, const Parameters& params)
587 : instance (env, Instance::Parameters())
588 #ifndef CTS_USES_VULKANSC
589 , vki(env.vkp, *instance.object)
591 , vki(env.vkp, *instance.object, env.commandLine, env.resourceInterface)
592 #endif // CTS_USES_VULKANSC
594 , queueFamilyIndex (~0u)
597 const vector<VkPhysicalDevice> physicalDevices = enumeratePhysicalDevices(vki, *instance.object);
599 if (physicalDevices.size() <= (size_t)params.deviceIndex)
600 TCU_THROW(NotSupportedError, "Device not found");
602 physicalDevice = physicalDevices[params.deviceIndex];
606 const vector<VkQueueFamilyProperties> queueProps = getPhysicalDeviceQueueFamilyProperties(vki, physicalDevice);
607 bool foundMatching = false;
609 for (size_t curQueueNdx = 0; curQueueNdx < queueProps.size(); curQueueNdx++)
611 if ((queueProps[curQueueNdx].queueFlags & params.queueFlags) == params.queueFlags)
613 queueFamilyIndex = (deUint32)curQueueNdx;
614 foundMatching = true;
619 TCU_THROW(NotSupportedError, "Matching queue not found");
624 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
626 return getSafeObjectCount<Device>(context, params, MAX_CONCURRENT_DEVICES);
629 static Move<VkDevice> create (const Environment& env, const Resources& res, const Parameters&)
631 const float queuePriority = 1.0;
633 const VkDeviceQueueCreateInfo queues[] =
636 VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
638 (VkDeviceQueueCreateFlags)0,
639 res.queueFamilyIndex,
641 &queuePriority, // pQueuePriorities
645 void* pNext = DE_NULL;
646 #ifdef CTS_USES_VULKANSC
647 VkDeviceObjectReservationCreateInfo memReservationInfo = env.commandLine.isSubProcess() ? env.resourceInterface->getStatMax() : resetDeviceObjectReservationCreateInfo();
648 memReservationInfo.pNext = pNext;
649 pNext = &memReservationInfo;
651 VkPhysicalDeviceVulkanSC10Features sc10Features = createDefaultSC10Features();
652 sc10Features.pNext = pNext;
653 pNext = &sc10Features;
655 VkPipelineCacheCreateInfo pcCI;
656 std::vector<VkPipelinePoolSize> poolSizes;
657 if (env.commandLine.isSubProcess())
659 if (env.resourceInterface->getCacheDataSize() > 0)
663 VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO, // VkStructureType sType;
664 DE_NULL, // const void* pNext;
665 VK_PIPELINE_CACHE_CREATE_READ_ONLY_BIT |
666 VK_PIPELINE_CACHE_CREATE_USE_APPLICATION_STORAGE_BIT, // VkPipelineCacheCreateFlags flags;
667 env.resourceInterface->getCacheDataSize(), // deUintptr initialDataSize;
668 env.resourceInterface->getCacheData() // const void* pInitialData;
670 memReservationInfo.pipelineCacheCreateInfoCount = 1;
671 memReservationInfo.pPipelineCacheCreateInfos = &pcCI;
674 poolSizes = env.resourceInterface->getPipelinePoolSizes();
675 if (!poolSizes.empty())
677 memReservationInfo.pipelinePoolSizeCount = deUint32(poolSizes.size());
678 memReservationInfo.pPipelinePoolSizes = poolSizes.data();
681 #endif // CTS_USES_VULKANSC
683 VkPhysicalDeviceFeatures enabledFeatures = getPhysicalDeviceFeatures(res.vki, res.physicalDevice);
685 const VkDeviceCreateInfo deviceInfo =
687 VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
689 (VkDeviceCreateFlags)0,
690 DE_LENGTH_OF_ARRAY(queues),
692 0u, // enabledLayerNameCount
693 DE_NULL, // ppEnabledLayerNames
694 0u, // enabledExtensionNameCount
695 DE_NULL, // ppEnabledExtensionNames
696 &enabledFeatures, // pEnabledFeatures
699 return createCustomDevice(env.commandLine.isValidationEnabled(), env.vkp, env.instance, res.vki, res.physicalDevice, &deviceInfo, env.allocationCallbacks);
706 typedef VkDevice Type;
710 deUint32 deviceGroupIndex;
711 deUint32 deviceIndex;
712 VkQueueFlags queueFlags;
714 Parameters (deUint32 deviceGroupIndex_, deUint32 deviceIndex_, VkQueueFlags queueFlags_)
715 : deviceGroupIndex (deviceGroupIndex_)
716 , deviceIndex (deviceIndex_)
717 , queueFlags (queueFlags_)
723 vector<string> extensions;
724 Dependency<Instance> instance;
725 #ifndef CTS_USES_VULKANSC
728 InstanceDriverSC vki;
730 vector<VkPhysicalDevice> physicalDevices;
731 deUint32 physicalDeviceCount;
732 deUint32 queueFamilyIndex;
734 Resources (const Environment& env, const Parameters& params)
735 : extensions (1, "VK_KHR_device_group_creation")
736 , instance (env, Instance::Parameters(extensions))
737 #ifndef CTS_USES_VULKANSC
738 , vki (env.vkp, *instance.object)
740 , vki (env.vkp, *instance.object, env.commandLine, env.resourceInterface)
742 , physicalDeviceCount (0)
743 , queueFamilyIndex (~0u)
746 const vector<VkPhysicalDeviceGroupProperties> devGroupProperties = enumeratePhysicalDeviceGroups(vki, *instance.object);
748 if (devGroupProperties.size() <= (size_t)params.deviceGroupIndex)
749 TCU_THROW(NotSupportedError, "Device Group not found");
751 physicalDeviceCount = devGroupProperties[params.deviceGroupIndex].physicalDeviceCount;
752 physicalDevices.resize(physicalDeviceCount);
754 for (deUint32 physicalDeviceIdx = 0; physicalDeviceIdx < physicalDeviceCount; physicalDeviceIdx++)
755 physicalDevices[physicalDeviceIdx] = devGroupProperties[params.deviceGroupIndex].physicalDevices[physicalDeviceIdx];
759 const vector<VkQueueFamilyProperties> queueProps = getPhysicalDeviceQueueFamilyProperties(vki, physicalDevices[params.deviceIndex]);
760 bool foundMatching = false;
762 for (size_t curQueueNdx = 0; curQueueNdx < queueProps.size(); curQueueNdx++)
764 if ((queueProps[curQueueNdx].queueFlags & params.queueFlags) == params.queueFlags)
766 queueFamilyIndex = (deUint32)curQueueNdx;
767 foundMatching = true;
772 TCU_THROW(NotSupportedError, "Matching queue not found");
777 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
779 return getSafeObjectCount<DeviceGroup>(context, params, MAX_CONCURRENT_DEVICES);
782 static Move<VkDevice> create (const Environment& env, const Resources& res, const Parameters& params)
784 const float queuePriority = 1.0;
786 const VkDeviceQueueCreateInfo queues[] =
789 VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
791 (VkDeviceQueueCreateFlags)0, // flags
792 res.queueFamilyIndex, // queueFamilyIndex
794 &queuePriority, // pQueuePriorities
798 VkDeviceGroupDeviceCreateInfo deviceGroupInfo =
800 VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO, //stype
802 res.physicalDeviceCount, //physicalDeviceCount
803 res.physicalDevices.data() //physicalDevices
806 void* pNext = &deviceGroupInfo;
807 #ifdef CTS_USES_VULKANSC
808 VkDeviceObjectReservationCreateInfo memReservationInfo = env.commandLine.isSubProcess() ? env.resourceInterface->getStatMax() : resetDeviceObjectReservationCreateInfo();
809 memReservationInfo.pNext = pNext;
810 pNext = &memReservationInfo;
812 VkPhysicalDeviceVulkanSC10Features sc10Features = createDefaultSC10Features();
813 sc10Features.pNext = pNext;
814 pNext = &sc10Features;
816 VkPipelineCacheCreateInfo pcCI;
817 std::vector<VkPipelinePoolSize> poolSizes;
818 if (env.commandLine.isSubProcess())
820 if (env.resourceInterface->getCacheDataSize() > 0)
824 VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO, // VkStructureType sType;
825 DE_NULL, // const void* pNext;
826 VK_PIPELINE_CACHE_CREATE_READ_ONLY_BIT |
827 VK_PIPELINE_CACHE_CREATE_USE_APPLICATION_STORAGE_BIT, // VkPipelineCacheCreateFlags flags;
828 env.resourceInterface->getCacheDataSize(), // deUintptr initialDataSize;
829 env.resourceInterface->getCacheData() // const void* pInitialData;
831 memReservationInfo.pipelineCacheCreateInfoCount = 1;
832 memReservationInfo.pPipelineCacheCreateInfos = &pcCI;
835 poolSizes = env.resourceInterface->getPipelinePoolSizes();
836 if (!poolSizes.empty())
838 memReservationInfo.pipelinePoolSizeCount = deUint32(poolSizes.size());
839 memReservationInfo.pPipelinePoolSizes = poolSizes.data();
842 #endif // CTS_USES_VULKANSC
844 VkPhysicalDeviceFeatures enabledFeatures = getPhysicalDeviceFeatures(res.vki, res.physicalDevices[params.deviceIndex]);
846 const VkDeviceCreateInfo deviceGroupCreateInfo =
848 VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
850 (VkDeviceCreateFlags)0,
851 DE_LENGTH_OF_ARRAY(queues),
853 0u, // enabledLayerNameCount
854 DE_NULL, // ppEnabledLayerNames
855 0u, // enabledExtensionNameCount
856 DE_NULL, // ppEnabledExtensionNames
857 &enabledFeatures, // pEnabledFeatures
860 return createCustomDevice(env.commandLine.isValidationEnabled(), env.vkp, env.instance, res.vki, res.physicalDevices[params.deviceIndex], &deviceGroupCreateInfo, env.allocationCallbacks);
866 typedef VkDeviceMemory Type;
871 deUint32 memoryTypeIndex;
873 Parameters (VkDeviceSize size_, deUint32 memoryTypeIndex_)
875 , memoryTypeIndex (memoryTypeIndex_)
877 DE_ASSERT(memoryTypeIndex < VK_MAX_MEMORY_TYPES);
883 Resources (const Environment&, const Parameters&) {}
886 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
888 const VkDeviceSize deviceMemoryUsage = params.size + getPageTableSize(context, params.size);
890 return getSafeObjectCount<DeviceMemory>(context,
892 de::min(context.getDeviceProperties().limits.maxMemoryAllocationCount,
893 (deUint32)DEFAULT_MAX_CONCURRENT_OBJECTS),
897 static Move<VkDeviceMemory> create (const Environment& env, const Resources&, const Parameters& params)
899 const VkMemoryAllocateInfo allocInfo =
901 VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
904 params.memoryTypeIndex
907 return allocateMemory(env.vkd, env.device, &allocInfo, env.allocationCallbacks);
911 DeviceMemory::Parameters getDeviceMemoryParameters (const VkMemoryRequirements& memReqs)
913 return DeviceMemory::Parameters(memReqs.size, deCtz32(memReqs.memoryTypeBits));
916 DeviceMemory::Parameters getDeviceMemoryParameters (const Environment& env, VkImage image)
918 return getDeviceMemoryParameters(getImageMemoryRequirements(env.vkd, env.device, image));
921 DeviceMemory::Parameters getDeviceMemoryParameters (const Environment& env, VkBuffer image)
923 return getDeviceMemoryParameters(getBufferMemoryRequirements(env.vkd, env.device, image));
928 typedef VkBuffer Type;
933 VkBufferUsageFlags usage;
935 Parameters (VkDeviceSize size_,
936 VkBufferUsageFlags usage_)
944 Resources (const Environment&, const Parameters&) {}
947 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
949 const Environment env (context, 1u);
950 const Resources res (env, params);
951 const Unique<VkBuffer> buffer (create(env, res, params));
952 const VkMemoryRequirements memReqs = getBufferMemoryRequirements(env.vkd, env.device, *buffer);
954 return getSafeObjectCount<Buffer>(context,
956 DEFAULT_MAX_CONCURRENT_OBJECTS,
957 getPageTableSize(context, memReqs.size));
960 static Move<VkBuffer> create (const Environment& env, const Resources&, const Parameters& params)
962 const VkBufferCreateInfo bufferInfo =
964 VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
966 (VkBufferCreateFlags)0,
969 VK_SHARING_MODE_EXCLUSIVE,
971 &env.queueFamilyIndex
974 return createBuffer(env.vkd, env.device, &bufferInfo, env.allocationCallbacks);
980 typedef VkBufferView Type;
984 Buffer::Parameters buffer;
989 Parameters (const Buffer::Parameters& buffer_,
991 VkDeviceSize offset_,
1002 Dependency<Buffer> buffer;
1003 Dependency<DeviceMemory> memory;
1005 Resources (const Environment& env, const Parameters& params)
1006 : buffer(env, params.buffer)
1007 , memory(env, getDeviceMemoryParameters(env, *buffer.object))
1009 VK_CHECK(env.vkd.bindBufferMemory(env.device, *buffer.object, *memory.object, 0));
1013 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
1015 return getSafeObjectCount<BufferView>(context, params, DEFAULT_MAX_CONCURRENT_OBJECTS);
1018 static Move<VkBufferView> create (const Environment& env, const Resources& res, const Parameters& params)
1020 const VkBufferViewCreateInfo bufferViewInfo =
1022 VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO,
1024 (VkBufferViewCreateFlags)0,
1031 return createBufferView(env.vkd, env.device, &bufferViewInfo, env.allocationCallbacks);
1037 typedef VkImage Type;
1041 VkImageCreateFlags flags;
1042 VkImageType imageType;
1047 VkSampleCountFlagBits samples;
1048 VkImageTiling tiling;
1049 VkImageUsageFlags usage;
1050 VkImageLayout initialLayout;
1052 Parameters (VkImageCreateFlags flags_,
1053 VkImageType imageType_,
1056 deUint32 mipLevels_,
1057 deUint32 arraySize_,
1058 VkSampleCountFlagBits samples_,
1059 VkImageTiling tiling_,
1060 VkImageUsageFlags usage_,
1061 VkImageLayout initialLayout_)
1063 , imageType (imageType_)
1066 , mipLevels (mipLevels_)
1067 , arraySize (arraySize_)
1068 , samples (samples_)
1071 , initialLayout (initialLayout_)
1077 Resources (const Environment&, const Parameters&) {}
1080 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
1082 const Environment env (context, 1u);
1083 const Resources res (env, params);
1084 const Unique<VkImage> image (create(env, res, params));
1085 const VkMemoryRequirements memReqs = getImageMemoryRequirements(env.vkd, env.device, *image);
1087 return getSafeObjectCount<Image>(context,
1089 DEFAULT_MAX_CONCURRENT_OBJECTS,
1090 getPageTableSize(context, memReqs.size));
1093 static Move<VkImage> create (const Environment& env, const Resources&, const Parameters& params)
1095 const VkImageCreateInfo imageInfo =
1097 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
1108 VK_SHARING_MODE_EXCLUSIVE, // sharingMode
1109 1u, // queueFamilyIndexCount
1110 &env.queueFamilyIndex, // pQueueFamilyIndices
1111 params.initialLayout
1114 return createImage(env.vkd, env.device, &imageInfo, env.allocationCallbacks);
1120 typedef VkImageView Type;
1124 Image::Parameters image;
1125 VkImageViewType viewType;
1127 VkComponentMapping components;
1128 VkImageSubresourceRange subresourceRange;
1130 Parameters (const Image::Parameters& image_,
1131 VkImageViewType viewType_,
1133 VkComponentMapping components_,
1134 VkImageSubresourceRange subresourceRange_)
1136 , viewType (viewType_)
1138 , components (components_)
1139 , subresourceRange (subresourceRange_)
1145 Dependency<Image> image;
1146 Dependency<DeviceMemory> memory;
1148 Resources (const Environment& env, const Parameters& params)
1149 : image (env, params.image)
1150 , memory(env, getDeviceMemoryParameters(env, *image.object))
1152 VK_CHECK(env.vkd.bindImageMemory(env.device, *image.object, *memory.object, 0));
1156 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
1158 return getSafeObjectCount<ImageView>(context, params, DEFAULT_MAX_CONCURRENT_OBJECTS);
1161 static Move<VkImageView> create (const Environment& env, const Resources& res, const Parameters& params)
1163 const VkImageViewCreateInfo imageViewInfo =
1165 VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
1167 (VkImageViewCreateFlags)0,
1172 params.subresourceRange,
1175 return createImageView(env.vkd, env.device, &imageViewInfo, env.allocationCallbacks);
1181 typedef VkSemaphore Type;
1185 VkSemaphoreCreateFlags flags;
1187 Parameters (VkSemaphoreCreateFlags flags_)
1194 Resources (const Environment&, const Parameters&) {}
1197 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
1199 return getSafeObjectCount<Semaphore>(context, params, MAX_CONCURRENT_SYNC_PRIMITIVES);
1202 static Move<VkSemaphore> create (const Environment& env, const Resources&, const Parameters& params)
1204 const VkSemaphoreCreateInfo semaphoreInfo =
1206 VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
1211 return createSemaphore(env.vkd, env.device, &semaphoreInfo, env.allocationCallbacks);
1217 typedef VkFence Type;
1221 VkFenceCreateFlags flags;
1223 Parameters (VkFenceCreateFlags flags_)
1230 Resources (const Environment&, const Parameters&) {}
1233 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
1235 return getSafeObjectCount<Fence>(context, params, MAX_CONCURRENT_SYNC_PRIMITIVES);
1238 static Move<VkFence> create (const Environment& env, const Resources&, const Parameters& params)
1240 const VkFenceCreateInfo fenceInfo =
1242 VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
1247 return createFence(env.vkd, env.device, &fenceInfo, env.allocationCallbacks);
1253 typedef VkEvent Type;
1257 VkEventCreateFlags flags;
1259 Parameters (VkEventCreateFlags flags_)
1266 Resources (const Environment&, const Parameters&) {}
1269 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
1271 return getSafeObjectCount<Event>(context, params, MAX_CONCURRENT_SYNC_PRIMITIVES);
1274 static Move<VkEvent> create (const Environment& env, const Resources&, const Parameters& params)
1276 const VkEventCreateInfo eventInfo =
1278 VK_STRUCTURE_TYPE_EVENT_CREATE_INFO,
1283 return createEvent(env.vkd, env.device, &eventInfo, env.allocationCallbacks);
1289 typedef VkQueryPool Type;
1293 VkQueryType queryType;
1294 deUint32 entryCount;
1295 VkQueryPipelineStatisticFlags pipelineStatistics;
1297 Parameters (VkQueryType queryType_,
1298 deUint32 entryCount_,
1299 VkQueryPipelineStatisticFlags pipelineStatistics_)
1300 : queryType (queryType_)
1301 , entryCount (entryCount_)
1302 , pipelineStatistics (pipelineStatistics_)
1308 Resources (const Environment&, const Parameters&) {}
1311 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
1313 return getSafeObjectCount<QueryPool>(context, params, MAX_CONCURRENT_QUERY_POOLS);
1316 static Move<VkQueryPool> create (const Environment& env, const Resources&, const Parameters& params)
1318 const VkQueryPoolCreateInfo queryPoolInfo =
1320 VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO,
1322 (VkQueryPoolCreateFlags)0,
1325 params.pipelineStatistics
1328 return createQueryPool(env.vkd, env.device, &queryPoolInfo, env.allocationCallbacks);
1334 typedef VkShaderModule Type;
1338 VkShaderStageFlagBits shaderStage;
1341 Parameters (VkShaderStageFlagBits shaderStage_,
1342 const std::string& binaryName_)
1343 : shaderStage (shaderStage_)
1344 , binaryName (binaryName_)
1350 const ProgramBinary& binary;
1352 Resources (const Environment& env, const Parameters& params)
1353 : binary(env.programBinaries.get(params.binaryName))
1357 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
1359 return getSafeObjectCount<ShaderModule>(context, params, DEFAULT_MAX_CONCURRENT_OBJECTS);
1362 static const char* getSource (VkShaderStageFlagBits stage)
1366 case VK_SHADER_STAGE_VERTEX_BIT:
1367 return "#version 310 es\n"
1368 "layout(location = 0) in highp vec4 a_position;\n"
1369 "void main () { gl_Position = a_position; }\n";
1371 case VK_SHADER_STAGE_FRAGMENT_BIT:
1372 return "#version 310 es\n"
1373 "layout(location = 0) out mediump vec4 o_color;\n"
1374 "void main () { o_color = vec4(1.0, 0.5, 0.25, 1.0); }";
1376 case VK_SHADER_STAGE_COMPUTE_BIT:
1377 return "#version 310 es\n"
1378 "layout(binding = 0) buffer Input { highp uint dataIn[]; };\n"
1379 "layout(binding = 1) buffer Output { highp uint dataOut[]; };\n"
1380 "void main (void)\n"
1382 " dataOut[gl_GlobalInvocationID.x] = ~dataIn[gl_GlobalInvocationID.x];\n"
1386 DE_FATAL("Not implemented");
1391 static void initPrograms (SourceCollections& dst, Parameters params)
1393 const char* const source = getSource(params.shaderStage);
1397 dst.glslSources.add(params.binaryName)
1398 << glu::ShaderSource(getGluShaderType(params.shaderStage), source);
1401 static Move<VkShaderModule> create (const Environment& env, const Resources& res, const Parameters&)
1403 const VkShaderModuleCreateInfo shaderModuleInfo =
1405 VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
1407 (VkShaderModuleCreateFlags)0,
1408 res.binary.getSize(),
1409 (const deUint32*)res.binary.getBinary(),
1412 return createShaderModule(env.vkd, env.device, &shaderModuleInfo, env.allocationCallbacks);
1416 struct PipelineCache
1418 typedef VkPipelineCache Type;
1422 Parameters (void) {}
1427 Resources (const Environment&, const Parameters&) {}
1430 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
1432 return getSafeObjectCount<PipelineCache>(context, params, MAX_CONCURRENT_PIPELINE_CACHES);
1435 static void initPrograms(SourceCollections& dst, Parameters)
1437 ShaderModule::initPrograms(dst, ShaderModule::Parameters(VK_SHADER_STAGE_COMPUTE_BIT, "comp"));
1440 static Move<VkPipelineCache> create (const Environment& env, const Resources&, const Parameters&)
1442 #ifdef CTS_USES_VULKANSC
1443 // creating dummy compute pipeline to ensure pipeline cache is not empty
1444 if (!env.commandLine.isSubProcess())
1446 const Unique<VkShaderModule> shaderModule (createShaderModule(env.vkd, env.device, env.programBinaries.get("comp"), 0u));
1448 const Move<VkDescriptorSetLayout> descriptorSetLayout (DescriptorSetLayoutBuilder()
1449 .addSingleBinding(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_SHADER_STAGE_COMPUTE_BIT)
1450 .addSingleBinding(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_SHADER_STAGE_COMPUTE_BIT)
1451 .build(env.vkd, env.device));
1453 const Move<VkPipelineLayout> pipelineLayout (makePipelineLayout(env.vkd, env.device, *descriptorSetLayout));
1455 const VkPipelineShaderStageCreateInfo stageCreateInfo =
1457 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, // VkStructureType sType;
1458 DE_NULL, // const void* pNext;
1459 0u, // VkPipelineShaderStageCreateFlags flags;
1460 VK_SHADER_STAGE_COMPUTE_BIT, // VkShaderStageFlagBits stage;
1461 *shaderModule, // VkShaderModule module;
1462 "main", // const char* pName;
1463 DE_NULL, // const VkSpecializationInfo* pSpecializationInfo;
1466 const VkComputePipelineCreateInfo pipelineInfo =
1468 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, // VkStructureType sType
1469 DE_NULL, // const void* pNext
1470 (VkPipelineCreateFlags)0, // VkPipelineCreateFlags flags
1471 stageCreateInfo, // VkPipelineShaderStageCreateInfo stage
1472 *pipelineLayout, // VkPipelineLayout layout
1473 DE_NULL, // VkPipeline basePipelineHandle
1474 0u // deInt32 basePipelineIndex
1477 Move<VkPipeline> pipeline = createComputePipeline(env.vkd, env.device, DE_NULL, &pipelineInfo);
1479 #endif // CTS_USES_VULKANSC
1480 const VkPipelineCacheCreateInfo pipelineCacheInfo =
1482 VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO, // VkStructureType sType;
1483 DE_NULL, // const void* pNext;
1484 #ifndef CTS_USES_VULKANSC
1485 (VkPipelineCacheCreateFlags)0u, // VkPipelineCacheCreateFlags flags;
1486 0u, // size_t initialDataSize;
1487 DE_NULL, // const void* pInitialData;
1489 VK_PIPELINE_CACHE_CREATE_READ_ONLY_BIT |
1490 VK_PIPELINE_CACHE_CREATE_USE_APPLICATION_STORAGE_BIT, // VkPipelineCacheCreateFlags flags;
1491 env.resourceInterface->getCacheDataSize(), // deUintptr initialDataSize;
1492 env.resourceInterface->getCacheData() // const void* pInitialData;
1493 #endif // CTS_USES_VULKANSC
1496 return createPipelineCache(env.vkd, env.device, &pipelineCacheInfo, env.allocationCallbacks);
1502 typedef VkSampler Type;
1508 VkSamplerMipmapMode mipmapMode;
1509 VkSamplerAddressMode addressModeU;
1510 VkSamplerAddressMode addressModeV;
1511 VkSamplerAddressMode addressModeW;
1513 VkBool32 anisotropyEnable;
1514 float maxAnisotropy;
1515 VkBool32 compareEnable;
1516 VkCompareOp compareOp;
1519 VkBorderColor borderColor;
1520 VkBool32 unnormalizedCoordinates;
1522 // \todo [2015-09-17 pyry] Other configurations
1524 : magFilter (VK_FILTER_NEAREST)
1525 , minFilter (VK_FILTER_NEAREST)
1526 , mipmapMode (VK_SAMPLER_MIPMAP_MODE_NEAREST)
1527 , addressModeU (VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE)
1528 , addressModeV (VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE)
1529 , addressModeW (VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE)
1531 , anisotropyEnable (VK_FALSE)
1532 , maxAnisotropy (1.0f)
1533 , compareEnable (VK_FALSE)
1534 , compareOp (VK_COMPARE_OP_ALWAYS)
1537 , borderColor (VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK)
1538 , unnormalizedCoordinates (VK_FALSE)
1544 Resources (const Environment&, const Parameters&) {}
1547 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
1549 return getSafeObjectCount<Sampler>(context,
1551 de::min(context.getDeviceProperties().limits.maxSamplerAllocationCount,
1552 (deUint32)DEFAULT_MAX_CONCURRENT_OBJECTS));
1555 static Move<VkSampler> create (const Environment& env, const Resources&, const Parameters& params)
1557 const VkSamplerCreateInfo samplerInfo =
1559 VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
1561 (VkSamplerCreateFlags)0,
1565 params.addressModeU,
1566 params.addressModeV,
1567 params.addressModeW,
1569 params.anisotropyEnable,
1570 params.maxAnisotropy,
1571 params.compareEnable,
1576 params.unnormalizedCoordinates
1579 return createSampler(env.vkd, env.device, &samplerInfo, env.allocationCallbacks);
1583 struct DescriptorSetLayout
1585 typedef VkDescriptorSetLayout Type;
1592 VkDescriptorType descriptorType;
1593 deUint32 descriptorCount;
1594 VkShaderStageFlags stageFlags;
1595 bool useImmutableSampler;
1597 Binding (deUint32 binding_,
1598 VkDescriptorType descriptorType_,
1599 deUint32 descriptorCount_,
1600 VkShaderStageFlags stageFlags_,
1601 bool useImmutableSampler_)
1602 : binding (binding_)
1603 , descriptorType (descriptorType_)
1604 , descriptorCount (descriptorCount_)
1605 , stageFlags (stageFlags_)
1606 , useImmutableSampler (useImmutableSampler_)
1612 vector<Binding> bindings;
1614 Parameters (const vector<Binding>& bindings_)
1615 : bindings(bindings_)
1618 static Parameters empty (void)
1620 return Parameters(vector<Binding>());
1623 static Parameters single (deUint32 binding,
1624 VkDescriptorType descriptorType,
1625 deUint32 descriptorCount,
1626 VkShaderStageFlags stageFlags,
1627 bool useImmutableSampler = false)
1629 vector<Binding> bindings;
1630 bindings.push_back(Binding(binding, descriptorType, descriptorCount, stageFlags, useImmutableSampler));
1631 return Parameters(bindings);
1637 vector<VkDescriptorSetLayoutBinding> bindings;
1638 MovePtr<Dependency<Sampler> > immutableSampler;
1639 vector<VkSampler> immutableSamplersPtr;
1641 Resources (const Environment& env, const Parameters& params)
1643 // Create immutable sampler if needed
1644 for (vector<Parameters::Binding>::const_iterator cur = params.bindings.begin(); cur != params.bindings.end(); cur++)
1646 if (cur->useImmutableSampler && !immutableSampler)
1648 immutableSampler = de::newMovePtr<Dependency<Sampler> >(env, Sampler::Parameters());
1650 if (cur->useImmutableSampler && immutableSamplersPtr.size() < (size_t)cur->descriptorCount)
1651 immutableSamplersPtr.resize(cur->descriptorCount, *immutableSampler->object);
1655 for (vector<Parameters::Binding>::const_iterator cur = params.bindings.begin(); cur != params.bindings.end(); cur++)
1657 const VkDescriptorSetLayoutBinding binding =
1660 cur->descriptorType,
1661 cur->descriptorCount,
1663 (cur->useImmutableSampler ? &immutableSamplersPtr[0] : DE_NULL)
1666 bindings.push_back(binding);
1671 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
1673 return getSafeObjectCount<DescriptorSetLayout>(context, params, DEFAULT_MAX_CONCURRENT_OBJECTS);
1676 static Move<VkDescriptorSetLayout> create (const Environment& env, const Resources& res, const Parameters&)
1678 const VkDescriptorSetLayoutCreateInfo descriptorSetLayoutInfo =
1680 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
1682 (VkDescriptorSetLayoutCreateFlags)0,
1683 (deUint32)res.bindings.size(),
1684 (res.bindings.empty() ? DE_NULL : &res.bindings[0])
1687 return createDescriptorSetLayout(env.vkd, env.device, &descriptorSetLayoutInfo, env.allocationCallbacks);
1691 struct PipelineLayout
1693 typedef VkPipelineLayout Type;
1697 vector<DescriptorSetLayout::Parameters> descriptorSetLayouts;
1698 vector<VkPushConstantRange> pushConstantRanges;
1700 Parameters (void) {}
1702 static Parameters empty (void)
1704 return Parameters();
1707 static Parameters singleDescriptorSet (const DescriptorSetLayout::Parameters& descriptorSetLayout)
1710 params.descriptorSetLayouts.push_back(descriptorSetLayout);
1717 typedef SharedPtr<Dependency<DescriptorSetLayout> > DescriptorSetLayoutDepSp;
1718 typedef vector<DescriptorSetLayoutDepSp> DescriptorSetLayouts;
1720 DescriptorSetLayouts descriptorSetLayouts;
1721 vector<VkDescriptorSetLayout> pSetLayouts;
1723 Resources (const Environment& env, const Parameters& params)
1725 for (vector<DescriptorSetLayout::Parameters>::const_iterator dsParams = params.descriptorSetLayouts.begin();
1726 dsParams != params.descriptorSetLayouts.end();
1729 descriptorSetLayouts.push_back(DescriptorSetLayoutDepSp(new Dependency<DescriptorSetLayout>(env, *dsParams)));
1730 pSetLayouts.push_back(*descriptorSetLayouts.back()->object);
1735 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
1737 return getSafeObjectCount<PipelineLayout>(context, params, DEFAULT_MAX_CONCURRENT_OBJECTS);
1740 static Move<VkPipelineLayout> create (const Environment& env, const Resources& res, const Parameters& params)
1742 const VkPipelineLayoutCreateInfo pipelineLayoutInfo =
1744 VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
1746 (VkPipelineLayoutCreateFlags)0,
1747 (deUint32)res.pSetLayouts.size(),
1748 (res.pSetLayouts.empty() ? DE_NULL : &res.pSetLayouts[0]),
1749 (deUint32)params.pushConstantRanges.size(),
1750 (params.pushConstantRanges.empty() ? DE_NULL : ¶ms.pushConstantRanges[0]),
1753 return createPipelineLayout(env.vkd, env.device, &pipelineLayoutInfo, env.allocationCallbacks);
1759 typedef VkRenderPass Type;
1761 // \todo [2015-09-17 pyry] More interesting configurations
1764 Parameters (void) {}
1769 Resources (const Environment&, const Parameters&) {}
1772 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
1774 return getSafeObjectCount<RenderPass>(context, params, DEFAULT_MAX_CONCURRENT_OBJECTS);
1777 static Move<VkRenderPass> create (const Environment& env, const Resources&, const Parameters&)
1779 return makeRenderPass(env.vkd, env.device, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_D16_UNORM,
1780 VK_ATTACHMENT_LOAD_OP_CLEAR,
1781 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1782 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1783 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
1784 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
1785 env.allocationCallbacks);
1789 struct GraphicsPipeline
1791 typedef VkPipeline Type;
1793 // \todo [2015-09-17 pyry] More interesting configurations
1796 Parameters (void) {}
1801 Dependency<ShaderModule> vertexShader;
1802 Dependency<ShaderModule> fragmentShader;
1803 Dependency<PipelineLayout> layout;
1804 Dependency<RenderPass> renderPass;
1805 Dependency<PipelineCache> pipelineCache;
1807 Resources (const Environment& env, const Parameters&)
1808 : vertexShader (env, ShaderModule::Parameters(VK_SHADER_STAGE_VERTEX_BIT, "vert"))
1809 , fragmentShader (env, ShaderModule::Parameters(VK_SHADER_STAGE_FRAGMENT_BIT, "frag"))
1810 , layout (env, PipelineLayout::Parameters::singleDescriptorSet(
1811 DescriptorSetLayout::Parameters::single(0u, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1u, VK_SHADER_STAGE_FRAGMENT_BIT, true)))
1812 , renderPass (env, RenderPass::Parameters())
1813 , pipelineCache (env, PipelineCache::Parameters())
1817 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
1819 return getSafeObjectCount<GraphicsPipeline>(context, params, DEFAULT_MAX_CONCURRENT_OBJECTS);
1822 static void initPrograms (SourceCollections& dst, Parameters)
1824 #ifdef CTS_USES_VULKANSC
1825 // Pipeline cache dependency uses compute shader to ensure that pipeline cache is not empty in subprocess.
1826 // We have to add this shader even if we don't plan to use it later in any *.graphics_pipeline test
1827 ShaderModule::initPrograms(dst, ShaderModule::Parameters(VK_SHADER_STAGE_COMPUTE_BIT, "comp"));
1828 #endif // CTS_USES_VULKANSC
1829 ShaderModule::initPrograms(dst, ShaderModule::Parameters(VK_SHADER_STAGE_VERTEX_BIT, "vert"));
1830 ShaderModule::initPrograms(dst, ShaderModule::Parameters(VK_SHADER_STAGE_FRAGMENT_BIT, "frag"));
1833 static vector<VkPipelineSp> createMultiple (const Environment& env, const Resources& res, const Parameters&, vector<VkPipeline>* const pOutHandles, VkResult* const pOutResult)
1835 DE_ASSERT(pOutResult);
1836 DE_ASSERT(pOutHandles);
1837 DE_ASSERT(pOutHandles->size() != 0);
1839 const VkPipelineShaderStageCreateInfo stages[] =
1842 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
1844 (VkPipelineShaderStageCreateFlags)0,
1845 VK_SHADER_STAGE_VERTEX_BIT,
1846 *res.vertexShader.object,
1848 DE_NULL, // pSpecializationInfo
1851 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
1853 (VkPipelineShaderStageCreateFlags)0,
1854 VK_SHADER_STAGE_FRAGMENT_BIT,
1855 *res.fragmentShader.object,
1857 DE_NULL, // pSpecializationInfo
1860 const VkVertexInputBindingDescription vertexBindings[] =
1865 VK_VERTEX_INPUT_RATE_VERTEX
1868 const VkVertexInputAttributeDescription vertexAttribs[] =
1873 VK_FORMAT_R32G32B32A32_SFLOAT,
1877 const VkPipelineVertexInputStateCreateInfo vertexInputState =
1879 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
1881 (VkPipelineVertexInputStateCreateFlags)0,
1882 DE_LENGTH_OF_ARRAY(vertexBindings),
1884 DE_LENGTH_OF_ARRAY(vertexAttribs),
1887 const VkPipelineInputAssemblyStateCreateInfo inputAssemblyState =
1889 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
1891 (VkPipelineInputAssemblyStateCreateFlags)0,
1892 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
1893 VK_FALSE // primitiveRestartEnable
1895 const VkViewport viewport = makeViewport(tcu::UVec2(64));
1896 const VkRect2D scissor = makeRect2D(tcu::UVec2(64));
1898 const VkPipelineViewportStateCreateInfo viewportState =
1900 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
1902 (VkPipelineViewportStateCreateFlags)0,
1908 const VkPipelineRasterizationStateCreateInfo rasterState =
1910 VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
1912 (VkPipelineRasterizationStateCreateFlags)0,
1913 VK_FALSE, // depthClampEnable
1914 VK_FALSE, // rasterizerDiscardEnable
1915 VK_POLYGON_MODE_FILL,
1916 VK_CULL_MODE_BACK_BIT,
1917 VK_FRONT_FACE_COUNTER_CLOCKWISE,
1918 VK_FALSE, // depthBiasEnable
1919 0.0f, // depthBiasConstantFactor
1920 0.0f, // depthBiasClamp
1921 0.0f, // depthBiasSlopeFactor
1924 const VkPipelineMultisampleStateCreateInfo multisampleState =
1926 VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
1928 (VkPipelineMultisampleStateCreateFlags)0,
1929 VK_SAMPLE_COUNT_1_BIT,
1930 VK_FALSE, // sampleShadingEnable
1931 1.0f, // minSampleShading
1932 DE_NULL, // pSampleMask
1933 VK_FALSE, // alphaToCoverageEnable
1934 VK_FALSE, // alphaToOneEnable
1936 const VkPipelineDepthStencilStateCreateInfo depthStencilState =
1938 VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
1940 (VkPipelineDepthStencilStateCreateFlags)0,
1941 VK_TRUE, // depthTestEnable
1942 VK_TRUE, // depthWriteEnable
1943 VK_COMPARE_OP_LESS, // depthCompareOp
1944 VK_FALSE, // depthBoundsTestEnable
1945 VK_FALSE, // stencilTestEnable
1946 { VK_STENCIL_OP_KEEP, VK_STENCIL_OP_KEEP, VK_STENCIL_OP_KEEP, VK_COMPARE_OP_ALWAYS, 0u, 0u, 0u },
1947 { VK_STENCIL_OP_KEEP, VK_STENCIL_OP_KEEP, VK_STENCIL_OP_KEEP, VK_COMPARE_OP_ALWAYS, 0u, 0u, 0u },
1948 0.0f, // minDepthBounds
1949 1.0f, // maxDepthBounds
1951 const VkPipelineColorBlendAttachmentState colorBlendAttState[]=
1954 VK_FALSE, // blendEnable
1955 VK_BLEND_FACTOR_ONE,
1956 VK_BLEND_FACTOR_ZERO,
1958 VK_BLEND_FACTOR_ONE,
1959 VK_BLEND_FACTOR_ZERO,
1961 VK_COLOR_COMPONENT_R_BIT|VK_COLOR_COMPONENT_G_BIT|VK_COLOR_COMPONENT_B_BIT|VK_COLOR_COMPONENT_A_BIT
1964 const VkPipelineColorBlendStateCreateInfo colorBlendState =
1966 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
1968 (VkPipelineColorBlendStateCreateFlags)0,
1969 VK_FALSE, // logicOpEnable
1971 DE_LENGTH_OF_ARRAY(colorBlendAttState),
1973 { 0.0f, 0.0f, 0.0f, 0.0f } // blendConstants
1975 const VkGraphicsPipelineCreateInfo pipelineInfo =
1977 VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
1979 (VkPipelineCreateFlags)0,
1980 DE_LENGTH_OF_ARRAY(stages),
1983 &inputAssemblyState,
1984 DE_NULL, // pTessellationState
1990 (const VkPipelineDynamicStateCreateInfo*)DE_NULL,
1992 *res.renderPass.object,
1994 (VkPipeline)0, // basePipelineHandle
1995 0, // basePipelineIndex
1998 const deUint32 numPipelines = static_cast<deUint32>(pOutHandles->size());
1999 VkPipeline* const pHandles = &(*pOutHandles)[0];
2000 vector<VkGraphicsPipelineCreateInfo> pipelineInfos (numPipelines, pipelineInfo);
2002 *pOutResult = env.vkd.createGraphicsPipelines(env.device, *res.pipelineCache.object, numPipelines, &pipelineInfos[0], env.allocationCallbacks, pHandles);
2004 vector<VkPipelineSp> pipelines;
2006 // Even if an error is returned, some pipelines may have been created successfully
2007 for (deUint32 i = 0; i < numPipelines; ++i)
2009 if (pHandles[i] != DE_NULL)
2010 pipelines.push_back(VkPipelineSp(new Move<VkPipeline>(check<VkPipeline>(pHandles[i]), Deleter<VkPipeline>(env.vkd, env.device, env.allocationCallbacks))));
2016 static Move<VkPipeline> create (const Environment& env, const Resources& res, const Parameters&)
2018 vector<VkPipeline> handles (1, DE_NULL);
2019 VkResult result = VK_NOT_READY;
2020 vector<VkPipelineSp> scopedHandles = createMultiple(env, res, Parameters(), &handles, &result);
2023 return Move<VkPipeline>(check<VkPipeline>(scopedHandles.front()->disown()), Deleter<VkPipeline>(env.vkd, env.device, env.allocationCallbacks));
2027 struct ComputePipeline
2029 typedef VkPipeline Type;
2031 // \todo [2015-09-17 pyry] More interesting configurations
2034 Parameters (void) {}
2039 Dependency<ShaderModule> shaderModule;
2040 Dependency<PipelineLayout> layout;
2041 Dependency<PipelineCache> pipelineCache;
2043 static DescriptorSetLayout::Parameters getDescriptorSetLayout (void)
2045 typedef DescriptorSetLayout::Parameters::Binding Binding;
2047 vector<Binding> bindings;
2049 bindings.push_back(Binding(0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1u, VK_SHADER_STAGE_COMPUTE_BIT, false));
2050 bindings.push_back(Binding(1, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1u, VK_SHADER_STAGE_COMPUTE_BIT, false));
2052 return DescriptorSetLayout::Parameters(bindings);
2055 Resources (const Environment& env, const Parameters&)
2056 : shaderModule (env, ShaderModule::Parameters(VK_SHADER_STAGE_COMPUTE_BIT, "comp"))
2057 , layout (env, PipelineLayout::Parameters::singleDescriptorSet(getDescriptorSetLayout()))
2058 , pipelineCache (env, PipelineCache::Parameters())
2062 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
2064 return getSafeObjectCount<ComputePipeline>(context, params, DEFAULT_MAX_CONCURRENT_OBJECTS);
2067 static void initPrograms (SourceCollections& dst, Parameters)
2069 ShaderModule::initPrograms(dst, ShaderModule::Parameters(VK_SHADER_STAGE_COMPUTE_BIT, "comp"));
2072 static Move<VkPipeline> create (const Environment& env, const Resources& res, const Parameters&)
2074 const VkComputePipelineCreateInfo pipelineInfo =
2076 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
2078 (VkPipelineCreateFlags)0,
2080 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
2082 (VkPipelineShaderStageCreateFlags)0,
2083 VK_SHADER_STAGE_COMPUTE_BIT,
2084 *res.shaderModule.object,
2086 DE_NULL // pSpecializationInfo
2089 (VkPipeline)0, // basePipelineHandle
2090 0u, // basePipelineIndex
2093 return createComputePipeline(env.vkd, env.device, *res.pipelineCache.object, &pipelineInfo, env.allocationCallbacks);
2096 static vector<VkPipelineSp> createMultiple (const Environment& env, const Resources& res, const Parameters&, vector<VkPipeline>* const pOutHandles, VkResult* const pOutResult)
2098 DE_ASSERT(pOutResult);
2099 DE_ASSERT(pOutHandles);
2100 DE_ASSERT(pOutHandles->size() != 0);
2102 const VkComputePipelineCreateInfo commonPipelineInfo =
2104 VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
2106 (VkPipelineCreateFlags)0,
2108 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
2110 (VkPipelineShaderStageCreateFlags)0,
2111 VK_SHADER_STAGE_COMPUTE_BIT,
2112 *res.shaderModule.object,
2114 DE_NULL // pSpecializationInfo
2117 (VkPipeline)0, // basePipelineHandle
2118 0u, // basePipelineIndex
2121 const deUint32 numPipelines = static_cast<deUint32>(pOutHandles->size());
2122 VkPipeline* const pHandles = &(*pOutHandles)[0];
2123 vector<VkComputePipelineCreateInfo> pipelineInfos (numPipelines, commonPipelineInfo);
2125 *pOutResult = env.vkd.createComputePipelines(env.device, *res.pipelineCache.object, numPipelines, &pipelineInfos[0], env.allocationCallbacks, pHandles);
2127 vector<VkPipelineSp> pipelines;
2129 // Even if an error is returned, some pipelines may have been created successfully
2130 for (deUint32 i = 0; i < numPipelines; ++i)
2132 if (pHandles[i] != DE_NULL)
2133 pipelines.push_back(VkPipelineSp(new Move<VkPipeline>(check<VkPipeline>(pHandles[i]), Deleter<VkPipeline>(env.vkd, env.device, env.allocationCallbacks))));
2140 struct DescriptorPool
2142 typedef VkDescriptorPool Type;
2146 VkDescriptorPoolCreateFlags flags;
2148 vector<VkDescriptorPoolSize> poolSizes;
2150 Parameters (VkDescriptorPoolCreateFlags flags_,
2152 const vector<VkDescriptorPoolSize>& poolSizes_)
2154 , maxSets (maxSets_)
2155 , poolSizes (poolSizes_)
2158 static Parameters singleType (VkDescriptorPoolCreateFlags flags,
2160 VkDescriptorType type,
2163 vector<VkDescriptorPoolSize> poolSizes;
2164 poolSizes.push_back(makeDescriptorPoolSize(type, count));
2165 return Parameters(flags, maxSets, poolSizes);
2171 Resources (const Environment&, const Parameters&) {}
2174 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
2176 return getSafeObjectCount<DescriptorPool>(context, params, DEFAULT_MAX_CONCURRENT_OBJECTS);
2179 static Move<VkDescriptorPool> create (const Environment& env, const Resources&, const Parameters& params)
2181 const VkDescriptorPoolCreateInfo descriptorPoolInfo =
2183 VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
2187 (deUint32)params.poolSizes.size(),
2188 (params.poolSizes.empty() ? DE_NULL : ¶ms.poolSizes[0])
2191 return createDescriptorPool(env.vkd, env.device, &descriptorPoolInfo, env.allocationCallbacks);
2195 struct DescriptorSet
2197 typedef VkDescriptorSet Type;
2201 DescriptorSetLayout::Parameters descriptorSetLayout;
2203 Parameters (const DescriptorSetLayout::Parameters& descriptorSetLayout_)
2204 : descriptorSetLayout(descriptorSetLayout_)
2210 Dependency<DescriptorPool> descriptorPool;
2211 Dependency<DescriptorSetLayout> descriptorSetLayout;
2213 static vector<VkDescriptorPoolSize> computePoolSizes (const DescriptorSetLayout::Parameters& layout, int maxSets)
2215 deUint32 countByType[VK_DESCRIPTOR_TYPE_LAST];
2216 vector<VkDescriptorPoolSize> typeCounts;
2218 std::fill(DE_ARRAY_BEGIN(countByType), DE_ARRAY_END(countByType), 0u);
2220 for (vector<DescriptorSetLayout::Parameters::Binding>::const_iterator cur = layout.bindings.begin();
2221 cur != layout.bindings.end();
2224 DE_ASSERT((deUint32)cur->descriptorType < VK_DESCRIPTOR_TYPE_LAST);
2225 countByType[cur->descriptorType] += cur->descriptorCount * maxSets;
2228 for (deUint32 type = 0; type < VK_DESCRIPTOR_TYPE_LAST; ++type)
2230 if (countByType[type] > 0)
2231 typeCounts.push_back(makeDescriptorPoolSize((VkDescriptorType)type, countByType[type]));
2237 Resources (const Environment& env, const Parameters& params)
2238 : descriptorPool (env, DescriptorPool::Parameters(VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, env.maxResourceConsumers, computePoolSizes(params.descriptorSetLayout, env.maxResourceConsumers)))
2239 , descriptorSetLayout (env, params.descriptorSetLayout)
2244 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
2246 return getSafeObjectCount<DescriptorSet>(context, params, DEFAULT_MAX_CONCURRENT_OBJECTS);
2249 static Move<VkDescriptorSet> create (const Environment& env, const Resources& res, const Parameters&)
2251 const VkDescriptorSetAllocateInfo allocateInfo =
2253 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
2255 *res.descriptorPool.object,
2257 &res.descriptorSetLayout.object.get(),
2260 return allocateDescriptorSet(env.vkd, env.device, &allocateInfo);
2263 static vector<VkDescriptorSetSp> createMultiple (const Environment& env, const Resources& res, const Parameters&, vector<VkDescriptorSet>* const pOutHandles, VkResult* const pOutResult)
2265 DE_ASSERT(pOutResult);
2266 DE_ASSERT(pOutHandles);
2267 DE_ASSERT(pOutHandles->size() != 0);
2269 const deUint32 numDescriptorSets = static_cast<deUint32>(pOutHandles->size());
2270 VkDescriptorSet* const pHandles = &(*pOutHandles)[0];
2271 const vector<VkDescriptorSetLayout> descriptorSetLayouts (numDescriptorSets, res.descriptorSetLayout.object.get());
2273 const VkDescriptorSetAllocateInfo allocateInfo =
2275 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
2277 *res.descriptorPool.object,
2279 &descriptorSetLayouts[0],
2282 *pOutResult = env.vkd.allocateDescriptorSets(env.device, &allocateInfo, pHandles);
2284 vector<VkDescriptorSetSp> descriptorSets;
2286 if (*pOutResult == VK_SUCCESS)
2288 for (deUint32 i = 0; i < numDescriptorSets; ++i)
2289 descriptorSets.push_back(VkDescriptorSetSp(new Move<VkDescriptorSet>(check<VkDescriptorSet>(pHandles[i]), Deleter<VkDescriptorSet>(env.vkd, env.device, *res.descriptorPool.object))));
2292 return descriptorSets;
2298 typedef VkFramebuffer Type;
2308 Dependency<ImageView> colorAttachment;
2309 Dependency<ImageView> depthStencilAttachment;
2310 Dependency<RenderPass> renderPass;
2312 Resources (const Environment& env, const Parameters&)
2313 : colorAttachment (env, ImageView::Parameters(Image::Parameters(0u, VK_IMAGE_TYPE_2D, VK_FORMAT_R8G8B8A8_UNORM,
2314 makeExtent3D(256, 256, 1),
2316 VK_SAMPLE_COUNT_1_BIT,
2317 VK_IMAGE_TILING_OPTIMAL,
2318 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
2319 VK_IMAGE_LAYOUT_UNDEFINED),
2320 VK_IMAGE_VIEW_TYPE_2D, VK_FORMAT_R8G8B8A8_UNORM,
2321 makeComponentMappingRGBA(),
2322 makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u)))
2323 , depthStencilAttachment (env, ImageView::Parameters(Image::Parameters(0u, VK_IMAGE_TYPE_2D, VK_FORMAT_D16_UNORM,
2324 makeExtent3D(256, 256, 1),
2326 VK_SAMPLE_COUNT_1_BIT,
2327 VK_IMAGE_TILING_OPTIMAL,
2328 VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
2329 VK_IMAGE_LAYOUT_UNDEFINED),
2330 VK_IMAGE_VIEW_TYPE_2D, VK_FORMAT_D16_UNORM,
2331 makeComponentMappingRGBA(),
2332 makeImageSubresourceRange(VK_IMAGE_ASPECT_DEPTH_BIT, 0u, 1u, 0u, 1u)))
2333 , renderPass (env, RenderPass::Parameters())
2337 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
2339 // \todo [2016-03-23 pyry] Take into account attachment sizes
2340 return getSafeObjectCount<Framebuffer>(context, params, DEFAULT_MAX_CONCURRENT_OBJECTS);
2343 static Move<VkFramebuffer> create (const Environment& env, const Resources& res, const Parameters&)
2345 const VkImageView attachments[] =
2347 *res.colorAttachment.object,
2348 *res.depthStencilAttachment.object,
2350 const VkFramebufferCreateInfo framebufferInfo =
2352 VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
2354 (VkFramebufferCreateFlags)0,
2355 *res.renderPass.object,
2356 (deUint32)DE_LENGTH_OF_ARRAY(attachments),
2363 return createFramebuffer(env.vkd, env.device, &framebufferInfo, env.allocationCallbacks);
2369 typedef VkCommandPool Type;
2373 VkCommandPoolCreateFlags flags;
2375 Parameters (VkCommandPoolCreateFlags flags_)
2382 Resources (const Environment&, const Parameters&) {}
2385 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
2387 return getSafeObjectCount<CommandPool>(context, params, DEFAULT_MAX_CONCURRENT_OBJECTS);
2390 static Move<VkCommandPool> create (const Environment& env, const Resources&, const Parameters& params)
2392 const VkCommandPoolCreateInfo cmdPoolInfo =
2394 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
2397 env.queueFamilyIndex,
2400 return createCommandPool(env.vkd, env.device, &cmdPoolInfo, env.allocationCallbacks);
2404 struct CommandBuffer
2406 typedef VkCommandBuffer Type;
2410 CommandPool::Parameters commandPool;
2411 VkCommandBufferLevel level;
2413 Parameters (const CommandPool::Parameters& commandPool_,
2414 VkCommandBufferLevel level_)
2415 : commandPool (commandPool_)
2422 Dependency<CommandPool> commandPool;
2424 Resources (const Environment& env, const Parameters& params)
2425 : commandPool(env, params.commandPool)
2429 static deUint32 getMaxConcurrent (Context& context, const Parameters& params)
2431 return getSafeObjectCount<CommandBuffer>(context, params, DEFAULT_MAX_CONCURRENT_OBJECTS);
2434 static Move<VkCommandBuffer> create (const Environment& env, const Resources& res, const Parameters& params)
2436 const VkCommandBufferAllocateInfo cmdBufferInfo =
2438 VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
2440 *res.commandPool.object,
2445 return allocateCommandBuffer(env.vkd, env.device, &cmdBufferInfo);
2448 static vector<VkCommandBufferSp> createMultiple (const Environment& env, const Resources& res, const Parameters& params, vector<VkCommandBuffer>* const pOutHandles, VkResult* const pOutResult)
2450 DE_ASSERT(pOutResult);
2451 DE_ASSERT(pOutHandles);
2452 DE_ASSERT(pOutHandles->size() != 0);
2454 const deUint32 numCommandBuffers = static_cast<deUint32>(pOutHandles->size());
2455 VkCommandBuffer* const pHandles = &(*pOutHandles)[0];
2457 const VkCommandBufferAllocateInfo cmdBufferInfo =
2459 VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
2461 *res.commandPool.object,
2466 *pOutResult = env.vkd.allocateCommandBuffers(env.device, &cmdBufferInfo, pHandles);
2468 vector<VkCommandBufferSp> commandBuffers;
2470 if (*pOutResult == VK_SUCCESS)
2472 for (deUint32 i = 0; i < numCommandBuffers; ++i)
2473 commandBuffers.push_back(VkCommandBufferSp(new Move<VkCommandBuffer>(check<VkCommandBuffer>(pHandles[i]), Deleter<VkCommandBuffer>(env.vkd, env.device, *res.commandPool.object))));
2476 return commandBuffers;
2482 template<typename Object>
2483 tcu::TestStatus createSingleTest (Context& context, typename Object::Parameters params)
2485 const Environment env (context, 1u);
2486 const typename Object::Resources res (env, params);
2489 Unique<typename Object::Type> obj (Object::create(env, res, params));
2492 return tcu::TestStatus::pass("Ok");
2495 template<typename Object>
2496 tcu::TestStatus createMultipleUniqueResourcesTest (Context& context, typename Object::Parameters params)
2498 const Environment env (context, 1u);
2499 const typename Object::Resources res0 (env, params);
2500 const typename Object::Resources res1 (env, params);
2501 const typename Object::Resources res2 (env, params);
2502 const typename Object::Resources res3 (env, params);
2505 Unique<typename Object::Type> obj0 (Object::create(env, res0, params));
2506 Unique<typename Object::Type> obj1 (Object::create(env, res1, params));
2507 Unique<typename Object::Type> obj2 (Object::create(env, res2, params));
2508 Unique<typename Object::Type> obj3 (Object::create(env, res3, params));
2511 return tcu::TestStatus::pass("Ok");
2514 #ifdef CTS_USES_VULKANSC
2516 tcu::TestStatus createMultipleUniqueResourcesTest<Instance> (Context& context, Instance::Parameters params)
2518 const Environment env(context, 1u);
2519 const typename Instance::Resources res0(env, params);
2520 const typename Instance::Resources res1(env, params);
2523 Unique<typename Instance::Type> obj0(Instance::create(env, res0, params));
2524 Unique<typename Instance::Type> obj1(Instance::create(env, res1, params));
2527 return tcu::TestStatus::pass("Ok");
2529 #endif // CTS_USES_VULKANSC
2531 template<typename Object>
2532 tcu::TestStatus createMultipleSharedResourcesTest (Context& context, typename Object::Parameters params)
2534 const Environment env (context, 4u);
2535 const typename Object::Resources res (env, params);
2538 Unique<typename Object::Type> obj0 (Object::create(env, res, params));
2539 Unique<typename Object::Type> obj1 (Object::create(env, res, params));
2540 Unique<typename Object::Type> obj2 (Object::create(env, res, params));
2541 Unique<typename Object::Type> obj3 (Object::create(env, res, params));
2544 return tcu::TestStatus::pass("Ok");
2547 #ifndef CTS_USES_VULKANSC
2549 // Class to wrap singleton devices used by private_data tests
2550 class SingletonDevice
2552 Move<VkDevice> createPrivateDataDevice(const Context &context, int idx)
2554 const int requestedSlots[NUM_DEVICES][2] =
2563 const float queuePriority = 1.0;
2564 const VkDeviceQueueCreateInfo queues[] =
2567 VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
2569 (VkDeviceQueueCreateFlags)0,
2570 context.getUniversalQueueFamilyIndex(),
2572 &queuePriority, // pQueuePriorities
2576 VkDevicePrivateDataCreateInfoEXT pdci0 =
2578 VK_STRUCTURE_TYPE_DEVICE_PRIVATE_DATA_CREATE_INFO_EXT, // VkStructureType sType;
2579 DE_NULL, // const void* pNext;
2580 0u, // uint32_t privateDataSlotRequestCount;
2582 VkDevicePrivateDataCreateInfoEXT pdci1 =
2584 VK_STRUCTURE_TYPE_DEVICE_PRIVATE_DATA_CREATE_INFO_EXT, // VkStructureType sType;
2585 DE_NULL, // const void* pNext;
2586 0u, // uint32_t privateDataSlotRequestCount;
2588 void *pNext = DE_NULL;
2590 if (requestedSlots[idx][0])
2593 pdci0.privateDataSlotRequestCount = requestedSlots[idx][0];
2594 if (requestedSlots[idx][1])
2596 pdci0.pNext = &pdci1;
2597 pdci1.privateDataSlotRequestCount = requestedSlots[idx][1];
2601 VkPhysicalDevicePrivateDataFeaturesEXT privateDataFeatures =
2603 VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES_EXT, // VkStructureType sType;
2604 pNext, // void* pNext;
2605 VK_TRUE, // VkBool32 privateData;
2607 pNext = &privateDataFeatures;
2609 const char *extName = "VK_EXT_private_data";
2611 VkPhysicalDeviceFeatures enabledFeatures = getPhysicalDeviceFeatures(context.getInstanceInterface(), context.getPhysicalDevice());
2613 const VkDeviceCreateInfo deviceInfo =
2615 VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
2617 (VkDeviceCreateFlags)0,
2618 DE_LENGTH_OF_ARRAY(queues),
2620 0u, // enabledLayerNameCount
2621 DE_NULL, // ppEnabledLayerNames
2622 1u, // enabledExtensionNameCount
2623 &extName, // ppEnabledExtensionNames
2624 &enabledFeatures, // pEnabledFeatures
2627 Move<VkDevice> device = createCustomDevice(context.getTestContext().getCommandLine().isValidationEnabled(),
2628 context.getPlatformInterface(), context.getInstance(), context.getInstanceInterface(), context.getPhysicalDevice(), &deviceInfo, DE_NULL);
2632 SingletonDevice (const Context& context, int idx)
2633 : m_logicalDevice (createPrivateDataDevice(context, idx))
2640 static const int NUM_DEVICES = 5;
2642 static const Unique<vk::VkDevice>& getDevice(const Context& context, int idx)
2644 if (!m_singletonDevice[idx])
2645 m_singletonDevice[idx] = SharedPtr<SingletonDevice>(new SingletonDevice(context, idx));
2647 DE_ASSERT(m_singletonDevice[idx]);
2648 return m_singletonDevice[idx]->m_logicalDevice;
2651 static void destroy()
2653 for (int idx = 0; idx < NUM_DEVICES; ++idx)
2654 m_singletonDevice[idx].clear();
2658 const Unique<vk::VkDevice> m_logicalDevice;
2659 static SharedPtr<SingletonDevice> m_singletonDevice[NUM_DEVICES];
2662 SharedPtr<SingletonDevice> SingletonDevice::m_singletonDevice[NUM_DEVICES];
2664 template<typename T> static deUint64 HandleToInt(T t) { return t.getInternal(); }
2665 template<typename T> static deUint64 HandleToInt(T *t) { return (deUint64)(deUintptr)(t); }
2667 template<typename Object>
2668 tcu::TestStatus createPrivateDataTest (Context& context, typename Object::Parameters params)
2670 if (!context.getPrivateDataFeatures().privateData)
2671 TCU_THROW(NotSupportedError, "privateData not supported");
2673 for (int d = 0; d < SingletonDevice::NUM_DEVICES; ++d)
2675 const Unique<vk::VkDevice>& device = SingletonDevice::getDevice(context, d);
2676 const Environment env (context.getPlatformInterface(),
2677 context.getUsedApiVersion(),
2678 context.getInstanceInterface(),
2679 context.getInstance(),
2680 context.getDeviceInterface(),
2682 context.getUniversalQueueFamilyIndex(),
2683 context.getBinaryCollection(),
2686 context.getTestContext().getCommandLine());
2688 const typename Object::Resources res (env, params);
2690 const VkPrivateDataSlotCreateInfoEXT createInfo =
2692 VK_STRUCTURE_TYPE_PRIVATE_DATA_SLOT_CREATE_INFO_EXT, // VkStructureType sType;
2693 DE_NULL, // const void* pNext;
2694 0u, // VkPrivateDataSlotCreateFlagsEXT flags;
2697 const int numSlots = 100;
2699 typedef Unique<VkPrivateDataSlot> PrivateDataSlotUp;
2700 typedef SharedPtr<PrivateDataSlotUp> PrivateDataSlotSp;
2701 vector<PrivateDataSlotSp> slots;
2703 // interleave allocating objects and slots
2704 for (int i = 0; i < numSlots / 2; ++i)
2706 Move<VkPrivateDataSlot> s = createPrivateDataSlot(env.vkd, *device, &createInfo, DE_NULL);
2707 slots.push_back(PrivateDataSlotSp(new PrivateDataSlotUp(s)));
2710 Unique<typename Object::Type> obj0 (Object::create(env, res, params));
2711 Unique<typename Object::Type> obj1 (Object::create(env, res, params));
2713 for (int i = numSlots / 2; i < numSlots; ++i)
2715 Move<VkPrivateDataSlot> s = createPrivateDataSlot(env.vkd, *device, &createInfo, DE_NULL);
2716 slots.push_back(PrivateDataSlotSp(new PrivateDataSlotUp(s)));
2719 Unique<typename Object::Type> obj2 (Object::create(env, res, params));
2720 Unique<typename Object::Type> obj3 (Object::create(env, res, params));
2722 Unique<typename Object::Type> *objs[4] = { &obj0, &obj1, &obj2, &obj3 };
2724 for (int r = 0; r < 3; ++r)
2728 // Test private data for the objects
2729 for (int o = 0; o < 4; ++o)
2731 auto &obj = *objs[o];
2732 for (int i = 0; i < numSlots; ++i)
2735 env.vkd.getPrivateData(*device, getObjectType<typename Object::Type>(), HandleToInt(obj.get()), **slots[i], &data);
2737 return tcu::TestStatus::fail("Expected initial value of zero");
2740 for (int o = 0; o < 4; ++o)
2742 auto &obj = *objs[o];
2743 for (int i = 0; i < numSlots; ++i)
2744 VK_CHECK(env.vkd.setPrivateData(*device, getObjectType<typename Object::Type>(), HandleToInt(obj.get()), **slots[i], i*i*i + o*o + 1));
2746 for (int o = 0; o < 4; ++o)
2748 auto &obj = *objs[o];
2749 for (int i = 0; i < numSlots; ++i)
2752 env.vkd.getPrivateData(*device, getObjectType<typename Object::Type>(), HandleToInt(obj.get()), **slots[i], &data);
2753 if (data != (deUint64)(i*i*i + o*o + 1))
2754 return tcu::TestStatus::fail("Didn't read back set value");
2759 // Test private data for the private data objects
2760 for (int o = 0; o < numSlots; ++o)
2762 auto &obj = **slots[o];
2763 for (int i = 0; i < numSlots; ++i)
2766 env.vkd.getPrivateData(*device, VK_OBJECT_TYPE_PRIVATE_DATA_SLOT_EXT, HandleToInt<VkPrivateDataSlotEXT>(obj), **slots[i], &data);
2768 return tcu::TestStatus::fail("Expected initial value of zero");
2771 for (int o = 0; o < numSlots; ++o)
2773 auto &obj = **slots[o];
2774 for (int i = 0; i < numSlots; ++i)
2775 VK_CHECK(env.vkd.setPrivateData(*device, VK_OBJECT_TYPE_PRIVATE_DATA_SLOT_EXT, HandleToInt<VkPrivateDataSlotEXT>(obj), **slots[i], i*i*i + o*o + 1));
2777 for (int o = 0; o < numSlots; ++o)
2779 auto &obj = **slots[o];
2780 for (int i = 0; i < numSlots; ++i)
2783 env.vkd.getPrivateData(*device, VK_OBJECT_TYPE_PRIVATE_DATA_SLOT_EXT, HandleToInt<VkPrivateDataSlotEXT>(obj), **slots[i], &data);
2784 if (data != (deUint64)(i*i*i + o*o + 1))
2785 return tcu::TestStatus::fail("Didn't read back set value");
2789 // Test private data for the device
2790 for (int i = 0; i < numSlots; ++i)
2793 env.vkd.getPrivateData(*device, VK_OBJECT_TYPE_DEVICE, (deUint64)(deUintptr)(*device), **slots[i], &data);
2795 return tcu::TestStatus::fail("Expected initial value of zero for device");
2797 for (int i = 0; i < numSlots; ++i)
2798 VK_CHECK(env.vkd.setPrivateData(*device, VK_OBJECT_TYPE_DEVICE, (deUint64)(deUintptr)(*device), **slots[i], i*i*i + r*r + 1));
2799 for (int i = 0; i < numSlots; ++i)
2802 env.vkd.getPrivateData(*device, VK_OBJECT_TYPE_DEVICE, (deUint64)(deUintptr)(*device), **slots[i], &data);
2803 if (data != (deUint64)(i*i*i + r*r + 1))
2804 return tcu::TestStatus::fail("Didn't read back set value from device");
2807 // Destroy and realloc slots for the next iteration
2809 for (int i = 0; i < numSlots; ++i)
2811 Move<VkPrivateDataSlotEXT> s = createPrivateDataSlot(env.vkd, *device, &createInfo, DE_NULL);
2812 slots.push_back(PrivateDataSlotSp(new PrivateDataSlotUp(s)));
2817 return tcu::TestStatus::pass("Ok");
2820 template<typename Object>
2821 tcu::TestStatus createMaxConcurrentTest (Context& context, typename Object::Parameters params)
2823 typedef Unique<typename Object::Type> UniqueObject;
2824 typedef SharedPtr<UniqueObject> ObjectPtr;
2826 const deUint32 numObjects = Object::getMaxConcurrent(context, params);
2827 const Environment env (context, numObjects);
2828 const typename Object::Resources res (env, params);
2829 vector<ObjectPtr> objects (numObjects);
2830 const deUint32 watchdogInterval = 1024;
2832 context.getTestContext().getLog()
2833 << TestLog::Message << "Creating " << numObjects << " " << getTypeName<typename Object::Type>() << " objects" << TestLog::EndMessage;
2835 for (deUint32 ndx = 0; ndx < numObjects; ndx++)
2837 objects[ndx] = ObjectPtr(new UniqueObject(Object::create(env, res, params)));
2839 if ((ndx > 0) && ((ndx % watchdogInterval) == 0))
2840 context.getTestContext().touchWatchdog();
2843 context.getTestContext().touchWatchdog();
2846 return tcu::TestStatus::pass("Ok");
2849 #endif // CTS_USES_VULKANSC
2851 // How many objects to create per thread
2852 template<typename Object> int getCreateCount (void) { return 100; }
2854 // Creating VkDevice and VkInstance can take significantly longer than other object types
2856 #ifndef CTS_USES_VULKANSC
2857 template<> int getCreateCount<Instance> (void) { return 20; }
2858 template<> int getCreateCount<Device> (void) { return 20; }
2859 template<> int getCreateCount<DeviceGroup> (void) { return 20; }
2861 template<> int getCreateCount<Instance> (void) { return 2; }
2862 template<> int getCreateCount<Device> (void) { return 2; }
2863 template<> int getCreateCount<DeviceGroup> (void) { return 2; }
2864 #endif // CTS_USES_VULKANSC
2866 template<typename Object>
2867 class CreateThread : public ThreadGroupThread
2870 CreateThread (const Environment& env, const typename Object::Resources& resources, const typename Object::Parameters& params)
2872 , m_resources (resources)
2876 void runThread (void)
2878 const int numIters = getCreateCount<Object>();
2879 #ifndef CTS_USES_VULKANSC
2880 const int itersBetweenSyncs = numIters / 5;
2882 const int itersBetweenSyncs = 1;
2883 #endif // CTS_USES_VULKANSC
2885 DE_ASSERT(itersBetweenSyncs > 0);
2887 for (int iterNdx = 0; iterNdx < numIters; iterNdx++)
2889 // Sync every Nth iteration to make entering driver at the same time more likely
2890 if ((iterNdx % itersBetweenSyncs) == 0)
2894 Unique<typename Object::Type> obj (Object::create(m_env, m_resources, m_params));
2895 #ifdef CTS_USES_VULKANSC
2906 const Environment& m_env;
2907 const typename Object::Resources& m_resources;
2908 const typename Object::Parameters& m_params;
2911 template<typename Object>
2912 tcu::TestStatus multithreadedCreateSharedResourcesTest (Context& context, typename Object::Parameters params)
2914 #ifdef CTS_USES_VULKANSC
2915 MultithreadedDestroyGuard mdGuard (context.getResourceInterface());
2916 #endif // CTS_USES_VULKANSC
2917 TestLog& log = context.getTestContext().getLog();
2918 const deUint32 numThreads = getDefaultTestThreadCount();
2919 const Environment env (context, numThreads);
2920 const typename Object::Resources res (env, params);
2921 ThreadGroup threads;
2923 log << TestLog::Message << "numThreads = " << numThreads << TestLog::EndMessage;
2925 for (deUint32 ndx = 0; ndx < numThreads; ndx++)
2926 threads.add(MovePtr<ThreadGroupThread>(new CreateThread<Object>(env, res, params)));
2928 return threads.run();
2931 template<typename Object>
2932 tcu::TestStatus multithreadedCreatePerThreadResourcesTest (Context& context, typename Object::Parameters params)
2934 typedef SharedPtr<typename Object::Resources> ResPtr;
2935 #ifdef CTS_USES_VULKANSC
2936 MultithreadedDestroyGuard mdGuard (context.getResourceInterface());
2937 #endif // CTS_USES_VULKANSC
2938 TestLog& log = context.getTestContext().getLog();
2939 const deUint32 numThreads = getDefaultTestThreadCount();
2940 const Environment env (context, 1u);
2941 vector<ResPtr> resources (numThreads);
2942 ThreadGroup threads;
2944 log << TestLog::Message << "numThreads = " << numThreads << TestLog::EndMessage;
2946 for (deUint32 ndx = 0; ndx < numThreads; ndx++)
2948 resources[ndx] = ResPtr(new typename Object::Resources(env, params));
2949 threads.add(MovePtr<ThreadGroupThread>(new CreateThread<Object>(env, *resources[ndx], params)));
2952 return threads.run();
2957 Device::Resources deviceRes;
2958 Unique<VkDevice> device;
2959 #ifndef CTS_USES_VULKANSC
2960 de::MovePtr<vk::DeviceDriver> vkd;
2962 de::MovePtr<vk::DeviceDriverSC, vk::DeinitDeviceDeleter> vkd;
2963 #endif // CTS_USES_VULKANSC
2966 EnvClone (const Environment& parent, const Device::Parameters& deviceParams, deUint32 maxResourceConsumers)
2967 : deviceRes (parent, deviceParams)
2968 , device (Device::create(parent, deviceRes, deviceParams))
2969 #ifndef CTS_USES_VULKANSC
2970 , vkd(de::MovePtr<DeviceDriver>(new DeviceDriver(parent.vkp, parent.instance, *device)))
2971 , env(parent.vkp, parent.apiVersion, parent.instanceInterface, parent.instance, *vkd, *device, deviceRes.queueFamilyIndex, parent.programBinaries, parent.allocationCallbacks, maxResourceConsumers, parent.commandLine)
2973 , vkd(de::MovePtr<DeviceDriverSC, DeinitDeviceDeleter>(new DeviceDriverSC(parent.vkp, parent.instance, *device, parent.commandLine, parent.resourceInterface, parent.vulkanSC10Properties, parent.properties), vk::DeinitDeviceDeleter(parent.resourceInterface.get(), *device)))
2974 , env(parent.vkp, parent.apiVersion, parent.instanceInterface, parent.instance, *vkd, *device, deviceRes.queueFamilyIndex, parent.programBinaries, parent.allocationCallbacks, maxResourceConsumers, parent.resourceInterface, parent.vulkanSC10Properties, parent.commandLine)
2975 #endif // CTS_USES_VULKANSC
2980 Device::Parameters getDefaulDeviceParameters (Context& context)
2982 return Device::Parameters(context.getTestContext().getCommandLine().getVKDeviceId()-1u,
2983 VK_QUEUE_GRAPHICS_BIT|VK_QUEUE_COMPUTE_BIT);
2986 template<typename Object>
2987 tcu::TestStatus multithreadedCreatePerThreadDeviceTest (Context& context, typename Object::Parameters params)
2989 #ifdef CTS_USES_VULKANSC
2990 MultithreadedDestroyGuard mdGuard(context.getResourceInterface());
2991 #endif // CTS_USES_VULKANSC
2992 typedef SharedPtr<EnvClone> EnvPtr;
2993 typedef SharedPtr<typename Object::Resources> ResPtr;
2995 TestLog& log = context.getTestContext().getLog();
2996 const deUint32 numThreads = getDefaultTestThreadCount();
2997 const Device::Parameters deviceParams = getDefaulDeviceParameters(context);
2998 const Environment sharedEnv (context, numThreads); // For creating Device's
2999 vector<EnvPtr> perThreadEnv (numThreads);
3000 vector<ResPtr> resources (numThreads);
3001 ThreadGroup threads;
3003 log << TestLog::Message << "numThreads = " << numThreads << TestLog::EndMessage;
3005 for (deUint32 ndx = 0; ndx < numThreads; ndx++)
3007 perThreadEnv[ndx] = EnvPtr(new EnvClone(sharedEnv, deviceParams, 1u));
3008 resources[ndx] = ResPtr(new typename Object::Resources(perThreadEnv[ndx]->env, params));
3010 threads.add(MovePtr<ThreadGroupThread>(new CreateThread<Object>(perThreadEnv[ndx]->env, *resources[ndx], params)));
3013 return threads.run();
3016 #ifndef CTS_USES_VULKANSC
3018 template<typename Object>
3019 tcu::TestStatus createSingleAllocCallbacksTest (Context& context, typename Object::Parameters params)
3021 const deUint32 noCmdScope = (1u << VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE)
3022 | (1u << VK_SYSTEM_ALLOCATION_SCOPE_DEVICE)
3023 | (1u << VK_SYSTEM_ALLOCATION_SCOPE_CACHE)
3024 | (1u << VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
3026 // Callbacks used by resources
3027 AllocationCallbackRecorder resCallbacks (getSystemAllocator(), 128);
3029 // Root environment still uses default instance and device, created without callbacks
3030 const Environment rootEnv (context.getPlatformInterface(),
3031 context.getUsedApiVersion(),
3032 context.getInstanceInterface(),
3033 context.getInstance(),
3034 context.getDeviceInterface(),
3035 context.getDevice(),
3036 context.getUniversalQueueFamilyIndex(),
3037 context.getBinaryCollection(),
3038 resCallbacks.getCallbacks(),
3040 #ifdef CTS_USES_VULKANSC
3041 context.getResourceInterface(),
3042 context.getDeviceVulkanSC10Properties(),
3043 #endif // CTS_USES_VULKANSC
3044 context.getTestContext().getCommandLine());
3047 // Test env has instance & device created with callbacks
3048 const EnvClone resEnv (rootEnv, getDefaulDeviceParameters(context), 1u);
3049 const typename Object::Resources res (resEnv.env, params);
3051 // Supply a separate callback recorder just for object construction
3052 AllocationCallbackRecorder objCallbacks(getSystemAllocator(), 128);
3053 const Environment objEnv (resEnv.env.vkp,
3054 resEnv.env.apiVersion,
3055 resEnv.env.instanceInterface,
3056 resEnv.env.instance,
3059 resEnv.env.queueFamilyIndex,
3060 resEnv.env.programBinaries,
3061 objCallbacks.getCallbacks(),
3062 resEnv.env.maxResourceConsumers,
3063 #ifdef CTS_USES_VULKANSC
3064 resEnv.env.resourceInterface,
3065 resEnv.env.vulkanSC10Properties,
3066 #endif // CTS_USES_VULKANSC
3067 resEnv.env.commandLine);
3070 Unique<typename Object::Type> obj (Object::create(objEnv, res, params));
3072 // Validate that no command-level allocations are live
3073 if (!validateAndLog(context.getTestContext().getLog(), objCallbacks, noCmdScope))
3074 return tcu::TestStatus::fail("Invalid allocation callback");
3077 // At this point all allocations made against object callbacks must have been freed
3078 if (!validateAndLog(context.getTestContext().getLog(), objCallbacks, 0u))
3079 return tcu::TestStatus::fail("Invalid allocation callback");
3082 if (!validateAndLog(context.getTestContext().getLog(), resCallbacks, 0u))
3083 return tcu::TestStatus::fail("Invalid allocation callback");
3085 return tcu::TestStatus::pass("Ok");
3088 #endif // CTS_USES_VULKANSC
3090 template<typename Object> deUint32 getOomIterLimit (void) { return 40; }
3091 #ifndef CTS_USES_VULKANSC
3092 template<> deUint32 getOomIterLimit<Device> (void) { return 20; }
3093 template<> deUint32 getOomIterLimit<DeviceGroup> (void) { return 20; }
3094 #endif // CTS_USES_VULKANSC
3096 #ifndef CTS_USES_VULKANSC
3098 template<typename Object>
3099 tcu::TestStatus allocCallbackFailTest (Context& context, typename Object::Parameters params)
3101 AllocationCallbackRecorder resCallbacks (getSystemAllocator(), 128);
3102 const Environment rootEnv (context.getPlatformInterface(),
3103 context.getUsedApiVersion(),
3104 context.getInstanceInterface(),
3105 context.getInstance(),
3106 context.getDeviceInterface(),
3107 context.getDevice(),
3108 context.getUniversalQueueFamilyIndex(),
3109 context.getBinaryCollection(),
3110 resCallbacks.getCallbacks(),
3112 #ifdef CTS_USES_VULKANSC
3113 context.getResourceInterface(),
3114 context.getDeviceVulkanSC10Properties(),
3115 #endif // CTS_USES_VULKANSC
3116 context.getTestContext().getCommandLine());
3117 deUint32 numPassingAllocs = 0;
3118 const deUint32 cmdLineIterCount = (deUint32)context.getTestContext().getCommandLine().getTestIterationCount();
3119 const deUint32 maxTries = cmdLineIterCount != 0 ? cmdLineIterCount : getOomIterLimit<Object>();
3120 const deUint32 finalLimit = std::max(maxTries, 10000u);
3121 bool createOk = false;
3124 const EnvClone resEnv (rootEnv, getDefaulDeviceParameters(context), 1u);
3125 const typename Object::Resources res (resEnv.env, params);
3127 // Iterate over test until object allocation succeeds
3130 DeterministicFailAllocator objAllocator(getSystemAllocator(),
3131 DeterministicFailAllocator::MODE_COUNT_AND_FAIL,
3133 AllocationCallbackRecorder recorder (objAllocator.getCallbacks(), 128);
3134 const Environment objEnv (resEnv.env.vkp,
3135 resEnv.env.apiVersion,
3136 resEnv.env.instanceInterface,
3137 resEnv.env.instance,
3140 resEnv.env.queueFamilyIndex,
3141 resEnv.env.programBinaries,
3142 recorder.getCallbacks(),
3143 resEnv.env.maxResourceConsumers,
3144 #ifdef CTS_USES_VULKANSC
3145 resEnv.env.resourceInterface,
3146 resEnv.env.vulkanSC10Properties,
3147 #endif // CTS_USES_VULKANSC
3148 resEnv.env.commandLine);
3150 context.getTestContext().getLog()
3152 << "Trying to create object with " << numPassingAllocs << " allocation" << (numPassingAllocs != 1 ? "s" : "") << " passing"
3153 << TestLog::EndMessage;
3158 Unique<typename Object::Type> obj (Object::create(objEnv, res, params));
3161 catch (const vk::OutOfMemoryError& e)
3163 if (e.getError() != VK_ERROR_OUT_OF_HOST_MEMORY)
3165 context.getTestContext().getLog() << e;
3166 return tcu::TestStatus::fail("Got invalid error code");
3170 if (!validateAndLog(context.getTestContext().getLog(), recorder, 0u))
3171 return tcu::TestStatus::fail("Invalid allocation callback");
3175 context.getTestContext().getLog()
3176 << TestLog::Message << "Object construction succeeded! " << TestLog::EndMessage;
3181 // if allocation didn't succeed with huge limit then stop trying
3182 if (numPassingAllocs >= finalLimit)
3184 // if we reached maxTries but didn't create object, try doing it with huge limit
3185 if (numPassingAllocs >= maxTries)
3186 numPassingAllocs = finalLimit;
3190 if (!validateAndLog(context.getTestContext().getLog(), resCallbacks, 0u))
3191 return tcu::TestStatus::fail("Invalid allocation callback");
3193 if (numPassingAllocs == 0)
3194 return tcu::TestStatus(QP_TEST_RESULT_QUALITY_WARNING, "Allocation callbacks not called");
3195 else if (numPassingAllocs >= finalLimit)
3199 context.getTestContext().getLog()
3200 << TestLog::Message << "Maximum iteration count (" << maxTries << ") reached without object construction passing. "
3201 << "Object was succesfully constructed with " << numPassingAllocs << " iterations limit." << TestLog::EndMessage;
3202 return tcu::TestStatus(QP_TEST_RESULT_PASS, "Construction passed but not all iterations were checked");
3205 context.getTestContext().getLog()
3206 << TestLog::Message << "WARNING: Maximum iteration count (" << finalLimit << ") reached without object construction passing. "
3207 << "OOM testing incomplete, use --deqp-test-iteration-count= to test with higher limit." << TestLog::EndMessage;
3208 return tcu::TestStatus(QP_TEST_RESULT_PASS, "Max iter count reached");
3211 return tcu::TestStatus::pass("Ok");
3214 #endif // CTS_USES_VULKANSC
3216 // Determine whether an API call sets the invalid handles to NULL (true) or leaves them undefined or not modified (false)
3217 template<typename T> inline bool isNullHandleOnAllocationFailure (Context&) { return false; }
3219 #ifndef CTS_USES_VULKANSC
3220 template<> inline bool isNullHandleOnAllocationFailure<VkCommandBuffer> (Context& context) { return hasDeviceExtension(context, "VK_KHR_maintenance1"); }
3221 template<> inline bool isNullHandleOnAllocationFailure<VkDescriptorSet> (Context& context) { return hasDeviceExtension(context, "VK_KHR_maintenance1"); }
3222 template<> inline bool isNullHandleOnAllocationFailure<VkPipeline> (Context&) { return true; }
3223 #endif // CTS_USES_VULKANSC
3225 template<typename T> inline bool isPooledObject (void) { return false; };
3226 #ifndef CTS_USES_VULKANSC
3227 template<> inline bool isPooledObject<VkCommandBuffer> (void) { return true; };
3228 template<> inline bool isPooledObject<VkDescriptorSet> (void) { return true; };
3229 #endif // CTS_USES_VULKANSC
3231 template<typename Object>
3232 tcu::TestStatus allocCallbackFailMultipleObjectsTest (Context& context, typename Object::Parameters params)
3234 typedef SharedPtr<Move<typename Object::Type> > ObjectTypeSp;
3236 static const deUint32 numObjects = 4;
3237 const bool expectNullHandles = isNullHandleOnAllocationFailure<typename Object::Type>(context);
3238 deUint32 numPassingAllocs = 0;
3241 vector<typename Object::Type> handles (numObjects);
3242 VkResult result = VK_NOT_READY;
3244 for (; numPassingAllocs <= numObjects; ++numPassingAllocs)
3246 ValidateQueryBits::fillBits(handles.begin(), handles.end()); // fill with garbage
3248 // \note We have to use the same allocator for both resource dependencies and the object under test,
3249 // because pooled objects take memory from the pool.
3250 DeterministicFailAllocator objAllocator(getSystemAllocator(), DeterministicFailAllocator::MODE_DO_NOT_COUNT, 0);
3251 AllocationCallbackRecorder recorder (objAllocator.getCallbacks(), 128);
3252 const Environment objEnv (context.getPlatformInterface(),
3253 context.getUsedApiVersion(),
3254 context.getInstanceInterface(),
3255 context.getInstance(),
3256 context.getDeviceInterface(),
3257 context.getDevice(),
3258 context.getUniversalQueueFamilyIndex(),
3259 context.getBinaryCollection(),
3260 recorder.getCallbacks(),
3262 #ifdef CTS_USES_VULKANSC
3263 context.getResourceInterface(),
3264 context.getDeviceVulkanSC10Properties(),
3265 #endif // CTS_USES_VULKANSC
3266 context.getTestContext().getCommandLine());
3268 context.getTestContext().getLog()
3270 << "Trying to create " << numObjects << " objects with " << numPassingAllocs << " allocation" << (numPassingAllocs != 1 ? "s" : "") << " passing"
3271 << TestLog::EndMessage;
3274 const typename Object::Resources res (objEnv, params);
3276 objAllocator.reset(DeterministicFailAllocator::MODE_COUNT_AND_FAIL, numPassingAllocs);
3277 const vector<ObjectTypeSp> scopedHandles = Object::createMultiple(objEnv, res, params, &handles, &result);
3280 if (result == VK_SUCCESS)
3282 context.getTestContext().getLog() << TestLog::Message << "Construction of all objects succeeded! " << TestLog::EndMessage;
3287 if (expectNullHandles)
3289 for (deUint32 nullNdx = numPassingAllocs; nullNdx < numObjects; ++nullNdx)
3291 if (handles[nullNdx] != DE_NULL)
3292 return tcu::TestStatus::fail("Some object handles weren't set to NULL");
3296 if (result != VK_ERROR_OUT_OF_HOST_MEMORY)
3297 return tcu::TestStatus::fail("Got invalid error code: " + de::toString(getResultName(result)));
3299 if (!validateAndLog(context.getTestContext().getLog(), recorder, 0u))
3300 return tcu::TestStatus::fail("Invalid allocation callback");
3305 if (numPassingAllocs == 0)
3307 if (isPooledObject<typename Object::Type>())
3308 return tcu::TestStatus::pass("Not validated: pooled objects didn't seem to use host memory");
3310 return tcu::TestStatus(QP_TEST_RESULT_QUALITY_WARNING, "Allocation callbacks not called");
3313 return tcu::TestStatus::pass("Ok");
3316 // Utilities for creating groups
3318 template<typename Object>
3319 struct NamedParameters
3322 typename Object::Parameters parameters;
3325 template<typename Object>
3326 struct CaseDescription
3328 typename FunctionInstance1<typename Object::Parameters>::Function function;
3329 const NamedParameters<Object>* paramsBegin;
3330 const NamedParameters<Object>* paramsEnd;
3331 typename FunctionSupport1<typename Object::Parameters>::Function supportFunction;
3334 #define EMPTY_CASE_DESC(OBJECT) \
3335 { (FunctionInstance1<OBJECT::Parameters>::Function)DE_NULL, DE_NULL, DE_NULL, DE_NULL }
3337 #define CASE_DESC(FUNCTION, CASES, SUPPORT) \
3338 { FUNCTION, DE_ARRAY_BEGIN(CASES), DE_ARRAY_END(CASES), SUPPORT }
3340 struct CaseDescriptions
3342 CaseDescription<Instance> instance;
3343 CaseDescription<Device> device;
3344 CaseDescription<DeviceGroup> deviceGroup;
3345 CaseDescription<DeviceMemory> deviceMemory;
3346 CaseDescription<Buffer> buffer;
3347 CaseDescription<BufferView> bufferView;
3348 CaseDescription<Image> image;
3349 CaseDescription<ImageView> imageView;
3350 CaseDescription<Semaphore> semaphore;
3351 CaseDescription<Event> event;
3352 CaseDescription<Fence> fence;
3353 CaseDescription<QueryPool> queryPool;
3354 CaseDescription<ShaderModule> shaderModule;
3355 CaseDescription<PipelineCache> pipelineCache;
3356 CaseDescription<PipelineLayout> pipelineLayout;
3357 CaseDescription<RenderPass> renderPass;
3358 CaseDescription<GraphicsPipeline> graphicsPipeline;
3359 CaseDescription<ComputePipeline> computePipeline;
3360 CaseDescription<DescriptorSetLayout> descriptorSetLayout;
3361 CaseDescription<Sampler> sampler;
3362 CaseDescription<DescriptorPool> descriptorPool;
3363 CaseDescription<DescriptorSet> descriptorSet;
3364 CaseDescription<Framebuffer> framebuffer;
3365 CaseDescription<CommandPool> commandPool;
3366 CaseDescription<CommandBuffer> commandBuffer;
3369 template<typename Object>
3370 void addCases (tcu::TestCaseGroup *group, const CaseDescription<Object>& cases)
3372 for (const NamedParameters<Object>* cur = cases.paramsBegin; cur != cases.paramsEnd; ++cur)
3374 if(cases.supportFunction == DE_NULL)
3375 addFunctionCase(group, cur->name, "", cases.function, cur->parameters);
3377 addFunctionCase(group, cur->name, "", cases.supportFunction, cases.function, cur->parameters);
3381 void checkImageCubeArraySupport (Context& context, const ImageView::Parameters params) {
3382 if (params.viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && !context.getDeviceFeatures().imageCubeArray)
3383 TCU_THROW(NotSupportedError, "imageCubeArray feature is not supported by this implementation");
3386 void checkEventSupport (Context& context, const Event::Parameters)
3388 #ifndef CTS_USES_VULKANSC
3389 if (context.isDeviceFunctionalitySupported("VK_KHR_portability_subset") && !context.getPortabilitySubsetFeatures().events)
3390 TCU_THROW(NotSupportedError, "VK_KHR_portability_subset: Events are not supported by this implementation");
3393 #endif // CTS_USES_VULKANSC
3396 void checkRecycleDescriptorSetMemorySupport (Context& context, const DescriptorSet::Parameters)
3398 #ifdef CTS_USES_VULKANSC
3399 if (!context.getDeviceVulkanSC10Properties().recycleDescriptorSetMemory)
3400 TCU_THROW(NotSupportedError, "VkPhysicalDeviceVulkanSC10Properties::recycleDescriptorSetMemory not supported by this implementation");
3403 #endif // CTS_USES_VULKANSC
3406 template<typename Object>
3407 void addCasesWithProgs (tcu::TestCaseGroup *group, const CaseDescription<Object>& cases)
3409 for (const NamedParameters<Object>* cur = cases.paramsBegin; cur != cases.paramsEnd; ++cur)
3411 if (cases.supportFunction == DE_NULL)
3412 addFunctionCaseWithPrograms(group, cur->name, "", Object::initPrograms, cases.function, cur->parameters);
3414 addFunctionCaseWithPrograms(group, cur->name, "", cases.supportFunction, Object::initPrograms, cases.function, cur->parameters);
3418 static void createTests (tcu::TestCaseGroup* group, CaseDescriptions cases)
3420 addCases (group, cases.instance);
3421 addCases (group, cases.device);
3422 addCases (group, cases.deviceGroup);
3423 addCases (group, cases.deviceMemory);
3424 addCases (group, cases.buffer);
3425 addCases (group, cases.bufferView);
3426 addCases (group, cases.image);
3427 addCases (group, cases.imageView);
3428 addCases (group, cases.semaphore);
3429 addCases (group, cases.event);
3430 addCases (group, cases.fence);
3431 addCases (group, cases.queryPool);
3432 addCases (group, cases.sampler);
3433 addCasesWithProgs (group, cases.shaderModule);
3434 #ifndef CTS_USES_VULKANSC
3435 addCases (group, cases.pipelineCache);
3437 addCasesWithProgs (group, cases.pipelineCache);
3438 #endif // CTS_USES_VULKANSC
3439 addCases (group, cases.pipelineLayout);
3440 addCases (group, cases.renderPass);
3441 addCasesWithProgs (group, cases.graphicsPipeline);
3442 addCasesWithProgs (group, cases.computePipeline);
3443 addCases (group, cases.descriptorSetLayout);
3444 addCases (group, cases.descriptorPool);
3445 addCases (group, cases.descriptorSet);
3446 addCases (group, cases.framebuffer);
3447 addCases (group, cases.commandPool);
3448 addCases (group, cases.commandBuffer);
3451 #ifndef CTS_USES_VULKANSC
3452 static void cleanupGroup (tcu::TestCaseGroup* group, CaseDescriptions cases)
3456 // Destroy singleton object
3458 SingletonDevice::destroy();
3460 #endif // CTS_USES_VULKANSC
3462 tcu::TestCaseGroup* createGroup (tcu::TestContext& testCtx, const char* name, const char* desc, const CaseDescriptions& cases)
3464 MovePtr<tcu::TestCaseGroup> group (new tcu::TestCaseGroup(testCtx, name, desc));
3465 createTests(group.get(), cases);
3466 return group.release();
3471 tcu::TestCaseGroup* createObjectManagementTests (tcu::TestContext& testCtx)
3473 MovePtr<tcu::TestCaseGroup> objectMgmtTests (new tcu::TestCaseGroup(testCtx, "object_management", "Object management tests"));
3475 const Image::Parameters img1D (0u, VK_IMAGE_TYPE_1D, VK_FORMAT_R8G8B8A8_UNORM, makeExtent3D(256, 1, 1), 1u, 4u, VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_LAYOUT_UNDEFINED);
3476 const Image::Parameters img2D (0u, VK_IMAGE_TYPE_2D, VK_FORMAT_R8G8B8A8_UNORM, makeExtent3D( 64, 64, 1), 1u, 12u, VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_LAYOUT_UNDEFINED);
3477 const Image::Parameters imgCube (VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, VK_IMAGE_TYPE_2D, VK_FORMAT_R8G8B8A8_UNORM, makeExtent3D( 64, 64, 1), 1u, 12u, VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_LAYOUT_UNDEFINED);
3478 const Image::Parameters img3D (0u, VK_IMAGE_TYPE_3D, VK_FORMAT_R8G8B8A8_UNORM, makeExtent3D( 64, 64, 4), 1u, 1u, VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_LAYOUT_UNDEFINED);
3479 const ImageView::Parameters imgView1D (img1D, VK_IMAGE_VIEW_TYPE_1D, img1D.format, makeComponentMappingRGBA(), makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u));
3480 const ImageView::Parameters imgView1DArr (img1D, VK_IMAGE_VIEW_TYPE_1D_ARRAY, img1D.format, makeComponentMappingRGBA(), makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 4u));
3481 const ImageView::Parameters imgView2D (img2D, VK_IMAGE_VIEW_TYPE_2D, img2D.format, makeComponentMappingRGBA(), makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u));
3482 const ImageView::Parameters imgView2DArr (img2D, VK_IMAGE_VIEW_TYPE_2D_ARRAY, img2D.format, makeComponentMappingRGBA(), makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 8u));
3483 const ImageView::Parameters imgViewCube (imgCube, VK_IMAGE_VIEW_TYPE_CUBE, img2D.format, makeComponentMappingRGBA(), makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 6u));
3484 const ImageView::Parameters imgViewCubeArr (imgCube, VK_IMAGE_VIEW_TYPE_CUBE_ARRAY, img2D.format, makeComponentMappingRGBA(), makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 12u));
3485 const ImageView::Parameters imgView3D (img3D, VK_IMAGE_VIEW_TYPE_3D, img3D.format, makeComponentMappingRGBA(), makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u));
3487 const DescriptorSetLayout::Parameters singleUboDescLayout = DescriptorSetLayout::Parameters::single(0u, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1u, VK_SHADER_STAGE_VERTEX_BIT);
3489 static const NamedParameters<Instance> s_instanceCases[] =
3491 { "instance", Instance::Parameters() },
3493 // \note Device index may change - must not be static
3495 const NamedParameters<Device> s_deviceCases[] =
3497 { "device", Device::Parameters(testCtx.getCommandLine().getVKDeviceId()-1u, VK_QUEUE_GRAPHICS_BIT) },
3499 const NamedParameters<DeviceGroup> s_deviceGroupCases[] =
3501 { "device_group", DeviceGroup::Parameters(testCtx.getCommandLine().getVKDeviceGroupId() - 1u, testCtx.getCommandLine().getVKDeviceId() - 1u, VK_QUEUE_GRAPHICS_BIT) },
3503 static const NamedParameters<DeviceMemory> s_deviceMemCases[] =
3505 { "device_memory_small", DeviceMemory::Parameters(1024, 0u) },
3507 static const NamedParameters<Buffer> s_bufferCases[] =
3509 { "buffer_uniform_small", Buffer::Parameters(1024u, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT), },
3510 { "buffer_uniform_large", Buffer::Parameters(1024u*1024u*16u, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT), },
3511 { "buffer_storage_small", Buffer::Parameters(1024u, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT), },
3512 { "buffer_storage_large", Buffer::Parameters(1024u*1024u*16u, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT), },
3514 static const NamedParameters<BufferView> s_bufferViewCases[] =
3516 { "buffer_view_uniform_r8g8b8a8_unorm", BufferView::Parameters(Buffer::Parameters(8192u, VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT), VK_FORMAT_R8G8B8A8_UNORM, 0u, 4096u) },
3517 { "buffer_view_storage_r8g8b8a8_unorm", BufferView::Parameters(Buffer::Parameters(8192u, VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT), VK_FORMAT_R8G8B8A8_UNORM, 0u, 4096u) },
3519 static const NamedParameters<Image> s_imageCases[] =
3521 { "image_1d", img1D },
3522 { "image_2d", img2D },
3523 { "image_3d", img3D },
3525 static const NamedParameters<ImageView> s_imageViewCases[] =
3527 { "image_view_1d", imgView1D },
3528 { "image_view_1d_arr", imgView1DArr },
3529 { "image_view_2d", imgView2D },
3530 { "image_view_2d_arr", imgView2DArr },
3531 { "image_view_cube", imgViewCube },
3532 { "image_view_cube_arr", imgViewCubeArr },
3533 { "image_view_3d", imgView3D },
3535 static const NamedParameters<Semaphore> s_semaphoreCases[] =
3537 { "semaphore", Semaphore::Parameters(0u), }
3539 static const NamedParameters<Event> s_eventCases[] =
3541 { "event", Event::Parameters(0u) }
3543 static const NamedParameters<Fence> s_fenceCases[] =
3545 { "fence", Fence::Parameters(0u) },
3546 { "fence_signaled", Fence::Parameters(VK_FENCE_CREATE_SIGNALED_BIT) }
3548 static const NamedParameters<QueryPool> s_queryPoolCases[] =
3550 { "query_pool", QueryPool::Parameters(VK_QUERY_TYPE_OCCLUSION, 1u, 0u) }
3552 static const NamedParameters<ShaderModule> s_shaderModuleCases[] =
3554 { "shader_module", ShaderModule::Parameters(VK_SHADER_STAGE_COMPUTE_BIT, "test") }
3556 static const NamedParameters<PipelineCache> s_pipelineCacheCases[] =
3558 { "pipeline_cache", PipelineCache::Parameters() }
3560 static const NamedParameters<PipelineLayout> s_pipelineLayoutCases[] =
3562 { "pipeline_layout_empty", PipelineLayout::Parameters::empty() },
3563 { "pipeline_layout_single", PipelineLayout::Parameters::singleDescriptorSet(singleUboDescLayout) }
3565 static const NamedParameters<RenderPass> s_renderPassCases[] =
3567 { "render_pass", RenderPass::Parameters() }
3569 static const NamedParameters<GraphicsPipeline> s_graphicsPipelineCases[] =
3571 { "graphics_pipeline", GraphicsPipeline::Parameters() }
3573 static const NamedParameters<ComputePipeline> s_computePipelineCases[] =
3575 { "compute_pipeline", ComputePipeline::Parameters() }
3577 static const NamedParameters<DescriptorSetLayout> s_descriptorSetLayoutCases[] =
3579 { "descriptor_set_layout_empty", DescriptorSetLayout::Parameters::empty() },
3580 { "descriptor_set_layout_single", singleUboDescLayout }
3582 static const NamedParameters<Sampler> s_samplerCases[] =
3584 { "sampler", Sampler::Parameters() }
3586 static const NamedParameters<DescriptorPool> s_descriptorPoolCases[] =
3588 { "descriptor_pool", DescriptorPool::Parameters::singleType((VkDescriptorPoolCreateFlags)0, 4u, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 3u) },
3589 { "descriptor_pool_free_descriptor_set", DescriptorPool::Parameters::singleType(VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 4u, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 3u) }
3591 static const NamedParameters<DescriptorSet> s_descriptorSetCases[] =
3593 { "descriptor_set", DescriptorSet::Parameters(singleUboDescLayout) }
3595 static const NamedParameters<Framebuffer> s_framebufferCases[] =
3597 { "framebuffer", Framebuffer::Parameters() }
3599 static const NamedParameters<CommandPool> s_commandPoolCases[] =
3601 { "command_pool", CommandPool::Parameters((VkCommandPoolCreateFlags)0) },
3602 { "command_pool_transient", CommandPool::Parameters(VK_COMMAND_POOL_CREATE_TRANSIENT_BIT) }
3604 static const NamedParameters<CommandBuffer> s_commandBufferCases[] =
3606 { "command_buffer_primary", CommandBuffer::Parameters(CommandPool::Parameters((VkCommandPoolCreateFlags)0u), VK_COMMAND_BUFFER_LEVEL_PRIMARY) },
3607 { "command_buffer_secondary", CommandBuffer::Parameters(CommandPool::Parameters((VkCommandPoolCreateFlags)0u), VK_COMMAND_BUFFER_LEVEL_SECONDARY) }
3610 const CaseDescriptions s_createSingleGroup =
3612 CASE_DESC(createSingleTest <Instance>, s_instanceCases, DE_NULL),
3613 CASE_DESC(createSingleTest <Device>, s_deviceCases, DE_NULL),
3614 CASE_DESC(createSingleTest <DeviceGroup>, s_deviceGroupCases, DE_NULL),
3615 CASE_DESC(createSingleTest <DeviceMemory>, s_deviceMemCases, DE_NULL),
3616 CASE_DESC(createSingleTest <Buffer>, s_bufferCases, DE_NULL),
3617 CASE_DESC(createSingleTest <BufferView>, s_bufferViewCases, DE_NULL),
3618 CASE_DESC(createSingleTest <Image>, s_imageCases, DE_NULL),
3619 CASE_DESC(createSingleTest <ImageView>, s_imageViewCases, checkImageCubeArraySupport),
3620 CASE_DESC(createSingleTest <Semaphore>, s_semaphoreCases, DE_NULL),
3621 CASE_DESC(createSingleTest <Event>, s_eventCases, checkEventSupport),
3622 CASE_DESC(createSingleTest <Fence>, s_fenceCases, DE_NULL),
3623 CASE_DESC(createSingleTest <QueryPool>, s_queryPoolCases, DE_NULL),
3624 CASE_DESC(createSingleTest <ShaderModule>, s_shaderModuleCases, DE_NULL),
3625 CASE_DESC(createSingleTest <PipelineCache>, s_pipelineCacheCases, DE_NULL),
3626 CASE_DESC(createSingleTest <PipelineLayout>, s_pipelineLayoutCases, DE_NULL),
3627 CASE_DESC(createSingleTest <RenderPass>, s_renderPassCases, DE_NULL),
3628 CASE_DESC(createSingleTest <GraphicsPipeline>, s_graphicsPipelineCases, DE_NULL),
3629 CASE_DESC(createSingleTest <ComputePipeline>, s_computePipelineCases, DE_NULL),
3630 CASE_DESC(createSingleTest <DescriptorSetLayout>, s_descriptorSetLayoutCases, DE_NULL),
3631 CASE_DESC(createSingleTest <Sampler>, s_samplerCases, DE_NULL),
3632 CASE_DESC(createSingleTest <DescriptorPool>, s_descriptorPoolCases, DE_NULL),
3633 CASE_DESC(createSingleTest <DescriptorSet>, s_descriptorSetCases, DE_NULL),
3634 CASE_DESC(createSingleTest <Framebuffer>, s_framebufferCases, DE_NULL),
3635 CASE_DESC(createSingleTest <CommandPool>, s_commandPoolCases, DE_NULL),
3636 CASE_DESC(createSingleTest <CommandBuffer>, s_commandBufferCases, DE_NULL),
3638 objectMgmtTests->addChild(createGroup(testCtx, "single", "Create single object", s_createSingleGroup));
3640 const CaseDescriptions s_createMultipleUniqueResourcesGroup =
3642 CASE_DESC(createMultipleUniqueResourcesTest <Instance>, s_instanceCases, DE_NULL),
3643 #ifndef CTS_USES_VULKANSC
3644 CASE_DESC(createMultipleUniqueResourcesTest <Device>, s_deviceCases, DE_NULL),
3645 CASE_DESC(createMultipleUniqueResourcesTest <DeviceGroup>, s_deviceGroupCases, DE_NULL),
3647 EMPTY_CASE_DESC(Device),
3648 EMPTY_CASE_DESC(DeviceGroup),
3650 CASE_DESC(createMultipleUniqueResourcesTest <DeviceMemory>, s_deviceMemCases, DE_NULL),
3651 CASE_DESC(createMultipleUniqueResourcesTest <Buffer>, s_bufferCases, DE_NULL),
3652 CASE_DESC(createMultipleUniqueResourcesTest <BufferView>, s_bufferViewCases, DE_NULL),
3653 CASE_DESC(createMultipleUniqueResourcesTest <Image>, s_imageCases, DE_NULL),
3654 CASE_DESC(createMultipleUniqueResourcesTest <ImageView>, s_imageViewCases, checkImageCubeArraySupport),
3655 CASE_DESC(createMultipleUniqueResourcesTest <Semaphore>, s_semaphoreCases, DE_NULL),
3656 CASE_DESC(createMultipleUniqueResourcesTest <Event>, s_eventCases, checkEventSupport),
3657 CASE_DESC(createMultipleUniqueResourcesTest <Fence>, s_fenceCases, DE_NULL),
3658 CASE_DESC(createMultipleUniqueResourcesTest <QueryPool>, s_queryPoolCases, DE_NULL),
3659 CASE_DESC(createMultipleUniqueResourcesTest <ShaderModule>, s_shaderModuleCases, DE_NULL),
3660 CASE_DESC(createMultipleUniqueResourcesTest <PipelineCache>, s_pipelineCacheCases, DE_NULL),
3661 CASE_DESC(createMultipleUniqueResourcesTest <PipelineLayout>, s_pipelineLayoutCases, DE_NULL),
3662 CASE_DESC(createMultipleUniqueResourcesTest <RenderPass>, s_renderPassCases, DE_NULL),
3663 CASE_DESC(createMultipleUniqueResourcesTest <GraphicsPipeline>, s_graphicsPipelineCases, DE_NULL),
3664 CASE_DESC(createMultipleUniqueResourcesTest <ComputePipeline>, s_computePipelineCases, DE_NULL),
3665 CASE_DESC(createMultipleUniqueResourcesTest <DescriptorSetLayout>, s_descriptorSetLayoutCases, DE_NULL),
3666 CASE_DESC(createMultipleUniqueResourcesTest <Sampler>, s_samplerCases, DE_NULL),
3667 CASE_DESC(createMultipleUniqueResourcesTest <DescriptorPool>, s_descriptorPoolCases, DE_NULL),
3668 CASE_DESC(createMultipleUniqueResourcesTest <DescriptorSet>, s_descriptorSetCases, DE_NULL),
3669 CASE_DESC(createMultipleUniqueResourcesTest <Framebuffer>, s_framebufferCases, DE_NULL),
3670 CASE_DESC(createMultipleUniqueResourcesTest <CommandPool>, s_commandPoolCases, DE_NULL),
3671 CASE_DESC(createMultipleUniqueResourcesTest <CommandBuffer>, s_commandBufferCases, DE_NULL),
3673 objectMgmtTests->addChild(createGroup(testCtx, "multiple_unique_resources", "Multiple objects with per-object unique resources", s_createMultipleUniqueResourcesGroup));
3675 const CaseDescriptions s_createMultipleSharedResourcesGroup =
3677 EMPTY_CASE_DESC(Instance), // No resources used
3678 #ifndef CTS_USES_VULKANSC
3679 CASE_DESC(createMultipleSharedResourcesTest <Device>, s_deviceCases, DE_NULL),
3680 CASE_DESC(createMultipleSharedResourcesTest <DeviceGroup>, s_deviceGroupCases, DE_NULL),
3682 EMPTY_CASE_DESC(Device),
3683 EMPTY_CASE_DESC(DeviceGroup),
3685 CASE_DESC(createMultipleSharedResourcesTest <DeviceMemory>, s_deviceMemCases, DE_NULL),
3686 CASE_DESC(createMultipleSharedResourcesTest <Buffer>, s_bufferCases, DE_NULL),
3687 CASE_DESC(createMultipleSharedResourcesTest <BufferView>, s_bufferViewCases, DE_NULL),
3688 CASE_DESC(createMultipleSharedResourcesTest <Image>, s_imageCases, DE_NULL),
3689 CASE_DESC(createMultipleSharedResourcesTest <ImageView>, s_imageViewCases, checkImageCubeArraySupport),
3690 CASE_DESC(createMultipleSharedResourcesTest <Semaphore>, s_semaphoreCases, DE_NULL),
3691 CASE_DESC(createMultipleSharedResourcesTest <Event>, s_eventCases, checkEventSupport),
3692 CASE_DESC(createMultipleSharedResourcesTest <Fence>, s_fenceCases, DE_NULL),
3693 CASE_DESC(createMultipleSharedResourcesTest <QueryPool>, s_queryPoolCases, DE_NULL),
3694 CASE_DESC(createMultipleSharedResourcesTest <ShaderModule>, s_shaderModuleCases, DE_NULL),
3695 CASE_DESC(createMultipleSharedResourcesTest <PipelineCache>, s_pipelineCacheCases, DE_NULL),
3696 CASE_DESC(createMultipleSharedResourcesTest <PipelineLayout>, s_pipelineLayoutCases, DE_NULL),
3697 CASE_DESC(createMultipleSharedResourcesTest <RenderPass>, s_renderPassCases, DE_NULL),
3698 CASE_DESC(createMultipleSharedResourcesTest <GraphicsPipeline>, s_graphicsPipelineCases, DE_NULL),
3699 CASE_DESC(createMultipleSharedResourcesTest <ComputePipeline>, s_computePipelineCases, DE_NULL),
3700 CASE_DESC(createMultipleSharedResourcesTest <DescriptorSetLayout>, s_descriptorSetLayoutCases, DE_NULL),
3701 CASE_DESC(createMultipleSharedResourcesTest <Sampler>, s_samplerCases, DE_NULL),
3702 CASE_DESC(createMultipleSharedResourcesTest <DescriptorPool>, s_descriptorPoolCases, DE_NULL),
3703 CASE_DESC(createMultipleSharedResourcesTest <DescriptorSet>, s_descriptorSetCases, DE_NULL),
3704 CASE_DESC(createMultipleSharedResourcesTest <Framebuffer>, s_framebufferCases, DE_NULL),
3705 CASE_DESC(createMultipleSharedResourcesTest <CommandPool>, s_commandPoolCases, DE_NULL),
3706 CASE_DESC(createMultipleSharedResourcesTest <CommandBuffer>, s_commandBufferCases, DE_NULL),
3708 objectMgmtTests->addChild(createGroup(testCtx, "multiple_shared_resources", "Multiple objects with shared resources", s_createMultipleSharedResourcesGroup));
3710 #ifndef CTS_USES_VULKANSC
3711 // Removed from Vulkan SC test set: VkAllocationCallbacks is not supported and pointers to this type must be NULL
3712 const CaseDescriptions s_createMaxConcurrentGroup =
3714 CASE_DESC(createMaxConcurrentTest <Instance>, s_instanceCases, DE_NULL),
3715 CASE_DESC(createMaxConcurrentTest <Device>, s_deviceCases, DE_NULL),
3716 CASE_DESC(createMaxConcurrentTest <DeviceGroup>, s_deviceGroupCases, DE_NULL),
3717 CASE_DESC(createMaxConcurrentTest <DeviceMemory>, s_deviceMemCases, DE_NULL),
3718 CASE_DESC(createMaxConcurrentTest <Buffer>, s_bufferCases, DE_NULL),
3719 CASE_DESC(createMaxConcurrentTest <BufferView>, s_bufferViewCases, DE_NULL),
3720 CASE_DESC(createMaxConcurrentTest <Image>, s_imageCases, DE_NULL),
3721 CASE_DESC(createMaxConcurrentTest <ImageView>, s_imageViewCases, checkImageCubeArraySupport),
3722 CASE_DESC(createMaxConcurrentTest <Semaphore>, s_semaphoreCases, DE_NULL),
3723 CASE_DESC(createMaxConcurrentTest <Event>, s_eventCases, checkEventSupport),
3724 CASE_DESC(createMaxConcurrentTest <Fence>, s_fenceCases, DE_NULL),
3725 CASE_DESC(createMaxConcurrentTest <QueryPool>, s_queryPoolCases, DE_NULL),
3726 CASE_DESC(createMaxConcurrentTest <ShaderModule>, s_shaderModuleCases, DE_NULL),
3727 CASE_DESC(createMaxConcurrentTest <PipelineCache>, s_pipelineCacheCases, DE_NULL),
3728 CASE_DESC(createMaxConcurrentTest <PipelineLayout>, s_pipelineLayoutCases, DE_NULL),
3729 CASE_DESC(createMaxConcurrentTest <RenderPass>, s_renderPassCases, DE_NULL),
3730 CASE_DESC(createMaxConcurrentTest <GraphicsPipeline>, s_graphicsPipelineCases, DE_NULL),
3731 CASE_DESC(createMaxConcurrentTest <ComputePipeline>, s_computePipelineCases, DE_NULL),
3732 CASE_DESC(createMaxConcurrentTest <DescriptorSetLayout>, s_descriptorSetLayoutCases, DE_NULL),
3733 CASE_DESC(createMaxConcurrentTest <Sampler>, s_samplerCases, DE_NULL),
3734 CASE_DESC(createMaxConcurrentTest <DescriptorPool>, s_descriptorPoolCases, DE_NULL),
3735 CASE_DESC(createMaxConcurrentTest <DescriptorSet>, s_descriptorSetCases, DE_NULL),
3736 CASE_DESC(createMaxConcurrentTest <Framebuffer>, s_framebufferCases, DE_NULL),
3737 CASE_DESC(createMaxConcurrentTest <CommandPool>, s_commandPoolCases, DE_NULL),
3738 CASE_DESC(createMaxConcurrentTest <CommandBuffer>, s_commandBufferCases, DE_NULL),
3740 objectMgmtTests->addChild(createGroup(testCtx, "max_concurrent", "Maximum number of concurrently live objects", s_createMaxConcurrentGroup));
3741 #endif // CTS_USES_VULKANSC
3743 const CaseDescriptions s_multithreadedCreatePerThreadDeviceGroup =
3745 EMPTY_CASE_DESC(Instance), // Does not make sense
3746 EMPTY_CASE_DESC(Device), // Does not make sense
3747 EMPTY_CASE_DESC(DeviceGroup), // Does not make sense
3748 CASE_DESC(multithreadedCreatePerThreadDeviceTest <DeviceMemory>, s_deviceMemCases, DE_NULL),
3749 CASE_DESC(multithreadedCreatePerThreadDeviceTest <Buffer>, s_bufferCases, DE_NULL),
3750 CASE_DESC(multithreadedCreatePerThreadDeviceTest <BufferView>, s_bufferViewCases, DE_NULL),
3751 CASE_DESC(multithreadedCreatePerThreadDeviceTest <Image>, s_imageCases, DE_NULL),
3752 CASE_DESC(multithreadedCreatePerThreadDeviceTest <ImageView>, s_imageViewCases, checkImageCubeArraySupport),
3753 CASE_DESC(multithreadedCreatePerThreadDeviceTest <Semaphore>, s_semaphoreCases, DE_NULL),
3754 CASE_DESC(multithreadedCreatePerThreadDeviceTest <Event>, s_eventCases, checkEventSupport),
3755 CASE_DESC(multithreadedCreatePerThreadDeviceTest <Fence>, s_fenceCases, DE_NULL),
3756 CASE_DESC(multithreadedCreatePerThreadDeviceTest <QueryPool>, s_queryPoolCases, DE_NULL),
3757 CASE_DESC(multithreadedCreatePerThreadDeviceTest <ShaderModule>, s_shaderModuleCases, DE_NULL),
3758 CASE_DESC(multithreadedCreatePerThreadDeviceTest <PipelineCache>, s_pipelineCacheCases, DE_NULL),
3759 CASE_DESC(multithreadedCreatePerThreadDeviceTest <PipelineLayout>, s_pipelineLayoutCases, DE_NULL),
3760 CASE_DESC(multithreadedCreatePerThreadDeviceTest <RenderPass>, s_renderPassCases, DE_NULL),
3761 CASE_DESC(multithreadedCreatePerThreadDeviceTest <GraphicsPipeline>, s_graphicsPipelineCases, DE_NULL),
3762 CASE_DESC(multithreadedCreatePerThreadDeviceTest <ComputePipeline>, s_computePipelineCases, DE_NULL),
3763 CASE_DESC(multithreadedCreatePerThreadDeviceTest <DescriptorSetLayout>, s_descriptorSetLayoutCases, DE_NULL),
3764 CASE_DESC(multithreadedCreatePerThreadDeviceTest <Sampler>, s_samplerCases, DE_NULL),
3765 CASE_DESC(multithreadedCreatePerThreadDeviceTest <DescriptorPool>, s_descriptorPoolCases, DE_NULL),
3766 CASE_DESC(multithreadedCreatePerThreadDeviceTest <DescriptorSet>, s_descriptorSetCases, checkRecycleDescriptorSetMemorySupport),
3767 CASE_DESC(multithreadedCreatePerThreadDeviceTest <Framebuffer>, s_framebufferCases, DE_NULL),
3768 CASE_DESC(multithreadedCreatePerThreadDeviceTest <CommandPool>, s_commandPoolCases, DE_NULL),
3769 CASE_DESC(multithreadedCreatePerThreadDeviceTest <CommandBuffer>, s_commandBufferCases, DE_NULL),
3771 objectMgmtTests->addChild(createGroup(testCtx, "multithreaded_per_thread_device", "Multithreaded object construction with per-thread device ", s_multithreadedCreatePerThreadDeviceGroup));
3773 const CaseDescriptions s_multithreadedCreatePerThreadResourcesGroup =
3775 CASE_DESC(multithreadedCreatePerThreadResourcesTest <Instance>, s_instanceCases, DE_NULL),
3776 CASE_DESC(multithreadedCreatePerThreadResourcesTest <Device>, s_deviceCases, DE_NULL),
3777 CASE_DESC(multithreadedCreatePerThreadResourcesTest <DeviceGroup>, s_deviceGroupCases, DE_NULL),
3778 CASE_DESC(multithreadedCreatePerThreadResourcesTest <DeviceMemory>, s_deviceMemCases, DE_NULL),
3779 CASE_DESC(multithreadedCreatePerThreadResourcesTest <Buffer>, s_bufferCases, DE_NULL),
3780 CASE_DESC(multithreadedCreatePerThreadResourcesTest <BufferView>, s_bufferViewCases, DE_NULL),
3781 CASE_DESC(multithreadedCreatePerThreadResourcesTest <Image>, s_imageCases, DE_NULL),
3782 CASE_DESC(multithreadedCreatePerThreadResourcesTest <ImageView>, s_imageViewCases, checkImageCubeArraySupport),
3783 CASE_DESC(multithreadedCreatePerThreadResourcesTest <Semaphore>, s_semaphoreCases, DE_NULL),
3784 CASE_DESC(multithreadedCreatePerThreadResourcesTest <Event>, s_eventCases, checkEventSupport),
3785 CASE_DESC(multithreadedCreatePerThreadResourcesTest <Fence>, s_fenceCases, DE_NULL),
3786 CASE_DESC(multithreadedCreatePerThreadResourcesTest <QueryPool>, s_queryPoolCases, DE_NULL),
3787 CASE_DESC(multithreadedCreatePerThreadResourcesTest <ShaderModule>, s_shaderModuleCases, DE_NULL),
3788 CASE_DESC(multithreadedCreatePerThreadResourcesTest <PipelineCache>, s_pipelineCacheCases, DE_NULL),
3789 CASE_DESC(multithreadedCreatePerThreadResourcesTest <PipelineLayout>, s_pipelineLayoutCases, DE_NULL),
3790 CASE_DESC(multithreadedCreatePerThreadResourcesTest <RenderPass>, s_renderPassCases, DE_NULL),
3791 CASE_DESC(multithreadedCreatePerThreadResourcesTest <GraphicsPipeline>, s_graphicsPipelineCases, DE_NULL),
3792 CASE_DESC(multithreadedCreatePerThreadResourcesTest <ComputePipeline>, s_computePipelineCases, DE_NULL),
3793 CASE_DESC(multithreadedCreatePerThreadResourcesTest <DescriptorSetLayout>, s_descriptorSetLayoutCases, DE_NULL),
3794 CASE_DESC(multithreadedCreatePerThreadResourcesTest <Sampler>, s_samplerCases, DE_NULL),
3795 CASE_DESC(multithreadedCreatePerThreadResourcesTest <DescriptorPool>, s_descriptorPoolCases, DE_NULL),
3796 CASE_DESC(multithreadedCreatePerThreadResourcesTest <DescriptorSet>, s_descriptorSetCases, checkRecycleDescriptorSetMemorySupport),
3797 CASE_DESC(multithreadedCreatePerThreadResourcesTest <Framebuffer>, s_framebufferCases, DE_NULL),
3798 CASE_DESC(multithreadedCreatePerThreadResourcesTest <CommandPool>, s_commandPoolCases, DE_NULL),
3799 CASE_DESC(multithreadedCreatePerThreadResourcesTest <CommandBuffer>, s_commandBufferCases, DE_NULL),
3801 objectMgmtTests->addChild(createGroup(testCtx, "multithreaded_per_thread_resources", "Multithreaded object construction with per-thread resources", s_multithreadedCreatePerThreadResourcesGroup));
3803 const CaseDescriptions s_multithreadedCreateSharedResourcesGroup =
3805 EMPTY_CASE_DESC(Instance),
3806 #ifndef CTS_USES_VULKANSC
3807 CASE_DESC(multithreadedCreateSharedResourcesTest <Device>, s_deviceCases, DE_NULL),
3808 CASE_DESC(multithreadedCreateSharedResourcesTest <DeviceGroup>, s_deviceGroupCases, DE_NULL),
3810 EMPTY_CASE_DESC(Device),
3811 EMPTY_CASE_DESC(DeviceGroup),
3813 CASE_DESC(multithreadedCreateSharedResourcesTest <DeviceMemory>, s_deviceMemCases, DE_NULL),
3814 CASE_DESC(multithreadedCreateSharedResourcesTest <Buffer>, s_bufferCases, DE_NULL),
3815 CASE_DESC(multithreadedCreateSharedResourcesTest <BufferView>, s_bufferViewCases, DE_NULL),
3816 CASE_DESC(multithreadedCreateSharedResourcesTest <Image>, s_imageCases, DE_NULL),
3817 CASE_DESC(multithreadedCreateSharedResourcesTest <ImageView>, s_imageViewCases, checkImageCubeArraySupport),
3818 CASE_DESC(multithreadedCreateSharedResourcesTest <Semaphore>, s_semaphoreCases, DE_NULL),
3819 CASE_DESC(multithreadedCreateSharedResourcesTest <Event>, s_eventCases, checkEventSupport),
3820 CASE_DESC(multithreadedCreateSharedResourcesTest <Fence>, s_fenceCases, DE_NULL),
3821 CASE_DESC(multithreadedCreateSharedResourcesTest <QueryPool>, s_queryPoolCases, DE_NULL),
3822 CASE_DESC(multithreadedCreateSharedResourcesTest <ShaderModule>, s_shaderModuleCases, DE_NULL),
3823 CASE_DESC(multithreadedCreateSharedResourcesTest <PipelineCache>, s_pipelineCacheCases, DE_NULL),
3824 CASE_DESC(multithreadedCreateSharedResourcesTest <PipelineLayout>, s_pipelineLayoutCases, DE_NULL),
3825 CASE_DESC(multithreadedCreateSharedResourcesTest <RenderPass>, s_renderPassCases, DE_NULL),
3826 CASE_DESC(multithreadedCreateSharedResourcesTest <GraphicsPipeline>, s_graphicsPipelineCases, DE_NULL),
3827 CASE_DESC(multithreadedCreateSharedResourcesTest <ComputePipeline>, s_computePipelineCases, DE_NULL),
3828 CASE_DESC(multithreadedCreateSharedResourcesTest <DescriptorSetLayout>, s_descriptorSetLayoutCases, DE_NULL),
3829 CASE_DESC(multithreadedCreateSharedResourcesTest <Sampler>, s_samplerCases, DE_NULL),
3830 CASE_DESC(multithreadedCreateSharedResourcesTest <DescriptorPool>, s_descriptorPoolCases, DE_NULL),
3831 EMPTY_CASE_DESC(DescriptorSet), // \note Needs per-thread DescriptorPool
3832 CASE_DESC(multithreadedCreateSharedResourcesTest <Framebuffer>, s_framebufferCases, DE_NULL),
3833 CASE_DESC(multithreadedCreateSharedResourcesTest <CommandPool>, s_commandPoolCases, DE_NULL),
3834 EMPTY_CASE_DESC(CommandBuffer), // \note Needs per-thread CommandPool
3836 objectMgmtTests->addChild(createGroup(testCtx, "multithreaded_shared_resources", "Multithreaded object construction with shared resources", s_multithreadedCreateSharedResourcesGroup));
3838 #ifndef CTS_USES_VULKANSC
3840 // Removed from Vulkan SC test set: VkAllocationCallbacks is not supported and pointers to this type must be NULL
3841 const CaseDescriptions s_createSingleAllocCallbacksGroup =
3843 CASE_DESC(createSingleAllocCallbacksTest <Instance>, s_instanceCases, DE_NULL),
3844 CASE_DESC(createSingleAllocCallbacksTest <Device>, s_deviceCases, DE_NULL),
3845 CASE_DESC(createSingleAllocCallbacksTest <DeviceGroup>, s_deviceGroupCases, DE_NULL),
3846 CASE_DESC(createSingleAllocCallbacksTest <DeviceMemory>, s_deviceMemCases, DE_NULL),
3847 CASE_DESC(createSingleAllocCallbacksTest <Buffer>, s_bufferCases, DE_NULL),
3848 CASE_DESC(createSingleAllocCallbacksTest <BufferView>, s_bufferViewCases, DE_NULL),
3849 CASE_DESC(createSingleAllocCallbacksTest <Image>, s_imageCases, DE_NULL),
3850 CASE_DESC(createSingleAllocCallbacksTest <ImageView>, s_imageViewCases, checkImageCubeArraySupport),
3851 CASE_DESC(createSingleAllocCallbacksTest <Semaphore>, s_semaphoreCases, DE_NULL),
3852 CASE_DESC(createSingleAllocCallbacksTest <Event>, s_eventCases, checkEventSupport),
3853 CASE_DESC(createSingleAllocCallbacksTest <Fence>, s_fenceCases, DE_NULL),
3854 CASE_DESC(createSingleAllocCallbacksTest <QueryPool>, s_queryPoolCases, DE_NULL),
3855 CASE_DESC(createSingleAllocCallbacksTest <ShaderModule>, s_shaderModuleCases, DE_NULL),
3856 CASE_DESC(createSingleAllocCallbacksTest <PipelineCache>, s_pipelineCacheCases, DE_NULL),
3857 CASE_DESC(createSingleAllocCallbacksTest <PipelineLayout>, s_pipelineLayoutCases, DE_NULL),
3858 CASE_DESC(createSingleAllocCallbacksTest <RenderPass>, s_renderPassCases, DE_NULL),
3859 CASE_DESC(createSingleAllocCallbacksTest <GraphicsPipeline>, s_graphicsPipelineCases, DE_NULL),
3860 CASE_DESC(createSingleAllocCallbacksTest <ComputePipeline>, s_computePipelineCases, DE_NULL),
3861 CASE_DESC(createSingleAllocCallbacksTest <DescriptorSetLayout>, s_descriptorSetLayoutCases, DE_NULL),
3862 CASE_DESC(createSingleAllocCallbacksTest <Sampler>, s_samplerCases, DE_NULL),
3863 CASE_DESC(createSingleAllocCallbacksTest <DescriptorPool>, s_descriptorPoolCases, DE_NULL),
3864 CASE_DESC(createSingleAllocCallbacksTest <DescriptorSet>, s_descriptorSetCases, DE_NULL),
3865 CASE_DESC(createSingleAllocCallbacksTest <Framebuffer>, s_framebufferCases, DE_NULL),
3866 CASE_DESC(createSingleAllocCallbacksTest <CommandPool>, s_commandPoolCases, DE_NULL),
3867 CASE_DESC(createSingleAllocCallbacksTest <CommandBuffer>, s_commandBufferCases, DE_NULL),
3869 objectMgmtTests->addChild(createGroup(testCtx, "single_alloc_callbacks", "Create single object", s_createSingleAllocCallbacksGroup));
3870 #endif // CTS_USES_VULKANSC
3873 #ifndef CTS_USES_VULKANSC
3874 // Removed from Vulkan SC test set: VkAllocationCallbacks is not supported and pointers to this type must be NULL
3875 // \note Skip pooled objects in this test group. They are properly handled by the "multiple" group farther down below.
3876 const CaseDescriptions s_allocCallbackFailGroup =
3878 CASE_DESC(allocCallbackFailTest <Instance>, s_instanceCases, DE_NULL),
3879 CASE_DESC(allocCallbackFailTest <Device>, s_deviceCases, DE_NULL),
3880 CASE_DESC(allocCallbackFailTest <DeviceGroup>, s_deviceGroupCases, DE_NULL),
3881 CASE_DESC(allocCallbackFailTest <DeviceMemory>, s_deviceMemCases, DE_NULL),
3882 CASE_DESC(allocCallbackFailTest <Buffer>, s_bufferCases, DE_NULL),
3883 CASE_DESC(allocCallbackFailTest <BufferView>, s_bufferViewCases, DE_NULL),
3884 CASE_DESC(allocCallbackFailTest <Image>, s_imageCases, DE_NULL),
3885 CASE_DESC(allocCallbackFailTest <ImageView>, s_imageViewCases, checkImageCubeArraySupport),
3886 CASE_DESC(allocCallbackFailTest <Semaphore>, s_semaphoreCases, DE_NULL),
3887 CASE_DESC(allocCallbackFailTest <Event>, s_eventCases, checkEventSupport),
3888 CASE_DESC(allocCallbackFailTest <Fence>, s_fenceCases, DE_NULL),
3889 CASE_DESC(allocCallbackFailTest <QueryPool>, s_queryPoolCases, DE_NULL),
3890 CASE_DESC(allocCallbackFailTest <ShaderModule>, s_shaderModuleCases, DE_NULL),
3891 CASE_DESC(allocCallbackFailTest <PipelineCache>, s_pipelineCacheCases, DE_NULL),
3892 CASE_DESC(allocCallbackFailTest <PipelineLayout>, s_pipelineLayoutCases, DE_NULL),
3893 CASE_DESC(allocCallbackFailTest <RenderPass>, s_renderPassCases, DE_NULL),
3894 CASE_DESC(allocCallbackFailTest <GraphicsPipeline>, s_graphicsPipelineCases, DE_NULL),
3895 CASE_DESC(allocCallbackFailTest <ComputePipeline>, s_computePipelineCases, DE_NULL),
3896 CASE_DESC(allocCallbackFailTest <DescriptorSetLayout>, s_descriptorSetLayoutCases, DE_NULL),
3897 CASE_DESC(allocCallbackFailTest <Sampler>, s_samplerCases, DE_NULL),
3898 CASE_DESC(allocCallbackFailTest <DescriptorPool>, s_descriptorPoolCases, DE_NULL),
3899 EMPTY_CASE_DESC(DescriptorSet),
3900 CASE_DESC(allocCallbackFailTest <Framebuffer>, s_framebufferCases, DE_NULL),
3901 CASE_DESC(allocCallbackFailTest <CommandPool>, s_commandPoolCases, DE_NULL),
3902 EMPTY_CASE_DESC(CommandBuffer),
3904 objectMgmtTests->addChild(createGroup(testCtx, "alloc_callback_fail", "Allocation callback failure", s_allocCallbackFailGroup));
3905 #endif // CTS_USES_VULKANSC
3907 #ifndef CTS_USES_VULKANSC
3908 // Removed from Vulkan SC test set: VkAllocationCallbacks is not supported and pointers to this type must be NULL
3909 // \note Test objects that can be created in bulk
3910 const CaseDescriptions s_allocCallbackFailMultipleObjectsGroup =
3912 EMPTY_CASE_DESC(Instance), // most objects can be created one at a time only
3913 EMPTY_CASE_DESC(Device),
3914 EMPTY_CASE_DESC(DeviceGroup),
3915 EMPTY_CASE_DESC(DeviceMemory),
3916 EMPTY_CASE_DESC(Buffer),
3917 EMPTY_CASE_DESC(BufferView),
3918 EMPTY_CASE_DESC(Image),
3919 EMPTY_CASE_DESC(ImageView),
3920 EMPTY_CASE_DESC(Semaphore),
3921 EMPTY_CASE_DESC(Event),
3922 EMPTY_CASE_DESC(Fence),
3923 EMPTY_CASE_DESC(QueryPool),
3924 EMPTY_CASE_DESC(ShaderModule),
3925 EMPTY_CASE_DESC(PipelineCache),
3926 EMPTY_CASE_DESC(PipelineLayout),
3927 EMPTY_CASE_DESC(RenderPass),
3928 CASE_DESC(allocCallbackFailMultipleObjectsTest <GraphicsPipeline>, s_graphicsPipelineCases, DE_NULL),
3929 CASE_DESC(allocCallbackFailMultipleObjectsTest <ComputePipeline>, s_computePipelineCases, DE_NULL),
3930 EMPTY_CASE_DESC(DescriptorSetLayout),
3931 EMPTY_CASE_DESC(Sampler),
3932 EMPTY_CASE_DESC(DescriptorPool),
3933 CASE_DESC(allocCallbackFailMultipleObjectsTest <DescriptorSet>, s_descriptorSetCases, DE_NULL),
3934 EMPTY_CASE_DESC(Framebuffer),
3935 EMPTY_CASE_DESC(CommandPool),
3936 CASE_DESC(allocCallbackFailMultipleObjectsTest <CommandBuffer>, s_commandBufferCases, DE_NULL),
3938 objectMgmtTests->addChild(createGroup(testCtx, "alloc_callback_fail_multiple", "Allocation callback failure creating multiple objects with one call", s_allocCallbackFailMultipleObjectsGroup));
3939 #endif // CTS_USES_VULKANSC
3941 #ifndef CTS_USES_VULKANSC
3942 // Removed from Vulkan SC test set: VK_EXT_private_data extension does not exist in Vulkan SC
3943 const CaseDescriptions s_privateDataResourcesGroup =
3945 EMPTY_CASE_DESC(Instance), // Does not make sense
3946 EMPTY_CASE_DESC(Device), // Device is tested in each object test
3947 EMPTY_CASE_DESC(DeviceGroup), // Device is tested in each object test
3948 CASE_DESC(createPrivateDataTest <DeviceMemory>, s_deviceMemCases, DE_NULL),
3949 CASE_DESC(createPrivateDataTest <Buffer>, s_bufferCases, DE_NULL),
3950 CASE_DESC(createPrivateDataTest <BufferView>, s_bufferViewCases, DE_NULL),
3951 CASE_DESC(createPrivateDataTest <Image>, s_imageCases, DE_NULL),
3952 CASE_DESC(createPrivateDataTest <ImageView>, s_imageViewCases, checkImageCubeArraySupport),
3953 CASE_DESC(createPrivateDataTest <Semaphore>, s_semaphoreCases, DE_NULL),
3954 CASE_DESC(createPrivateDataTest <Event>, s_eventCases, checkEventSupport),
3955 CASE_DESC(createPrivateDataTest <Fence>, s_fenceCases, DE_NULL),
3956 CASE_DESC(createPrivateDataTest <QueryPool>, s_queryPoolCases, DE_NULL),
3957 CASE_DESC(createPrivateDataTest <ShaderModule>, s_shaderModuleCases, DE_NULL),
3958 CASE_DESC(createPrivateDataTest <PipelineCache>, s_pipelineCacheCases, DE_NULL),
3959 CASE_DESC(createPrivateDataTest <PipelineLayout>, s_pipelineLayoutCases, DE_NULL),
3960 CASE_DESC(createPrivateDataTest <RenderPass>, s_renderPassCases, DE_NULL),
3961 CASE_DESC(createPrivateDataTest <GraphicsPipeline>, s_graphicsPipelineCases, DE_NULL),
3962 CASE_DESC(createPrivateDataTest <ComputePipeline>, s_computePipelineCases, DE_NULL),
3963 CASE_DESC(createPrivateDataTest <DescriptorSetLayout>, s_descriptorSetLayoutCases, DE_NULL),
3964 CASE_DESC(createPrivateDataTest <Sampler>, s_samplerCases, DE_NULL),
3965 CASE_DESC(createPrivateDataTest <DescriptorPool>, s_descriptorPoolCases, DE_NULL),
3966 CASE_DESC(createPrivateDataTest <DescriptorSet>, s_descriptorSetCases, DE_NULL),
3967 CASE_DESC(createPrivateDataTest <Framebuffer>, s_framebufferCases, DE_NULL),
3968 CASE_DESC(createPrivateDataTest <CommandPool>, s_commandPoolCases, DE_NULL),
3969 CASE_DESC(createPrivateDataTest <CommandBuffer>, s_commandBufferCases, DE_NULL),
3971 objectMgmtTests->addChild(createTestGroup(testCtx, "private_data", "Multiple objects with private data", createTests, s_privateDataResourcesGroup, cleanupGroup));
3972 #endif // CTS_USES_VULKANSC
3974 return objectMgmtTests.release();