Treat AHB YUV as external format
... as it does not have an equivalent format in the
AHardwareBuffer Format Equivalence table in the Vulkan spec.
(Note: AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420 format handling
needs to be updated as we currently assume a 3 plane layout)
Bug: b/175132241
Test: launch Cuttlefish w/ SwANGLE and open Camera
Change-Id: I2ac6a9937b2fd75f559d654f1e179ea5bcfa456f
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/51051
Presubmit-Ready: Jason Macnak <natsu@google.com>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Vulkan/VkDeviceMemoryExternalAndroid.cpp b/src/Vulkan/VkDeviceMemoryExternalAndroid.cpp
index bf38a2f..f353e8a 100644
--- a/src/Vulkan/VkDeviceMemoryExternalAndroid.cpp
+++ b/src/Vulkan/VkDeviceMemoryExternalAndroid.cpp
@@ -398,6 +398,13 @@
pFormat->suggestedXChromaOffset = VK_CHROMA_LOCATION_COSITED_EVEN;
pFormat->suggestedYChromaOffset = VK_CHROMA_LOCATION_COSITED_EVEN;
+ // YUV formats are not listed in the AHardwareBuffer Format Equivalence table in the Vulkan spec.
+ // Clients must use VkExternalFormatANDROID.
+ if(pFormat->format == VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM)
+ {
+ pFormat->format = VK_FORMAT_UNDEFINED;
+ }
+
return VK_SUCCESS;
}