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 "vktTestCaseDefs.hpp"
33
34 struct vr_executor;
35 struct vr_config;
36
37 namespace glu
38 {
39 struct ProgramSources;
40 }
41
42 namespace vk
43 {
44 class PlatformInterface;
45 class Allocator;
46 struct SourceCollections;
47 }
48
49 namespace vkt
50 {
51
52 class DefaultDevice;
53
54 class Context
55 {
56 public:
57 Context (tcu::TestContext& testCtx,
58 const vk::PlatformInterface& platformInterface,
59 vk::BinaryCollection& progCollection);
60 ~Context (void);
61
getTestContext(void) const62 tcu::TestContext& getTestContext (void) const { return m_testCtx; }
getPlatformInterface(void) const63 const vk::PlatformInterface& getPlatformInterface (void) const { return m_platformInterface; }
getBinaryCollection(void) const64 vk::BinaryCollection& getBinaryCollection (void) const { return m_progCollection; }
65
66 // Default instance & device, selected with --deqp-vk-device-id=N
67 deUint32 getAvailableInstanceVersion (void) const;
68 const std::vector<std::string>& getInstanceExtensions (void) const;
69 vk::VkInstance getInstance (void) const;
70 const vk::InstanceInterface& getInstanceInterface (void) const;
71 vk::VkPhysicalDevice getPhysicalDevice (void) const;
72 deUint32 getDeviceVersion (void) const;
73 const vk::VkPhysicalDeviceFeatures& getDeviceFeatures (void) const;
74 const vk::VkPhysicalDeviceFeatures2& getDeviceFeatures2 (void) const;
75 const vk::VkPhysicalDeviceSamplerYcbcrConversionFeatures&
76 getSamplerYCbCrConversionFeatures
77 (void) const;
78 const vk::VkPhysicalDevice8BitStorageFeaturesKHR&
79 get8BitStorageFeatures (void) const;
80 const vk::VkPhysicalDevice16BitStorageFeatures&
81 get16BitStorageFeatures (void) const;
82 const vk::VkPhysicalDeviceVariablePointerFeatures&
83 getVariablePointerFeatures (void) const;
84 const vk::VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT&
85 getVertexAttributeDivisorFeatures(void) const;
86 const vk::VkPhysicalDeviceVulkanMemoryModelFeaturesKHR&
87 getVulkanMemoryModelFeatures (void) const;
88 const vk::VkPhysicalDeviceShaderAtomicInt64FeaturesKHR&
89 getShaderAtomicInt64Features (void) const;
90 const vk::VkPhysicalDeviceConditionalRenderingFeaturesEXT&
91 getConditionalRenderingFeatures (void) const;
92 const vk::VkPhysicalDeviceScalarBlockLayoutFeaturesEXT&
93 getScalarBlockLayoutFeatures (void) const;
94 const vk::VkPhysicalDeviceFloat16Int8FeaturesKHR&
95 getFloat16Int8Features (void) const;
96 const vk::VkPhysicalDeviceProperties& getDeviceProperties (void) const;
97 const std::vector<std::string>& getDeviceExtensions (void) const;
98 vk::VkDevice getDevice (void) const;
99 const vk::DeviceInterface& getDeviceInterface (void) const;
100 deUint32 getUniversalQueueFamilyIndex (void) const;
101 vk::VkQueue getUniversalQueue (void) const;
102 deUint32 getUsedApiVersion (void) const;
103 deUint32 getSparseQueueFamilyIndex (void) const;
104 vk::VkQueue getSparseQueue (void) const;
105 vk::Allocator& getDefaultAllocator (void) const;
106 vr_executor* getExecutor (void) const;
107 bool contextSupports (const deUint32 majorNum, const deUint32 minorNum, const deUint32 patchNum) const;
108 bool contextSupports (const vk::ApiVersion version) const;
109 bool contextSupports (const deUint32 requiredApiVersionBits) const;
110 bool requireDeviceExtension (const std::string& required);
111 bool requireInstanceExtension (const std::string& required);
112 bool requireDeviceCoreFeature (const DeviceCoreFeature requiredDeviceCoreFeature);
113
114 protected:
115 tcu::TestContext& m_testCtx;
116 const vk::PlatformInterface& m_platformInterface;
117 vk::BinaryCollection& m_progCollection;
118
119 const de::UniquePtr<DefaultDevice> m_device;
120 const de::UniquePtr<vk::Allocator> m_allocator;
121
122 vr_executor* m_executor;
123 vr_config* m_config;
124
125 private:
126 Context (const Context&); // Not allowed
127 Context& operator= (const Context&); // Not allowed
128
129 static void* getInstanceProc (const char* name, void* user_data);
130 static void errorCb (const char *message, void *user_data);
131 };
132
133 class TestInstance;
134
135 class TestCase : public tcu::TestCase
136 {
137 public:
138 TestCase (tcu::TestContext& testCtx, const std::string& name, const std::string& description);
139 TestCase (tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description);
~TestCase(void)140 virtual ~TestCase (void) {}
141
142 virtual void initPrograms (vk::SourceCollections& programCollection) const;
143 virtual TestInstance* createInstance (Context& context) const = 0;
144 virtual void checkSupport (Context& context) const;
145
iterate(void)146 IterateResult iterate (void) { DE_ASSERT(false); return STOP; } // Deprecated in this module
147 };
148
149 class TestInstance
150 {
151 public:
TestInstance(Context & context)152 TestInstance (Context& context) : m_context(context) {}
~TestInstance(void)153 virtual ~TestInstance (void) {}
154
155 virtual tcu::TestStatus iterate (void) = 0;
156
157 protected:
158 Context& m_context;
159
160 private:
161 TestInstance (const TestInstance&);
162 TestInstance& operator= (const TestInstance&);
163 };
164
TestCase(tcu::TestContext & testCtx,const std::string & name,const std::string & description)165 inline TestCase::TestCase (tcu::TestContext& testCtx, const std::string& name, const std::string& description)
166 : tcu::TestCase(testCtx, name.c_str(), description.c_str())
167 {
168 }
169
TestCase(tcu::TestContext & testCtx,tcu::TestNodeType type,const std::string & name,const std::string & description)170 inline TestCase::TestCase (tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description)
171 : tcu::TestCase(testCtx, type, name.c_str(), description.c_str())
172 {
173 }
174
175 } // vkt
176
177 #endif // _VKTTESTCASE_HPP
178