• 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 	vk::VkInstance								getInstance						(void) const;
64 	const vk::InstanceInterface&				getInstanceInterface			(void) const;
65 	vk::VkPhysicalDevice						getPhysicalDevice				(void) const;
66 	const vk::VkPhysicalDeviceFeatures&			getDeviceFeatures				(void) const;
67 	const vk::VkPhysicalDeviceProperties&		getDeviceProperties				(void) const;
68 	vk::VkDevice								getDevice						(void) const;
69 	const vk::DeviceInterface&					getDeviceInterface				(void) const;
70 	deUint32									getUniversalQueueFamilyIndex	(void) const;
71 	vk::VkQueue									getUniversalQueue				(void) const;
72 
73 	vk::Allocator&								getDefaultAllocator				(void) const;
74 
75 protected:
76 	tcu::TestContext&							m_testCtx;
77 	const vk::PlatformInterface&				m_platformInterface;
78 	vk::ProgramCollection<vk::ProgramBinary>&	m_progCollection;
79 
80 	const de::UniquePtr<DefaultDevice>			m_device;
81 	const de::UniquePtr<vk::Allocator>			m_allocator;
82 
83 private:
84 												Context							(const Context&); // Not allowed
85 	Context&									operator=						(const Context&); // Not allowed
86 };
87 
88 
89 class TestInstance;
90 
91 class TestCase : public tcu::TestCase
92 {
93 public:
94 							TestCase		(tcu::TestContext& testCtx, const std::string& name, const std::string& description);
95 							TestCase		(tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description);
~TestCase(void)96 	virtual					~TestCase		(void) {}
97 
98 	virtual void			initPrograms	(vk::SourceCollections& programCollection) const;
99 	virtual TestInstance*	createInstance	(Context& context) const = 0;
100 
iterate(void)101 	IterateResult			iterate			(void) { DE_ASSERT(false); return STOP; } // Deprecated in this module
102 };
103 
104 class TestInstance
105 {
106 public:
TestInstance(Context & context)107 								TestInstance	(Context& context) : m_context(context) {}
~TestInstance(void)108 	virtual						~TestInstance	(void) {}
109 
110 	virtual tcu::TestStatus		iterate			(void) = 0;
111 
112 protected:
113 	Context&					m_context;
114 
115 private:
116 								TestInstance	(const TestInstance&);
117 	TestInstance&				operator=		(const TestInstance&);
118 };
119 
TestCase(tcu::TestContext & testCtx,const std::string & name,const std::string & description)120 inline TestCase::TestCase (tcu::TestContext& testCtx, const std::string& name, const std::string& description)
121 	: tcu::TestCase(testCtx, name.c_str(), description.c_str())
122 {
123 }
124 
TestCase(tcu::TestContext & testCtx,tcu::TestNodeType type,const std::string & name,const std::string & description)125 inline TestCase::TestCase (tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description)
126 	: tcu::TestCase(testCtx, type, name.c_str(), description.c_str())
127 {
128 }
129 
130 } // vkt
131 
132 #endif // _VKTTESTCASE_HPP
133