Implement Android shared image query so device creation can succeed

Bug: b/122837060
Change-Id: I8524a46d79e1327d494acc5ee494bad87bc9676b
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/30190
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Hernan Liatis <hliatis@google.com>
diff --git a/src/Vulkan/VkPhysicalDevice.cpp b/src/Vulkan/VkPhysicalDevice.cpp
index 5e1deab..b64b17b 100644
--- a/src/Vulkan/VkPhysicalDevice.cpp
+++ b/src/Vulkan/VkPhysicalDevice.cpp
@@ -328,6 +328,13 @@
 	properties->combinedImageSamplerDescriptorCount = 0;
 }
 
+#ifdef __ANDROID__
+void PhysicalDevice::getProperties(VkPhysicalDevicePresentationPropertiesANDROID* properties) const
+{
+	properties->sharedImage = VK_FALSE;
+}
+#endif
+
 void PhysicalDevice::getProperties(const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, VkExternalBufferProperties* pExternalBufferProperties) const
 {
 	pExternalBufferProperties->externalMemoryProperties.compatibleHandleTypes = 0;
diff --git a/src/Vulkan/VkPhysicalDevice.hpp b/src/Vulkan/VkPhysicalDevice.hpp
index e07ce79..11d5162 100644
--- a/src/Vulkan/VkPhysicalDevice.hpp
+++ b/src/Vulkan/VkPhysicalDevice.hpp
@@ -17,6 +17,10 @@
 
 #include "VkObject.hpp"
 
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+#include <vulkan/vk_android_native_buffer.h>
+#endif
+
 namespace vk
 {
 
@@ -49,6 +53,9 @@
 	void getProperties(VkPhysicalDeviceSubgroupProperties* properties) const;
 	void getProperties(const VkExternalMemoryHandleTypeFlagBits* handleType, VkExternalImageFormatProperties* properties) const;
 	void getProperties(VkSamplerYcbcrConversionImageFormatProperties* properties) const;
+#ifdef __ANDROID__
+	void getProperties(VkPhysicalDevicePresentationPropertiesANDROID* properties) const;
+#endif
 	void getProperties(const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, VkExternalBufferProperties* pExternalBufferProperties) const;
 	void getProperties(const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, VkExternalFenceProperties* pExternalFenceProperties) const;
 	void getProperties(const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, VkExternalSemaphoreProperties* pExternalSemaphoreProperties) const;
diff --git a/src/Vulkan/libVulkan.cpp b/src/Vulkan/libVulkan.cpp
index aaa2079..fb86db6 100644
--- a/src/Vulkan/libVulkan.cpp
+++ b/src/Vulkan/libVulkan.cpp
@@ -2035,7 +2035,9 @@
 	VkBaseOutStructure* extensionProperties = reinterpret_cast<VkBaseOutStructure*>(pProperties->pNext);
 	while(extensionProperties)
 	{
-		switch(extensionProperties->sType)
+		// Casting to a long since some structures, such as VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID
+		// are not enumerated in the official Vulkan header
+		switch((long)(extensionProperties->sType))
 		{
 		case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES:
 			{
@@ -2078,6 +2080,14 @@
 			ASSERT(!HasExtensionProperty(VK_EXT_SAMPLE_LOCATIONS_EXTENSION_NAME, deviceExtensionProperties,
 			                             sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
 			break;
+#ifdef __ANDROID__
+		case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID:
+			{
+				auto& properties = *reinterpret_cast<VkPhysicalDevicePresentationPropertiesANDROID*>(extensionProperties);
+				vk::Cast(physicalDevice)->getProperties(&properties);
+			}
+			break;
+#endif
 		default:
 			// "the [driver] must skip over, without processing (other than reading the sType and pNext members) any structures in the chain with sType values not defined by [supported extenions]"
 			UNIMPLEMENTED("extensionProperties->sType");   // TODO(b/119321052): UNIMPLEMENTED() should be used only for features that must still be implemented. Use a more informational macro here.