• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "vktCustomInstancesDevices.hpp"
29 #include "vkRef.hpp"
30 #include "vkPlatform.hpp"
31 #include "deUniquePtr.hpp"
32 #include "tcuCommandLine.hpp"
33 
34 #include <map>
35 #include <vector>
36 
37 namespace vkt
38 {
39 namespace sparse
40 {
41 
42 struct Queue
43 {
44     vk::VkQueue queueHandle;
45     uint32_t queueFamilyIndex;
46     uint32_t queueIndex;
47 };
48 
49 struct QueueRequirements
50 {
QueueRequirementsvkt::sparse::QueueRequirements51     QueueRequirements(const vk::VkQueueFlags qFlags, const uint32_t qCount) : queueFlags(qFlags), queueCount(qCount)
52     {
53     }
54 
55     vk::VkQueueFlags queueFlags;
56     uint32_t queueCount;
57 };
58 
59 class SparseResourcesBaseInstance : public TestInstance
60 {
61 public:
SparseResourcesBaseInstance(Context & context,bool useDeviceGroups=false,bool forceSpecificQueue=false)62     SparseResourcesBaseInstance(Context &context, bool useDeviceGroups = false, bool forceSpecificQueue = false)
63         : TestInstance(context)
64         , m_numPhysicalDevices(1)
65         , m_useDeviceGroups(useDeviceGroups)
66         , m_forceSpecificQueue(forceSpecificQueue)
67     {
68         const tcu::CommandLine &cmdLine = context.getTestContext().getCommandLine();
69         m_deviceGroupIdx                = cmdLine.getVKDeviceGroupId() - 1;
70     }
usingDeviceGroups()71     bool usingDeviceGroups()
72     {
73         return m_useDeviceGroups;
74     }
75 
76 protected:
77     typedef std::vector<QueueRequirements> QueueRequirementsVec;
78 
79     uint32_t m_numPhysicalDevices;
80 
81     void createDeviceSupportingQueues(const QueueRequirementsVec &queueRequirements,
82                                       bool requireShaderImageAtomicInt64Features = false,
83                                       bool requireMaintenance5                   = false);
84     const Queue &getQueue(const vk::VkQueueFlags queueFlags, const uint32_t queueIndex) const;
getDeviceInterface(void) const85     const vk::DeviceInterface &getDeviceInterface(void) const
86     {
87         return *m_deviceDriver;
88     }
getDevice(void) const89     vk::VkDevice getDevice(void) const
90     {
91         return *m_logicalDevice;
92     }
getAllocator(void)93     vk::Allocator &getAllocator(void)
94     {
95         return *m_allocator;
96     }
getPhysicalDevice(uint32_t i=0)97     vk::VkPhysicalDevice getPhysicalDevice(uint32_t i = 0)
98     {
99         return m_physicalDevices[i];
100     }
101 
102 private:
103     bool m_useDeviceGroups;
104     bool m_forceSpecificQueue;
105     uint32_t m_deviceGroupIdx;
106     CustomInstance m_deviceGroupInstance;
107     std::vector<vk::VkPhysicalDevice> m_physicalDevices;
108     std::map<vk::VkQueueFlags, std::vector<Queue>> m_queues;
109     de::MovePtr<vk::DeviceDriver> m_deviceDriver;
110     vk::Move<vk::VkDevice> m_logicalDevice;
111     de::MovePtr<vk::Allocator> m_allocator;
112 };
113 
114 } // namespace sparse
115 } // namespace vkt
116 
117 #endif // _VKTSPARSERESOURCESBASE_HPP
118