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_MAKE_VERSION(MAJOR, MINOR, PATCH) ((MAJOR << 22) | (MINOR << 12) | PATCH)
51 #define VK_BIT(NUM) (1<<NUM)
53 #define VK_CHECK(EXPR) vk::checkResult((EXPR), #EXPR, __FILE__, __LINE__)
54 #define VK_CHECK_MSG(EXPR, MSG) vk::checkResult((EXPR), MSG, __FILE__, __LINE__)
56 /*--------------------------------------------------------------------*//*!
57 * \brief Vulkan utilities
58 *//*--------------------------------------------------------------------*/
62 typedef deUint64 VkDeviceSize;
63 typedef deUint32 VkSampleMask;
64 typedef deUint32 VkBool32;
65 typedef deUint32 VkFlags;
67 // enum HandleType { HANDLE_TYPE_INSTANCE, ... };
68 #include "vkHandleType.inl"
70 template<HandleType Type>
74 Handle (void) {} // \note Left uninitialized on purpose
75 Handle (deUint64 internal) : m_internal(internal) {}
77 Handle& operator= (deUint64 internal) { m_internal = internal; return *this; }
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; }
82 bool operator! (void) const { return !m_internal; }
84 deUint64 getInternal (void) const { return m_internal; }
86 enum { HANDLE_TYPE = Type };
92 #include "vkBasicTypes.inl"
94 enum { VK_QUEUE_FAMILY_IGNORED = 0xffffffff };
95 enum { VK_NO_ATTACHMENT = 0xffffffff };
101 VK_WHOLE_SIZE = (~0ULL),
104 typedef VKAPI_ATTR void (VKAPI_CALL* PFN_vkVoidFunction) (void);
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);
112 #include "vkStructTypes.inl"
116 #include "vkFunctionPointerTypes.inl"
119 class PlatformInterface
122 #include "vkVirtualPlatformInterface.inl"
125 PlatformInterface (void) {}
128 PlatformInterface (const PlatformInterface&);
129 PlatformInterface& operator= (const PlatformInterface&);
132 class InstanceInterface
135 #include "vkVirtualInstanceInterface.inl"
138 InstanceInterface (void) {}
141 InstanceInterface (const InstanceInterface&);
142 InstanceInterface& operator= (const InstanceInterface&);
145 class DeviceInterface
148 #include "vkVirtualDeviceInterface.inl"
151 DeviceInterface (void) {}
154 DeviceInterface (const DeviceInterface&);
155 DeviceInterface& operator= (const DeviceInterface&);
158 class Error : public tcu::TestError
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();
165 VkResult getError (void) const { return m_error; }
168 const VkResult m_error;
171 class OutOfMemoryError : public tcu::ResourceError
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();
178 VkResult getError (void) const { return m_error; }
181 const VkResult m_error;
184 void checkResult (VkResult result, const char* message, const char* file, int line);
188 #endif // _VKDEFS_HPP