vulkan: do not query non-enabled WSI functions
Initialize dispatch table entries for non-enabled WSI functions to stubs.
We do not want to initialize them to NULL because they may still be
invoked through the exported WSI entrypoints.
Bug: 25850852
Change-Id: I25b715700990ad7432740f031764d70396024d32
diff --git a/vulkan/libvulkan/api.cpp b/vulkan/libvulkan/api.cpp
index eeb32d4..e7f10b3 100644
--- a/vulkan/libvulkan/api.cpp
+++ b/vulkan/libvulkan/api.cpp
@@ -465,6 +465,7 @@
VkExtensionProperties* driver_extensions_;
uint32_t driver_extension_count_;
+ std::bitset<driver::ProcHook::EXTENSION_COUNT> enabled_extensions_;
};
LayerChain::LayerChain(bool is_instance, const VkAllocationCallbacks& allocator)
@@ -477,7 +478,9 @@
get_instance_proc_addr_(nullptr),
get_device_proc_addr_(nullptr),
driver_extensions_(nullptr),
- driver_extension_count_(0) {}
+ driver_extension_count_(0) {
+ enabled_extensions_.set(driver::ProcHook::EXTENSION_CORE);
+}
LayerChain::~LayerChain() {
allocator_.pfnFree(allocator_.pUserData, driver_extensions_);
@@ -694,11 +697,11 @@
// initialize InstanceData
InstanceData& data = GetData(instance);
- memset(&data, 0, sizeof(data));
data.instance = instance;
- if (!InitDispatchTable(instance, get_instance_proc_addr_)) {
+ if (!InitDispatchTable(instance, get_instance_proc_addr_,
+ enabled_extensions_)) {
if (data.dispatch.DestroyInstance)
data.dispatch.DestroyInstance(instance, allocator);
@@ -774,9 +777,8 @@
// initialize DeviceData
DeviceData& data = GetData(dev);
- memset(&data, 0, sizeof(data));
- if (!InitDispatchTable(dev, get_device_proc_addr_)) {
+ if (!InitDispatchTable(dev, get_device_proc_addr_, enabled_extensions_)) {
if (data.dispatch.DestroyDevice)
data.dispatch.DestroyDevice(dev, allocator);
@@ -816,6 +818,10 @@
ALOGE("Failed to enable missing instance extension %s", name);
return VK_ERROR_EXTENSION_NOT_PRESENT;
}
+
+ auto ext_bit = driver::GetProcHookExtension(name);
+ if (ext_bit != driver::ProcHook::EXTENSION_UNKNOWN)
+ enabled_extensions_.set(ext_bit);
}
return VK_SUCCESS;
@@ -849,6 +855,10 @@
ALOGE("Failed to enable missing device extension %s", name);
return VK_ERROR_EXTENSION_NOT_PRESENT;
}
+
+ auto ext_bit = driver::GetProcHookExtension(name);
+ if (ext_bit != driver::ProcHook::EXTENSION_UNKNOWN)
+ enabled_extensions_.set(ext_bit);
}
return VK_SUCCESS;