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/get_proc_addr.cpp.tmpl b/vulkan/libvulkan/get_proc_addr.cpp.tmpl
index 6d5f618..c6ec0d1 100644
--- a/vulkan/libvulkan/get_proc_addr.cpp.tmpl
+++ b/vulkan/libvulkan/get_proc_addr.cpp.tmpl
@@ -78,7 +78,7 @@
const NameProcEntry kInstanceProcTbl[] = {«
// clang-format off
{{range $f := SortBy (AllCommands $) "FunctionName"}}
- {{if eq (Macro "Vtbl" $f) "Instance"}}
+ {{if and (Macro "IsDispatched" $f) (eq (Macro "Vtbl" $f) "Instance")}}
{"{{Macro "FunctionName" $f}}", reinterpret_cast<PFN_vkVoidFunction>({{Macro "FunctionName" $f}})},
{{end}}
{{end}}
@@ -88,7 +88,7 @@
const NameProcEntry kDeviceProcTbl[] = {«
// clang-format off
{{range $f := SortBy (AllCommands $) "FunctionName"}}
- {{if eq (Macro "Vtbl" $f) "Device"}}
+ {{if and (Macro "IsDispatched" $f) (eq (Macro "Vtbl" $f) "Device")}}
{"{{Macro "FunctionName" $f}}", reinterpret_cast<PFN_vkVoidFunction>({{Macro "FunctionName" $f}})},
{{end}}
{{end}}
@@ -98,7 +98,7 @@
const NameOffsetEntry kInstanceOffsetTbl[] = {«
// clang-format off
{{range $f := SortBy (AllCommands $) "FunctionName"}}
- {{if eq (Macro "Vtbl" $f) "Instance"}}
+ {{if and (Macro "IsDispatched" $f) (eq (Macro "Vtbl" $f) "Instance")}}
{"{{Macro "FunctionName" $f}}", offsetof(InstanceVtbl, {{TrimPrefix "vk" (Macro "FunctionName" $f)}})},
{{end}}
{{end}}
@@ -108,7 +108,7 @@
const NameOffsetEntry kDeviceOffsetTbl[] = {«
// clang-format off
{{range $f := SortBy (AllCommands $) "FunctionName"}}
- {{if eq (Macro "Vtbl" $f) "Device"}}
+ {{if and (Macro "IsDispatched" $f) (eq (Macro "Vtbl" $f) "Device")}}
{"{{Macro "FunctionName" $f}}", offsetof(DeviceVtbl, {{TrimPrefix "vk" (Macro "FunctionName" $f)}})},
{{end}}
{{end}}
@@ -194,7 +194,7 @@
{{end}}
{{range $f := AllCommands $}}
{{if eq (Macro "Vtbl" $f) "Instance"}}
- {{if (GetAnnotation $f "extension")}}
+ {{if and (GetAnnotation $f "extension") (Macro "IsDispatched" $f)}}
vtbl.{{TrimPrefix "vk" (Macro "FunctionName" $f)}} = §
reinterpret_cast<{{Macro "FunctionPtrName" $f}}>(§
get_proc_addr(instance, "{{Macro "FunctionName" $f}}"));
@@ -265,3 +265,32 @@
} // namespace vulkan
¶
{{end}}
+
+
+{{/*
+-------------------------------------------------------------------------------
+ This function emits nil for extension entrypoints that should not be
+ included in dispatch tables, "true" otherwise. Extensions that are ony used
+ directly between the loader and driver, or that aren't supported on Android
+ at all, should be excluded from dispatch.
+-------------------------------------------------------------------------------
+*/}}
+{{define "IsUnsupportedExtension"}}
+ {{$ext := index $.Arguments 0}}
+ {{ if eq $ext "VK_EXT_KHR_display"}}true
+ {{else if eq $ext "VK_EXT_KHR_display_swapchain"}}true
+ {{else if eq $ext "VK_EXT_KHR_x11_surface"}}true
+ {{else if eq $ext "VK_EXT_KHR_xcb_surface"}}true
+ {{else if eq $ext "VK_EXT_KHR_wayland_surface"}}true
+ {{else if eq $ext "VK_EXT_KHR_mir_surface"}}true
+ {{else if eq $ext "VK_EXT_KHR_win32_surface"}}true
+ {{end}}
+{{end}}
+
+{{define "IsDispatched"}}
+ {{AssertType $ "Function"}}
+ {{$ext := GetAnnotation $ "extension"}}
+ {{if not $ext}}true
+ {{else if not (Macro "IsUnsupportedExtension" $ext)}}true
+ {{end}}
+{{end}}