tu: Generate entrypoints for each gen
authorDanylo Piliaiev <dpiliaiev@igalia.com>
Thu, 9 Mar 2023 18:57:51 +0000 (19:57 +0100)
committerMarge Bot <emma+marge@anholt.net>
Fri, 24 Mar 2023 15:49:26 +0000 (15:49 +0000)
Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21931>

src/freedreno/vulkan/meson.build
src/freedreno/vulkan/tu_common.h
src/freedreno/vulkan/tu_device.cc

index 19c1bd6..334a614 100644 (file)
@@ -4,10 +4,13 @@
 tu_entrypoints = custom_target(
   'tu_entrypoints',
   input : [vk_entrypoints_gen, vk_api_xml],
-  output : ['tu_entrypoints.h', 'tu_entrypoints.c'],
+  output : ['tu_entrypoints.h', 'tu_entrypoints.cc'],
   command : [
     prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
     '--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'tu',
+    '--include', 'adreno_common.xml.h',
+    '--tmpl-prefix', 'tu', '--tmpl-param', 'chip CHIP',
+    '--tmpl-variants', '<A6XX>', '<A7XX>',
   ],
   depend_files : vk_entrypoints_gen_depend_files,
 )
index 136760e..58ff178 100644 (file)
 #define TU_FROM_HANDLE(__tu_type, __name, __handle)                          \
    VK_FROM_HANDLE(__tu_type, __name, __handle)
 
+#define ACT_0(ACTION)
+#define ACT_1(ACTION, X) ACTION(X)
+#define ACT_2(ACTION, X, ...) ACTION(X) ACT_1(ACTION, __VA_ARGS__)
+#define ACT_3(ACTION, X, ...) ACTION(X) ACT_2(ACTION, __VA_ARGS__)
+#define ACT_4(ACTION, X, ...) ACTION(X) ACT_3(ACTION, __VA_ARGS__)
+#define ACT_5(ACTION, X, ...) ACTION(X) ACT_4(ACTION, __VA_ARGS__)
+#define ACT_6(ACTION, X, ...) ACTION(X) ACT_5(ACTION, __VA_ARGS__)
+
+#define GET_ACT_MACRO(_0, _1, _2, _3, _4, _5, _6, NAME, ...) NAME
+
+/* Do the action for the each vararg. It could be macro, function call, etc. */
+#define ACTION_FOR_EACH(action, ...)                                               \
+   GET_ACT_MACRO(_0, __VA_ARGS__, ACT_6, ACT_5, ACT_4, ACT_3, ACT_2, ACT_1, ACT_0) \
+   (action, __VA_ARGS__)
+
+#define TU_GPU_GENS A6XX, A7XX
+#define TU_GENX(entrypoint) \
+  ACTION_FOR_EACH(entrypoint ## _GENS, TU_GPU_GENS)
+
 /* vk object types */
 struct tu_buffer;
 struct tu_buffer_view;
index 1e3d40c..d8acc58 100644 (file)
@@ -2127,6 +2127,17 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice,
    struct vk_device_dispatch_table dispatch_table;
    vk_device_dispatch_table_from_entrypoints(
       &dispatch_table, &tu_device_entrypoints, true);
+
+   switch (fd_dev_gen(&physical_device->dev_id)) {
+   case 6:
+      vk_device_dispatch_table_from_entrypoints(
+         &dispatch_table, &tu_device_entrypoints_a6xx, false);
+      break;
+   case 7:
+      vk_device_dispatch_table_from_entrypoints(
+         &dispatch_table, &tu_device_entrypoints_a7xx, false);
+   }
+
    vk_device_dispatch_table_from_entrypoints(
       &dispatch_table, &wsi_device_entrypoints, false);