Merge "Remove broken record_variable_selection test from MR1 must-pass." into lollipo...
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / framework / vulkan / vkDefs.hpp
1 #ifndef _VKDEFS_HPP
2 #define _VKDEFS_HPP
3 /*-------------------------------------------------------------------------
4  * Vulkan CTS Framework
5  * --------------------
6  *
7  * Copyright (c) 2015 Google Inc.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and/or associated documentation files (the
11  * "Materials"), to deal in the Materials without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Materials, and to
14  * permit persons to whom the Materials are furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice(s) and this permission notice shall be
18  * included in all copies or substantial portions of the Materials.
19  *
20  * The Materials are Confidential Information as defined by the
21  * Khronos Membership Agreement until designated non-confidential by
22  * Khronos, at which point this condition clause shall be removed.
23  *
24  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
27  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
28  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
29  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
30  * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
31  *
32  *//*!
33  * \file
34  * \brief Vulkan utilites.
35  *//*--------------------------------------------------------------------*/
36
37 #include "tcuDefs.hpp"
38
39 #if (DE_OS == DE_OS_ANDROID)
40 #       include <sys/cdefs.h>
41 #       if !defined(__NDK_FPABI__)
42 #               define __NDK_FPABI__
43 #       endif
44 #       define VKAPI_ATTR __NDK_FPABI__
45 #else
46 #       define VKAPI_ATTR
47 #endif
48
49 #if (DE_OS == DE_OS_WIN32) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED))
50 #       define VKAPI_CALL __stdcall
51 #else
52 #       define VKAPI_CALL
53 #endif
54
55 #define VK_DEFINE_HANDLE(NAME, TYPE)                                    typedef struct NAME##_s* NAME
56 #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(NAME, TYPE)   typedef Handle<TYPE> NAME
57
58 #define VK_MAKE_VERSION(MAJOR, MINOR, PATCH)    ((MAJOR << 22) | (MINOR << 12) | PATCH)
59 #define VK_BIT(NUM)                                                             (1<<NUM)
60
61 #define VK_CHECK(EXPR)                                                  vk::checkResult((EXPR), #EXPR, __FILE__, __LINE__)
62 #define VK_CHECK_MSG(EXPR, MSG)                                 vk::checkResult((EXPR), MSG, __FILE__, __LINE__)
63
64 /*--------------------------------------------------------------------*//*!
65  * \brief Vulkan utilities
66  *//*--------------------------------------------------------------------*/
67 namespace vk
68 {
69
70 typedef deUint64        VkDeviceSize;
71 typedef deUint32        VkSampleMask;
72 typedef deUint32        VkBool32;
73 typedef deUint32        VkFlags;
74
75 // enum HandleType { HANDLE_TYPE_INSTANCE, ... };
76 #include "vkHandleType.inl"
77
78 template<HandleType Type>
79 class Handle
80 {
81 public:
82                                 Handle          (void) {} // \note Left uninitialized on purpose
83                                 Handle          (deUint64 internal) : m_internal(internal) {}
84
85         Handle&         operator=       (deUint64 internal)                                     { m_internal = internal; return *this;                  }
86
87         bool            operator==      (const Handle<Type>& other) const       { return this->m_internal == other.m_internal;  }
88         bool            operator!=      (const Handle<Type>& other) const       { return this->m_internal != other.m_internal;  }
89
90         bool            operator!       (void) const                                            { return !m_internal;                                                   }
91
92         deUint64        getInternal     (void) const                                            { return m_internal;                                                    }
93
94         enum { HANDLE_TYPE = Type };
95
96 private:
97         deUint64        m_internal;
98 };
99
100 #include "vkBasicTypes.inl"
101
102 enum { VK_QUEUE_FAMILY_IGNORED          = 0xffffffff    };
103 enum { VK_NO_ATTACHMENT                         = 0xffffffff    };
104
105 enum
106 {
107         VK_FALSE                = 0,
108         VK_TRUE                 = 1,
109         VK_WHOLE_SIZE   = (~0ULL),
110 };
111
112 typedef VKAPI_ATTR void         (VKAPI_CALL* PFN_vkVoidFunction)                                        (void);
113
114 typedef VKAPI_ATTR void*        (VKAPI_CALL* PFN_vkAllocationFunction)                          (void* pUserData, size_t size, size_t alignment, VkSystemAllocationScope allocationScope);
115 typedef VKAPI_ATTR void*        (VKAPI_CALL* PFN_vkReallocationFunction)                        (void* pUserData, void* pOriginal, size_t size, size_t alignment, VkSystemAllocationScope allocationScope);
116 typedef VKAPI_ATTR void         (VKAPI_CALL* PFN_vkFreeFunction)                                        (void* pUserData, void* pMem);
117 typedef VKAPI_ATTR void         (VKAPI_CALL* PFN_vkInternalAllocationNotification)      (void* pUserData, size_t size, VkInternalAllocationType allocationType, VkSystemAllocationScope allocationScope);
118 typedef VKAPI_ATTR void         (VKAPI_CALL* PFN_vkInternalFreeNotification)            (void* pUserData, size_t size, VkInternalAllocationType allocationType, VkSystemAllocationScope allocationScope);
119
120 #include "vkStructTypes.inl"
121
122 extern "C"
123 {
124 #include "vkFunctionPointerTypes.inl"
125 }
126
127 class PlatformInterface
128 {
129 public:
130 #include "vkVirtualPlatformInterface.inl"
131
132 protected:
133                                                 PlatformInterface       (void) {}
134
135 private:
136                                                 PlatformInterface       (const PlatformInterface&);
137         PlatformInterface&      operator=                       (const PlatformInterface&);
138 };
139
140 class InstanceInterface
141 {
142 public:
143 #include "vkVirtualInstanceInterface.inl"
144
145 protected:
146                                                 InstanceInterface       (void) {}
147
148 private:
149                                                 InstanceInterface       (const InstanceInterface&);
150         InstanceInterface&      operator=                       (const InstanceInterface&);
151 };
152
153 class DeviceInterface
154 {
155 public:
156 #include "vkVirtualDeviceInterface.inl"
157
158 protected:
159                                                 DeviceInterface         (void) {}
160
161 private:
162                                                 DeviceInterface         (const DeviceInterface&);
163         DeviceInterface&        operator=                       (const DeviceInterface&);
164 };
165
166 class Error : public tcu::TestError
167 {
168 public:
169                                         Error                           (VkResult error, const char* message, const char* expr, const char* file, int line);
170                                         Error                           (VkResult error, const std::string& message);
171         virtual                 ~Error                          (void) throw();
172
173         VkResult                getError                        (void) const { return m_error; }
174
175 private:
176         const VkResult  m_error;
177 };
178
179 class OutOfMemoryError : public tcu::ResourceError
180 {
181 public:
182                                         OutOfMemoryError        (VkResult error, const char* message, const char* expr, const char* file, int line);
183                                         OutOfMemoryError        (VkResult error, const std::string& message);
184         virtual                 ~OutOfMemoryError       (void) throw();
185
186         VkResult                getError                        (void) const { return m_error; }
187
188 private:
189         const VkResult  m_error;
190 };
191
192 void                    checkResult                     (VkResult result, const char* message, const char* file, int line);
193
194 } // vk
195
196 #endif // _VKDEFS_HPP