Vulkan: correctly expose Vulkan entry points
This change fixes the advertisement of core Vulkan entry points as below:
1. GIPA returns a valid checked_proc for 1.1 core device APIs.
2. GDPA returns NULL for 1.1 core device APIs on a 1.0 physical device.
Bug: 134185757
Bug: 142266108
Test: dEQP-VK.memory.binding on 1.1 loader and 1.0 device ICD
Test: dEQP-VK.api.info.instance on 1.1 loader and 1.0 instance ICD
Change-Id: Ieb814516a4019f1a330178bfeb414e1450895c5c
Merged-In: I0a3e06dc04bade4f36a7e68ee2f53979c656ee4e
diff --git a/vulkan/libvulkan/code-generator.tmpl b/vulkan/libvulkan/code-generator.tmpl
index bdd3573..a5a0405 100644
--- a/vulkan/libvulkan/code-generator.tmpl
+++ b/vulkan/libvulkan/code-generator.tmpl
@@ -765,6 +765,19 @@
{{end}}
+
+{{/*
+------------------------------------------------------------------------------
+ Emits the ProcHook enum for core Vulkan API verions.
+------------------------------------------------------------------------------
+*/}}
+{{define "driver.GetProcHookEnum"}}
+ {{if GetAnnotation $ "vulkan1_1"}}ProcHook::EXTENSION_CORE_1_1
+ {{else}}ProcHook::EXTENSION_CORE_1_0
+ {{end}}
+{{end}}
+
+
{{/*
------------------------------------------------------------------------------
Emits true if a function needs a ProcHook stub.
@@ -778,6 +791,8 @@
{{if $ext}}
{{if not (Macro "IsExtensionInternal" $ext)}}true{{end}}
{{end}}
+
+ {{if GetAnnotation $ "vulkan1_1"}}true{{end}}
{{end}}
{{end}}
@@ -801,7 +816,8 @@
{{TrimPrefix "VK_" $e}},
{{end}}
¶
- EXTENSION_CORE, // valid bit
+ EXTENSION_CORE_1_0,
+ EXTENSION_CORE_1_1,
EXTENSION_COUNT,
EXTENSION_UNKNOWN,
};
@@ -838,14 +854,21 @@
{{AssertType $ "Function"}}
{{if (Macro "driver.NeedProcHookStub" $)}}
+ {{$ext_name := Strings ("")}}
+ {{$ext_hook := Strings ("")}}
{{$ext := GetAnnotation $ "extension"}}
- {{$ext_name := index $ext.Arguments 0}}
+ {{if $ext}}
+ {{$ext_name = index $ext.Arguments 0}}
+ {{$ext_hook = Strings ("ProcHook::") (Macro "BaseName" $ext)}}
+ {{else}}
+ {{$ext_name = Strings ("VK_VERSION_1_0")}}
+ {{$ext_hook = (Macro "driver.GetProcHookEnum" $)}}
+ {{end}}
{{$base := (Macro "BaseName" $)}}
VKAPI_ATTR {{Node "Type" $.Return}} checked{{$base}}({{Macro "Parameters" $}}) {
{{$p0 := index $.CallParameters 0}}
- {{$ext_hook := Strings ("ProcHook::") (Macro "BaseName" $ext)}}
if (GetData({{$p0.Name}}).hook_extensions[{{$ext_hook}}]) {
{{if not (IsVoid $.Return.Type)}}return §{{end}}
@@ -878,7 +901,7 @@
{
"{{$.Name}}",
ProcHook::GLOBAL,
- ProcHook::EXTENSION_CORE,
+ {{Macro "driver.GetProcHookEnum" $}},
reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
nullptr,
},
@@ -911,7 +934,7 @@
nullptr,
{{end}}
{{else}}
- ProcHook::EXTENSION_CORE,
+ {{Macro "driver.GetProcHookEnum" $}},
reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
nullptr,
{{end}}
@@ -934,18 +957,23 @@
ProcHook::DEVICE,
{{$ext := GetAnnotation $ "extension"}}
- {{if $ext}}
- ProcHook::{{Macro "BaseName" $ext}},
-
- {{if (Macro "IsExtensionInternal" $ext)}}
- nullptr,
- nullptr,
+ {{if or $ext (GetAnnotation $ "vulkan1_1")}}
+ {{if $ext}}
+ ProcHook::{{Macro "BaseName" $ext}},
+ {{if Macro "IsExtensionInternal" $ext}}
+ nullptr,
+ nullptr,
+ {{else}}
+ reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
+ reinterpret_cast<PFN_vkVoidFunction>(checked{{$base}}),
+ {{end}}
{{else}}
+ {{Macro "driver.GetProcHookEnum" $}},
reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
reinterpret_cast<PFN_vkVoidFunction>(checked{{$base}}),
{{end}}
{{else}}
- ProcHook::EXTENSION_CORE,
+ {{Macro "driver.GetProcHookEnum" $}},
reinterpret_cast<PFN_vkVoidFunction>({{$base}}),
nullptr,
{{end}}