Fix glu::FboRenderContext
[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) && defined(__ARM_ARCH_7A__)
40 #       define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
41 #else
42 #       define VKAPI_ATTR
43 #endif
44
45 #if (DE_OS == DE_OS_WIN32) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED))
46 #       define VKAPI_CALL __stdcall
47 #else
48 #       define VKAPI_CALL
49 #endif
50
51 #define VK_DEFINE_HANDLE(NAME, TYPE)                                    typedef struct NAME##_s* NAME
52 #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(NAME, TYPE)   typedef Handle<TYPE> NAME
53
54 #define VK_MAKE_VERSION(MAJOR, MINOR, PATCH)    ((MAJOR << 22) | (MINOR << 12) | PATCH)
55 #define VK_BIT(NUM)                                                             (1<<NUM)
56
57 #define VK_CHECK(EXPR)                                                  vk::checkResult((EXPR), #EXPR, __FILE__, __LINE__)
58 #define VK_CHECK_MSG(EXPR, MSG)                                 vk::checkResult((EXPR), MSG, __FILE__, __LINE__)
59
60 /*--------------------------------------------------------------------*//*!
61  * \brief Vulkan utilities
62  *//*--------------------------------------------------------------------*/
63 namespace vk
64 {
65
66 typedef deUint64        VkDeviceSize;
67 typedef deUint32        VkSampleMask;
68 typedef deUint32        VkBool32;
69 typedef deUint32        VkFlags;
70
71 // enum HandleType { HANDLE_TYPE_INSTANCE, ... };
72 #include "vkHandleType.inl"
73
74 template<HandleType Type>
75 class Handle
76 {
77 public:
78                                 Handle          (void) {} // \note Left uninitialized on purpose
79                                 Handle          (deUint64 internal) : m_internal(internal) {}
80
81         Handle&         operator=       (deUint64 internal)                                     { m_internal = internal; return *this;                  }
82
83         bool            operator==      (const Handle<Type>& other) const       { return this->m_internal == other.m_internal;  }
84         bool            operator!=      (const Handle<Type>& other) const       { return this->m_internal != other.m_internal;  }
85
86         bool            operator!       (void) const                                            { return !m_internal;                                                   }
87
88         deUint64        getInternal     (void) const                                            { return m_internal;                                                    }
89
90         enum { HANDLE_TYPE = Type };
91
92 private:
93         deUint64        m_internal;
94 };
95
96 #include "vkBasicTypes.inl"
97
98 enum { VK_QUEUE_FAMILY_IGNORED          = 0xffffffff    };
99 enum { VK_NO_ATTACHMENT                         = 0xffffffff    };
100
101 enum
102 {
103         VK_FALSE                = 0,
104         VK_TRUE                 = 1,
105         VK_WHOLE_SIZE   = (~0ULL),
106 };
107
108 typedef VKAPI_ATTR void         (VKAPI_CALL* PFN_vkVoidFunction)                                        (void);
109
110 typedef VKAPI_ATTR void*        (VKAPI_CALL* PFN_vkAllocationFunction)                          (void* pUserData, size_t size, size_t alignment, VkSystemAllocationScope allocationScope);
111 typedef VKAPI_ATTR void*        (VKAPI_CALL* PFN_vkReallocationFunction)                        (void* pUserData, void* pOriginal, size_t size, size_t alignment, VkSystemAllocationScope allocationScope);
112 typedef VKAPI_ATTR void         (VKAPI_CALL* PFN_vkFreeFunction)                                        (void* pUserData, void* pMem);
113 typedef VKAPI_ATTR void         (VKAPI_CALL* PFN_vkInternalAllocationNotification)      (void* pUserData, size_t size, VkInternalAllocationType allocationType, VkSystemAllocationScope allocationScope);
114 typedef VKAPI_ATTR void         (VKAPI_CALL* PFN_vkInternalFreeNotification)            (void* pUserData, size_t size, VkInternalAllocationType allocationType, VkSystemAllocationScope allocationScope);
115
116 #include "vkStructTypes.inl"
117
118 extern "C"
119 {
120 #include "vkFunctionPointerTypes.inl"
121 }
122
123 class PlatformInterface
124 {
125 public:
126 #include "vkVirtualPlatformInterface.inl"
127
128 protected:
129                                                 PlatformInterface       (void) {}
130
131 private:
132                                                 PlatformInterface       (const PlatformInterface&);
133         PlatformInterface&      operator=                       (const PlatformInterface&);
134 };
135
136 class InstanceInterface
137 {
138 public:
139 #include "vkVirtualInstanceInterface.inl"
140
141 protected:
142                                                 InstanceInterface       (void) {}
143
144 private:
145                                                 InstanceInterface       (const InstanceInterface&);
146         InstanceInterface&      operator=                       (const InstanceInterface&);
147 };
148
149 class DeviceInterface
150 {
151 public:
152 #include "vkVirtualDeviceInterface.inl"
153
154 protected:
155                                                 DeviceInterface         (void) {}
156
157 private:
158                                                 DeviceInterface         (const DeviceInterface&);
159         DeviceInterface&        operator=                       (const DeviceInterface&);
160 };
161
162 class Error : public tcu::TestError
163 {
164 public:
165                                         Error                           (VkResult error, const char* message, const char* expr, const char* file, int line);
166                                         Error                           (VkResult error, const std::string& message);
167         virtual                 ~Error                          (void) throw();
168
169         VkResult                getError                        (void) const { return m_error; }
170
171 private:
172         const VkResult  m_error;
173 };
174
175 class OutOfMemoryError : public tcu::ResourceError
176 {
177 public:
178                                         OutOfMemoryError        (VkResult error, const char* message, const char* expr, const char* file, int line);
179                                         OutOfMemoryError        (VkResult error, const std::string& message);
180         virtual                 ~OutOfMemoryError       (void) throw();
181
182         VkResult                getError                        (void) const { return m_error; }
183
184 private:
185         const VkResult  m_error;
186 };
187
188 void                    checkResult                     (VkResult result, const char* message, const char* file, int line);
189
190 } // vk
191
192 #endif // _VKDEFS_HPP