Remove confidentiality clause from Vulkan CTS license
[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 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26  * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
27  *
28  *//*!
29  * \file
30  * \brief Vulkan utilites.
31  *//*--------------------------------------------------------------------*/
32
33 #include "tcuDefs.hpp"
34
35 #if (DE_OS == DE_OS_ANDROID) && defined(__ARM_ARCH_7A__)
36 #       define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
37 #else
38 #       define VKAPI_ATTR
39 #endif
40
41 #if (DE_OS == DE_OS_WIN32) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED))
42 #       define VKAPI_CALL __stdcall
43 #else
44 #       define VKAPI_CALL
45 #endif
46
47 #define VK_DEFINE_HANDLE(NAME, TYPE)                                    typedef struct NAME##_s* NAME
48 #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(NAME, TYPE)   typedef Handle<TYPE> NAME
49
50 #define VK_MAKE_VERSION(MAJOR, MINOR, PATCH)    ((MAJOR << 22) | (MINOR << 12) | PATCH)
51 #define VK_BIT(NUM)                                                             (1<<NUM)
52
53 #define VK_CHECK(EXPR)                                                  vk::checkResult((EXPR), #EXPR, __FILE__, __LINE__)
54 #define VK_CHECK_MSG(EXPR, MSG)                                 vk::checkResult((EXPR), MSG, __FILE__, __LINE__)
55
56 /*--------------------------------------------------------------------*//*!
57  * \brief Vulkan utilities
58  *//*--------------------------------------------------------------------*/
59 namespace vk
60 {
61
62 typedef deUint64        VkDeviceSize;
63 typedef deUint32        VkSampleMask;
64 typedef deUint32        VkBool32;
65 typedef deUint32        VkFlags;
66
67 // enum HandleType { HANDLE_TYPE_INSTANCE, ... };
68 #include "vkHandleType.inl"
69
70 template<HandleType Type>
71 class Handle
72 {
73 public:
74                                 Handle          (void) {} // \note Left uninitialized on purpose
75                                 Handle          (deUint64 internal) : m_internal(internal) {}
76
77         Handle&         operator=       (deUint64 internal)                                     { m_internal = internal; return *this;                  }
78
79         bool            operator==      (const Handle<Type>& other) const       { return this->m_internal == other.m_internal;  }
80         bool            operator!=      (const Handle<Type>& other) const       { return this->m_internal != other.m_internal;  }
81
82         bool            operator!       (void) const                                            { return !m_internal;                                                   }
83
84         deUint64        getInternal     (void) const                                            { return m_internal;                                                    }
85
86         enum { HANDLE_TYPE = Type };
87
88 private:
89         deUint64        m_internal;
90 };
91
92 #include "vkBasicTypes.inl"
93
94 enum { VK_QUEUE_FAMILY_IGNORED          = 0xffffffff    };
95 enum { VK_NO_ATTACHMENT                         = 0xffffffff    };
96
97 enum
98 {
99         VK_FALSE                = 0,
100         VK_TRUE                 = 1,
101         VK_WHOLE_SIZE   = (~0ULL),
102 };
103
104 typedef VKAPI_ATTR void         (VKAPI_CALL* PFN_vkVoidFunction)                                        (void);
105
106 typedef VKAPI_ATTR void*        (VKAPI_CALL* PFN_vkAllocationFunction)                          (void* pUserData, size_t size, size_t alignment, VkSystemAllocationScope allocationScope);
107 typedef VKAPI_ATTR void*        (VKAPI_CALL* PFN_vkReallocationFunction)                        (void* pUserData, void* pOriginal, size_t size, size_t alignment, VkSystemAllocationScope allocationScope);
108 typedef VKAPI_ATTR void         (VKAPI_CALL* PFN_vkFreeFunction)                                        (void* pUserData, void* pMem);
109 typedef VKAPI_ATTR void         (VKAPI_CALL* PFN_vkInternalAllocationNotification)      (void* pUserData, size_t size, VkInternalAllocationType allocationType, VkSystemAllocationScope allocationScope);
110 typedef VKAPI_ATTR void         (VKAPI_CALL* PFN_vkInternalFreeNotification)            (void* pUserData, size_t size, VkInternalAllocationType allocationType, VkSystemAllocationScope allocationScope);
111
112 #include "vkStructTypes.inl"
113
114 extern "C"
115 {
116 #include "vkFunctionPointerTypes.inl"
117 }
118
119 class PlatformInterface
120 {
121 public:
122 #include "vkVirtualPlatformInterface.inl"
123
124 protected:
125                                                 PlatformInterface       (void) {}
126
127 private:
128                                                 PlatformInterface       (const PlatformInterface&);
129         PlatformInterface&      operator=                       (const PlatformInterface&);
130 };
131
132 class InstanceInterface
133 {
134 public:
135 #include "vkVirtualInstanceInterface.inl"
136
137 protected:
138                                                 InstanceInterface       (void) {}
139
140 private:
141                                                 InstanceInterface       (const InstanceInterface&);
142         InstanceInterface&      operator=                       (const InstanceInterface&);
143 };
144
145 class DeviceInterface
146 {
147 public:
148 #include "vkVirtualDeviceInterface.inl"
149
150 protected:
151                                                 DeviceInterface         (void) {}
152
153 private:
154                                                 DeviceInterface         (const DeviceInterface&);
155         DeviceInterface&        operator=                       (const DeviceInterface&);
156 };
157
158 class Error : public tcu::TestError
159 {
160 public:
161                                         Error                           (VkResult error, const char* message, const char* expr, const char* file, int line);
162                                         Error                           (VkResult error, const std::string& message);
163         virtual                 ~Error                          (void) throw();
164
165         VkResult                getError                        (void) const { return m_error; }
166
167 private:
168         const VkResult  m_error;
169 };
170
171 class OutOfMemoryError : public tcu::ResourceError
172 {
173 public:
174                                         OutOfMemoryError        (VkResult error, const char* message, const char* expr, const char* file, int line);
175                                         OutOfMemoryError        (VkResult error, const std::string& message);
176         virtual                 ~OutOfMemoryError       (void) throw();
177
178         VkResult                getError                        (void) const { return m_error; }
179
180 private:
181         const VkResult  m_error;
182 };
183
184 void                    checkResult                     (VkResult result, const char* message, const char* file, int line);
185
186 } // vk
187
188 #endif // _VKDEFS_HPP