• 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 "tcuDefs.hpp"
27 #include "tcuTestCase.hpp"
28 #include "vktTestCaseUtil.hpp"
29 
30 #include "vkDefs.hpp"
31 #include "vkMemUtil.hpp"
32 #include "vkPlatform.hpp"
33 #include "vkRef.hpp"
34 #include "vkTypeUtil.hpp"
35 
36 #include "deUniquePtr.hpp"
37 #include "deStringUtil.hpp"
38 
39 #include <map>
40 #include <vector>
41 
42 namespace vkt
43 {
44 namespace sparse
45 {
46 
47 enum
48 {
49 	NO_MATCH_FOUND = ~((deUint32)0)
50 };
51 
52 struct Queue
53 {
54 	vk::VkQueue	queueHandle;
55 	deUint32	queueFamilyIndex;
56 };
57 
58 struct QueueRequirements
59 {
QueueRequirementsvkt::sparse::QueueRequirements60 	QueueRequirements(const vk::VkQueueFlags qFlags, const deUint32	qCount)
61 		: queueFlags(qFlags)
62 		, queueCount(qCount)
63 	{}
64 
65 	vk::VkQueueFlags	queueFlags;
66 	deUint32			queueCount;
67 };
68 
69 typedef std::vector<QueueRequirements> QueueRequirementsVec;
70 
71 class SparseResourcesBaseInstance : public TestInstance
72 {
73 public:
74 					SparseResourcesBaseInstance		(Context &context);
75 
76 protected:
77 
78 	typedef			std::map<vk::VkQueueFlags, std::vector<Queue> >								QueuesMap;
79 	typedef			std::vector<vk::VkQueueFamilyProperties>										QueueFamilyPropertiesVec;
80 	typedef			vk::Move<vk::VkDevice>															DevicePtr;
81 
82 	bool			createDeviceSupportingQueues	(const QueueRequirementsVec&					queueRequirements);
83 
84 	const Queue&	getQueue						(const vk::VkQueueFlags							queueFlags,
85 													 const deUint32									queueIndex);
86 
87 	deUint32		findMatchingMemoryType			(const vk::VkPhysicalDeviceMemoryProperties&	deviceMemoryProperties,
88 													 const vk::VkMemoryRequirements&				objectMemoryRequirements,
89 													 const vk::MemoryRequirement&					memoryRequirement) const;
90 	DevicePtr		m_logicalDevice;
91 
92 private:
93 
94 	deUint32		findMatchingQueueFamilyIndex	(const QueueFamilyPropertiesVec&				queueFamilyProperties,
95 													 const vk::VkQueueFlags							queueFlags) const;
96 	QueuesMap		m_queues;
97 };
98 
99 } // sparse
100 } // vkt
101 
102 #endif // _VKTSPARSERESOURCESBASE_HPP
103