Module: Mesa Branch: main Commit: e74a3284f53a9ae10e69236c6de548584f7c828c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e74a3284f53a9ae10e69236c6de548584f7c828c
Author: Marcin Ślusarz <[email protected]> Date: Mon Feb 27 16:33:46 2023 +0100 anv: halve the push constants space in mesh pipelines It's only used by fragment shaders, so halving it matches the size used in the most optimal primitive pipeline (VS + FS). This change frees some URB space for mesh and task shaders and as a result improves vk_meshlet_cadscene performance by up to 2%, depending on the model. Reviewed-by: José Roberto de Souza <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21559> --- src/intel/common/intel_urb_config.c | 2 +- src/intel/dev/intel_device_info.c | 8 ++++++++ src/intel/dev/intel_device_info.h | 6 ++++++ src/intel/vulkan/genX_cmd_buffer.c | 9 +++++++-- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/intel/common/intel_urb_config.c b/src/intel/common/intel_urb_config.c index d898683be93..f593f8c5d20 100644 --- a/src/intel/common/intel_urb_config.c +++ b/src/intel/common/intel_urb_config.c @@ -315,7 +315,7 @@ intel_get_mesh_urb_config(const struct intel_device_info *devinfo, * of entries, so we need to discount the space for constants for all of * them. See 3DSTATE_URB_ALLOC_MESH and 3DSTATE_URB_ALLOC_TASK. */ - const unsigned push_constant_kb = devinfo->max_constant_urb_size_kb; + const unsigned push_constant_kb = devinfo->mesh_max_constant_urb_size_kb; total_urb_kb -= push_constant_kb; /* TODO(mesh): Take push constant size as parameter instead of considering always diff --git a/src/intel/dev/intel_device_info.c b/src/intel/dev/intel_device_info.c index 7594e02254c..20eed6d4a2e 100644 --- a/src/intel/dev/intel_device_info.c +++ b/src/intel/dev/intel_device_info.c @@ -1317,6 +1317,14 @@ intel_get_device_info_from_pci_id(int pci_id, if (devinfo->display_ver == 0) devinfo->display_ver = devinfo->ver; + if (devinfo->has_mesh_shading) { + /* Half of push constant space matches the size used in the simplest + * primitive pipeline (VS + FS). Tweaking this affects performance. + */ + devinfo->mesh_max_constant_urb_size_kb = + devinfo->max_constant_urb_size_kb / 2; + } + intel_device_info_update_cs_workgroup_threads(devinfo); return true; diff --git a/src/intel/dev/intel_device_info.h b/src/intel/dev/intel_device_info.h index 8a6a7d7fb69..d7ad6af8bb0 100644 --- a/src/intel/dev/intel_device_info.h +++ b/src/intel/dev/intel_device_info.h @@ -369,6 +369,12 @@ struct intel_device_info */ unsigned max_constant_urb_size_kb; + /* Maximum size that can be allocated to constants in mesh pipeline. + * This essentially applies to fragment shaders only, since mesh stages + * don't need to allocate space for push constants. + */ + unsigned mesh_max_constant_urb_size_kb; + /** * Size of the command streamer prefetch. This is important to know for * self modifying batches. diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index 1af7dff8aca..dde5542cfd8 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -1920,8 +1920,13 @@ cmd_buffer_alloc_gfx_push_constants(struct anv_cmd_buffer *cmd_buffer) if (stages == cmd_buffer->state.gfx.push_constant_stages) return; - const unsigned push_constant_kb = - cmd_buffer->device->info->max_constant_urb_size_kb; + unsigned push_constant_kb; + + const struct intel_device_info *devinfo = cmd_buffer->device->info; + if (anv_pipeline_is_mesh(cmd_buffer->state.gfx.pipeline)) + push_constant_kb = devinfo->mesh_max_constant_urb_size_kb; + else + push_constant_kb = devinfo->max_constant_urb_size_kb; const unsigned num_stages = util_bitcount(stages & VK_SHADER_STAGE_ALL_GRAPHICS);
