anv: Move the physical device dispatch table to anv_instance
authorJason Ekstrand <jason@jlekstrand.net>
Sat, 18 Jan 2020 05:17:48 +0000 (23:17 -0600)
committerMarge Bot <eric+marge@anholt.net>
Mon, 20 Jan 2020 22:08:52 +0000 (22:08 +0000)
We don't actually have genX versions of any physical device level
commands so we don't need the trampoline versions and we don't need to
have a separate table per physical device.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3461>

src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_entrypoints_gen.py
src/intel/vulkan/anv_private.h

index 880d8d9844c75258d014549366510ed156fa1da8..6d7c7ad3c979de4be317784e4e133bd8f8844c5f 100644 (file)
@@ -709,16 +709,15 @@ VkResult anv_CreateInstance(
       }
    }
 
-   struct anv_physical_device *pdevice = &instance->physicalDevice;
-   for (unsigned i = 0; i < ARRAY_SIZE(pdevice->dispatch.entrypoints); i++) {
+   for (unsigned i = 0; i < ARRAY_SIZE(instance->physical_device_dispatch.entrypoints); i++) {
       /* Vulkan requires that entrypoints for extensions which have not been
        * enabled must not be advertised.
        */
       if (!anv_physical_device_entrypoint_is_enabled(i, instance->app_info.api_version,
                                                      &instance->enabled_extensions)) {
-         pdevice->dispatch.entrypoints[i] = NULL;
+         instance->physical_device_dispatch.entrypoints[i] = NULL;
       } else {
-         pdevice->dispatch.entrypoints[i] =
+         instance->physical_device_dispatch.entrypoints[i] =
             anv_physical_device_dispatch_table.entrypoints[i];
       }
    }
@@ -2214,7 +2213,7 @@ PFN_vkVoidFunction anv_GetInstanceProcAddr(
 
    idx = anv_get_physical_device_entrypoint_index(pName);
    if (idx >= 0)
-      return instance->physicalDevice.dispatch.entrypoints[idx];
+      return instance->physical_device_dispatch.entrypoints[idx];
 
    idx = anv_get_device_entrypoint_index(pName);
    if (idx >= 0)
@@ -2276,7 +2275,7 @@ PFN_vkVoidFunction vk_icdGetPhysicalDeviceProcAddr(
    if (idx < 0)
       return NULL;
 
-   return instance->physicalDevice.dispatch.entrypoints[idx];
+   return instance->physical_device_dispatch.entrypoints[idx];
 }
 
 
index 6b90786577da282e89de931bc55cbd887d371324..b524897a0f6ef60a9a648e4b5ffafe258518fc98 100644 (file)
@@ -302,45 +302,30 @@ const struct anv_instance_dispatch_table anv_instance_dispatch_table = {
 % endfor
 };
 
-% for layer in LAYERS:
-  % for e in physical_device_entrypoints:
-    % if e.alias:
-      <% continue %>
-    % endif
-    % if e.guard is not None:
+% for e in physical_device_entrypoints:
+  % if e.alias and e.alias.enabled:
+    <% continue %>
+  % endif
+  % if e.guard is not None:
 #ifdef ${e.guard}
-    % endif
-    % if layer == 'anv':
-      ${e.return_type} __attribute__ ((weak))
-      ${e.prefixed_name('anv')}(${e.decl_params()})
-      {
-        % if e.params[0].type == 'VkPhysicalDevice':
-          ANV_FROM_HANDLE(anv_physical_device, anv_physical_device, ${e.params[0].name});
-          return anv_physical_device->dispatch.${e.name}(${e.call_params()});
-        % else:
-          assert(!"Unhandled device child trampoline case: ${e.params[0].type}");
-        % endif
-      }
-    % else:
-      ${e.return_type} ${e.prefixed_name(layer)}(${e.decl_params()}) __attribute__ ((weak));
-    % endif
-    % if e.guard is not None:
+  % endif
+  ${e.return_type} ${e.prefixed_name('anv')}(${e.decl_params()}) __attribute__ ((weak));
+  % if e.guard is not None:
 #endif // ${e.guard}
-    % endif
-  % endfor
+  % endif
+% endfor
 
-  const struct anv_physical_device_dispatch_table ${layer}_physical_device_dispatch_table = {
-  % for e in physical_device_entrypoints:
-    % if e.guard is not None:
+const struct anv_physical_device_dispatch_table anv_physical_device_dispatch_table = {
+% for e in physical_device_entrypoints:
+  % if e.guard is not None:
 #ifdef ${e.guard}
-    % endif
-    .${e.name} = ${e.prefixed_name(layer)},
-    % if e.guard is not None:
+  % endif
+  .${e.name} = ${e.prefixed_name('anv')},
+  % if e.guard is not None:
 #endif // ${e.guard}
-    % endif
-  % endfor
-  };
+  % endif
 % endfor
+};
 
 
 % for layer in LAYERS:
index afc1b14953e0bfbdb4d3f8e464f22ebfff3b122f..838f27dc45f2ef9a9c352ad701a0392ac7c8e59c 100644 (file)
@@ -1014,7 +1014,6 @@ struct anv_physical_device {
     bool                                        always_flush_cache;
 
     struct anv_device_extension_table           supported_extensions;
-    struct anv_physical_device_dispatch_table   dispatch;
 
     uint32_t                                    eu_total;
     uint32_t                                    subslice_total;
@@ -1055,6 +1054,7 @@ struct anv_instance {
 
     struct anv_instance_extension_table         enabled_extensions;
     struct anv_instance_dispatch_table          dispatch;
+    struct anv_physical_device_dispatch_table   physical_device_dispatch;
     struct anv_device_dispatch_table            device_dispatch;
 
     int                                         physicalDeviceCount;