1 #ifndef _VKTSPARSERESOURCESBASE_HPP
2 #define _VKTSPARSERESOURCESBASE_HPP
3 /*------------------------------------------------------------------------
4 * Vulkan Conformance Tests
5 * ------------------------
7 * Copyright (c) 2016 The Khronos Group Inc.
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
22 * \file vktSparseResourcesBase.hpp
23 * \brief Sparse Resources Base Instance
24 *//*--------------------------------------------------------------------*/
27 #include "vktTestCase.hpp"
28 #include "vktCustomInstancesDevices.hpp"
30 #include "vkPlatform.hpp"
31 #include "deUniquePtr.hpp"
32 #include "tcuCommandLine.hpp"
44 vk::VkQueue queueHandle;
45 deUint32 queueFamilyIndex;
49 struct QueueRequirements
51 QueueRequirements(const vk::VkQueueFlags qFlags, const deUint32 qCount)
56 vk::VkQueueFlags queueFlags;
60 class SparseResourcesBaseInstance : public TestInstance
63 SparseResourcesBaseInstance (Context &context, bool useDeviceGroups = false)
64 : TestInstance (context)
65 , m_numPhysicalDevices (1)
66 , m_useDeviceGroups (useDeviceGroups)
68 const tcu::CommandLine& cmdLine = context.getTestContext().getCommandLine();
69 m_deviceGroupIdx = cmdLine.getVKDeviceGroupId() - 1;
71 bool usingDeviceGroups() { return m_useDeviceGroups; }
74 typedef std::vector<QueueRequirements> QueueRequirementsVec;
76 deUint32 m_numPhysicalDevices;
78 void createDeviceSupportingQueues (const QueueRequirementsVec& queueRequirements);
79 const Queue& getQueue (const vk::VkQueueFlags queueFlags, const deUint32 queueIndex) const;
80 const vk::DeviceInterface& getDeviceInterface (void) const { return *m_deviceDriver; }
81 vk::VkDevice getDevice (void) const { return *m_logicalDevice; }
82 vk::Allocator& getAllocator (void) { return *m_allocator; }
83 vk::VkPhysicalDevice getPhysicalDevice (deUint32 i = 0) { return m_physicalDevices[i];}
86 bool m_useDeviceGroups;
87 deUint32 m_deviceGroupIdx;
88 CustomInstance m_deviceGroupInstance;
89 std::vector<vk::VkPhysicalDevice> m_physicalDevices;
90 std::map<vk::VkQueueFlags, std::vector<Queue> > m_queues;
91 de::MovePtr<vk::DeviceDriver> m_deviceDriver;
92 vk::Move<vk::VkDevice> m_logicalDevice;
93 de::MovePtr<vk::Allocator> m_allocator;
99 #endif // _VKTSPARSERESOURCESBASE_HPP