• 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 
31 namespace glu
32 {
33 struct ProgramSources;
34 }
35 
36 namespace vk
37 {
38 class PlatformInterface;
39 class ProgramBinary;
40 template<typename Program> class ProgramCollection;
41 class Allocator;
42 struct SourceCollections;
43 }
44 
45 namespace vkt
46 {
47 
48 class DefaultDevice;
49 
50 class Context
51 {
52 public:
53 												Context							(tcu::TestContext&							testCtx,
54 																				 const vk::PlatformInterface&				platformInterface,
55 																				 vk::ProgramCollection<vk::ProgramBinary>&	progCollection);
56 												~Context						(void);
57 
getTestContext(void) const58 	tcu::TestContext&							getTestContext					(void) const { return m_testCtx;			}
getPlatformInterface(void) const59 	const vk::PlatformInterface&				getPlatformInterface			(void) const { return m_platformInterface;	}
getBinaryCollection(void) const60 	vk::ProgramCollection<vk::ProgramBinary>&	getBinaryCollection				(void) const { return m_progCollection;		}
61 
62 	// Default instance & device, selected with --deqp-vk-device-id=N
63 	const std::vector<std::string>&				getInstanceExtensions			(void) const;
64 	vk::VkInstance								getInstance						(void) const;
65 	const vk::InstanceInterface&				getInstanceInterface			(void) const;
66 	vk::VkPhysicalDevice						getPhysicalDevice				(void) const;
67 	const vk::VkPhysicalDeviceFeatures&			getDeviceFeatures				(void) const;
68 	const vk::VkPhysicalDeviceFeatures2KHR&		getDeviceFeatures2				(void) const;
69 	const vk::VkPhysicalDeviceProperties&		getDeviceProperties				(void) const;
70 	const std::vector<std::string>&				getDeviceExtensions				(void) const;
71 	vk::VkDevice								getDevice						(void) const;
72 	const vk::DeviceInterface&					getDeviceInterface				(void) const;
73 	deUint32									getUniversalQueueFamilyIndex	(void) const;
74 	vk::VkQueue									getUniversalQueue				(void) const;
75 
76 	vk::Allocator&								getDefaultAllocator				(void) const;
77 
78 protected:
79 	tcu::TestContext&							m_testCtx;
80 	const vk::PlatformInterface&				m_platformInterface;
81 	vk::ProgramCollection<vk::ProgramBinary>&	m_progCollection;
82 
83 	const de::UniquePtr<DefaultDevice>			m_device;
84 	const de::UniquePtr<vk::Allocator>			m_allocator;
85 
86 private:
87 												Context							(const Context&); // Not allowed
88 	Context&									operator=						(const Context&); // Not allowed
89 };
90 
91 
92 class TestInstance;
93 
94 class TestCase : public tcu::TestCase
95 {
96 public:
97 							TestCase		(tcu::TestContext& testCtx, const std::string& name, const std::string& description);
98 							TestCase		(tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description);
~TestCase(void)99 	virtual					~TestCase		(void) {}
100 
101 	virtual void			initPrograms	(vk::SourceCollections& programCollection) const;
102 	virtual TestInstance*	createInstance	(Context& context) const = 0;
103 
iterate(void)104 	IterateResult			iterate			(void) { DE_ASSERT(false); return STOP; } // Deprecated in this module
105 };
106 
107 class TestInstance
108 {
109 public:
TestInstance(Context & context)110 								TestInstance	(Context& context) : m_context(context) {}
~TestInstance(void)111 	virtual						~TestInstance	(void) {}
112 
113 	virtual tcu::TestStatus		iterate			(void) = 0;
114 
115 protected:
116 	Context&					m_context;
117 
118 private:
119 								TestInstance	(const TestInstance&);
120 	TestInstance&				operator=		(const TestInstance&);
121 };
122 
TestCase(tcu::TestContext & testCtx,const std::string & name,const std::string & description)123 inline TestCase::TestCase (tcu::TestContext& testCtx, const std::string& name, const std::string& description)
124 	: tcu::TestCase(testCtx, name.c_str(), description.c_str())
125 {
126 }
127 
TestCase(tcu::TestContext & testCtx,tcu::TestNodeType type,const std::string & name,const std::string & description)128 inline TestCase::TestCase (tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description)
129 	: tcu::TestCase(testCtx, type, name.c_str(), description.c_str())
130 {
131 }
132 
133 } // vkt
134 
135 #endif // _VKTTESTCASE_HPP
136