• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _VKTTESTCASE_HPP
2 #define _VKTTESTCASE_HPP
3 /*-------------------------------------------------------------------------
4  * Vulkan Conformance Tests
5  * ------------------------
6  *
7  * Copyright (c) 2015 Google 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
23  * \brief Vulkan test case base classes
24  *//*--------------------------------------------------------------------*/
25 
26 #include "tcuDefs.hpp"
27 #include "tcuTestCase.hpp"
28 #include "vkDefs.hpp"
29 #include "deUniquePtr.hpp"
30 #include "vkPrograms.hpp"
31 #include "vkApiVersion.hpp"
32 #include "vkDebugReportUtil.hpp"
33 #include "vkPlatform.hpp"
34 #include "vkResourceInterface.hpp"
35 #include "vktTestCaseDefs.hpp"
36 #include "vkPipelineConstructionUtil.hpp"
37 #include <vector>
38 #include <string>
39 
40 namespace glu
41 {
42 struct ProgramSources;
43 }
44 
45 namespace vk
46 {
47 class PlatformInterface;
48 class Allocator;
49 struct SourceCollections;
50 }
51 
52 namespace vkt
53 {
54 
55 struct ContextCommonData {
56 	const vk::InstanceInterface&	vki;
57 	vk::VkDevice					device;
58 	const vk::DeviceInterface&		vkd;
59 	vk::VkPhysicalDevice			physicalDevice;
60 	vk::Allocator&					allocator;
61 	deUint32						qfIndex;
62 	vk::VkQueue						queue;
63 };
64 
65 class DefaultDevice;
66 
67 class Context
68 {
69 public:
70 												Context								(tcu::TestContext&						testCtx,
71 																					 const vk::PlatformInterface&			platformInterface,
72 																					 vk::BinaryCollection&					progCollection,
73 																					 de::SharedPtr<vk::ResourceInterface>	resourceInterface);
74 												~Context							(void);
75 
getTestContext(void) const76 	tcu::TestContext&								getTestContext						(void) const { return m_testCtx;			}
getPlatformInterface(void) const77 	const vk::PlatformInterface&					getPlatformInterface				(void) const { return m_platformInterface;	}
getBinaryCollection(void) const78 	vk::BinaryCollection&							getBinaryCollection					(void) const { return m_progCollection;		}
79 
80 	// Default instance & device, selected with --deqp-vk-device-id=N
81 	deUint32										getMaximumFrameworkVulkanVersion	(void) const;
82 	deUint32										getAvailableInstanceVersion			(void) const;
83 	const std::vector<std::string>&					getInstanceExtensions				(void) const;
84 	vk::VkInstance									getInstance							(void) const;
85 	const vk::InstanceInterface&					getInstanceInterface				(void) const;
86 	vk::VkPhysicalDevice							getPhysicalDevice					(void) const;
87 	deUint32										getDeviceVersion					(void) const;
88 	bool											isDeviceFeatureInitialized			(vk::VkStructureType sType) const;
89 	const vk::VkPhysicalDeviceFeatures&				getDeviceFeatures					(void) const;
90 	const vk::VkPhysicalDeviceFeatures2&			getDeviceFeatures2					(void) const;
91 	const vk::VkPhysicalDeviceVulkan11Features&		getDeviceVulkan11Features			(void) const;
92 	const vk::VkPhysicalDeviceVulkan12Features&		getDeviceVulkan12Features			(void) const;
93 #ifndef CTS_USES_VULKANSC
94 	const vk::VkPhysicalDeviceVulkan13Features&		getDeviceVulkan13Features			(void) const;
95 #endif
96 #ifdef CTS_USES_VULKANSC
97 	const vk::VkPhysicalDeviceVulkanSC10Features&	getDeviceVulkanSC10Features			(void) const;
98 #endif // CTS_USES_VULKANSC
99 
100 	bool											isInstanceFunctionalitySupported	(const std::string& extension) const;
101 	bool											isDeviceFunctionalitySupported		(const std::string& extension) const;
102 
103 #include "vkDeviceFeaturesForContextDecl.inl"
104 
105 	bool											isDevicePropertyInitialized			(vk::VkStructureType sType) const;
106 	const vk::VkPhysicalDeviceProperties&			getDeviceProperties					(void) const;
107 	const vk::VkPhysicalDeviceProperties2&			getDeviceProperties2				(void) const;
108 	const vk::VkPhysicalDeviceVulkan11Properties&	getDeviceVulkan11Properties			(void) const;
109 	const vk::VkPhysicalDeviceVulkan12Properties&	getDeviceVulkan12Properties			(void) const;
110 #ifndef CTS_USES_VULKANSC
111 	const vk::VkPhysicalDeviceVulkan13Properties&	getDeviceVulkan13Properties			(void) const;
112 #endif
113 #ifdef CTS_USES_VULKANSC
114 	const vk::VkPhysicalDeviceVulkanSC10Properties&	getDeviceVulkanSC10Properties		(void) const;
115 #endif // CTS_USES_VULKANSC
116 
117 #include "vkDevicePropertiesForContextDecl.inl"
118 
119 	const std::vector<std::string>&				getDeviceExtensions					(void) const;
120 	vk::VkDevice								getDevice							(void) const;
121 	const vk::DeviceInterface&					getDeviceInterface					(void) const;
122 	deUint32									getUniversalQueueFamilyIndex		(void) const;
123 	vk::VkQueue									getUniversalQueue					(void) const;
124 	deUint32									getUsedApiVersion					(void) const;
125 	deUint32									getSparseQueueFamilyIndex			(void) const;
126 	vk::VkQueue									getSparseQueue						(void) const;
127 	de::SharedPtr<vk::ResourceInterface>		getResourceInterface				(void) const;
128 	vk::Allocator&								getDefaultAllocator					(void) const;
129 	bool										contextSupports						(const deUint32 variantNum, const deUint32 majorNum, const deUint32 minorNum, const deUint32 patchNum) const;
130 	bool										contextSupports						(const vk::ApiVersion version) const;
131 	bool										contextSupports						(const deUint32 requiredApiVersionBits) const;
132 	bool										requireDeviceFunctionality			(const std::string& required) const;
133 	bool										requireInstanceFunctionality		(const std::string& required) const;
134 	bool										requireDeviceCoreFeature			(const DeviceCoreFeature requiredDeviceCoreFeature);
135 
136 #ifndef CTS_USES_VULKANSC
137 	vk::VkFormatProperties3						getFormatProperties					(const vk::VkFormat&	format)	const;
138 	vk::VkFormatProperties3						getRequiredFormatProperties			(const vk::VkFormat&	format)	const;
139 #endif // CTS_USES_VULKANSC
140 
141 
142 	void*											getInstanceProcAddr					();
143 
144 	bool											isBufferDeviceAddressSupported		(void) const;
145 
resultSetOnValidation() const146 	bool											resultSetOnValidation				() const		{ return m_resultSetOnValidation;	}
resultSetOnValidation(bool value)147 	void											resultSetOnValidation				(bool value)	{ m_resultSetOnValidation = value;	}
148 
149 #ifndef CTS_USES_VULKANSC
150 	bool										hasDebugReportRecorder			() const;
151 	vk::DebugReportRecorder&					getDebugReportRecorder			() const;
152 #endif // CTS_USES_VULKANSC
153 
154 	void checkPipelineLibraryRequirements (const vk::PipelineConstructionType		pipelineConstructionType);
155 	void resetCommandPoolForVKSC													(const vk::VkDevice			device,
156 																					 const vk::VkCommandPool	commandPool);
157 	ContextCommonData getContextCommonData											();
158 
159 protected:
160 	tcu::TestContext&								m_testCtx;
161 	const vk::PlatformInterface&					m_platformInterface;
162 	vk::BinaryCollection&							m_progCollection;
163 
164 	de::SharedPtr<vk::ResourceInterface>		m_resourceInterface;
165 	const de::UniquePtr<DefaultDevice>			m_device;
166 	const de::UniquePtr<vk::Allocator>			m_allocator;
167 
168 	bool											m_resultSetOnValidation;
169 
170 private:
171 												Context								(const Context&); // Not allowed
172 	Context&									operator=							(const Context&); // Not allowed
173 };
174 
175 class TestInstance;
176 
177 class TestCase : public tcu::TestCase
178 {
179 public:
180 							TestCase		(tcu::TestContext& testCtx, const std::string& name, const std::string& description);
181 							TestCase		(tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description);
~TestCase(void)182 	virtual					~TestCase		(void) {}
183 
184 	virtual void			delayedInit		(void); // non-const init called after checkSupport but before initPrograms
185 	virtual void			initPrograms	(vk::SourceCollections& programCollection) const;
186 	virtual TestInstance*	createInstance	(Context& context) const = 0;
187 	virtual void			checkSupport	(Context& context) const;
188 
iterate(void)189 	IterateResult			iterate			(void) { DE_ASSERT(false); return STOP; } // Deprecated in this module
190 };
191 
192 class TestInstance
193 {
194 public:
TestInstance(Context & context)195 								TestInstance	(Context& context) : m_context(context) {}
~TestInstance(void)196 	virtual						~TestInstance	(void) {}
197 
198 	virtual tcu::TestStatus		iterate			(void) = 0;
199 
200 protected:
201 	Context&					m_context;
202 
203 private:
204 								TestInstance	(const TestInstance&);
205 	TestInstance&				operator=		(const TestInstance&);
206 };
207 
TestCase(tcu::TestContext & testCtx,const std::string & name,const std::string & description)208 inline TestCase::TestCase (tcu::TestContext& testCtx, const std::string& name, const std::string& description)
209 	: tcu::TestCase(testCtx, name.c_str(), description.c_str())
210 {
211 }
212 
TestCase(tcu::TestContext & testCtx,tcu::TestNodeType type,const std::string & name,const std::string & description)213 inline TestCase::TestCase (tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description)
214 	: tcu::TestCase(testCtx, type, name.c_str(), description.c_str())
215 {
216 }
217 
218 #ifndef CTS_USES_VULKANSC
219 
220 void collectAndReportDebugMessages(vk::DebugReportRecorder &debugReportRecorder, Context& context);
221 
222 #endif // CTS_USES_VULKANSC
223 
224 } // vkt
225 
226 #endif // _VKTTESTCASE_HPP
227