Merge "Vulkan: avoid calling cancelBuffer on a shared buffer" into tm-dev
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp
index 45bc4c9..c4b1487 100644
--- a/vulkan/libvulkan/swapchain.cpp
+++ b/vulkan/libvulkan/swapchain.cpp
@@ -299,6 +299,7 @@
}
void ReleaseSwapchainImage(VkDevice device,
+ bool shared_present,
ANativeWindow* window,
int release_fence,
Swapchain::Image& image,
@@ -330,7 +331,8 @@
}
image.dequeue_fence = -1;
- if (window) {
+ // It's invalid to call cancelBuffer on a shared buffer
+ if (window && !shared_present) {
window->cancelBuffer(window, image.buffer.get(), release_fence);
} else {
if (release_fence >= 0) {
@@ -364,9 +366,10 @@
if (swapchain->surface.swapchain_handle != HandleFromSwapchain(swapchain))
return;
for (uint32_t i = 0; i < swapchain->num_images; i++) {
- if (!swapchain->images[i].dequeued)
- ReleaseSwapchainImage(device, nullptr, -1, swapchain->images[i],
- true);
+ if (!swapchain->images[i].dequeued) {
+ ReleaseSwapchainImage(device, swapchain->shared, nullptr, -1,
+ swapchain->images[i], true);
+ }
}
swapchain->surface.swapchain_handle = VK_NULL_HANDLE;
swapchain->timing.clear();
@@ -1084,7 +1087,8 @@
}
for (uint32_t i = 0; i < swapchain->num_images; i++) {
- ReleaseSwapchainImage(device, window, -1, swapchain->images[i], false);
+ ReleaseSwapchainImage(device, swapchain->shared, window, -1,
+ swapchain->images[i], false);
}
if (active) {
@@ -1854,7 +1858,8 @@
WorstPresentResult(swapchain_result, VK_SUBOPTIMAL_KHR);
}
} else {
- ReleaseSwapchainImage(device, nullptr, fence, img, true);
+ ReleaseSwapchainImage(device, swapchain.shared, nullptr, fence,
+ img, true);
swapchain_result = VK_ERROR_OUT_OF_DATE_KHR;
}