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_MAKE_VERSION(MAJOR, MINOR, PATCH) (((deUint32)(MAJOR) << 22u) | ((deUint32)(MINOR) << 12u) | (deUint32)(PATCH))
44 #define VK_BIT(NUM) (1u<<(deUint32)(NUM))
46 #define VK_CHECK(EXPR) vk::checkResult((EXPR), #EXPR, __FILE__, __LINE__)
47 #define VK_CHECK_MSG(EXPR, MSG) vk::checkResult((EXPR), MSG, __FILE__, __LINE__)
49 /*--------------------------------------------------------------------*//*!
50 * \brief Vulkan utilities
51 *//*--------------------------------------------------------------------*/
55 typedef deUint64 VkDeviceSize;
56 typedef deUint32 VkSampleMask;
57 typedef deUint32 VkBool32;
58 typedef deUint32 VkFlags;
60 // enum HandleType { HANDLE_TYPE_INSTANCE, ... };
61 #include "vkHandleType.inl"
63 template<HandleType Type>
67 Handle (void) {} // \note Left uninitialized on purpose
68 Handle (deUint64 internal) : m_internal(internal) {}
70 Handle& operator= (deUint64 internal) { m_internal = internal; return *this; }
72 bool operator== (const Handle<Type>& other) const { return this->m_internal == other.m_internal; }
73 bool operator!= (const Handle<Type>& other) const { return this->m_internal != other.m_internal; }
75 bool operator! (void) const { return !m_internal; }
77 deUint64 getInternal (void) const { return m_internal; }
79 enum { HANDLE_TYPE = Type };
85 #include "vkBasicTypes.inl"
87 enum { VK_QUEUE_FAMILY_IGNORED = 0xffffffff };
88 enum { VK_NO_ATTACHMENT = 0xffffffff };
94 VK_WHOLE_SIZE = (~0ULL),
97 typedef VKAPI_ATTR void (VKAPI_CALL* PFN_vkVoidFunction) (void);
99 typedef VKAPI_ATTR void* (VKAPI_CALL* PFN_vkAllocationFunction) (void* pUserData,
102 VkSystemAllocationScope allocationScope);
103 typedef VKAPI_ATTR void* (VKAPI_CALL* PFN_vkReallocationFunction) (void* pUserData,
107 VkSystemAllocationScope allocationScope);
108 typedef VKAPI_ATTR void (VKAPI_CALL* PFN_vkFreeFunction) (void* pUserData,
110 typedef VKAPI_ATTR void (VKAPI_CALL* PFN_vkInternalAllocationNotification) (void* pUserData,
112 VkInternalAllocationType allocationType,
113 VkSystemAllocationScope allocationScope);
114 typedef VKAPI_ATTR void (VKAPI_CALL* PFN_vkInternalFreeNotification) (void* pUserData,
116 VkInternalAllocationType allocationType,
117 VkSystemAllocationScope allocationScope);
119 typedef VKAPI_ATTR VkBool32 (VKAPI_CALL* PFN_vkDebugReportCallbackEXT) (VkDebugReportFlagsEXT flags,
120 VkDebugReportObjectTypeEXT objectType,
124 const char* pLayerPrefix,
125 const char* pMessage,
128 #include "vkStructTypes.inl"
132 #include "vkFunctionPointerTypes.inl"
135 class PlatformInterface
138 #include "vkVirtualPlatformInterface.inl"
141 PlatformInterface (void) {}
144 PlatformInterface (const PlatformInterface&);
145 PlatformInterface& operator= (const PlatformInterface&);
148 class InstanceInterface
151 #include "vkVirtualInstanceInterface.inl"
154 InstanceInterface (void) {}
157 InstanceInterface (const InstanceInterface&);
158 InstanceInterface& operator= (const InstanceInterface&);
161 class DeviceInterface
164 #include "vkVirtualDeviceInterface.inl"
167 DeviceInterface (void) {}
170 DeviceInterface (const DeviceInterface&);
171 DeviceInterface& operator= (const DeviceInterface&);
174 class Error : public tcu::TestError
177 Error (VkResult error, const char* message, const char* expr, const char* file, int line);
178 Error (VkResult error, const std::string& message);
179 virtual ~Error (void) throw();
181 VkResult getError (void) const { return m_error; }
184 const VkResult m_error;
187 class OutOfMemoryError : public tcu::ResourceError
190 OutOfMemoryError (VkResult error, const char* message, const char* expr, const char* file, int line);
191 OutOfMemoryError (VkResult error, const std::string& message);
192 virtual ~OutOfMemoryError (void) throw();
194 VkResult getError (void) const { return m_error; }
197 const VkResult m_error;
200 void checkResult (VkResult result, const char* message, const char* file, int line);
204 #endif // _VKDEFS_HPP