• 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 "vktTestCaseDefs.hpp"
35 #include <vector>
36 #include <string>
37 
38 namespace glu
39 {
40 struct ProgramSources;
41 }
42 
43 namespace vk
44 {
45 class PlatformInterface;
46 class Allocator;
47 struct SourceCollections;
48 }
49 
50 namespace vkt
51 {
52 
53 class DefaultDevice;
54 
55 class Context
56 {
57 public:
58 													Context								(tcu::TestContext&				testCtx,
59 																						 const vk::PlatformInterface&	platformInterface,
60 																						 vk::BinaryCollection&			progCollection);
61 													~Context							(void);
62 
getTestContext(void) const63 	tcu::TestContext&								getTestContext						(void) const { return m_testCtx;			}
getPlatformInterface(void) const64 	const vk::PlatformInterface&					getPlatformInterface				(void) const { return m_platformInterface;	}
getBinaryCollection(void) const65 	vk::BinaryCollection&							getBinaryCollection					(void) const { return m_progCollection;		}
66 
67 	// Default instance & device, selected with --deqp-vk-device-id=N
68 	deUint32										getMaximumFrameworkVulkanVersion	(void) const;
69 	deUint32										getAvailableInstanceVersion			(void) const;
70 	const std::vector<std::string>&					getInstanceExtensions				(void) const;
71 	vk::VkInstance									getInstance							(void) const;
72 	const vk::InstanceInterface&					getInstanceInterface				(void) const;
73 	vk::VkPhysicalDevice							getPhysicalDevice					(void) const;
74 	deUint32										getDeviceVersion					(void) const;
75 	bool											isDeviceFeatureInitialized			(vk::VkStructureType sType) const;
76 	const vk::VkPhysicalDeviceFeatures&				getDeviceFeatures					(void) const;
77 	const vk::VkPhysicalDeviceFeatures2&			getDeviceFeatures2					(void) const;
78 	const vk::VkPhysicalDeviceVulkan11Features&		getDeviceVulkan11Features			(void) const;
79 	const vk::VkPhysicalDeviceVulkan12Features&		getDeviceVulkan12Features			(void) const;
80 	const vk::VkPhysicalDeviceVulkan13Features&		getDeviceVulkan13Features			(void) const;
81 
82 	bool											isInstanceFunctionalitySupported	(const std::string& extension) const;
83 	bool											isDeviceFunctionalitySupported		(const std::string& extension) const;
84 
85 #include "vkDeviceFeaturesForContextDecl.inl"
86 
87 	bool											isDevicePropertyInitialized			(vk::VkStructureType sType) const;
88 	const vk::VkPhysicalDeviceProperties&			getDeviceProperties					(void) const;
89 	const vk::VkPhysicalDeviceProperties2&			getDeviceProperties2				(void) const;
90 	const vk::VkPhysicalDeviceVulkan11Properties&	getDeviceVulkan11Properties			(void) const;
91 	const vk::VkPhysicalDeviceVulkan12Properties&	getDeviceVulkan12Properties			(void) const;
92 	const vk::VkPhysicalDeviceVulkan13Properties&	getDeviceVulkan13Properties			(void) const;
93 
94 #include "vkDevicePropertiesForContextDecl.inl"
95 
96 	const std::vector<std::string>&					getDeviceExtensions					(void) const;
97 	vk::VkDevice									getDevice							(void) const;
98 	const vk::DeviceInterface&						getDeviceInterface					(void) const;
99 	deUint32										getUniversalQueueFamilyIndex		(void) const;
100 	vk::VkQueue										getUniversalQueue					(void) const;
101 	deUint32										getUsedApiVersion					(void) const;
102 	deUint32										getSparseQueueFamilyIndex			(void) const;
103 	vk::VkQueue										getSparseQueue						(void) const;
104 	vk::Allocator&									getDefaultAllocator					(void) const;
105 	bool											contextSupports						(const deUint32 majorNum, const deUint32 minorNum, const deUint32 patchNum) const;
106 	bool											contextSupports						(const vk::ApiVersion version) const;
107 	bool											contextSupports						(const deUint32 requiredApiVersionBits) const;
108 	bool											requireDeviceFunctionality			(const std::string& required) const;
109 	bool											requireInstanceFunctionality		(const std::string& required) const;
110 	bool											requireDeviceCoreFeature			(const DeviceCoreFeature requiredDeviceCoreFeature);
111 
112 
113 	vk::VkFormatProperties3						getFormatProperties					(const vk::VkFormat&	format)	const;
114 	vk::VkFormatProperties3						getRequiredFormatProperties			(const vk::VkFormat&	format)	const;
115 
116 	void*											getInstanceProcAddr					();
117 
118 	bool											isBufferDeviceAddressSupported		(void) const;
119 
resultSetOnValidation() const120 	bool											resultSetOnValidation				() const		{ return m_resultSetOnValidation;	}
resultSetOnValidation(bool value)121 	void											resultSetOnValidation				(bool value)	{ m_resultSetOnValidation = value;	}
122 
123 	bool											hasDebugReportRecorder				() const;
124 	vk::DebugReportRecorder&						getDebugReportRecorder				() const;
125 
126 protected:
127 	tcu::TestContext&								m_testCtx;
128 	const vk::PlatformInterface&					m_platformInterface;
129 	vk::BinaryCollection&							m_progCollection;
130 
131 	const de::UniquePtr<DefaultDevice>				m_device;
132 	const de::UniquePtr<vk::Allocator>				m_allocator;
133 
134 	bool											m_resultSetOnValidation;
135 
136 private:
137 												Context								(const Context&); // Not allowed
138 	Context&									operator=							(const Context&); // Not allowed
139 };
140 
141 class TestInstance;
142 
143 class TestCase : public tcu::TestCase
144 {
145 public:
146 							TestCase		(tcu::TestContext& testCtx, const std::string& name, const std::string& description);
147 							TestCase		(tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description);
~TestCase(void)148 	virtual					~TestCase		(void) {}
149 
150 	virtual void			delayedInit		(void); // non-const init called after checkSupport but before initPrograms
151 	virtual void			initPrograms	(vk::SourceCollections& programCollection) const;
152 	virtual TestInstance*	createInstance	(Context& context) const = 0;
153 	virtual void			checkSupport	(Context& context) const;
154 
iterate(void)155 	IterateResult			iterate			(void) { DE_ASSERT(false); return STOP; } // Deprecated in this module
156 };
157 
158 class TestInstance
159 {
160 public:
TestInstance(Context & context)161 								TestInstance	(Context& context) : m_context(context) {}
~TestInstance(void)162 	virtual						~TestInstance	(void) {}
163 
164 	virtual tcu::TestStatus		iterate			(void) = 0;
165 
166 protected:
167 	Context&					m_context;
168 
169 private:
170 								TestInstance	(const TestInstance&);
171 	TestInstance&				operator=		(const TestInstance&);
172 };
173 
TestCase(tcu::TestContext & testCtx,const std::string & name,const std::string & description)174 inline TestCase::TestCase (tcu::TestContext& testCtx, const std::string& name, const std::string& description)
175 	: tcu::TestCase(testCtx, name.c_str(), description.c_str())
176 {
177 }
178 
TestCase(tcu::TestContext & testCtx,tcu::TestNodeType type,const std::string & name,const std::string & description)179 inline TestCase::TestCase (tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description)
180 	: tcu::TestCase(testCtx, type, name.c_str(), description.c_str())
181 {
182 }
183 
184 void collectAndReportDebugMessages(vk::DebugReportRecorder &debugReportRecorder, Context& context);
185 
186 } // vkt
187 
188 #endif // _VKTTESTCASE_HPP
189