vulkan: Implement VkSurfaceKHR and use vulkanext.h
Between header version 0.183.0 and 0.184.0, a copy of vulkan.h which
includes extensions was added to the registry, called vulkanext.h. The
vulkan.h included here is actually the registry's vulkanext.h.
(In a later upstream change, the no-extensions version was removed
from the registry, and vulkanext.h was renamed vulkan.h, matching what
we're doing here.)
The version of the extensions picked up in the header file is later
than the ones used in the previous SDK, so this change also updates
our implementation to the extension versions included in the header.
The main change is replacing the VkSurfaceDescriptionKHR structure
with a VkSurfaceKHR object.
Change-Id: I18fa5a269db0fcdbdbde3e9304167bc15e456f85
(cherry picked from commit 957a59a48a8d2e81ca3bb52aacd8d08b1b43dc74)
diff --git a/vulkan/libvulkan/loader.h b/vulkan/libvulkan/loader.h
index 5e0a6c9..3e34e75 100644
--- a/vulkan/libvulkan/loader.h
+++ b/vulkan/libvulkan/loader.h
@@ -18,9 +18,8 @@
#define LIBVULKAN_LOADER_H 1
#define VK_PROTOTYPES
+#define VK_USE_PLATFORM_ANDROID_KHR
#include <vulkan/vulkan.h>
-#include <vulkan/vk_ext_khr_swapchain.h>
-#include <vulkan/vk_ext_khr_device_swapchain.h>
#include <vulkan/vk_ext_android_native_buffer.h>
namespace vulkan {
@@ -52,6 +51,8 @@
PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties;
// Layers and loader only, not implemented by drivers
+ PFN_vkCreateAndroidSurfaceKHR CreateAndroidSurfaceKHR;
+ PFN_vkDestroySurfaceKHR DestroySurfaceKHR;
PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
// clang-format on
};
@@ -230,11 +231,16 @@
VkCmdBuffer* cmdbuffers);
VkResult DestroyDevice(VkDevice drv_device);
-void* AllocDeviceMem(VkDevice device,
- size_t size,
- size_t align,
- VkSystemAllocType type);
-void FreeDeviceMem(VkDevice device, void* ptr);
+void* AllocMem(VkInstance instance,
+ size_t size,
+ size_t align,
+ VkSystemAllocType type);
+void FreeMem(VkInstance instance, void* ptr);
+void* AllocMem(VkDevice device,
+ size_t size,
+ size_t align,
+ VkSystemAllocType type);
+void FreeMem(VkDevice device, void* ptr);
const DeviceVtbl& GetDriverVtbl(VkDevice device);
const DeviceVtbl& GetDriverVtbl(VkQueue queue);
@@ -260,20 +266,22 @@
// -----------------------------------------------------------------------------
// swapchain.cpp
-VkResult GetPhysicalDeviceSurfaceSupportKHR(
- VkPhysicalDevice pdev,
- uint32_t queue_family,
- const VkSurfaceDescriptionKHR* surface_desc,
- VkBool32* supported);
+VkResult CreateAndroidSurfaceKHR(VkInstance instance,
+ ANativeWindow* window,
+ VkSurfaceKHR* surface);
+void DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface);
+VkBool32 GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice pdev,
+ uint32_t queue_family,
+ VkSurfaceKHR surface);
VkResult GetSurfacePropertiesKHR(VkDevice device,
- const VkSurfaceDescriptionKHR* surface_desc,
+ VkSurfaceKHR surface,
VkSurfacePropertiesKHR* properties);
VkResult GetSurfaceFormatsKHR(VkDevice device,
- const VkSurfaceDescriptionKHR* surface_desc,
+ VkSurfaceKHR surface,
uint32_t* count,
VkSurfaceFormatKHR* formats);
VkResult GetSurfacePresentModesKHR(VkDevice device,
- const VkSurfaceDescriptionKHR* surface_desc,
+ VkSurfaceKHR surface,
uint32_t* count,
VkPresentModeKHR* modes);
VkResult CreateSwapchainKHR(VkDevice device,