anv: compute the largest GRL kernel scratch size
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Thu, 30 Mar 2023 10:22:53 +0000 (13:22 +0300)
committerMarge Bot <emma+marge@anholt.net>
Fri, 31 Mar 2023 14:18:58 +0000 (14:18 +0000)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Felix DeGrood <felix.j.degrood@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22179>

src/intel/vulkan/anv_private.h
src/intel/vulkan/genX_state.c
src/intel/vulkan/grl/genX_grl.h
src/intel/vulkan/grl/genX_grl_dispatch.c

index e9b9a2a..cf9d67e 100644 (file)
@@ -1000,6 +1000,9 @@ struct anv_physical_device {
     uint8_t                                     device_uuid[VK_UUID_SIZE];
     uint8_t                                     rt_uuid[VK_UUID_SIZE];
 
+    /* Maximum amount of scratch space used by all the GRL kernels */
+    uint32_t                                    max_grl_scratch_size;
+
     struct vk_sync_type                         sync_syncobj_type;
     struct vk_sync_timeline_type                sync_timeline_type;
     const struct vk_sync_type *                 sync_types[4];
index 2639b9d..e6498e7 100644 (file)
@@ -527,6 +527,7 @@ genX(init_physical_device_state)(ASSERTED struct anv_physical_device *pdevice)
    assert(pdevice->info.verx10 == GFX_VERx10);
 #if GFX_VERx10 >= 125 && ANV_SUPPORT_RT
    genX(grl_load_rt_uuid)(pdevice->rt_uuid);
+   pdevice->max_grl_scratch_size = genX(grl_max_scratch_size)();
 #endif
 }
 
index 687edf7..57aefa7 100644 (file)
@@ -44,6 +44,9 @@ genX(grl_dispatch)(struct anv_cmd_buffer *cmd_buffer,
 void
 genX(grl_load_rt_uuid)(uint8_t *out_uuid);
 
+uint32_t
+genX(grl_max_scratch_size)(void);
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif
index 347a461..eff7c40 100644 (file)
@@ -90,3 +90,19 @@ genX(grl_dispatch)(struct anv_cmd_buffer *cmd_buffer,
    genX(cmd_buffer_dispatch_kernel)(cmd_buffer, &ak, global_size,
                                     arg_count, args);
 }
+
+uint32_t
+genX(grl_max_scratch_size)(void)
+{
+   uint32_t scratch_size = 0;
+
+   for (uint32_t i = 0; i < GRL_CL_KERNEL_MAX; i++) {
+      struct brw_kernel kernel_data;
+      genX(grl_get_cl_kernel)(&kernel_data, i);
+
+      scratch_size = MAX2(kernel_data.prog_data.base.total_scratch,
+                          scratch_size);
+   }
+
+   return scratch_size;
+}