[Mesa-dev] [PATCH 16/21] anv: Add a per-instance dispatch table

Jason Ekstrand jason at jlekstrand.net
Sat Jan 20 19:11:51 UTC 2018


We also switch GetInstanceProcAddr over to use it.
---
 src/intel/vulkan/anv_device.c  | 7 ++++++-
 src/intel/vulkan/anv_private.h | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index dda283b..c85ccc9 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -573,6 +573,7 @@ VkResult anv_CreateInstance(
 
    instance->apiVersion = client_version;
    instance->enabled_extensions = enabled_extensions;
+   instance->dispatch = anv_dispatch_table;
    instance->physicalDeviceCount = -1;
 
    if (pthread_mutex_init(&instance->callbacks_mutex, NULL) != 0) {
@@ -1095,7 +1096,11 @@ PFN_vkVoidFunction anv_GetInstanceProcAddr(
    if (instance == NULL)
       return NULL;
 
-   return anv_lookup_entrypoint(NULL, pName);
+   int idx = anv_get_entrypoint_index(pName);
+   if (idx < 0)
+      return NULL;
+
+   return instance->dispatch.entrypoints[idx];
 }
 
 /* With version 1+ of the loader interface the ICD should expose
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 7d1cae1..81ec8b0 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -814,6 +814,7 @@ struct anv_instance {
 
     uint32_t                                    apiVersion;
     struct anv_instance_extension_table         enabled_extensions;
+    struct anv_dispatch_table                   dispatch;
 
     int                                         physicalDeviceCount;
     struct anv_physical_device                  physicalDevice;
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list