Merge vk-gl-cts/vulkan-cts-1.2.7 into vk-gl-cts/vulkan-cts-1.2.8
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / modules / vulkan / vktTestCase.hpp
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
63         tcu::TestContext&                                                               getTestContext                                          (void) const { return m_testCtx;                        }
64         const vk::PlatformInterface&                                    getPlatformInterface                            (void) const { return m_platformInterface;      }
65         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
81         bool                                                                                    isInstanceFunctionalitySupported        (const std::string& extension) const;
82         bool                                                                                    isDeviceFunctionalitySupported          (const std::string& extension) const;
83
84 #include "vkDeviceFeaturesForContextDecl.inl"
85
86         bool                                                                                    isDevicePropertyInitialized                     (vk::VkStructureType sType) const;
87         const vk::VkPhysicalDeviceProperties&                   getDeviceProperties                                     (void) const;
88         const vk::VkPhysicalDeviceProperties2&                  getDeviceProperties2                            (void) const;
89         const vk::VkPhysicalDeviceVulkan11Properties&   getDeviceVulkan11Properties                     (void) const;
90         const vk::VkPhysicalDeviceVulkan12Properties&   getDeviceVulkan12Properties                     (void) const;
91
92 #include "vkDevicePropertiesForContextDecl.inl"
93
94         const std::vector<std::string>&                                 getDeviceExtensions                                     (void) const;
95         vk::VkDevice                                                                    getDevice                                                       (void) const;
96         const vk::DeviceInterface&                                              getDeviceInterface                                      (void) const;
97         deUint32                                                                                getUniversalQueueFamilyIndex            (void) const;
98         vk::VkQueue                                                                             getUniversalQueue                                       (void) const;
99         deUint32                                                                                getUsedApiVersion                                       (void) const;
100         deUint32                                                                                getSparseQueueFamilyIndex                       (void) const;
101         vk::VkQueue                                                                             getSparseQueue                                          (void) const;
102         vk::Allocator&                                                                  getDefaultAllocator                                     (void) const;
103         bool                                                                                    contextSupports                                         (const deUint32 majorNum, const deUint32 minorNum, const deUint32 patchNum) const;
104         bool                                                                                    contextSupports                                         (const vk::ApiVersion version) const;
105         bool                                                                                    contextSupports                                         (const deUint32 requiredApiVersionBits) const;
106         bool                                                                                    requireDeviceFunctionality                      (const std::string& required) const;
107         bool                                                                                    requireInstanceFunctionality            (const std::string& required) const;
108         bool                                                                                    requireDeviceCoreFeature                        (const DeviceCoreFeature requiredDeviceCoreFeature);
109
110         vk::VkFormatProperties3KHR                                              getFormatProperties                                     (const vk::VkFormat&    format) const;
111         vk::VkFormatProperties3KHR                                              getRequiredFormatProperties                     (const vk::VkFormat&    format) const;
112
113         void*                                                                                   getInstanceProcAddr                                     ();
114
115         bool                                                                                    isBufferDeviceAddressSupported          (void) const;
116
117         bool                                                                                    resultSetOnValidation                           () const                { return m_resultSetOnValidation;       }
118         void                                                                                    resultSetOnValidation                           (bool value)    { m_resultSetOnValidation = value;      }
119
120         bool                                                                                    hasDebugReportRecorder                          () const;
121         vk::DebugReportRecorder&                                                getDebugReportRecorder                          () const;
122
123 protected:
124         tcu::TestContext&                                                               m_testCtx;
125         const vk::PlatformInterface&                                    m_platformInterface;
126         vk::BinaryCollection&                                                   m_progCollection;
127
128         const de::UniquePtr<DefaultDevice>                              m_device;
129         const de::UniquePtr<vk::Allocator>                              m_allocator;
130
131         bool                                                                                    m_resultSetOnValidation;
132
133 private:
134                                                                                                 Context                                                         (const Context&); // Not allowed
135         Context&                                                                        operator=                                                       (const Context&); // Not allowed
136 };
137
138 class TestInstance;
139
140 class TestCase : public tcu::TestCase
141 {
142 public:
143                                                         TestCase                (tcu::TestContext& testCtx, const std::string& name, const std::string& description);
144                                                         TestCase                (tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description);
145         virtual                                 ~TestCase               (void) {}
146
147         virtual void                    delayedInit             (void); // non-const init called after checkSupport but before initPrograms
148         virtual void                    initPrograms    (vk::SourceCollections& programCollection) const;
149         virtual TestInstance*   createInstance  (Context& context) const = 0;
150         virtual void                    checkSupport    (Context& context) const;
151
152         IterateResult                   iterate                 (void) { DE_ASSERT(false); return STOP; } // Deprecated in this module
153 };
154
155 class TestInstance
156 {
157 public:
158                                                                 TestInstance    (Context& context) : m_context(context) {}
159         virtual                                         ~TestInstance   (void) {}
160
161         virtual tcu::TestStatus         iterate                 (void) = 0;
162
163 protected:
164         Context&                                        m_context;
165
166 private:
167                                                                 TestInstance    (const TestInstance&);
168         TestInstance&                           operator=               (const TestInstance&);
169 };
170
171 inline TestCase::TestCase (tcu::TestContext& testCtx, const std::string& name, const std::string& description)
172         : tcu::TestCase(testCtx, name.c_str(), description.c_str())
173 {
174 }
175
176 inline TestCase::TestCase (tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description)
177         : tcu::TestCase(testCtx, type, name.c_str(), description.c_str())
178 {
179 }
180
181 void collectAndReportDebugMessages(vk::DebugReportRecorder &debugReportRecorder, Context& context);
182
183 } // vkt
184
185 #endif // _VKTTESTCASE_HPP