From 7eba054c5ba82b8a2366e5a340ec0b6376cc314c Mon Sep 17 00:00:00 2001 From: Christoph Neuhauser Date: Mon, 18 May 2026 19:42:26 +0200 Subject: [PATCH] anv: Add compute only divergent atomics fusion optimization for Blender Blender uses atomic operations as part of its virtual shadow mapping implementation. Virtual shadow mapping page tagging in compute shaders benefits from divergent atomics fusion, while fragment shaders doing the atomic raster step in general have worse performance with this optimization turned on. Thus, an option is added to only apply divergent atomics fusion to compute shaders in ANV, and this option is enabled for Blender. Initial support for divergent atomics fusion optimization in ANV was added in https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40631. Signed-off-by: Christoph Neuhauser Part-of: --- src/intel/vulkan/anv_instance.c | 3 +++ src/intel/vulkan/anv_private.h | 1 + src/intel/vulkan/anv_shader_compile.c | 7 +++++++ src/util/00-mesa-defaults.conf | 7 +++++++ src/util/driconf.h | 4 ++++ 5 files changed, 22 insertions(+) diff --git a/src/intel/vulkan/anv_instance.c b/src/intel/vulkan/anv_instance.c index 431e724643f..8fe85d7e1e2 100644 --- a/src/intel/vulkan/anv_instance.c +++ b/src/intel/vulkan/anv_instance.c @@ -43,6 +43,7 @@ static const driOptionDescription anv_dri_options[] = { DRI_CONF_ANV_FORCE_INDIRECT_DESCRIPTORS(false) DRI_CONF_ANV_DISABLE_LINK_TIME_OPTIMIZATION(false) DRI_CONF_ANV_ENABLE_OPT_DIVERGENT_ATOMICS(0) + DRI_CONF_ANV_ENABLE_OPT_DIVERGENT_ATOMICS_COMPUTE_ONLY(0) DRI_CONF_ANV_BRW_DISABLE_SUBGROUP_SIZE_CONTROL(false) DRI_CONF_SHADER_SPILLING_RATE(11) DRI_CONFIG_INTEL_FORCE_COMPUTE_SURFACE_PREFETCH(true) @@ -318,6 +319,8 @@ anv_init_dri_options(struct anv_instance *instance) driQueryOptionb(&instance->dri_options, "anv_disable_link_time_optimization"); instance->enable_opt_divergent_atomics = driQueryOptioni(&instance->dri_options, "anv_enable_opt_divergent_atomics"); + instance->enable_opt_divergent_atomics_compute_only = + driQueryOptioni(&instance->dri_options, "anv_enable_opt_divergent_atomics_compute_only"); instance->stack_ids = driQueryOptioni(&instance->dri_options, "intel_stack_id"); switch (instance->stack_ids) { diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index c39695398a3..4f632340ac3 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1813,6 +1813,7 @@ struct anv_instance { bool disable_lto; bool disable_push_constant_alloc; enum brw_divergent_atomics_flags enable_opt_divergent_atomics; + enum brw_divergent_atomics_flags enable_opt_divergent_atomics_compute_only; bool force_sampler_prefetch; bool force_compute_surface_prefetch; unsigned generated_indirect_threshold; diff --git a/src/intel/vulkan/anv_shader_compile.c b/src/intel/vulkan/anv_shader_compile.c index c2422110562..498d7e3ac89 100644 --- a/src/intel/vulkan/anv_shader_compile.c +++ b/src/intel/vulkan/anv_shader_compile.c @@ -665,7 +665,14 @@ populate_cs_prog_key(struct brw_cs_prog_key *key, const struct vk_physical_device *device, const struct vk_pipeline_robustness_state *rs) { + + const struct anv_physical_device *pdevice = + container_of(device, const struct anv_physical_device, vk); + populate_base_prog_key(&key->base, device, rs); + + key->base.divergent_atomics_flags |= + pdevice->instance->enable_opt_divergent_atomics_compute_only; } static void diff --git a/src/util/00-mesa-defaults.conf b/src/util/00-mesa-defaults.conf index 53a0e46f2f3..544517e0505 100644 --- a/src/util/00-mesa-defaults.conf +++ b/src/util/00-mesa-defaults.conf @@ -1157,6 +1157,13 @@ TODO: document the other workarounds. -->