Merge vk-gl-cts/opengl-es-cts-3.2.7 into vk-gl-cts/master
[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         void*                                                                                   getInstanceProcAddr                                     ();
111
112         bool                                                                                    isBufferDeviceAddressSupported          (void) const;
113
114         bool                                                                                    resultSetOnValidation                           () const                { return m_resultSetOnValidation;       }
115         void                                                                                    resultSetOnValidation                           (bool value)    { m_resultSetOnValidation = value;      }
116
117         bool                                                                                    hasDebugReportRecorder                          () const;
118         vk::DebugReportRecorder&                                                getDebugReportRecorder                          () const;
119
120 protected:
121         tcu::TestContext&                                                               m_testCtx;
122         const vk::PlatformInterface&                                    m_platformInterface;
123         vk::BinaryCollection&                                                   m_progCollection;
124
125         const de::UniquePtr<DefaultDevice>                              m_device;
126         const de::UniquePtr<vk::Allocator>                              m_allocator;
127
128         bool                                                                                    m_resultSetOnValidation;
129
130 private:
131                                                                                                 Context                                                         (const Context&); // Not allowed
132         Context&                                                                        operator=                                                       (const Context&); // Not allowed
133 };
134
135 class TestInstance;
136
137 class TestCase : public tcu::TestCase
138 {
139 public:
140                                                         TestCase                (tcu::TestContext& testCtx, const std::string& name, const std::string& description);
141                                                         TestCase                (tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description);
142         virtual                                 ~TestCase               (void) {}
143
144         virtual void                    delayedInit             (void); // non-const init called after checkSupport but before initPrograms
145         virtual void                    initPrograms    (vk::SourceCollections& programCollection) const;
146         virtual TestInstance*   createInstance  (Context& context) const = 0;
147         virtual void                    checkSupport    (Context& context) const;
148
149         IterateResult                   iterate                 (void) { DE_ASSERT(false); return STOP; } // Deprecated in this module
150 };
151
152 class TestInstance
153 {
154 public:
155                                                                 TestInstance    (Context& context) : m_context(context) {}
156         virtual                                         ~TestInstance   (void) {}
157
158         virtual tcu::TestStatus         iterate                 (void) = 0;
159
160 protected:
161         Context&                                        m_context;
162
163 private:
164                                                                 TestInstance    (const TestInstance&);
165         TestInstance&                           operator=               (const TestInstance&);
166 };
167
168 inline TestCase::TestCase (tcu::TestContext& testCtx, const std::string& name, const std::string& description)
169         : tcu::TestCase(testCtx, name.c_str(), description.c_str())
170 {
171 }
172
173 inline TestCase::TestCase (tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description)
174         : tcu::TestCase(testCtx, type, name.c_str(), description.c_str())
175 {
176 }
177
178 void collectAndReportDebugMessages(vk::DebugReportRecorder &debugReportRecorder, Context& context);
179
180 } // vkt
181
182 #endif // _VKTTESTCASE_HPP