3 /*-------------------------------------------------------------------------
7 * Copyright (c) 2015 Google Inc.
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:
17 * The above copyright notice(s) and this permission notice shall be
18 * included in all copies or substantial portions of the Materials.
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.
30 * \brief Vulkan utilites.
31 *//*--------------------------------------------------------------------*/
33 #include "tcuDefs.hpp"
35 #if (DE_OS == DE_OS_ANDROID) && defined(__ARM_ARCH_7A__)
36 # define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
41 #if (DE_OS == DE_OS_WIN32) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED))
42 # define VKAPI_CALL __stdcall
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
50 #define VK_DEFINE_PLATFORM_TYPE(NAME, COMPATIBLE) \
53 COMPATIBLE internal; \
54 explicit NAME (COMPATIBLE internal_) \
55 : internal(internal_) {} \
59 #define VK_MAKE_VERSION(MAJOR, MINOR, PATCH) ((MAJOR << 22) | (MINOR << 12) | PATCH)
60 #define VK_BIT(NUM) (1<<NUM)
62 #define VK_CHECK(EXPR) vk::checkResult((EXPR), #EXPR, __FILE__, __LINE__)
63 #define VK_CHECK_MSG(EXPR, MSG) vk::checkResult((EXPR), MSG, __FILE__, __LINE__)
65 /*--------------------------------------------------------------------*//*!
66 * \brief Vulkan utilities
67 *//*--------------------------------------------------------------------*/
71 typedef deUint64 VkDeviceSize;
72 typedef deUint32 VkSampleMask;
73 typedef deUint32 VkBool32;
74 typedef deUint32 VkFlags;
76 // enum HandleType { HANDLE_TYPE_INSTANCE, ... };
77 #include "vkHandleType.inl"
79 template<HandleType Type>
83 Handle (void) {} // \note Left uninitialized on purpose
84 Handle (deUint64 internal) : m_internal(internal) {}
86 Handle& operator= (deUint64 internal) { m_internal = internal; return *this; }
88 bool operator== (const Handle<Type>& other) const { return this->m_internal == other.m_internal; }
89 bool operator!= (const Handle<Type>& other) const { return this->m_internal != other.m_internal; }
91 bool operator! (void) const { return !m_internal; }
93 deUint64 getInternal (void) const { return m_internal; }
95 enum { HANDLE_TYPE = Type };
101 #include "vkBasicTypes.inl"
103 enum { VK_QUEUE_FAMILY_IGNORED = 0xffffffff };
104 enum { VK_NO_ATTACHMENT = 0xffffffff };
110 VK_WHOLE_SIZE = (~0ULL),
130 typedef VKAPI_ATTR void (VKAPI_CALL* PFN_vkVoidFunction) (void);
132 typedef VKAPI_ATTR void* (VKAPI_CALL* PFN_vkAllocationFunction) (void* pUserData,
135 VkSystemAllocationScope allocationScope);
136 typedef VKAPI_ATTR void* (VKAPI_CALL* PFN_vkReallocationFunction) (void* pUserData,
140 VkSystemAllocationScope allocationScope);
141 typedef VKAPI_ATTR void (VKAPI_CALL* PFN_vkFreeFunction) (void* pUserData,
143 typedef VKAPI_ATTR void (VKAPI_CALL* PFN_vkInternalAllocationNotification) (void* pUserData,
145 VkInternalAllocationType allocationType,
146 VkSystemAllocationScope allocationScope);
147 typedef VKAPI_ATTR void (VKAPI_CALL* PFN_vkInternalFreeNotification) (void* pUserData,
149 VkInternalAllocationType allocationType,
150 VkSystemAllocationScope allocationScope);
152 typedef VKAPI_ATTR VkBool32 (VKAPI_CALL* PFN_vkDebugReportCallbackEXT) (VkDebugReportFlagsEXT flags,
153 VkDebugReportObjectTypeEXT objectType,
157 const char* pLayerPrefix,
158 const char* pMessage,
161 #include "vkStructTypes.inl"
165 #include "vkFunctionPointerTypes.inl"
168 class PlatformInterface
171 #include "vkVirtualPlatformInterface.inl"
174 PlatformInterface (void) {}
177 PlatformInterface (const PlatformInterface&);
178 PlatformInterface& operator= (const PlatformInterface&);
181 class InstanceInterface
184 #include "vkVirtualInstanceInterface.inl"
187 InstanceInterface (void) {}
190 InstanceInterface (const InstanceInterface&);
191 InstanceInterface& operator= (const InstanceInterface&);
194 class DeviceInterface
197 #include "vkVirtualDeviceInterface.inl"
200 DeviceInterface (void) {}
203 DeviceInterface (const DeviceInterface&);
204 DeviceInterface& operator= (const DeviceInterface&);
207 class Error : public tcu::TestError
210 Error (VkResult error, const char* message, const char* expr, const char* file, int line);
211 Error (VkResult error, const std::string& message);
212 virtual ~Error (void) throw();
214 VkResult getError (void) const { return m_error; }
217 const VkResult m_error;
220 class OutOfMemoryError : public tcu::ResourceError
223 OutOfMemoryError (VkResult error, const char* message, const char* expr, const char* file, int line);
224 OutOfMemoryError (VkResult error, const std::string& message);
225 virtual ~OutOfMemoryError (void) throw();
227 VkResult getError (void) const { return m_error; }
230 const VkResult m_error;
233 void checkResult (VkResult result, const char* message, const char* file, int line);
237 #endif // _VKDEFS_HPP