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 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.
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.
34 * \brief Vulkan utilites.
35 *//*--------------------------------------------------------------------*/
37 #include "tcuDefs.hpp"
39 #if (DE_OS == DE_OS_ANDROID)
40 # include <sys/cdefs.h>
41 # if !defined(__NDK_FPABI__)
42 # define __NDK_FPABI__
44 # define VKAPI_ATTR __NDK_FPABI__
49 #if (DE_OS == DE_OS_WIN32) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED))
50 # define VKAPI_CALL __stdcall
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
58 #define VK_MAKE_VERSION(MAJOR, MINOR, PATCH) ((MAJOR << 22) | (MINOR << 12) | PATCH)
59 #define VK_BIT(NUM) (1<<NUM)
61 #define VK_CHECK(EXPR) vk::checkResult((EXPR), #EXPR, __FILE__, __LINE__)
62 #define VK_CHECK_MSG(EXPR, MSG) vk::checkResult((EXPR), MSG, __FILE__, __LINE__)
64 /*--------------------------------------------------------------------*//*!
65 * \brief Vulkan utilities
66 *//*--------------------------------------------------------------------*/
70 typedef deUint64 VkDeviceSize;
71 typedef deUint32 VkSampleMask;
72 typedef deUint32 VkBool32;
73 typedef deUint32 VkFlags;
75 // enum HandleType { HANDLE_TYPE_INSTANCE, ... };
76 #include "vkHandleType.inl"
78 template<HandleType Type>
82 Handle (void) {} // \note Left uninitialized on purpose
83 Handle (deUint64 internal) : m_internal(internal) {}
85 Handle& operator= (deUint64 internal) { m_internal = internal; return *this; }
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; }
90 bool operator! (void) const { return !m_internal; }
92 deUint64 getInternal (void) const { return m_internal; }
94 enum { HANDLE_TYPE = Type };
100 #include "vkBasicTypes.inl"
102 enum { VK_QUEUE_FAMILY_IGNORED = 0xffffffff };
103 enum { VK_NO_ATTACHMENT = 0xffffffff };
109 VK_WHOLE_SIZE = (~0ULL),
112 typedef VKAPI_ATTR void (VKAPI_CALL* PFN_vkVoidFunction) (void);
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);
120 #include "vkStructTypes.inl"
124 #include "vkFunctionPointerTypes.inl"
127 class PlatformInterface
130 #include "vkVirtualPlatformInterface.inl"
133 PlatformInterface (void) {}
136 PlatformInterface (const PlatformInterface&);
137 PlatformInterface& operator= (const PlatformInterface&);
140 class InstanceInterface
143 #include "vkVirtualInstanceInterface.inl"
146 InstanceInterface (void) {}
149 InstanceInterface (const InstanceInterface&);
150 InstanceInterface& operator= (const InstanceInterface&);
153 class DeviceInterface
156 #include "vkVirtualDeviceInterface.inl"
159 DeviceInterface (void) {}
162 DeviceInterface (const DeviceInterface&);
163 DeviceInterface& operator= (const DeviceInterface&);
166 class Error : public tcu::TestError
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();
173 VkResult getError (void) const { return m_error; }
176 const VkResult m_error;
179 class OutOfMemoryError : public tcu::ResourceError
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();
186 VkResult getError (void) const { return m_error; }
189 const VkResult m_error;
192 void checkResult (VkResult result, const char* message, const char* file, int line);
196 #endif // _VKDEFS_HPP