Skip to content

Shaders: a float wave prefix sum (wavePrefixOp) is wrong on a Radeon iGPU in the lane whose own term is NaN, +infinity or 2^60 #1172

Backlog

Description

@rouges78

A float wave prefix sum is lowered to wavePrefixOp kind 0 (WavePrefixSum). On an AMD Radeon driver the value a lane gets is wrong when that lane's own term is NaN, +infinity or 2^60 (the one large value tried).

Found with a synthetic test while testing #470: hand-written console programs, no game files. I have not seen it in a game and do not know whether any game shader takes a float wave prefix sum over such values. It does not come from #470: the float prefix sum already on main lowers the same way, and the same lanes are wrong on ffe310e.

Setup. One group of 32 threads, WaveSize(32), dxil.dll validation on. Each lane loads a float from a structured buffer, a whole-wave section scans it, and each lane stores its prefix to a raw UAV. Compared lane by lane with the section's instructions run on the CPU. The terms are small multiples of 0.25, so their sums are exact in any order; then a term is replaced (NaN in lanes 9 and 20, or in lane 0; the other two in lane 11).

the lane's own term exclusive prefix in that lane inclusive prefix in that lane
NaN NaN, want the sum of the lanes below (-3.75 in lane 9, 0 in lane 0) NaN, as wanted
2^60 0, want -17.75 2^60, as wanted
+infinity NaN, want -17.75 NaN, want +infinity

Every other lane is as wanted, and the set with no such term is exact.

  • Where: Radeon iGPU of a Ryzen 7 7700X, driver 32.0.21030.2001 (September 2025), waves of 32 to 64. One GPU and one driver version.
  • Not there: an RTX 4080 (driver 621.14) is exact in every case, and the integer prefix sum is exact on both.
  • Not the translator: plain HLSL WavePrefixSum compiled by DXC 1.8.2502.11 (Windows SDK 10.0.26100) gives the same wrong lanes and values on the Radeon (shader below).
  • Documentation: Microsoft defines the result as the sum over the active lanes with smaller indices, and says the lowest active lane always receives 0; with a NaN in lane 0 that lane reads NaN. The same page says the order of operations is not guaranteed. No order of the lanes below gives these values, but the 2^60 row is the one a vendor could call rounding.
  • The three results fit a prefix made as the sum up to and including the lane, less the lane's own term. That reading is mine; the driver is closed.
  • The exclusive prefix is the raw result of the op, so it is the exposed one. The inclusive one adds the term back, and of the cases tried only the infinite term shows there.

I have not tried a fix.

HLSL that shows it without the translator
#define RS "DescriptorTable(SRV(t0)), DescriptorTable(UAV(u0))"
StructuredBuffer<float> In : register(t0);
RWByteAddressBuffer Out : register(u0);

[RootSignature(RS)]
[WaveSize(32)]
[numthreads(32, 1, 1)]
void main()
{
    uint lane = WaveGetLaneIndex();
    float x = In[lane];
    Out.Store(lane * 4, asuint(WavePrefixSum(x)));
}

dxc -T cs_6_6 -E main, one group dispatched, In holding 32 floats. This is the exclusive form; WavePrefixSum(x) + x is the inclusive one.

Test: wave_prefix_tests.rs, from the readback posted on #470. It is not on main: added to ffe310e with its two lines in emit/mod.rs, the sum tests need no other change. On the Radeon an_exclusive_prefix_sum_of_f32_reads_back fails on the NaN, 2^60 and infinity sets and an_inclusive_prefix_sum_of_f32_reads_back on the infinity set; every set is exact on the RTX 4080.

Edit: the link now points at a commit that has the 2^60 and infinity sets (lane 11 set to 0x5D800000 and 0x7F800000). They were not pushed when this was opened.

AI-assisted (Claude Code), run on my own hardware.

