Add tests for VK_KHR_image_format_list
[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
31 namespace glu
32 {
33 struct ProgramSources;
34 }
35
36 namespace vk
37 {
38 class PlatformInterface;
39 class ProgramBinary;
40 template<typename Program> class ProgramCollection;
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::ProgramCollection<vk::ProgramBinary>&      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::ProgramCollection<vk::ProgramBinary>&       getBinaryCollection                             (void) const { return m_progCollection;         }
61
62         // Default instance & device, selected with --deqp-vk-device-id=N
63         const std::vector<std::string>&                         getInstanceExtensions                   (void) const;
64         vk::VkInstance                                                          getInstance                                             (void) const;
65         const vk::InstanceInterface&                            getInstanceInterface                    (void) const;
66         vk::VkPhysicalDevice                                            getPhysicalDevice                               (void) const;
67         const vk::VkPhysicalDeviceFeatures&                     getDeviceFeatures                               (void) const;
68         const vk::VkPhysicalDeviceProperties&           getDeviceProperties                             (void) const;
69         const std::vector<std::string>&                         getDeviceExtensions                             (void) const;
70         vk::VkDevice                                                            getDevice                                               (void) const;
71         const vk::DeviceInterface&                                      getDeviceInterface                              (void) const;
72         deUint32                                                                        getUniversalQueueFamilyIndex    (void) const;
73         vk::VkQueue                                                                     getUniversalQueue                               (void) const;
74
75         vk::Allocator&                                                          getDefaultAllocator                             (void) const;
76
77 protected:
78         tcu::TestContext&                                                       m_testCtx;
79         const vk::PlatformInterface&                            m_platformInterface;
80         vk::ProgramCollection<vk::ProgramBinary>&       m_progCollection;
81
82         const de::UniquePtr<DefaultDevice>                      m_device;
83         const de::UniquePtr<vk::Allocator>                      m_allocator;
84
85 private:
86                                                                                                 Context                                                 (const Context&); // Not allowed
87         Context&                                                                        operator=                                               (const Context&); // Not allowed
88 };
89
90
91 class TestInstance;
92
93 class TestCase : public tcu::TestCase
94 {
95 public:
96                                                         TestCase                (tcu::TestContext& testCtx, const std::string& name, const std::string& description);
97                                                         TestCase                (tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description);
98         virtual                                 ~TestCase               (void) {}
99
100         virtual void                    initPrograms    (vk::SourceCollections& programCollection) const;
101         virtual TestInstance*   createInstance  (Context& context) const = 0;
102
103         IterateResult                   iterate                 (void) { DE_ASSERT(false); return STOP; } // Deprecated in this module
104 };
105
106 class TestInstance
107 {
108 public:
109                                                                 TestInstance    (Context& context) : m_context(context) {}
110         virtual                                         ~TestInstance   (void) {}
111
112         virtual tcu::TestStatus         iterate                 (void) = 0;
113
114 protected:
115         Context&                                        m_context;
116
117 private:
118                                                                 TestInstance    (const TestInstance&);
119         TestInstance&                           operator=               (const TestInstance&);
120 };
121
122 inline TestCase::TestCase (tcu::TestContext& testCtx, const std::string& name, const std::string& description)
123         : tcu::TestCase(testCtx, name.c_str(), description.c_str())
124 {
125 }
126
127 inline TestCase::TestCase (tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description)
128         : tcu::TestCase(testCtx, type, name.c_str(), description.c_str())
129 {
130 }
131
132 } // vkt
133
134 #endif // _VKTTESTCASE_HPP