diff options
author | Chris Forbes <chrisforbes@google.com> | 2017-03-30 19:48:39 +1300 |
---|---|---|
committer | Chris Forbes <chrisforbes@google.com> | 2017-03-31 17:50:40 +1300 |
commit | fca0f29e100d60163d408439f1a5750c353c9ade (patch) | |
tree | b04272ea623773020b5163bb7a2680b0f06cfc58 /vulkan | |
parent | c88409c2b8e99be8d5f134e260c4c29b1e632b3c (diff) | |
download | native-fca0f29e100d60163d408439f1a5750c353c9ade.tar.gz |
vulkan: Dequeue the shared buffer again after presenting
Ensures that the shared buffer is always dequeued. This is tidier than
the previous hacky approach of dequeueing it on demand just prior to
this.
Test: build
Change-Id: I0202271a12106470329180b51a2eea19ceab31af
Diffstat (limited to 'vulkan')
-rw-r--r-- | vulkan/libvulkan/swapchain.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp index a4f968a7b2..2fee8a5fbf 100644 --- a/vulkan/libvulkan/swapchain.cpp +++ b/vulkan/libvulkan/swapchain.cpp @@ -1440,6 +1440,7 @@ VkResult QueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* present_info) { static_cast<int64_t>(time->desiredPresentTime)); } } + err = window->queueBuffer(window, img.buffer.get(), fence); // queueBuffer always closes fence, even on error if (err != 0) { @@ -1454,6 +1455,30 @@ VkResult QueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* present_info) { img.dequeue_fence = -1; } img.dequeued = false; + + // If the swapchain is in shared mode, immediately dequeue the + // buffer so it can be presented again without an intervening + // call to AcquireNextImageKHR. We expect to get the same buffer + // back from every call to dequeueBuffer in this mode. + if (swapchain.shared && swapchain_result == VK_SUCCESS) { + ANativeWindowBuffer* buffer; + int fence_fd; + err = window->dequeueBuffer(window, &buffer, &fence_fd); + if (err != 0) { + ALOGE("dequeueBuffer failed: %s (%d)", strerror(-err), err); + swapchain_result = WorstPresentResult(swapchain_result, + VK_ERROR_SURFACE_LOST_KHR); + } + else if (img.buffer != buffer) { + ALOGE("got wrong image back for shared swapchain"); + swapchain_result = WorstPresentResult(swapchain_result, + VK_ERROR_SURFACE_LOST_KHR); + } + else { + img.dequeue_fence = fence_fd; + img.dequeued = true; + } + } } if (swapchain_result != VK_SUCCESS) { ReleaseSwapchainImage(device, window, fence, img); |