| 1 | // Copyright 2019-2023, Collabora, Ltd.cxx . . $ `<file>/src/xrt/auxiliary/vk/vk_mini_helpers.h`/ |
| 2 | // SPDX-License-Identifier: BSL-1.0 |
| 3 | /*! |
| 4 | * @file |
| 5 | * @brief Super small defines that makes writing Vulkan code smaller. |
| 6 | * @author Jakob Bornecrantz <[email protected]> |
| 7 | * @ingroup aux_vk |
| 8 | */ |
| 9 | |
| 10 | #pragma once |
| 11 | |
| 12 | #include "vk/vk_helpers.h"cxx . . $ `<file>/src/xrt/auxiliary/vk/vk_helpers.h`/ |
| 13 | |
| 14 | |
| 15 | /*! |
| 16 | * Calls `vkDestroy##TYPE` on @p THING if it is not @p VK_NULL_HANDLE, sets it |
| 17 | * to @p VK_NULL_HANDLE afterwards. The implicit argument @p vk will be used to |
| 18 | * look up the function, and @p vk->device will be used as the device. |
| 19 | * |
| 20 | * @param TYPE The type of the thing to be destroyed. |
| 21 | * @param THING Object to be destroyed. |
| 22 | * |
| 23 | * @ingroup aux_vk |
| 24 | */ |
| 25 | #define Dcxx . . $ `src/xrt/auxiliary/vk/vk_mini_helpers.h:25:9`!(TYPE, THING) \ |
| 26 | if (THING != VK_NULL_HANDLEcxx . . $ `<external>/13734482859137699468/vulkan_core.h:43:21`!) { \ |
| 27 | vk->vkDestroy##TYPE(vk->device, THING, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); \ |
| 28 | THING = VK_NULL_HANDLEcxx . . $ `<external>/13734482859137699468/vulkan_core.h:43:21`!; \ |
| 29 | } |
| 30 | |
| 31 | /*! |
| 32 | * Calls `vkFree##TYPE` on @p THING` if it is not @p VK_NULL_HANDLE, sets it to |
| 33 | * @p VK_NULL_HANDLE afterwards. The implicit argument @p vk will be used to |
| 34 | * look up the function, and @p vk->device will be used as the device. |
| 35 | * |
| 36 | * @param TYPE The type of the thing to be freed. |
| 37 | * @param THING Object to be freed. |
| 38 | * |
| 39 | * @ingroup aux_vk |
| 40 | */ |
| 41 | #define DFcxx . . $ `src/xrt/auxiliary/vk/vk_mini_helpers.h:41:9`!(TYPE, THING) \ |
| 42 | if (THING != VK_NULL_HANDLEcxx . . $ `<external>/13734482859137699468/vulkan_core.h:43:21`!) { \ |
| 43 | vk->vkFree##TYPE(vk->device, THING, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); \ |
| 44 | THING = VK_NULL_HANDLEcxx . . $ `<external>/13734482859137699468/vulkan_core.h:43:21`!; \ |
| 45 | } |