1 #ifndef _VKTTESTCASE_HPP
2 #define _VKTTESTCASE_HPP
3 /*-------------------------------------------------------------------------
4 * Vulkan Conformance Tests
5 * ------------------------
7 * Copyright (c) 2015 Google Inc.
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 * \brief Vulkan test case base classes
24 *//*--------------------------------------------------------------------*/
26 #include "tcuDefs.hpp"
27 #include "tcuTestCase.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"
42 struct ProgramSources;
47 class PlatformInterface;
49 struct SourceCollections;
55 struct ContextCommonData {
56 const vk::InstanceInterface& vki;
58 const vk::DeviceInterface& vkd;
59 vk::VkPhysicalDevice physicalDevice;
60 vk::Allocator& allocator;
70 Context (tcu::TestContext& testCtx,
71 const vk::PlatformInterface& platformInterface,
72 vk::BinaryCollection& progCollection,
73 de::SharedPtr<vk::ResourceInterface> resourceInterface);
76 tcu::TestContext& getTestContext (void) const { return m_testCtx; }
77 const vk::PlatformInterface& getPlatformInterface (void) const { return m_platformInterface; }
78 vk::BinaryCollection& getBinaryCollection (void) const { return m_progCollection; }
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;
96 #ifdef CTS_USES_VULKANSC
97 const vk::VkPhysicalDeviceVulkanSC10Features& getDeviceVulkanSC10Features (void) const;
98 #endif // CTS_USES_VULKANSC
100 bool isInstanceFunctionalitySupported (const std::string& extension) const;
101 bool isDeviceFunctionalitySupported (const std::string& extension) const;
103 #include "vkDeviceFeaturesForContextDecl.inl"
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;
113 #ifdef CTS_USES_VULKANSC
114 const vk::VkPhysicalDeviceVulkanSC10Properties& getDeviceVulkanSC10Properties (void) const;
115 #endif // CTS_USES_VULKANSC
117 #include "vkDevicePropertiesForContextDecl.inl"
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);
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
142 void* getInstanceProcAddr ();
144 bool isBufferDeviceAddressSupported (void) const;
146 bool resultSetOnValidation () const { return m_resultSetOnValidation; }
147 void resultSetOnValidation (bool value) { m_resultSetOnValidation = value; }
149 #ifndef CTS_USES_VULKANSC
150 bool hasDebugReportRecorder () const;
151 vk::DebugReportRecorder& getDebugReportRecorder () const;
152 #endif // CTS_USES_VULKANSC
154 void checkPipelineLibraryRequirements (const vk::PipelineConstructionType pipelineConstructionType);
155 void resetCommandPoolForVKSC (const vk::VkDevice device,
156 const vk::VkCommandPool commandPool);
157 ContextCommonData getContextCommonData ();
160 tcu::TestContext& m_testCtx;
161 const vk::PlatformInterface& m_platformInterface;
162 vk::BinaryCollection& m_progCollection;
164 de::SharedPtr<vk::ResourceInterface> m_resourceInterface;
165 const de::UniquePtr<DefaultDevice> m_device;
166 const de::UniquePtr<vk::Allocator> m_allocator;
168 bool m_resultSetOnValidation;
171 Context (const Context&); // Not allowed
172 Context& operator= (const Context&); // Not allowed
177 class TestCase : public tcu::TestCase
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);
182 virtual ~TestCase (void) {}
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;
189 IterateResult iterate (void) { DE_ASSERT(false); return STOP; } // Deprecated in this module
195 TestInstance (Context& context) : m_context(context) {}
196 virtual ~TestInstance (void) {}
198 virtual tcu::TestStatus iterate (void) = 0;
204 TestInstance (const TestInstance&);
205 TestInstance& operator= (const TestInstance&);
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())
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())
218 #ifndef CTS_USES_VULKANSC
220 void collectAndReportDebugMessages(vk::DebugReportRecorder &debugReportRecorder, Context& context);
222 #endif // CTS_USES_VULKANSC
226 #endif // _VKTTESTCASE_HPP