From 7a627fa8f31657fcd3ee780dadf7fa5033464c13 Mon Sep 17 00:00:00 2001 From: Sagar Ghuge Date: Thu, 16 Apr 2026 15:20:46 -0700 Subject: [PATCH] anv: Fix Wa_14021821874, Wa_14018813551, Wa_14026600921 StackSizePerRay is the RTDispatchGlobals::AsyncStackSize and DisableRTGlobalsKnownValues is to interpret how many Max BVH levels we need to use. It's not relevant to Vulkan, since we have just 2 fixed BVH levels. Fixes: cb423ee6 ("anv: Fix Wa_14021821874, Wa_14018813551, Wa_14026600921") Fixes: c1a44e8d ("anv: force StackIDControl value for Wa_14021821874") Signed-off-by: Sagar Ghuge Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/compiler/brw/brw_rt.h | 32 +++++++++++++++++++++++++---- src/intel/vulkan/genX_cmd_compute.c | 3 ++- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/intel/compiler/brw/brw_rt.h b/src/intel/compiler/brw/brw_rt.h index 8ec39946a56..8fbc968d467 100644 --- a/src/intel/compiler/brw/brw_rt.h +++ b/src/intel/compiler/brw/brw_rt.h @@ -216,7 +216,26 @@ brw_rt_compute_scratch_layout(struct brw_rt_scratch_layout *layout, assert(size % 64 == 0); /* Cache-line aligned */ assert(size < UINT32_MAX); layout->ray_stack_start = size; - layout->ray_stack_stride = BRW_RT_ASYNC_STACK_STRIDE; + + /* Wa_14021821874, Wa_14018813551, Wa_14026600921: + * + * StackIDControlOverride_RTGlobals = 0 (i.e. 2k) + * SetStackSizePerRay = 64 (64*64B) + * DisableRTGlobalsKnownValues = 1 + * + * StackSizePerRay is the RTDispatchGlobals::AsyncStackSize and + * DisableRTGlobalsKnownValues is to interpret how many Max BVH levels we + * need to use. It's not relevant to Vulkan, since we have just 2 fixed BVH + * levels. + */ + if (intel_needs_workaround(devinfo, 14021821874) || + intel_needs_workaround(devinfo, 14018813551) || + intel_needs_workaround(devinfo, 14026600921)) { + layout->ray_stack_stride = 64 * 64; + } else { + layout->ray_stack_stride = BRW_RT_ASYNC_STACK_STRIDE; + } + size += num_stack_ids * layout->ray_stack_stride; /* Finally, we place the SW stacks for the individual ray-tracing shader @@ -266,9 +285,14 @@ brw_rt_ray_queries_stack_ids_per_dss(const struct intel_device_info *devinfo) /* Wa_14021821874, Wa_14018813551, Wa_14026600921: * - * "StackIDControlOverride_RTGlobals = 0 (i.e. 2k)". We - * already set stack size per ray to 64 in brw_nir_lower_rt_intrinsics - * as the workaround also requires. + * StackIDControlOverride_RTGlobals = 0 (i.e. 2k) + * SetStackSizePerRay = 64 (64*64B) + * DisableRTGlobalsKnownValues = 1 + * + * StackSizePerRay is the RTDispatchGlobals::AsyncStackSize and + * DisableRTGlobalsKnownValues is to interpret how many Max BVH levels we + * need to use. It's not relevant to Vulkan, since we have just 2 fixed BVH + * levels. */ if (intel_needs_workaround(devinfo, 14021821874) || intel_needs_workaround(devinfo, 14018813551) || diff --git a/src/intel/vulkan/genX_cmd_compute.c b/src/intel/vulkan/genX_cmd_compute.c index fab710ef5a1..00752d70861 100644 --- a/src/intel/vulkan/genX_cmd_compute.c +++ b/src/intel/vulkan/genX_cmd_compute.c @@ -890,7 +890,8 @@ genX(cmd_buffer_ray_query_globals)(struct anv_cmd_buffer *cmd_buffer) .bo = device->ray_query_bo[idx], .offset = (i + 1) * (device->ray_query_bo[idx]->size / 2), }, - .AsyncRTStackSize = BRW_RT_SIZEOF_RAY_QUERY / 64, + .AsyncRTStackSize = + cmd_buffer->state.rt.scratch.layout.ray_stack_stride / 64, .NumDSSRTStacks = stack_ids_per_dss, .MaxBVHLevels = BRW_RT_MAX_BVH_LEVELS, .Flags = RT_DEPTH_TEST_LESS_EQUAL,