Mesa (main): vulkan/util: generate vk_dispatch_table that combines all dispatch tables

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun May 30 02:16:49 UTC 2021


Module: Mesa
Branch: main
Commit: 17d7b0bb8f00e3fd251c535c63d3253a2611e52b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=17d7b0bb8f00e3fd251c535c63d3253a2611e52b

Author: Hoe Hao Cheng <haochengho12907 at gmail.com>
Date:   Thu May 27 22:12:57 2021 +0800

vulkan/util: generate vk_dispatch_table that combines all dispatch tables

Zink uses this, as it doesn't need to differentiate all the entrypoints.

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11045>

---

 src/vulkan/util/vk_dispatch_table_gen.py | 40 +++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 6 deletions(-)

diff --git a/src/vulkan/util/vk_dispatch_table_gen.py b/src/vulkan/util/vk_dispatch_table_gen.py
index 7b566ba0f00..0966bc50fd6 100644
--- a/src/vulkan/util/vk_dispatch_table_gen.py
+++ b/src/vulkan/util/vk_dispatch_table_gen.py
@@ -67,8 +67,7 @@ TEMPLATE_H = Template(COPYRIGHT + """\
 extern "C" {
 #endif
 
-<%def name="dispatch_table(type, entrypoints)">
-struct vk_${type}_dispatch_table {
+<%def name="dispatch_table(entrypoints)">
 % for e in entrypoints:
   % if e.alias:
     <% continue %>
@@ -101,8 +100,9 @@ struct vk_${type}_dispatch_table {
 #endif
   % endif
 % endfor
-};
+</%def>
 
+<%def name="entrypoint_table(type, entrypoints)">
 struct vk_${type}_entrypoint_table {
 % for e in entrypoints:
   % if e.guard is not None:
@@ -118,9 +118,37 @@ struct vk_${type}_entrypoint_table {
 };
 </%def>
 
-${dispatch_table('instance', instance_entrypoints)}
-${dispatch_table('physical_device', physical_device_entrypoints)}
-${dispatch_table('device', device_entrypoints)}
+struct vk_instance_dispatch_table {
+  ${dispatch_table(instance_entrypoints)}
+};
+
+struct vk_physical_device_dispatch_table {
+  ${dispatch_table(physical_device_entrypoints)}
+};
+
+struct vk_device_dispatch_table {
+  ${dispatch_table(device_entrypoints)}
+};
+
+struct vk_dispatch_table {
+    union {
+        struct {
+            struct vk_instance_dispatch_table instance;
+            struct vk_physical_device_dispatch_table physical_device;
+            struct vk_device_dispatch_table device;
+        };
+
+        struct {
+            ${dispatch_table(instance_entrypoints)}
+            ${dispatch_table(physical_device_entrypoints)}
+            ${dispatch_table(device_entrypoints)}
+        };
+    };
+};
+
+${entrypoint_table('instance', instance_entrypoints)}
+${entrypoint_table('physical_device', physical_device_entrypoints)}
+${entrypoint_table('device', device_entrypoints)}
 
 void
 vk_instance_dispatch_table_load(struct vk_instance_dispatch_table *table,



More information about the mesa-commit mailing list