Add stubs for Native Buffer implementation

Bug: b/122837237
Change-Id: Ic9d306e11ff5dd64f6ba0f0f6cb3a1e9a882411a
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/30189
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Hernan Liatis <hliatis@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
diff --git a/src/Vulkan/VkGetProcAddress.cpp b/src/Vulkan/VkGetProcAddress.cpp
index e1d3f9c..1158d45 100644
--- a/src/Vulkan/VkGetProcAddress.cpp
+++ b/src/Vulkan/VkGetProcAddress.cpp
@@ -22,6 +22,7 @@
 #ifdef __ANDROID__
 #include <cerrno>
 #include <hardware/hwvulkan.h>
+#include <vulkan/vk_android_native_buffer.h>
 #endif
 
 namespace vk
@@ -266,6 +267,11 @@
 	MAKE_VULKAN_DEVICE_ENTRY(vkQueuePresentKHR),
 	MAKE_VULKAN_DEVICE_ENTRY(vkGetDeviceGroupPresentCapabilitiesKHR),
 	MAKE_VULKAN_DEVICE_ENTRY(vkGetDeviceGroupSurfacePresentModesKHR),
+#else
+	MAKE_VULKAN_DEVICE_ENTRY(vkGetSwapchainGrallocUsageANDROID),
+	MAKE_VULKAN_DEVICE_ENTRY(vkGetSwapchainGrallocUsage2ANDROID),
+	MAKE_VULKAN_DEVICE_ENTRY(vkAcquireImageANDROID),
+	MAKE_VULKAN_DEVICE_ENTRY(vkQueueSignalReleaseImageANDROID),
 #endif
 };
 #undef MAKE_VULKAN_DEVICE_ENTRY
diff --git a/src/Vulkan/libVulkan.cpp b/src/Vulkan/libVulkan.cpp
index 88b0312..aaa2079 100644
--- a/src/Vulkan/libVulkan.cpp
+++ b/src/Vulkan/libVulkan.cpp
@@ -46,6 +46,10 @@
 #include "WSI/XlibSurfaceKHR.hpp"
 #endif
 
+#ifdef __ANDROID__
+#include <vulkan/vk_android_native_buffer.h>
+#endif
+
 #include "WSI/VkSwapchainKHR.hpp"
 
 #include <algorithm>
@@ -122,6 +126,8 @@
 	{ VK_KHR_VARIABLE_POINTERS_EXTENSION_NAME, VK_KHR_VARIABLE_POINTERS_SPEC_VERSION },
 #ifndef __ANDROID__
 	{ VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_SWAPCHAIN_SPEC_VERSION },
+#else
+	{ VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME, VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION },
 #endif
 };
 
@@ -2503,4 +2509,39 @@
 
 #endif    // ! __ANDROID__
 
+#ifdef __ANDROID__
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsage2ANDROID(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, VkSwapchainImageUsageFlagsANDROID swapchainUsage, uint64_t* grallocConsumerUsage, uint64_t* grallocProducerUsage)
+{
+	TRACE("(VkDevice device = 0x%X, VkFormat format = 0x%X, VkImageUsageFlags imageUsage = 0x%X, VkSwapchainImageUsageFlagsANDROID swapchainUsage = 0x%X, uint64_t* grallocConsumerUsage = 0x%X, uin64_t* grallocProducerUsage = 0x%X)",
+			device, format, imageUsage, swapchainUsage, grallocConsumerUsage, grallocProducerUsage);
+
+	return VK_SUCCESS;
+}
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsageANDROID(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, int* grallocUsage)
+{
+	TRACE("(VkDevice device = 0x%X, VkFormat format = 0x%X, VkImageUsageFlags imageUsage = 0x%X, int* grallocUsage = 0x%X)",
+			device, format, imageUsage, grallocUsage);
+
+	return VK_SUCCESS;
+}
+
+VKAPI_ATTR VkResult VKAPI_CALL vkAcquireImageANDROID(VkDevice device, VkImage image, int nativeFenceFd, VkSemaphore semaphore, VkFence fence)
+{
+	TRACE("(VkDevice device = 0x%X, VkImage image = 0x%X, int nativeFenceFd = 0x%X, VkSemaphore semaphore = 0x%X, VkFence fence = 0x%X)",
+			device, image, nativeFenceFd, semaphore, fence);
+
+	return VK_SUCCESS;
+}
+
+VKAPI_ATTR VkResult VKAPI_CALL vkQueueSignalReleaseImageANDROID(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore* pWaitSemaphores, VkImage image, int* pNativeFenceFd)
+{
+	TRACE("(VkQueue queue = 0x%X, uint32_t waitSemaphoreCount = 0x%X, const VkSemaphore* pWaitSemaphores = 0x%X, VkImage image = 0x%X, int* pNativeFenceFd = 0x%X)",
+			queue, waitSemaphoreCount, pWaitSemaphores, image, pNativeFenceFd);
+
+	return VK_SUCCESS;
+}
+#endif // __ANDROID__
+
 }