Vulkan: Improve error translation in CreateSwapChainKHR
Set VK_ERROR_OUT_OF_DEVICE_MEMORY in case the cause of the failure from
dequeueBuffer is an actual ENOMEM situation. Otherwise set
VK_ERROR_SURFACE_LOST_KHR as catch-all.
Bug: 145331195
Test: dEQP-VK.wsi.android.swapchain.create.image_extent
Change-Id: I8e7b4af3133e2a851beeda3618e24ca86279d317
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp
index 8f4667e..a020e74 100644
--- a/vulkan/libvulkan/swapchain.cpp
+++ b/vulkan/libvulkan/swapchain.cpp
@@ -1311,7 +1311,14 @@
&img.dequeue_fence);
if (err != 0) {
ALOGE("dequeueBuffer[%u] failed: %s (%d)", i, strerror(-err), err);
- result = VK_ERROR_SURFACE_LOST_KHR;
+ switch (-err) {
+ case ENOMEM:
+ result = VK_ERROR_OUT_OF_DEVICE_MEMORY;
+ break;
+ default:
+ result = VK_ERROR_SURFACE_LOST_KHR;
+ break;
+ }
break;
}
img.buffer = buffer;