[Mesa-dev] [PATCH 2/4] vulkan/util: Add support to not generate the trampolines.

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Tue Aug 7 23:14:32 UTC 2018


radv does not need them and the trampolines need a dispatch
table in the instance and device.
---
 src/vulkan/util/vk_entrypoints_gen.py | 47 +++++++++++++++------------
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/src/vulkan/util/vk_entrypoints_gen.py b/src/vulkan/util/vk_entrypoints_gen.py
index 5caaa834aa2..7d0ff2698b8 100644
--- a/src/vulkan/util/vk_entrypoints_gen.py
+++ b/src/vulkan/util/vk_entrypoints_gen.py
@@ -61,7 +61,9 @@ struct ${name_prefix}_dispatch_table {
 %for layer in LAYERS:
 extern const struct ${name_prefix}_dispatch_table ${layer}_dispatch_table;
 %endfor
+%if generate_trampolines:
 extern const struct ${name_prefix}_dispatch_table ${name_prefix}_tramp_dispatch_table;
+%endif
 
 % for e in entrypoints:
   % if e.alias:
@@ -146,7 +148,7 @@ static const uint16_t string_map[${strmap.hash_size}] = {
 };
 
 int
-${name_prefix}_string_map_lookup(const char *str)
+${name_prefix}_get_entrypoint_index(const char *str)
 {
     static const uint32_t prime_factor = ${strmap.prime_factor};
     static const uint32_t prime_step = ${strmap.prime_step};
@@ -206,15 +208,16 @@ ${name_prefix}_string_map_lookup(const char *str)
 % endfor
 
 
+% if generate_trampolines:
 /** Trampoline entrypoints for all device functions */
 
-% for e in entrypoints:
-  % if e.alias or not e.is_device_entrypoint():
-    <% continue %>
-  % endif
-  % if e.guard is not None:
+  % for e in entrypoints:
+    % if e.alias or not e.is_device_entrypoint():
+      <% continue %>
+    % endif
+    % if e.guard is not None:
 #ifdef ${e.guard}
-  % endif
+    % endif
   static ${e.return_type}
   ${e.prefixed_name(name_prefix + '_tramp')}(${e.decl_params()})
   {
@@ -231,25 +234,26 @@ ${name_prefix}_string_map_lookup(const char *str)
       assert(!"Unhandled device child trampoline case: ${e.params[0].type}");
     % endif
   }
-  % if e.guard is not None:
+    % if e.guard is not None:
 #endif // ${e.guard}
-  % endif
-% endfor
+    % endif
+  % endfor
 
 const struct ${name_prefix}_dispatch_table ${name_prefix}_tramp_dispatch_table = {
-% for e in entrypoints:
-  % if not e.is_device_entrypoint():
-    <% continue %>
-  % endif
-  % if e.guard is not None:
+  % for e in entrypoints:
+    % if not e.is_device_entrypoint():
+      <% continue %>
+    % endif
+    % if e.guard is not None:
 #ifdef ${e.guard}
-  % endif
+    % endif
     .${e.name} = ${e.prefixed_name(name_prefix + '_tramp')},
-  % if e.guard is not None:
+    % if e.guard is not None:
 #endif // ${e.guard}
-  % endif
-% endfor
+    % endif
+  % endfor
 };
+%endif
 
 
 /** Return true if the core version or extension in which the given entrypoint
@@ -461,7 +465,8 @@ def get_entrypoints_defines(doc):
     return entrypoints_to_defines
 
 
-def generate_entrypoints(max_api_version, extensions, layers, name_prefix, xml_files, out_c, out_h, has_intel_entrypoints=False):
+def generate_entrypoints(max_api_version, extensions, layers, name_prefix, xml_files, out_c, out_h,
+                         has_intel_entrypoints=False, generate_trampolines=True):
     entrypoints = []
 
     for filename in xml_files:
@@ -495,11 +500,13 @@ def generate_entrypoints(max_api_version, extensions, layers, name_prefix, xml_f
             f.write(TEMPLATE_H.render(entrypoints=entrypoints,
                                       LAYERS=layers,
                                       name_prefix=name_prefix,
+                                      generate_trampolines=generate_trampolines,
                                       filename=os.path.basename(__file__)))
         with open(out_c, 'wb') as f:
             f.write(TEMPLATE_C.render(entrypoints=entrypoints,
                                       LAYERS=layers,
                                       name_prefix=name_prefix,
+                                      generate_trampolines=generate_trampolines,
                                       strmap=strmap,
                                       filename=os.path.basename(__file__)))
     except Exception:
-- 
2.18.0



More information about the mesa-dev mailing list