Repository navigation
Conversation
The LDS float minimum and maximum were refused ("an LDS operation"), so
any program using one failed to translate. DXIL has no float atomics on
groupshared memory, so they become integer atomics: floats with the sign
bit clear order as signed integers, those with it set in reverse as
unsigned ones. The maximum is a signed max for non-negative data and an
unsigned min for the rest (the minimum: signed min, unsigned max). Each
lane issues both atomics, one with a value that leaves the dword as it
is, so each lane still changes it in a single atomic step; -0 orders
below +0, and NaN data leaves the dword. The _rtn forms return the old
value.
Tests: a one-thread program checks every pair of 14 values (and NaN
data) for both the dword afterwards and the returned old value; a
64-thread program checks the result under contention across waves.
The test builder now takes a thread count and an LDS size.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LAKSHYA-cmd-tech
left a comment
There was a problem hiding this comment.
Tested on Windows 11 with Rust 1.98.1 (x86_64-pc-windows-msvc).
- cargo test -p victory-shader: all 71 tests passed (0 failed). Both new hardware and cross-wave atomic tests (ds_min_max_f32_order_floats_and_return_the_old_value and ds_min_max_f32_are_atomic_across_waves) succeeded cleanly.
- cargo xtask policy: 151 files ok.
- Verified integer atomic bit-representation transformation logic for float LDS min/max in emit/lower.rs.
|
RDNA2 hardware measurement of Setup. AMD Radeon iGPU of a Ryzen 7 9800X3D, gfx1036 (RDNA2), AMD driver 32.0.21042.62, Windows 11 Pro 26200. In a HIP kernel (assembled by the AMD driver's amd_comgr), each lane writes a "memory" value to its own LDS dword, runs This model fits 289/289 in all four modes, for min and max, with and without
Against this PR, with f32 denormals kept, every row without a NaN matches (182/289), including -0 < +0. The 107 others:
With f32 denormals flushed there are 28 more: data AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run. |
A hardware measurement on the pull request (gfx1036, all pairs of 17 values in four modes) showed the NaN rules differ from the integer atomics' order: an sNaN, data first, then memory, is written quieted; otherwise a NaN loses to a number, also a NaN already in the dword (two quiet NaNs give the data). No single integer atomic can express the memory side, so the operation is now a compare-exchange loop around the measured choice. Numbers keep the same order (-0 below +0). The test reference follows the measured model, with quiet and signalling NaNs of both signs in memory and as data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@Lyrnc thank you, that measurement settles it. I followed your model in 5d07613: the integer-atomic pair is replaced by a compare-exchange loop around rules 2-5, since no single integer atomic can let a NaN already in the dword lose to a number. Both quiet NaNs give the data, as you reported. The test now has quiet and signalling NaNs of both signs, in memory and as data (361 pairs per op, dword afterwards and @LAKSHYA-cmd-tech thanks for testing. The lowering changed after your approval (now a CAS loop), so it may be worth another look. AI-assisted (Claude Code). |
|
Tested
AI use: Claude Code (Claude Opus 5.5) ran the tests and drafted this comment. |
|
AMD hardware check, Windows 11, Adrenalin driver: RX 9070 (RDNA4) and the Ryzen 9600X iGPU (RDNA2, gfx1036), each picked as the D3D12 device for
|
# Conflicts: # crates/victory-shader/src/emit/valu_tests.rs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged current Note for testing: AI-assisted (Claude Code). |
catminou4
left a comment
There was a problem hiding this comment.
Merges cleanly with main; macOS arm64, rustc 1.98.1, cargo test -p victory-shader --locked with the PR merged into main 8e79c80 → 70 passed / 0 failed / 1 ignored (1 ignored = Windows GPU execution suite).
The lowering is a CAS loop around lds_float_pick, and I checked the pick against the hardware reference in the new tests: sNaN quieted with data first, a NaN losing to a number, two quiet NaNs giving the data, and the sign-flip key ordering -0 below +0 — all match lds_min_max_ref. _rtn is handled by the existing replace("_rtn", "") at the atomic matcher, and the tests cover both the old-value-return and read-back forms, plus cross-wave atomicity on WARP and hardware.
Three notes, none blocking:
- The host-execution tests in
valu_tests.rsare Windows-gated, so on macOS this PR is compile-checked only; the gfx1036 measurements in the description are the real evidence — CI on Windows will exercise them. lower.rsnow has the// ---- instructions ----comment twice in a row (hunk at ~2251) — drop one.- The denormal shortcut is documented in the comment; fine as long as MODE stays unmodelled.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@catminou4 thanks for the review. Note 2 is fixed in b108d2f (one AI-assisted (Claude Code). |
|
@Parakeet-Wheat the same question as on #596, if you have time: how many AI-assisted (Claude Code). |
|
@mercuryVM here are the counts for
Offline translation and validation only; no shader contents or extracted data included. AI-assisted (Claude Code); run on my machine. |
|
@Parakeet-Wheat thank you. Zero in the title, all LDS min/max integer: noted at the top of the description. I'll also cut the semantics test's run time (one dispatch per case makes it take over 60 s on your 3070) if this PR stays open. AI-assisted (Claude Code). |
|
AMD check at
Synthetic tests only, no game files. Tested with AI assistance (Claude Code). |
|
Automated triage for the maintainers. Needs rebase. This PR does not merge cleanly into current The content has not been reviewed yet; it will be once the branch is rebased onto Generated by Claude Code |
GPU: Keep small readback copies fast on Wine and Proton
What
ds_min_f32,ds_max_f32,ds_min_rtn_f32andds_max_rtn_f32were refused (an LDS operation), so any compute or mesh program that used one failed to translate. DXIL has no float atomics on groupshared memory, so each now lowers to a compare-exchange loop. The loop reads the dword, computes what RDNA2 would write, and retriescmpxchguntil no other lane changed the dword in between.What RDNA2 writes follows @Lyrnc's measurement on gfx1036, all pairs of 17 values in four modes, reported in a comment below:
_rtnforms return the dword's value from before.The first commit used a pair of integer atomics (signed max plus unsigned min). The numbers come out the same, but that cannot express NaNs already in memory. The second commit replaces it with the loop after the measurement.
Known gap, marked
shortcut:in the code: f32 denormals compare as kept. With the console's MODE flushing them, they would order as ±0 first, and the translator does not model MODE.Helpers
Lower::lds_float_min_max(the loop) andLower::lds_float_pick(the choice) are incrates/victory-shader/src/emit/lower.rs. Invalu_tests.rs, the test builder now takes a thread count and an LDS size (build_cs;build_valu_cscalls it unchanged), andrun_cases_onpicks the devices.Effect on the title: none
Measured by @Parakeet-Wheat on the retail 1.0.2.1 shaders, in a comment below: the title contains 0
ds_{min,max}{,_rtn}_f32; its LDS minimum and maximum are all integer (ds_max_u32,ds_min_u32,ds_max_i32).victory translate --list --validategives the same outcome onmainand on this PR: 21,736 validated, 4,003 failed, 162 rejected. So this PR only completes the instruction set. It doesn't unblock anything in the game, and it can wait behind work that does.Overlap
I searched open and closed PRs: #164 adds the integer LDS atomics with
cmpst. No PR handles the float forms; #163 lists them as refused.Tested
Windows 11, NVIDIA RTX 5070, AMD CPU. No game data.
ds_min_max_f32_order_floats_and_return_the_old_value: a one-thread program, for every pair from 19 values (±0, ±1, ±2.5, ±1e-30, ±denormal, ±inf, ±MAX, plus quiet and signalling NaNs of both signs) in memory and as data, for both ops. It checks the dword afterwards (read back withds_read_b32) and the old value returned by_rtn, against a reference that follows the measured model. Hardware only: a one-wave program with LDS declaresWaveSize(32)(existing behaviour), and WARP's pipeline creation refuses it.ds_min_max_f32_are_atomic_across_waves: 64 threads each apply(thread - 32)as a float to one dword after a barrier. Checks max from -inf (31), max from 100 (100), min from +inf (-32) and min from -0 (-32). Runs on hardware and WARP.ds_max_f32 on NaN [0x7fc00000] with 0 gave 0x7fc00000, want 0).cargo test --workspace: all passed (victory-shader 71 passed).rustfmt --edition 2024 --checkon both files: clean.cargo clippy -p victory-shader --all-targets: no warnings.cargo xtask policy: 151 files ok.Not tested
AI-assisted (Claude Code).
🤖 Generated with Claude Code