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 <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9508>
This commit is contained in:
Mike Blumenkrantz 2021-03-12 07:30:39 -05:00 committed by Marge Bot
parent 76078ed9fe
commit a41e98ddca

View file

@ -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