vulkan,anv: Move the DEFINE_HANDLE_CASTS macros to vk_object.h
We've already got these duplicated a bunch of places. They should
really probably live in common code. The new versions take two more
arguments:
1. The struct member which gets you from __driver_type to the
vk_object_base. This requires drivers which use this to also use
vk_object_base.
2. The VkObjectType enum which represents that object type.
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Kristian H. Kristensen <hoegsberg@google.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4690>
This commit is contained in:
committed by
Marge Bot
parent
682c81bdfb
commit
73fb7cdbe1
@@ -55,6 +55,37 @@ void vk_device_init(struct vk_device *device,
|
||||
const VkAllocationCallbacks *device_alloc);
|
||||
void vk_device_finish(struct vk_device *device);
|
||||
|
||||
#define VK_DEFINE_HANDLE_CASTS(__driver_type, __base, __VkType, __VK_TYPE) \
|
||||
static inline struct __driver_type * \
|
||||
__driver_type ## _from_handle(__VkType _handle) \
|
||||
{ \
|
||||
STATIC_ASSERT(offsetof(struct __driver_type, __base) == 0); \
|
||||
return (struct __driver_type *) _handle; \
|
||||
} \
|
||||
\
|
||||
static inline __VkType \
|
||||
__driver_type ## _to_handle(struct __driver_type *_obj) \
|
||||
{ \
|
||||
return (__VkType) _obj; \
|
||||
}
|
||||
|
||||
#define VK_DEFINE_NONDISP_HANDLE_CASTS(__driver_type, __base, __VkType, __VK_TYPE) \
|
||||
static inline struct __driver_type * \
|
||||
__driver_type ## _from_handle(__VkType _handle) \
|
||||
{ \
|
||||
STATIC_ASSERT(offsetof(struct __driver_type, __base) == 0); \
|
||||
return (struct __driver_type *)(uintptr_t) _handle; \
|
||||
} \
|
||||
\
|
||||
static inline __VkType \
|
||||
__driver_type ## _to_handle(struct __driver_type *_obj) \
|
||||
{ \
|
||||
return (__VkType)(uintptr_t) _obj; \
|
||||
}
|
||||
|
||||
#define VK_FROM_HANDLE(__driver_type, __name, __handle) \
|
||||
struct __driver_type *__name = __driver_type ## _from_handle(__handle)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user