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