From a41e98ddcae038f88448bc3afe410c4e44072fa8 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 12 Mar 2021 07:30:39 -0500 Subject: [PATCH] vk/util: add a util macro for initializing stack vk_shader_module structs radv does a lot of this, so having a central dispatch point will be useful in case changes are made to this struct in the future Reviewed-by: Jason Ekstrand Part-of: --- src/vulkan/util/vk_shader_module.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/vulkan/util/vk_shader_module.h b/src/vulkan/util/vk_shader_module.h index baeed513308..d4e64dfc35a 100644 --- a/src/vulkan/util/vk_shader_module.h +++ b/src/vulkan/util/vk_shader_module.h @@ -43,6 +43,19 @@ struct vk_shader_module { VK_DEFINE_NONDISP_HANDLE_CASTS(vk_shader_module, base, VkShaderModule, VK_OBJECT_TYPE_SHADER_MODULE) + +/* this should only be used for stack-allocated, temporary objects */ +#define vk_shader_module_handle_from_nir(_nir) \ + vk_shader_module_to_handle(&(struct vk_shader_module) { \ + .base.type = VK_OBJECT_TYPE_SHADER_MODULE, \ + .nir = _nir, \ + }) +#define vk_shader_module_from_nir(_nir) \ + (struct vk_shader_module) { \ + .base.type = VK_OBJECT_TYPE_SHADER_MODULE, \ + .nir = _nir, \ + } + #ifdef __cplusplus } #endif