Mesa (master): anv: Add a per-device dispatch table

Jason Ekstrand jekstrand at kemper.freedesktop.org
Tue Jan 23 08:38:21 UTC 2018


Module: Mesa
Branch: master
Commit: e3d27542aec33c7e0c2048a46a8a3cf71f09e907
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e3d27542aec33c7e0c2048a46a8a3cf71f09e907

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Tue Jan 16 18:24:56 2018 -0800

anv: Add a per-device dispatch table

We also switch GetDeviceProcAddr over to use it.

Reviewed-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>

---

 src/intel/vulkan/anv_device.c  | 44 +++++++++++++++++++++++++++++++++++++++++-
 src/intel/vulkan/anv_private.h |  1 +
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index d827aec9a7..e70ddf1799 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -1117,7 +1117,15 @@ PFN_vkVoidFunction anv_GetDeviceProcAddr(
     const char*                                 pName)
 {
    ANV_FROM_HANDLE(anv_device, device, _device);
-   return anv_lookup_entrypoint(&device->info, pName);
+
+   if (!device || !pName)
+      return NULL;
+
+   int idx = anv_get_entrypoint_index(pName);
+   if (idx < 0)
+      return NULL;
+
+   return device->dispatch.entrypoints[idx];
 }
 
 VkResult
@@ -1256,6 +1264,38 @@ VkResult anv_EnumerateDeviceExtensionProperties(
    return vk_outarray_status(&out);
 }
 
+static void
+anv_device_init_dispatch(struct anv_device *device)
+{
+   const struct anv_dispatch_table *genX_table;
+   switch (device->info.gen) {
+   case 10:
+      genX_table = &gen10_dispatch_table;
+      break;
+   case 9:
+      genX_table = &gen9_dispatch_table;
+      break;
+   case 8:
+      genX_table = &gen8_dispatch_table;
+      break;
+   case 7:
+      if (device->info.is_haswell)
+         genX_table = &gen75_dispatch_table;
+      else
+         genX_table = &gen7_dispatch_table;
+      break;
+   default:
+      unreachable("unsupported gen\n");
+   }
+
+   for (unsigned i = 0; i < ARRAY_SIZE(device->dispatch.entrypoints); i++) {
+      if (genX_table->entrypoints[i])
+         device->dispatch.entrypoints[i] = genX_table->entrypoints[i];
+      else
+         device->dispatch.entrypoints[i] = anv_dispatch_table.entrypoints[i];
+   }
+}
+
 VkResult anv_CreateDevice(
     VkPhysicalDevice                            physicalDevice,
     const VkDeviceCreateInfo*                   pCreateInfo,
@@ -1342,6 +1382,8 @@ VkResult anv_CreateDevice(
       pCreateInfo->pEnabledFeatures->robustBufferAccess;
    device->enabled_extensions = enabled_extensions;
 
+   anv_device_init_dispatch(device);
+
    if (pthread_mutex_init(&device->mutex, NULL) != 0) {
       result = vk_error(VK_ERROR_INITIALIZATION_FAILED);
       goto fail_context_id;
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index d1b2ebc11f..45dbcfdcb6 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -859,6 +859,7 @@ struct anv_device {
     bool                                        can_chain_batches;
     bool                                        robust_buffer_access;
     struct anv_device_extension_table           enabled_extensions;
+    struct anv_dispatch_table                   dispatch;
 
     struct anv_bo_pool                          batch_bo_pool;
 




More information about the mesa-commit mailing list