From 17d7b0bb8f00e3fd251c535c63d3253a2611e52b Mon Sep 17 00:00:00 2001 From: Hoe Hao Cheng Date: Thu, 27 May 2021 22:12:57 +0800 Subject: [PATCH] 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 Acked-By: Mike Blumenkrantz Part-of: --- 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 7b566ba..0966bc5 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 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 { }; -${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, -- 2.7.4