Activity

  1. pickles976 commented on Nov 24, 2026

    @pickles976

    Divergence note from ivall/xcl, plus a possible structural exit: we do not emit WavePrefixSum at all — our lowering has no dependency on the vendor prefix intrinsic, so this Radeon-driver defect cannot reach our users, and it suggests your fix need not be a lane-correction hack: a shift-and-add Hillis-Steele lowering (5 log-rounds of WaveReadLaneAt(v, lane - step) guarded for lane >= step, IEEE-754 add) is bit-exact under the sequential order the ISA defines (v_peres-style prefix semantics) while touching no vendor fast path. Cost: 5 cross-lane reads vs one intrinsic — on the affected driver that is the difference between wrong and right; on healthy drivers a one-line capability switch keeps WavePrefixOp.\n\nTwo rows worth adding to your synthetic before this settles: ① integer prefix on the same driver — if the int path is correct, the defect is in the float fast path specifically and your capability table can be typed; ② WaveExclusivePrefixSum float on the same NaN/+inf/2^60 lanes — vendor fast paths for inclusive and exclusive variants are often different code, and if both are wrong the "replace the float path" conclusion generalizes immediately instead of needing a second bug report later. On 2^60 specifically: that looks like the driver specializing associativity-reordered sums past IEEE (any reassociation changes the exact result once saturation-like fast adds enter) — if so, plain large-but-normal pairs (2^60, 1.0, repeated) would reproduce without exotic values, which matters for judging whether a real title can hit it.

  2. Paull007 commented on Nov 24, 2026

    @Paull007

    0001-Shaders-a-float-wave-prefix-sum-from-lane-reads-not-.patch

    A possible fix (patch attached): float prefix sums are built from lane reads instead of WavePrefixOp, so the driver's float prefix path is never used. Each lane points at the nearest active lane below it (from a ballot), and each round adds that lane's partial sum and takes its pointer, so inactive lanes are never read. Integer sums keep WavePrefixOp. The inclusive sum now comes straight from the scan, which also fixes the +infinity inclusive row.

    Checked: a CPU model of the emitted steps matches a sequential sum over random masks, wave sizes 32/64/128, and NaN/+inf/2^60 terms; a new lowering test goes through the new path; all shader tests pass. Not run on a GPU yet: could someone with the Radeon iGPU run wave_prefix_tests.rs with this applied? It also touches the same match arm as PR 470.

    AI-assisted (Claude).

  3. WALID1618Y commented on Nov 24, 2026

    @WALID1618Y

    Ran @Paull007's 0001-Shaders-a-float-wave-prefix-sum-from-lane-reads-not-.patch on main (ffe310e) with @rouges78's wave_prefix_tests.rs plus the two extra edge-case sets from the issue (2^60 = 0x5D80_0000 and +infinity = 0x7F80_0000 in lane 11).

    Environment: Windows 11, Rust 1.98.1, dxil.dll validation enabled (VICTORY_DXIL), NVIDIA GeForce RTX 3050 (Ampere, driver 32.0.16.2124, waves of 32 to 32) + Microsoft WARP (10.0.26100.9818, waves of 4 to 4 — skipped for WaveSize(32)). Synthetic tests only; no game data.

    Checks:

    • git apply --check: clean on ffe310e
    • cargo clippy -p victory-shader --all-targets --locked -- -D warnings: clean
    • a_float_wave_prefix_sum_lowers_without_wave_prefix_op: pass (dxil.dll: valid)
    Test Input set RTX 3050 (32.0.16.2124) dxil.dll
    an_inclusive_prefix_sum_of_f32_reads_back floats EXACT valid
    NaN in lanes 9 and 20 EXACT valid
    NaN in lane 0 EXACT valid
    2^60 in lane 11 EXACT valid
    +inf in lane 11 EXACT valid
    an_exclusive_prefix_sum_of_f32_reads_back floats EXACT valid
    NaN in lanes 9 and 20 EXACT valid
    NaN in lane 0 EXACT valid
    2^60 in lane 11 EXACT valid
    +inf in lane 11 EXACT valid
    an_inclusive_prefix_sum_of_u32_reads_back around 0x80000000 & 0 EXACT valid
    an_exclusive_prefix_sum_of_u32_reads_back around 0x80000000 & 0 EXACT valid

    This confirms the lane-read pointer-jumping lowering validates cleanly with dxil.dll and executes bit-exactly on NVIDIA Ampere (still needs a Radeon iGPU run to verify the AMD driver defect itself is cleared).

    AI-assisted; all builds, DXIL validations, and GPU dispatches were executed locally on my RTX 3050.

  4. added a commit that references this issue on Nov 24, 2026
    e7ef4e3
  5. tumbubu commented on Nov 24, 2026

    @tumbubu

    Reproduced on a discrete RDNA3 card with a newer driver, in Wave64 and pixel shaders too; #1408 fixes it there.

    #1458's AMD run used RADV, where #1172 does not occur. This run uses AMD's Windows driver.

    • AMD Radeon RX 7900 XT (RDNA3), driver 32.0.31036.15, D3D12 waves 32..64, Windows 11 Pro 26300
    • dxil.dll from Windows SDK 10.0.26100: the modules were validated
    • No game files: synthetic tests only

    main (ffe310e) with only #1408's wave_prefix_tests.rs added (and its two lines in emit/mod.rs; no lowering change):

    cargo test -p victory-shader --locked wave_prefix -- --test-threads=1
    
    Test 7900 XT on main First wrong lane
    wave_prefix_sum_f32_exclusive_wave32 fails nan_lanes_9_20, lane 9: NaN, want -3.75
    wave_prefix_sum_f32_inclusive_wave32 fails pos_inf_lane_11, lane 11: NaN, want +inf
    wave_prefix_sum_f32_wave64 fails nan_lanes_9_20, lane 9: NaN, want -3.75
    wave_prefix_sum_f32_pixel_quad_all_backends fails PS exclusive, nan_lane_0, lane 0: NaN, want 0
    wave_prefix_sum_u32_reads_back pass –

    These are the same wrong values as in #1172's table. Each test stops at its first wrong lane, so later cases in the same test are not listed. Compared with #1172:

    • the bug is not limited to the iGPU or to the September 2025 driver (32.0.21030);
    • it is not limited to WaveSize(32) compute: Wave64 compute and the pixel-shader form fail the same way.

    #1408 head a69e324, cargo test -p victory-shader --locked -- --test-threads=1: 125 passed, 0 failed, 1 ignored. That is main's 120 plus the 5 above, all passing on the 7900 XT. No test that passes on main fails.

  6. added a commit that references this issue on Nov 25, 2026
    8254052
  7. Marvisak commented on Nov 25, 2026

    @Marvisak
    Owner

    Automated triage for the maintainers.

    Confirmed by reading main (940d32f): shape in crates/victory-shader/src/emit/lower.rs lowers a float wave prefix sum to wavePrefixOp.f32 and builds the inclusive form by adding the lane's own term back. So the AMD Windows driver's results reach translated shaders unchanged. The reports here show the wrong lanes on two AMD Windows drivers (a Radeon iGPU and an RX 7900 XT, also in Wave64 and pixel shaders), and exact results on NVIDIA and on RADV (#1458). The integer path is exact.

    The fix is open as PR #1408 (float prefix sums built from lane reads; integer sums keep wavePrefixOp). It passed on the RX 7900 XT, so review and further runs go there. Nobody has seen this in the title yet.


    Generated by Claude Code

  8. JAEdotUK commented on Nov 26, 2026

    @JAEdotUK

    Reproduces on RDNA4. RX 9070 XT, driver 32.0.32015.7029, Windows 11 (10.0.26200.9974), waves 32..=64. main's float wavePrefixOp path (the parent of #1408 with #1408's tests) fails in the same lanes as the table above: exclusive NaN lanes 9 and 20 give NaN in lane 9 where -3.75 is wanted (Wave32 and Wave64), inclusive +inf in lane 11 gives NaN, and the pixel-shader exclusive case with NaN in lane 0 gives NaN where 0 is wanted. The u32 test passes. Each test stops at its first wrong lane, so later sets (such as 2^60) are not listed. With #1408 at 3a4ee54 all five tests pass on the same GPU. Details are in my report on #1408.

    AI use: prepared with Claude (Claude Sonnet 5.5); the test run was done by me on my own machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: shaderbugtriage: confirmed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions