3 /*-------------------------------------------------------------------------
7 * Copyright (c) 2015 Google Inc.
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief Vulkan utilites.
24 *//*--------------------------------------------------------------------*/
26 #include "tcuDefs.hpp"
28 #if (DE_OS == DE_OS_ANDROID) && defined(__ARM_ARCH_7A__)
29 # define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
34 #if (DE_OS == DE_OS_WIN32) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED))
35 # define VKAPI_CALL __stdcall
40 #define VK_DEFINE_HANDLE(NAME, TYPE) typedef struct NAME##_s* NAME
41 #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(NAME, TYPE) typedef Handle<TYPE> NAME
43 #define VK_DEFINE_PLATFORM_TYPE(NAME, COMPATIBLE) \
46 COMPATIBLE internal; \
47 explicit NAME (COMPATIBLE internal_) \
48 : internal(internal_) {} \
52 #define VK_MAKE_VERSION(MAJOR, MINOR, PATCH) ((MAJOR << 22) | (MINOR << 12) | PATCH)
53 #define VK_BIT(NUM) (1<<NUM)
55 #define VK_CHECK(EXPR) vk::checkResult((EXPR), #EXPR, __FILE__, __LINE__)
56 #define VK_CHECK_MSG(EXPR, MSG) vk::checkResult((EXPR), MSG, __FILE__, __LINE__)
58 /*--------------------------------------------------------------------*//*!
59 * \brief Vulkan utilities
60 *//*--------------------------------------------------------------------*/
64 typedef deUint64 VkDeviceSize;
65 typedef deUint32 VkSampleMask;
66 typedef deUint32 VkBool32;
67 typedef deUint32 VkFlags;
69 // enum HandleType { HANDLE_TYPE_INSTANCE, ... };
70 #include "vkHandleType.inl"
72 template<HandleType Type>
76 Handle (void) {} // \note Left uninitialized on purpose
77 Handle (deUint64 internal) : m_internal(internal) {}
79 Handle& operator= (deUint64 internal) { m_internal = internal; return *this; }
81 bool operator== (const Handle<Type>& other) const { return this->m_internal == other.m_internal; }
82 bool operator!= (const Handle<Type>& other) const { return this->m_internal != other.m_internal; }
84 bool operator! (void) const { return !m_internal; }
86 deUint64 getInternal (void) const { return m_internal; }
88 enum { HANDLE_TYPE = Type };
94 #include "vkBasicTypes.inl"
96 enum { VK_QUEUE_FAMILY_IGNORED = 0xffffffff };
97 enum { VK_NO_ATTACHMENT = 0xffffffff };
103 VK_WHOLE_SIZE = (~0ULL),
123 typedef VKAPI_ATTR void (VKAPI_CALL* PFN_vkVoidFunction) (void);
125 typedef VKAPI_ATTR void* (VKAPI_CALL* PFN_vkAllocationFunction) (void* pUserData,
128 VkSystemAllocationScope allocationScope);
129 typedef VKAPI_ATTR void* (VKAPI_CALL* PFN_vkReallocationFunction) (void* pUserData,
133 VkSystemAllocationScope allocationScope);
134 typedef VKAPI_ATTR void (VKAPI_CALL* PFN_vkFreeFunction) (void* pUserData,
136 typedef VKAPI_ATTR void (VKAPI_CALL* PFN_vkInternalAllocationNotification) (void* pUserData,
138 VkInternalAllocationType allocationType,
139 VkSystemAllocationScope allocationScope);
140 typedef VKAPI_ATTR void (VKAPI_CALL* PFN_vkInternalFreeNotification) (void* pUserData,
142 VkInternalAllocationType allocationType,
143 VkSystemAllocationScope allocationScope);
145 typedef VKAPI_ATTR VkBool32 (VKAPI_CALL* PFN_vkDebugReportCallbackEXT) (VkDebugReportFlagsEXT flags,
146 VkDebugReportObjectTypeEXT objectType,
150 const char* pLayerPrefix,
151 const char* pMessage,
154 #include "vkStructTypes.inl"
158 #include "vkFunctionPointerTypes.inl"
161 class PlatformInterface
164 #include "vkVirtualPlatformInterface.inl"
167 PlatformInterface (void) {}
170 PlatformInterface (const PlatformInterface&);
171 PlatformInterface& operator= (const PlatformInterface&);
174 class InstanceInterface
177 #include "vkVirtualInstanceInterface.inl"
180 InstanceInterface (void) {}
183 InstanceInterface (const InstanceInterface&);
184 InstanceInterface& operator= (const InstanceInterface&);
187 class DeviceInterface
190 #include "vkVirtualDeviceInterface.inl"
193 DeviceInterface (void) {}
196 DeviceInterface (const DeviceInterface&);
197 DeviceInterface& operator= (const DeviceInterface&);
200 class Error : public tcu::TestError
203 Error (VkResult error, const char* message, const char* expr, const char* file, int line);
204 Error (VkResult error, const std::string& message);
205 virtual ~Error (void) throw();
207 VkResult getError (void) const { return m_error; }
210 const VkResult m_error;
213 class OutOfMemoryError : public tcu::ResourceError
216 OutOfMemoryError (VkResult error, const char* message, const char* expr, const char* file, int line);
217 OutOfMemoryError (VkResult error, const std::string& message);
218 virtual ~OutOfMemoryError (void) throw();
220 VkResult getError (void) const { return m_error; }
223 const VkResult m_error;
226 void checkResult (VkResult result, const char* message, const char* file, int line);
230 #endif // _VKDEFS_HPP