libvulkan: Implement new VkFence parameter in vkAcquireNextImageKHR
This parameter was added recently but wasn't hooked up. This adds a
new parameter to the vkAcquireImageANDROID extension function, and
plumbs the fence through from vkAcquireNextImageKHR to it.
This change also fixes some function signatures for API functions that
are implemented in the loader bottom rather than the driver. These
functions are only ever called through function pointers returned by
vkGet*ProcAddr, and therefore pass through a cast to
PFN_vkVoidFunction. So the compiler had no way to know they were
supposed to match a particular prototype, and couldn't issue an error
when they didn't. This change adds explicit static casts to the
expected function pointer type before reinterpret casting to the
generic function pointer type to enable compile errors.
Change-Id: I8a7e065502f783d5f2381b43c880644868234f8f
(cherry picked from commit f62f5de0c60212796b6d910cbd194c7002226264)
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp
index 39a581c..88e4d6f 100644
--- a/vulkan/libvulkan/swapchain.cpp
+++ b/vulkan/libvulkan/swapchain.cpp
@@ -487,9 +487,9 @@
}
VKAPI_ATTR
-VkResult DestroySwapchainKHR(VkDevice device,
- VkSwapchainKHR swapchain_handle,
- const VkAllocationCallbacks* /*allocator*/) {
+void DestroySwapchainKHR(VkDevice device,
+ VkSwapchainKHR swapchain_handle,
+ const VkAllocationCallbacks* /*allocator*/) {
const DeviceVtbl& driver_vtbl = GetDriverVtbl(device);
Swapchain* swapchain = SwapchainFromHandle(swapchain_handle);
const std::shared_ptr<ANativeWindow>& window = swapchain->surface.window;
@@ -509,8 +509,6 @@
swapchain->~Swapchain();
FreeMem(device, swapchain);
-
- return VK_SUCCESS;
}
VKAPI_ATTR
@@ -538,6 +536,7 @@
VkSwapchainKHR swapchain_handle,
uint64_t timeout,
VkSemaphore semaphore,
+ VkFence vk_fence,
uint32_t* image_index) {
Swapchain& swapchain = *SwapchainFromHandle(swapchain_handle);
ANativeWindow* window = swapchain.surface.window.get();
@@ -549,8 +548,8 @@
"vkAcquireNextImageKHR: non-infinite timeouts not yet implemented");
ANativeWindowBuffer* buffer;
- int fence;
- err = window->dequeueBuffer(window, &buffer, &fence);
+ int fence_fd;
+ err = window->dequeueBuffer(window, &buffer, &fence_fd);
if (err != 0) {
// TODO(jessehall): Improve error reporting. Can we enumerate possible
// errors and translate them to valid Vulkan result codes?
@@ -562,30 +561,31 @@
for (idx = 0; idx < swapchain.num_images; idx++) {
if (swapchain.images[idx].buffer.get() == buffer) {
swapchain.images[idx].dequeued = true;
- swapchain.images[idx].dequeue_fence = fence;
+ swapchain.images[idx].dequeue_fence = fence_fd;
break;
}
}
if (idx == swapchain.num_images) {
ALOGE("dequeueBuffer returned unrecognized buffer");
- window->cancelBuffer(window, buffer, fence);
+ window->cancelBuffer(window, buffer, fence_fd);
return VK_ERROR_OUT_OF_DATE_KHR;
}
int fence_clone = -1;
- if (fence != -1) {
- fence_clone = dup(fence);
+ if (fence_fd != -1) {
+ fence_clone = dup(fence_fd);
if (fence_clone == -1) {
ALOGE("dup(fence) failed, stalling until signalled: %s (%d)",
strerror(errno), errno);
- sync_wait(fence, -1 /* forever */);
+ sync_wait(fence_fd, -1 /* forever */);
}
}
const DeviceVtbl& driver_vtbl = GetDriverVtbl(device);
if (driver_vtbl.AcquireImageANDROID) {
- result = driver_vtbl.AcquireImageANDROID(
- device, swapchain.images[idx].image, fence_clone, semaphore);
+ result =
+ driver_vtbl.AcquireImageANDROID(device, swapchain.images[idx].image,
+ fence_clone, semaphore, vk_fence);
} else {
ALOG_ASSERT(driver_vtbl.ImportNativeFenceANDROID,
"Have neither vkAcquireImageANDROID nor "
@@ -601,7 +601,7 @@
// number between the time the driver closes it and the time we close
// it. We must assume one of: the driver *always* closes it even on
// failure, or *never* closes it on failure.
- window->cancelBuffer(window, buffer, fence);
+ window->cancelBuffer(window, buffer, fence_fd);
swapchain.images[idx].dequeued = false;
swapchain.images[idx].dequeue_fence = -1;
return result;