wsi: Add acquired member to wsi_image

Tracks whether this wsi_image has been acquired by the app

Signed-off-by: Joshua Ashton <joshua@froggi.es>
This commit is contained in:
Joshua Ashton 2024-03-21 16:11:11 +00:00
parent e209b02b97
commit d9cbc79941
3 changed files with 19 additions and 1 deletions

View file

@ -1049,6 +1049,15 @@ wsi_ReleaseSwapchainImagesEXT(VkDevice _device,
const VkReleaseSwapchainImagesInfoEXT *pReleaseInfo) const VkReleaseSwapchainImagesInfoEXT *pReleaseInfo)
{ {
VK_FROM_HANDLE(wsi_swapchain, swapchain, pReleaseInfo->swapchain); VK_FROM_HANDLE(wsi_swapchain, swapchain, pReleaseInfo->swapchain);
for (uint32_t i = 0; i < pReleaseInfo->imageIndexCount; i++) {
uint32_t index = pReleaseInfo->pImageIndices[i];
assert(index < swapchain->image_count);
struct wsi_image *image = swapchain->get_wsi_image(swapchain, index);
assert(image->acquired);
image->acquired = false;
}
VkResult result = swapchain->release_images(swapchain, VkResult result = swapchain->release_images(swapchain,
pReleaseInfo->imageIndexCount, pReleaseInfo->imageIndexCount,
pReleaseInfo->pImageIndices); pReleaseInfo->pImageIndices);
@ -1208,6 +1217,8 @@ wsi_common_acquire_next_image2(const struct wsi_device *wsi,
struct wsi_image *image = struct wsi_image *image =
swapchain->get_wsi_image(swapchain, *pImageIndex); swapchain->get_wsi_image(swapchain, *pImageIndex);
image->acquired = true;
if (pAcquireInfo->semaphore != VK_NULL_HANDLE) { if (pAcquireInfo->semaphore != VK_NULL_HANDLE) {
VkResult signal_result = VkResult signal_result =
wsi_signal_semaphore_for_image(device, swapchain, image, wsi_signal_semaphore_for_image(device, swapchain, image,
@ -1458,6 +1469,10 @@ wsi_common_queue_present(const struct wsi_device *wsi,
if (result != VK_SUCCESS) if (result != VK_SUCCESS)
goto fail_present; goto fail_present;
/* The app can only submit images they have acquired. */
assert(image->acquired);
image->acquired = false;
#ifdef HAVE_LIBDRM #ifdef HAVE_LIBDRM
if (has_signal_dma_buf) { if (has_signal_dma_buf) {
result = wsi_signal_dma_buf_from_semaphore(swapchain, image); result = wsi_signal_dma_buf_from_semaphore(swapchain, image);

View file

@ -130,6 +130,10 @@ struct wsi_image {
VkDeviceMemory memory; VkDeviceMemory memory;
VkCommandBuffer *cmd_buffers; VkCommandBuffer *cmd_buffers;
} blit; } blit;
/* Whether or not the image has been acquired
* on the CPU side via acquire_next_image.
*/
bool acquired;
#ifndef _WIN32 #ifndef _WIN32
uint64_t drm_modifier; uint64_t drm_modifier;

View file

@ -1666,7 +1666,6 @@ wsi_wl_swapchain_release_images(struct wsi_swapchain *wsi_chain,
struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain; struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain;
for (uint32_t i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
uint32_t index = indices[i]; uint32_t index = indices[i];
assert(chain->images[index].busy);
chain->images[index].busy = false; chain->images[index].busy = false;
} }
return VK_SUCCESS; return VK_SUCCESS;