From c5423d3e27311e550f45b4dd9431e4c814dae0e6 Mon Sep 17 00:00:00 2001 From: Raviraj Uppal Date: Wed, 1 Apr 2026 12:03:33 +0530 Subject: [PATCH] ac/nir: Fixed OpenGL CTS transform feedback overflow detection test case The ordered atomic commits the post-add offset to memory, but overflow was computed using the pre-add offset, causing partial overflows to be missed and counters to become corrupted. Fixes: "KHR-GL46.transform_feedback_overflow_query_ARB.multiple-streams-one-buffer-per-stream" based on the postwrite buffer offset, rather than the offset before the current workgroups writes. Reviewed-by: Marek Olsak Part-of: --- src/amd/common/nir/ac_nir_prerast_utils.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/amd/common/nir/ac_nir_prerast_utils.c b/src/amd/common/nir/ac_nir_prerast_utils.c index 79ce7f710af..fc5bcae64e7 100644 --- a/src/amd/common/nir/ac_nir_prerast_utils.c +++ b/src/amd/common/nir/ac_nir_prerast_utils.c @@ -1131,8 +1131,10 @@ ac_nir_ngg_build_streamout_buffer_info(nir_builder *b, nir_def *overflow = nir_ilt(b, buffer_size, buffer_offset); any_overflow = nir_ior(b, any_overflow, overflow); + nir_def *new_buffer_offset = nir_iadd(b, buffer_offset, + workgroup_buffer_sizes[buffer]); overflow_amount[buffer] = nir_imax(b, nir_imm_int(b, 0), - nir_isub(b, buffer_offset, buffer_size)); + nir_isub(b, new_buffer_offset, buffer_size)); unsigned stream = info->buffer_to_stream[buffer]; /* when previous workgroup overflow, we can't emit any primitive */