monado/src/xrt/compositor/client/comp_vk_client.h
Christoph Haag 778515739f comp: Guard acquire/release with a fence
Fixes validation warning when acquiring images before the command buffer
of the previous acquire or release on the same queue has finished.

VUID-vkQueueSubmit-pCommandBuffers-00071(ERROR / SPEC): msgNum: 774851941 - Validation Error: [ VUID-vkQueueSubmit-pCommandBuffers-00071 ] Object 0: handle = 0x558634c5c750, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x2e2f4d65 | vkQueueSubmit(): pSubmits[0].pCommandBuffers[0] VkCommandBuffer 0x558634b85a10[] is already in use and is not marked for simultaneous use. The Vulkan spec states: If any element of the pCommandBuffers member of any element of pSubmits was not recorded with the VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT, it must not be in the pending state (https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VUID-vkQueueSubmit-pCommandBuffers-00071)
    Objects: 1
        [0] 0x558634c5c750, type: 3, name: NULL
2021-08-16 15:52:57 +02:00

103 lines
2.1 KiB
C

// Copyright 2019, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Vulkan client side glue to compositor header.
* @author Jakob Bornecrantz <jakob@collabora.com>
* @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
* @ingroup comp_client
*/
#pragma once
#include "vk/vk_helpers.h"
#include "xrt/xrt_gfx_vk.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
*
* Structs
*
*/
struct client_vk_compositor;
/*!
* Wraps the real compositor swapchain providing a Vulkan based interface.
*
* Almost a one to one mapping to a OpenXR swapchain.
*
* @ingroup comp_client
* @implements xrt_swapchain_vk
*/
struct client_vk_swapchain
{
struct xrt_swapchain_vk base;
//! Owning reference to the backing native swapchain.
struct xrt_swapchain_native *xscn;
//! Non-owning reference to our parent compositor.
struct client_vk_compositor *c;
// Memory
VkDeviceMemory mems[XRT_MAX_SWAPCHAIN_IMAGES];
// Prerecorded swapchain image ownership/layout transition barriers
VkCommandBuffer acquire[XRT_MAX_SWAPCHAIN_IMAGES];
VkCommandBuffer release[XRT_MAX_SWAPCHAIN_IMAGES];
VkFence acquire_release_fence[XRT_MAX_SWAPCHAIN_IMAGES];
};
/*!
* @class client_vk_compositor
*
* Wraps the real compositor providing a Vulkan based interface.
*
* @ingroup comp_client
* @implements xrt_compositor_vk
*/
struct client_vk_compositor
{
struct xrt_compositor_vk base;
//! Owning reference to the backing native compositor
struct xrt_compositor_native *xcn;
struct vk_bundle vk;
};
/*
*
* Functions and helpers.
*
*/
/*!
* Create a new client_vk_compositor.
*
* Takes owenership of provided xcn.
*
* @public @memberof client_vk_compositor
* @see xrt_compositor_native
*/
struct client_vk_compositor *
client_vk_compositor_create(struct xrt_compositor_native *xcn,
VkInstance instance,
PFN_vkGetInstanceProcAddr getProc,
VkPhysicalDevice physicalDevice,
VkDevice device,
uint32_t queueFamilyIndex,
uint32_t queueIndex);
#ifdef __cplusplus
}
#endif