mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-19 13:18:32 +00:00
a/vk: Add mini defines helpers
This commit is contained in:
parent
0fb3e9a943
commit
42080b068c
|
@ -19,6 +19,7 @@ add_library(
|
|||
vk_image_allocator.h
|
||||
vk_image_readback_to_xf_pool.c
|
||||
vk_image_readback_to_xf_pool.h
|
||||
vk_mini_helpers.h
|
||||
vk_print.c
|
||||
vk_state_creators.c
|
||||
vk_surface_info.c
|
||||
|
|
45
src/xrt/auxiliary/vk/vk_mini_helpers.h
Normal file
45
src/xrt/auxiliary/vk/vk_mini_helpers.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
// Copyright 2019-2023, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
/*!
|
||||
* @file
|
||||
* @brief Super small defines that makes writing Vulkan code smaller.
|
||||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||
* @ingroup aux_vk
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "vk/vk_helpers.h"
|
||||
|
||||
|
||||
/*!
|
||||
* Calls `vkDestroy##TYPE` on @p THING if it is not @p VK_NULL_HANDLE, sets it
|
||||
* to @p VK_NULL_HANDLE afterwards. The implicit argument @p vk will be used to
|
||||
* look up the function, and @p vk->device will be used as the device.
|
||||
*
|
||||
* @param TYPE The type of the thing to be destroyed.
|
||||
* @param THING Object to be destroyed.
|
||||
*
|
||||
* @ingroup aux_vk
|
||||
*/
|
||||
#define D(TYPE, THING) \
|
||||
if (THING != VK_NULL_HANDLE) { \
|
||||
vk->vkDestroy##TYPE(vk->device, THING, NULL); \
|
||||
THING = VK_NULL_HANDLE; \
|
||||
}
|
||||
|
||||
/*!
|
||||
* Calls `vkFree##TYPE` on @p THING` if it is not @p VK_NULL_HANDLE, sets it to
|
||||
* @p VK_NULL_HANDLE afterwards. The implicit argument @p vk will be used to
|
||||
* look up the function, and @p vk->device will be used as the device.
|
||||
*
|
||||
* @param TYPE The type of the thing to be freed.
|
||||
* @param THING Object to be freed.
|
||||
*
|
||||
* @ingroup aux_vk
|
||||
*/
|
||||
#define DF(TYPE, THING) \
|
||||
if (THING != VK_NULL_HANDLE) { \
|
||||
vk->vkFree##TYPE(vk->device, THING, NULL); \
|
||||
THING = VK_NULL_HANDLE; \
|
||||
}
|
Loading…
Reference in a new issue