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) && defined(__ARM_ARCH_7A__)
40 # define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
45 #if (DE_OS == DE_OS_WIN32) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED))
46 # define VKAPI_CALL __stdcall
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
54 #define VK_MAKE_VERSION(MAJOR, MINOR, PATCH) ((MAJOR << 22) | (MINOR << 12) | PATCH)
55 #define VK_BIT(NUM) (1<<NUM)
57 #define VK_CHECK(EXPR) vk::checkResult((EXPR), #EXPR, __FILE__, __LINE__)
58 #define VK_CHECK_MSG(EXPR, MSG) vk::checkResult((EXPR), MSG, __FILE__, __LINE__)
60 /*--------------------------------------------------------------------*//*!
61 * \brief Vulkan utilities
62 *//*--------------------------------------------------------------------*/
66 typedef deUint64 VkDeviceSize;
67 typedef deUint32 VkSampleMask;
68 typedef deUint32 VkBool32;
69 typedef deUint32 VkFlags;
71 // enum HandleType { HANDLE_TYPE_INSTANCE, ... };
72 #include "vkHandleType.inl"
74 template<HandleType Type>
78 Handle (void) {} // \note Left uninitialized on purpose
79 Handle (deUint64 internal) : m_internal(internal) {}
81 Handle& operator= (deUint64 internal) { m_internal = internal; return *this; }
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; }
86 bool operator! (void) const { return !m_internal; }
88 deUint64 getInternal (void) const { return m_internal; }
90 enum { HANDLE_TYPE = Type };
96 #include "vkBasicTypes.inl"
98 enum { VK_QUEUE_FAMILY_IGNORED = 0xffffffff };
99 enum { VK_NO_ATTACHMENT = 0xffffffff };
105 VK_WHOLE_SIZE = (~0ULL),
108 typedef VKAPI_ATTR void (VKAPI_CALL* PFN_vkVoidFunction) (void);
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);
116 #include "vkStructTypes.inl"
120 #include "vkFunctionPointerTypes.inl"
123 class PlatformInterface
126 #include "vkVirtualPlatformInterface.inl"
129 PlatformInterface (void) {}
132 PlatformInterface (const PlatformInterface&);
133 PlatformInterface& operator= (const PlatformInterface&);
136 class InstanceInterface
139 #include "vkVirtualInstanceInterface.inl"
142 InstanceInterface (void) {}
145 InstanceInterface (const InstanceInterface&);
146 InstanceInterface& operator= (const InstanceInterface&);
149 class DeviceInterface
152 #include "vkVirtualDeviceInterface.inl"
155 DeviceInterface (void) {}
158 DeviceInterface (const DeviceInterface&);
159 DeviceInterface& operator= (const DeviceInterface&);
162 class Error : public tcu::TestError
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();
169 VkResult getError (void) const { return m_error; }
172 const VkResult m_error;
175 class OutOfMemoryError : public tcu::ResourceError
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();
182 VkResult getError (void) const { return m_error; }
185 const VkResult m_error;
188 void checkResult (VkResult result, const char* message, const char* file, int line);
192 #endif // _VKDEFS_HPP