Merge "Check for shader type support in negative shader directive tests" into nougat...
[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 enum MatrixLoadFlags
49 {
50         LOAD_FULL_MATRIX                = 0,
51         LOAD_MATRIX_COMPONENTS  = 1,
52 };
53
54 class DefaultDevice;
55
56 class Context
57 {
58 public:
59                                                                                                 Context                                                 (tcu::TestContext&                                                      testCtx,
60                                                                                                                                                                  const vk::PlatformInterface&                           platformInterface,
61                                                                                                                                                                  vk::ProgramCollection<vk::ProgramBinary>&      progCollection);
62                                                                                                 ~Context                                                (void);
63
64         tcu::TestContext&                                                       getTestContext                                  (void) const { return m_testCtx;                        }
65         const vk::PlatformInterface&                            getPlatformInterface                    (void) const { return m_platformInterface;      }
66         vk::ProgramCollection<vk::ProgramBinary>&       getBinaryCollection                             (void) const { return m_progCollection;         }
67
68         // Default instance & device, selected with --deqp-vk-device-id=N
69         vk::VkInstance                                                          getInstance                                             (void) const;
70         const vk::InstanceInterface&                            getInstanceInterface                    (void) const;
71         vk::VkPhysicalDevice                                            getPhysicalDevice                               (void) const;
72         const vk::VkPhysicalDeviceFeatures&                     getDeviceFeatures                               (void) const;
73         const vk::VkPhysicalDeviceProperties&           getDeviceProperties                             (void) const;
74         const std::vector<std::string>&                         getDeviceExtensions                             (void) const;
75         vk::VkDevice                                                            getDevice                                               (void) const;
76         const vk::DeviceInterface&                                      getDeviceInterface                              (void) const;
77         deUint32                                                                        getUniversalQueueFamilyIndex    (void) const;
78         vk::VkQueue                                                                     getUniversalQueue                               (void) const;
79
80         vk::Allocator&                                                          getDefaultAllocator                             (void) const;
81
82 protected:
83         tcu::TestContext&                                                       m_testCtx;
84         const vk::PlatformInterface&                            m_platformInterface;
85         vk::ProgramCollection<vk::ProgramBinary>&       m_progCollection;
86
87         const de::UniquePtr<DefaultDevice>                      m_device;
88         const de::UniquePtr<vk::Allocator>                      m_allocator;
89
90 private:
91                                                                                                 Context                                                 (const Context&); // Not allowed
92         Context&                                                                        operator=                                               (const Context&); // Not allowed
93 };
94
95
96 class TestInstance;
97
98 class TestCase : public tcu::TestCase
99 {
100 public:
101                                                         TestCase                (tcu::TestContext& testCtx, const std::string& name, const std::string& description);
102                                                         TestCase                (tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description);
103         virtual                                 ~TestCase               (void) {}
104
105         virtual void                    initPrograms    (vk::SourceCollections& programCollection) const;
106         virtual TestInstance*   createInstance  (Context& context) const = 0;
107
108         IterateResult                   iterate                 (void) { DE_ASSERT(false); return STOP; } // Deprecated in this module
109 };
110
111 class TestInstance
112 {
113 public:
114                                                                 TestInstance    (Context& context) : m_context(context) {}
115         virtual                                         ~TestInstance   (void) {}
116
117         virtual tcu::TestStatus         iterate                 (void) = 0;
118
119 protected:
120         Context&                                        m_context;
121
122 private:
123                                                                 TestInstance    (const TestInstance&);
124         TestInstance&                           operator=               (const TestInstance&);
125 };
126
127 inline TestCase::TestCase (tcu::TestContext& testCtx, const std::string& name, const std::string& description)
128         : tcu::TestCase(testCtx, name.c_str(), description.c_str())
129 {
130 }
131
132 inline TestCase::TestCase (tcu::TestContext& testCtx, tcu::TestNodeType type, const std::string& name, const std::string& description)
133         : tcu::TestCase(testCtx, type, name.c_str(), description.c_str())
134 {
135 }
136
137 } // vkt
138
139 #endif // _VKTTESTCASE_HPP