9d079c2924d6b0a1dd0d47a0f4b0a07e8b42f62b
[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
33 namespace glu
34 {
35 struct ProgramSources;
36 }
37
38 namespace vk
39 {
40 class PlatformInterface;
41 class Allocator;
42 struct SourceCollections;
43 }
44
45 namespace vkt
46 {
47
48 class DefaultDevice;
49
50 class Context
51 {
52 public:
53                                                                                                 Context                                                 (tcu::TestContext&                              testCtx,
54                                                                                                                                                                  const vk::PlatformInterface&   platformInterface,
55                                                                                                                                                                  vk::BinaryCollection&                  progCollection);
56                                                                                                 ~Context                                                (void);
57
58         tcu::TestContext&                                                       getTestContext                                  (void) const { return m_testCtx;                        }
59         const vk::PlatformInterface&                            getPlatformInterface                    (void) const { return m_platformInterface;      }
60         vk::BinaryCollection&                                           getBinaryCollection                             (void) const { return m_progCollection;         }
61
62         // Default instance & device, selected with --deqp-vk-device-id=N
63         deUint32                                                                        getAvailableInstanceVersion             (void) const;
64         const std::vector<std::string>&                         getInstanceExtensions                   (void) const;
65         vk::VkInstance                                                          getInstance                                             (void) const;
66         const vk::InstanceInterface&                            getInstanceInterface                    (void) const;
67         vk::VkPhysicalDevice                                            getPhysicalDevice                               (void) const;
68         deUint32                                                                        getDeviceVersion                                (void) const;
69         const vk::VkPhysicalDeviceFeatures&                     getDeviceFeatures                               (void) const;
70         const vk::VkPhysicalDeviceFeatures2&            getDeviceFeatures2                              (void) const;
71         const vk::VkPhysicalDeviceSamplerYcbcrConversionFeatures&
72                                                                                                 getSamplerYCbCrConversionFeatures
73                                                                                                                                                                 (void) const;
74         const vk::VkPhysicalDevice16BitStorageFeatures&
75                                                                                                 get16BitStorageFeatures                 (void) const;
76         const vk::VkPhysicalDeviceVariablePointerFeatures&
77                                                                                                 getVariablePointerFeatures              (void) const;
78         const vk::VkPhysicalDeviceProperties&           getDeviceProperties                             (void) const;
79         const std::vector<std::string>&                         getDeviceExtensions                             (void) const;
80         vk::VkDevice                                                            getDevice                                               (void) const;
81         const vk::DeviceInterface&                                      getDeviceInterface                              (void) const;
82         deUint32                                                                        getUniversalQueueFamilyIndex    (void) const;
83         vk::VkQueue                                                                     getUniversalQueue                               (void) const;
84         deUint32                                                                        getUsedApiVersion                               (void) const;
85         deUint32                                                                        getSparseQueueFamilyIndex               (void) const;
86         vk::VkQueue                                                                     getSparseQueue                                  (void) const;
87         vk::Allocator&                                                          getDefaultAllocator                             (void) const;
88         bool                                                                            contextSupports                                 (const deUint32 majorNum, const deUint32 minorNum, const deUint32 patchNum) const;
89         bool                                                                            contextSupports                                 (const vk::ApiVersion version) const;
90         bool                                                                            contextSupports                                 (const deUint32 requiredApiVersionBits) const;
91
92 protected:
93         tcu::TestContext&                                                       m_testCtx;
94         const vk::PlatformInterface&                            m_platformInterface;
95         vk::BinaryCollection&                                           m_progCollection;
96
97         const de::UniquePtr<DefaultDevice>                      m_device;
98         const de::UniquePtr<vk::Allocator>                      m_allocator;
99
100 private:
101                                                                                                 Context                                                 (const Context&); // Not allowed
102         Context&                                                                        operator=                                               (const Context&); // Not allowed
103 };
104
105 class TestInstance;
106
107 class TestCase : public tcu::TestCase
108 {
109 public:
110                                                         TestCase                (tcu::TestContext& testCtx, const std::string& name, const std::string& description);
111                                                         TestCase                (tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description);
112         virtual                                 ~TestCase               (void) {}
113
114         virtual void                    initPrograms    (vk::SourceCollections& programCollection) const;
115         virtual TestInstance*   createInstance  (Context& context) const = 0;
116
117         IterateResult                   iterate                 (void) { DE_ASSERT(false); return STOP; } // Deprecated in this module
118 };
119
120 class TestInstance
121 {
122 public:
123                                                                 TestInstance    (Context& context) : m_context(context) {}
124         virtual                                         ~TestInstance   (void) {}
125
126         virtual tcu::TestStatus         iterate                 (void) = 0;
127
128 protected:
129         Context&                                        m_context;
130
131 private:
132                                                                 TestInstance    (const TestInstance&);
133         TestInstance&                           operator=               (const TestInstance&);
134 };
135
136 inline TestCase::TestCase (tcu::TestContext& testCtx, const std::string& name, const std::string& description)
137         : tcu::TestCase(testCtx, name.c_str(), description.c_str())
138 {
139 }
140
141 inline TestCase::TestCase (tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description)
142         : tcu::TestCase(testCtx, type, name.c_str(), description.c_str())
143 {
144 }
145
146 } // vkt
147
148 #endif // _VKTTESTCASE_HPP