aux/vk: Add functions to initialize and clean up mutexes in the vk_bundle

This commit is contained in:
Ryan Pavlik 2021-03-30 11:49:51 -05:00 committed by Jakob Bornecrantz
parent 11bf681e3b
commit adb5eefb86
2 changed files with 44 additions and 0 deletions

View file

@ -1152,6 +1152,26 @@ err_destroy:
return ret;
}
VkResult
vk_init_mutex(struct vk_bundle *vk)
{
if (os_mutex_init(&vk->cmd_pool_mutex) < 0) {
return VK_ERROR_INITIALIZATION_FAILED;
}
if (os_mutex_init(&vk->queue_mutex) < 0) {
return VK_ERROR_INITIALIZATION_FAILED;
}
return VK_SUCCESS;
}
VkResult
vk_deinit_mutex(struct vk_bundle *vk)
{
os_mutex_destroy(&vk->cmd_pool_mutex);
os_mutex_destroy(&vk->queue_mutex);
return VK_SUCCESS;
}
VkResult
vk_init_from_given(struct vk_bundle *vk,
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr,

View file

@ -331,6 +331,23 @@ vk_get_loader_functions(struct vk_bundle *vk, PFN_vkGetInstanceProcAddr g);
VkResult
vk_get_instance_functions(struct vk_bundle *vk);
/*!
* @brief Initialize mutexes in the @ref vk_bundle.
*
* Not required for all uses, but a precondition for some.
*
* @ingroup aux_vk
*/
VkResult
vk_init_mutex(struct vk_bundle *vk);
/*!
* @brief De-initialize mutexes in the @ref vk_bundle.
* @ingroup aux_vk
*/
VkResult
vk_deinit_mutex(struct vk_bundle *vk);
/*!
* @ingroup aux_vk
*/
@ -464,12 +481,14 @@ vk_create_view_swizzle(struct vk_bundle *vk,
VkImageView *out_view);
/*!
* @pre Requires successful call to vk_init_mutex
* @ingroup aux_vk
*/
VkResult
vk_init_cmd_buffer(struct vk_bundle *vk, VkCommandBuffer *out_cmd_buffer);
/*!
* @pre Requires successful call to vk_init_mutex
* @ingroup aux_vk
*/
VkResult
@ -483,6 +502,7 @@ vk_set_image_layout(struct vk_bundle *vk,
VkImageSubresourceRange subresource_range);
/*!
* @pre Requires successful call to vk_init_mutex
* @ingroup aux_vk
*/
VkResult
@ -531,6 +551,10 @@ vk_buffer_destroy(struct vk_buffer *self, struct vk_bundle *vk);
bool
vk_update_buffer(struct vk_bundle *vk, float *buffer, size_t buffer_size, VkDeviceMemory memory);
/*!
* @pre Requires successful call to vk_init_mutex
* @ingroup aux_vk
*/
VkResult
vk_locked_submit(struct vk_bundle *vk, VkQueue queue, uint32_t count, const VkSubmitInfo *infos, VkFence fence);