1 #ifndef _VKTSPARSERESOURCESBASE_HPP 2 #define _VKTSPARSERESOURCESBASE_HPP 3 /*------------------------------------------------------------------------ 4 * Vulkan Conformance Tests 5 * ------------------------ 6 * 7 * Copyright (c) 2016 The Khronos Group Inc. 8 * 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 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 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. 20 * 21 *//*! 22 * \file vktSparseResourcesBase.hpp 23 * \brief Sparse Resources Base Instance 24 *//*--------------------------------------------------------------------*/ 25 26 #include "vkDefs.hpp" 27 #include "vktTestCase.hpp" 28 #include "vkRef.hpp" 29 #include "vkPlatform.hpp" 30 #include "deUniquePtr.hpp" 31 #include "tcuCommandLine.hpp" 32 33 #include <map> 34 #include <vector> 35 36 namespace vkt 37 { 38 namespace sparse 39 { 40 41 struct Queue 42 { 43 vk::VkQueue queueHandle; 44 deUint32 queueFamilyIndex; 45 deUint32 queueIndex; 46 }; 47 48 struct QueueRequirements 49 { QueueRequirementsvkt::sparse::QueueRequirements50 QueueRequirements(const vk::VkQueueFlags qFlags, const deUint32 qCount) 51 : queueFlags(qFlags) 52 , queueCount(qCount) 53 {} 54 55 vk::VkQueueFlags queueFlags; 56 deUint32 queueCount; 57 }; 58 59 class SparseResourcesBaseInstance : public TestInstance 60 { 61 public: SparseResourcesBaseInstance(Context & context,bool useDeviceGroups=false)62 SparseResourcesBaseInstance (Context &context, bool useDeviceGroups = false) 63 : TestInstance (context) 64 , m_numPhysicalDevices (1) 65 , m_useDeviceGroups (useDeviceGroups) 66 { 67 const tcu::CommandLine& cmdLine = context.getTestContext().getCommandLine(); 68 m_deviceGroupIdx = cmdLine.getVKDeviceGroupId() - 1; 69 } usingDeviceGroups()70 bool usingDeviceGroups() { return m_useDeviceGroups; } 71 72 protected: 73 typedef std::vector<QueueRequirements> QueueRequirementsVec; 74 75 deUint32 m_numPhysicalDevices; 76 77 void createDeviceSupportingQueues (const QueueRequirementsVec& queueRequirements); 78 const Queue& getQueue (const vk::VkQueueFlags queueFlags, const deUint32 queueIndex) const; getDeviceInterface(void) const79 const vk::DeviceInterface& getDeviceInterface (void) const { return *m_deviceDriver; } getDevice(void) const80 vk::VkDevice getDevice (void) const { return *m_logicalDevice; } getAllocator(void)81 vk::Allocator& getAllocator (void) { return *m_allocator; } getPhysicalDevice(deUint32 i=0)82 vk::VkPhysicalDevice getPhysicalDevice (deUint32 i = 0) { return m_physicalDevices[i];} 83 84 private: 85 bool m_useDeviceGroups; 86 deUint32 m_deviceGroupIdx; 87 vk::Move<vk::VkInstance> m_deviceGroupInstance; 88 std::vector<vk::VkPhysicalDevice> m_physicalDevices; 89 std::map<vk::VkQueueFlags, std::vector<Queue> > m_queues; 90 de::MovePtr<vk::DeviceDriver> m_deviceDriver; 91 vk::Move<vk::VkDevice> m_logicalDevice; 92 de::MovePtr<vk::Allocator> m_allocator; 93 }; 94 95 } // sparse 96 } // vkt 97 98 #endif // _VKTSPARSERESOURCESBASE_HPP 99