fix(shader): flush the operands of image, buffer and global float atomics #8055

Merged
thuanquang merged 2 commits from upstream-pr/8055 into main 2026-10-23 16:38:11 +00:00
thuanquang commented 2026-10-19 19:08:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-19T19:08:38Z.


What

On RDNA 2, the memory float atomics flush denormal operands the way the LDS ones do. This covers image_atomic_fmin, image_atomic_fmax and image_atomic_fcmpswap, the same three as buffer_atomic_* and global_atomic_*, and the _x2 forms of the buffer and global ones. They flush both operands to a signed zero when bit 0 of the shader's denormal field is clear: the f32 field for the 32-bit forms, the f16/f64 field for _x2.

The emulator flushed only the LDS forms. Under FLOAT_MODE 0xc0, which most titles use, a denormal operand of a memory float atomic kept its value:

  • fmax of old +0 and data 0x00000001 stored 0x00000001; the hardware stores +0.
  • fcmpswap of old +0 with a comparand of 0x80000001 left memory unchanged; the hardware compares the flushed -0, finds it equal and swaps.

The change:

  • TranslationContext::floatAtomicFlush, renamed from sharedFloatFlush, now also sets MemoryInfo::flushDenormals for the image, buffer and flat float atomic opcodes. It keeps the same bits and the same default for a shader without a known float mode: flush f32, keep f64.
  • AtomicFloatBits applies the flag in minMax and compareSwap.
  • The image, buffer and flat emitters pass the flag. The flat ones cover the direct path, the LDS and scratch apertures, and BDA.

The LDS emitters now pass the flag the same way instead of flushing at each call site, so the rule is written once. Without the flag, the emitted SPIR-V is unchanged. The new debt entry records the rule and what it was measured on. The flat_atomic_* forms take the same path, including the LDS and scratch apertures, but are neither measured nor run by the new test.

The three existing tests from #332, #506 and #562 (agc_driver_buffer_atomics_float, agc_driver_global_atomics_float, agc_driver_image_atomics_float) were measured with denormals kept. They ran with no float mode, which the translator treats as flushing f32, as for the LDS forms and as in the 0xc0 most titles use. They now set FLOAT_MODE 0xf0, the mode of their tables. Without that they fail with this change: lane 1 fmax_mem0 is 0x00000000, expected 0x00000001.

The rule, measured on every row below:

  • fmin and fmax compare the flushed operands and write the flushed winner, also when the old value wins.
  • fcmpswap compares the flushed old value with the flushed comparand (both zeros equal, NaN never equal). On a match it stores the source as given; otherwise memory is unchanged.
  • IEEE mode, the wave size and the surface format (32_UINT, 32_SINT, 32_FLOAT) don't change any result, and neither does the other denormal field.

Tested

Hardware: RX 6700 XT (gfx1031), raw ISA through the tools/hw-oracle template, run with the comgr and HIP runtime of AMD's Windows driver 32.0.21045.5002.

  • Operands: 20 x 20 f32 pairs and 18 x 18 f64 pairs: signed zeros, the smallest and largest denormals of both signs, the smallest normal, ±1, π, the largest normals, infinities, and quiet and signalling NaNs of both signs and with payloads.
  • fcmpswap comparand: alternately the old value and the source.
  • Each row stores the old value, runs the atomic with glc and reads the dword back:
forms modes rows stored = this rule stored = no flush (main)
image fmin/fmax/fcmpswap f32 field 0 and 3 on 32_UINT, 32_SINT and 32_FLOAT, 1 and 2 on 32_FLOAT; IEEE 0/1, wave32/64 38,400 all not in fields 0 and 2
buffer, the same three f32 field 0-3, IEEE 0/1, wave32/64 19,200 all not in fields 0 and 2
global, the same three f32 field 0-3, IEEE 0/1, wave32/64 19,200 all not in fields 0 and 2
buffer and global _x2 forms f16/f64 field 0-3, IEEE 0/1, wave32/64 31,104 all not in fields 0 and 2
buffer and image 32-bit forms, buffer _x2 forms each field 0, 2 or 3 with the other at 0, 2 or 3 30,348 all

In fields 0 and 2, the flush changes 352 of the 1,600 rows per mode for fmin, 288 for fmax and 56 for fcmpswap (32-bit); for _x2, 352, 256 and 56 of 1,296. Every returned value is the old value.

Emulator: the new agc_driver_memory_float_atomic_modes runs the buffer and image forms and the buffer _x2 forms over 32 of those pairs in six float modes: no float mode, 0xc0, 0xf0, 0x00, 0x50 and 0xa0. The global forms run in FLOAT_MODE 0x00 only, where both widths flush, with global_atomic_fmin and global_atomic_fmin_x2. Their stored value depends on the flush in 13 of the 32 rows at each width. Its expected stored values are the GPU's own results for those rows. Programs are assembled for gfx1013.

CI cost: llvmpipe needs a long time to compile the global float atomics, which is what pushed the first version of this test past the CI timeout. Cold runs on lavapipe (Mesa 25.2.8 with LLVM 20.1.2, as on Linux CI, MESA_SHADER_CACHE_DISABLE=true, ANYPS5_NO_SHADER_CACHE=1) on one machine under the same heavy load:

Version of the test Cold run
first version (all three global operations in three float modes) 232 s
global forms in FLOAT_MODE 0x00 only 86–93 s
this version (global fmin and fmin_x2 in 0x00 only) 22.5 s

Two controls, both on lavapipe:

  • With the global path's flush turned off, the test fails at global, FLOAT_MODE 0x00, lane 4 fmin stored 0x80000001, expected 0x80000000.
  • With this PR's code reverted and the new test kept, it fails at buffer, no float mode, lane 3 fmax stored 0x00000001, expected 0x00000000.

This push (rebased onto main 49c9bdf37, head 06c1c0300) ran on the RX 6700 XT with AMD's driver 32.0.21045.5002:

  • These 8 tests pass 3 of 3: agc_driver_memory_float_atomic_modes, agc_driver_global_atomics_float, agc_driver_buffer_atomics_float, agc_driver_image_atomics_float, agc_driver_lds_add_f32, agc_driver_lds_float_atomic_modes, agc_driver_lds_atomics and agc_driver_lds_mixed_width_atomics.
  • With the Khronos validation layer there are 0 VUID- lines on main a07e985c8 (the same tests without the new one) and on this head. The layer was inserted in every test process.

Windows 11 26200, RX 6700 XT, AMD's driver 32.0.21045.5002, Release:

  • main 38de0a470 with only the new test fails 3 of 3: buffer, no float mode, lane 3 fmax stored 0x00000001, expected 0x00000000. Local variants that start with the image or the global path fail the same way on main (lane 3 fmax stores 0x00000001, no float mode). Variants that check only the _x2 forms fail in FLOAT_MODE 0x00, where buffer_atomic_fmax_x2 and global_atomic_fmax_x2 store 0x0000000000000001 for an expected 0.
  • With this PR it passes 3 of 3.
  • 30 related tests pass 3 of 3: every *atomic* test, agc_shader_disk_cache, agc_shader_memory and agc_driver_image_cache_bits.
  • The new test skips on a device without shaderBufferInt64Atomics, as BufferAtomicsFloat does.
  • Full ctest --parallel 4: 1685 tests, 8 failed, none from this change:
    • log_macros and log_macros_timestamps: ccache rewrites __FILE__ in local builds.
    • agc_trimmed_import: #6499.
    • agc_driver_draw_cache_reuse_off, agc_driver_layered_volume_vertex_no_gpl and agc_driver_stencil_replay: each lost the device because its driver cache was filled in the other library mode first (#7809, which #7828 fixes). main 38de0a470 fails the same group here, with agc_driver_stencil_replay_no_gpl instead of agc_driver_stencil_replay, since the order depends on the cache.
    • agc_driver_bda_device and guest_nanosleep_timer_self_test timed out in the first minute while another build held the CPU. Rerun alone, both pass 3 of 3.
    • guest_memory failed in an earlier run of this branch with flexible memory exhausted. It fails the same way on main here, and it passed in this run and 3 of 3 alone.

Validation layer A/B: Khronos validation layer (VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, layer built from Vulkan-ValidationLayers, loader debug confirms Insert instance layer "VK_LAYER_KHRONOS_validation"), ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1, ctest -V on agc_driver_memory_float_atomic_modes, agc_driver_buffer_atomics_float, agc_driver_global_atomics_float, agc_driver_image_atomics_float and agc_driver_lds_float_atomic_modes. main 38de0a470 (with the new test file added): 4 pass, the new test fails as above, 0 VUID- messages. This PR: 5 of 5 pass, 0 VUID- messages. Neither log has was not found but was requested.

wachi35676 checked the rule independently on a second RDNA 2 chip (gfx1036, Windows driver 32.0.21042.62) and ran the tests on an RTX 5070 Ti and a Radeon iGPU, with the same red/green; see the comment below.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 6700 XT (gfx1031), AMD Windows driver 32.0.21045.5002, Windows 11 26200
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4926007495 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8055). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-19T19:08:38Z. --- ### What On RDNA 2, the memory float atomics flush denormal operands the way the LDS ones do. This covers `image_atomic_fmin`, `image_atomic_fmax` and `image_atomic_fcmpswap`, the same three as `buffer_atomic_*` and `global_atomic_*`, and the `_x2` forms of the buffer and global ones. They flush both operands to a signed zero when bit 0 of the shader's denormal field is clear: the f32 field for the 32-bit forms, the f16/f64 field for `_x2`. The emulator flushed only the LDS forms. Under `FLOAT_MODE` 0xc0, which most titles use, a denormal operand of a memory float atomic kept its value: - `fmax` of old +0 and data 0x00000001 stored 0x00000001; the hardware stores +0. - `fcmpswap` of old +0 with a comparand of 0x80000001 left memory unchanged; the hardware compares the flushed -0, finds it equal and swaps. The change: - `TranslationContext::floatAtomicFlush`, renamed from `sharedFloatFlush`, now also sets `MemoryInfo::flushDenormals` for the image, buffer and flat float atomic opcodes. It keeps the same bits and the same default for a shader without a known float mode: flush f32, keep f64. - `AtomicFloatBits` applies the flag in `minMax` and `compareSwap`. - The image, buffer and flat emitters pass the flag. The flat ones cover the direct path, the LDS and scratch apertures, and BDA. The LDS emitters now pass the flag the same way instead of flushing at each call site, so the rule is written once. Without the flag, the emitted SPIR-V is unchanged. The new debt entry records the rule and what it was measured on. The `flat_atomic_*` forms take the same path, including the LDS and scratch apertures, but are neither measured nor run by the new test. The three existing tests from #332, #506 and #562 (`agc_driver_buffer_atomics_float`, `agc_driver_global_atomics_float`, `agc_driver_image_atomics_float`) were measured with denormals kept. They ran with no float mode, which the translator treats as flushing f32, as for the LDS forms and as in the 0xc0 most titles use. They now set `FLOAT_MODE` 0xf0, the mode of their tables. Without that they fail with this change: `lane 1 fmax_mem0 is 0x00000000, expected 0x00000001`. The rule, measured on every row below: - `fmin` and `fmax` compare the flushed operands and write the flushed winner, also when the old value wins. - `fcmpswap` compares the flushed old value with the flushed comparand (both zeros equal, NaN never equal). On a match it stores the source as given; otherwise memory is unchanged. - IEEE mode, the wave size and the surface format (32_UINT, 32_SINT, 32_FLOAT) don't change any result, and neither does the other denormal field. ### Tested **Hardware:** RX 6700 XT (gfx1031), raw ISA through the `tools/hw-oracle` template, run with the comgr and HIP runtime of AMD's Windows driver 32.0.21045.5002. - Operands: 20 x 20 f32 pairs and 18 x 18 f64 pairs: signed zeros, the smallest and largest denormals of both signs, the smallest normal, ±1, π, the largest normals, infinities, and quiet and signalling NaNs of both signs and with payloads. - `fcmpswap` comparand: alternately the old value and the source. - Each row stores the old value, runs the atomic with `glc` and reads the dword back: | forms | modes | rows | stored = this rule | stored = no flush (`main`) | |---|---|---|---|---| | image `fmin`/`fmax`/`fcmpswap` | f32 field 0 and 3 on 32_UINT, 32_SINT and 32_FLOAT, 1 and 2 on 32_FLOAT; IEEE 0/1, wave32/64 | 38,400 | all | not in fields 0 and 2 | | buffer, the same three | f32 field 0-3, IEEE 0/1, wave32/64 | 19,200 | all | not in fields 0 and 2 | | global, the same three | f32 field 0-3, IEEE 0/1, wave32/64 | 19,200 | all | not in fields 0 and 2 | | buffer and global `_x2` forms | f16/f64 field 0-3, IEEE 0/1, wave32/64 | 31,104 | all | not in fields 0 and 2 | | buffer and image 32-bit forms, buffer `_x2` forms | each field 0, 2 or 3 with the other at 0, 2 or 3 | 30,348 | all | | In fields 0 and 2, the flush changes 352 of the 1,600 rows per mode for `fmin`, 288 for `fmax` and 56 for `fcmpswap` (32-bit); for `_x2`, 352, 256 and 56 of 1,296. Every returned value is the old value. **Emulator:** the new `agc_driver_memory_float_atomic_modes` runs the buffer and image forms and the buffer `_x2` forms over 32 of those pairs in six float modes: no float mode, 0xc0, 0xf0, 0x00, 0x50 and 0xa0. The global forms run in `FLOAT_MODE` 0x00 only, where both widths flush, with `global_atomic_fmin` and `global_atomic_fmin_x2`. Their stored value depends on the flush in 13 of the 32 rows at each width. Its expected stored values are the GPU's own results for those rows. Programs are assembled for gfx1013. **CI cost:** llvmpipe needs a long time to compile the global float atomics, which is what pushed the first version of this test past the CI timeout. Cold runs on lavapipe (Mesa 25.2.8 with LLVM 20.1.2, as on Linux CI, `MESA_SHADER_CACHE_DISABLE=true`, `ANYPS5_NO_SHADER_CACHE=1`) on one machine under the same heavy load: | Version of the test | Cold run | |---|---| | first version (all three global operations in three float modes) | 232 s | | global forms in `FLOAT_MODE` 0x00 only | 86–93 s | | this version (global `fmin` and `fmin_x2` in 0x00 only) | 22.5 s | Two controls, both on lavapipe: - With the global path's flush turned off, the test fails at `global, FLOAT_MODE 0x00, lane 4 fmin stored 0x80000001, expected 0x80000000`. - With this PR's code reverted and the new test kept, it fails at `buffer, no float mode, lane 3 fmax stored 0x00000001, expected 0x00000000`. **This push** (rebased onto `main` `49c9bdf37`, head `06c1c0300`) ran on the RX 6700 XT with AMD's driver 32.0.21045.5002: - These 8 tests pass 3 of 3: `agc_driver_memory_float_atomic_modes`, `agc_driver_global_atomics_float`, `agc_driver_buffer_atomics_float`, `agc_driver_image_atomics_float`, `agc_driver_lds_add_f32`, `agc_driver_lds_float_atomic_modes`, `agc_driver_lds_atomics` and `agc_driver_lds_mixed_width_atomics`. - With the Khronos validation layer there are 0 `VUID-` lines on `main` `a07e985c8` (the same tests without the new one) and on this head. The layer was inserted in every test process. Windows 11 26200, RX 6700 XT, AMD's driver 32.0.21045.5002, Release: - `main` `38de0a470` with only the new test fails 3 of 3: `buffer, no float mode, lane 3 fmax stored 0x00000001, expected 0x00000000`. Local variants that start with the image or the global path fail the same way on `main` (lane 3 `fmax` stores 0x00000001, no float mode). Variants that check only the `_x2` forms fail in `FLOAT_MODE` 0x00, where `buffer_atomic_fmax_x2` and `global_atomic_fmax_x2` store 0x0000000000000001 for an expected 0. - With this PR it passes 3 of 3. - 30 related tests pass 3 of 3: every `*atomic*` test, `agc_shader_disk_cache`, `agc_shader_memory` and `agc_driver_image_cache_bits`. - The new test skips on a device without `shaderBufferInt64Atomics`, as `BufferAtomicsFloat` does. - Full `ctest --parallel 4`: 1685 tests, 8 failed, none from this change: - `log_macros` and `log_macros_timestamps`: ccache rewrites `__FILE__` in local builds. - `agc_trimmed_import`: #6499. - `agc_driver_draw_cache_reuse_off`, `agc_driver_layered_volume_vertex_no_gpl` and `agc_driver_stencil_replay`: each lost the device because its driver cache was filled in the other library mode first (#7809, which #7828 fixes). `main` `38de0a470` fails the same group here, with `agc_driver_stencil_replay_no_gpl` instead of `agc_driver_stencil_replay`, since the order depends on the cache. - `agc_driver_bda_device` and `guest_nanosleep_timer_self_test` timed out in the first minute while another build held the CPU. Rerun alone, both pass 3 of 3. - `guest_memory` failed in an earlier run of this branch with `flexible memory exhausted`. It fails the same way on `main` here, and it passed in this run and 3 of 3 alone. **Validation layer A/B:** Khronos validation layer (`VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, layer built from Vulkan-ValidationLayers, loader debug confirms `Insert instance layer "VK_LAYER_KHRONOS_validation"`), `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_REQUIRE_VULKAN=1`, `ctest -V` on `agc_driver_memory_float_atomic_modes`, `agc_driver_buffer_atomics_float`, `agc_driver_global_atomics_float`, `agc_driver_image_atomics_float` and `agc_driver_lds_float_atomic_modes`. `main` `38de0a470` (with the new test file added): 4 pass, the new test fails as above, 0 `VUID-` messages. This PR: 5 of 5 pass, 0 `VUID-` messages. Neither log has `was not found but was requested`. wachi35676 checked the rule independently on a second RDNA 2 chip (gfx1036, Windows driver 32.0.21042.62) and ran the tests on an RTX 5070 Ti and a Radeon iGPU, with the same red/green; see the comment below. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 6700 XT (gfx1031), AMD Windows driver 32.0.21045.5002, Windows 11 26200 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
wachi35676 commented 2026-10-20 01:56:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-20T01:56:30Z.


Independent check on a second RDNA2 chip, plus Windows runs on NVIDIA and an AMD iGPU.

Hardware rule, gfx1036 (Ryzen 5 9600X iGPU, AMD Windows driver 32.0.21042.62). I ran raw ISA through the driver's own comgr 2.9 and HIP runtime (amd_comgr_2.dll and amdhip64_6.dll). The harness is a small Windows loader around a kernel like tools/hw-oracle/template.s, with wave32, DX10_CLAMP 1, round to nearest and hipMalloc (coarse) memory. For each row it stores the old value, runs the atomic without glc and reads the dword or qword back. I compared every stored value with the rule in this PR's debt entry and with main's no-flush lowering:

forms modes rows stored = this PR's rule stored = no flush
global_atomic_fmin/fmax, buffer_atomic_fmin/fmax (32-bit) denorm32 0-3, IEEE 0/1 384 384 256 (every miss is in field 0 or 2)
global_atomic_fcmpswap, buffer_atomic_fcmpswap denorm32 0-3, IEEE 0/1 128 128 88
global/buffer_atomic_fmin_x2/fmax_x2 denorm16 0-3 (denorm32 3), IEEE 0/1 384 384 256

The operands were signed zeros, ±min and max denormals, ±1, the smallest normal and a quiet NaN on either side. The fcmpswap rows include comparand 0x80000001 against old +0, a denormal old against a comparand of +0, and a denormal source, which is stored unflushed. Two examples with denorm32 0: fmax(old 0x7fc00000, data 0x00000001) stores 0x00000000, and fmax(old 0x00000001, data 0x7fc00000) stores 0x00000000, the flushed old value, as the entry says. With denorm32 1 and 3 both store 0x00000001. Image and flat forms were not run here. Sources and raw rows: winoracle.c, run.py, run64.py, model.py, gfx1036_results.txt and gfx1036_x2.txt (available on request).

Emulator, Windows 11 26300, MinGW GCC 15.2 Release, main eb7500680 + this PR (285642c2b, merges cleanly):

  • agc_driver_memory_float_atomic_modes and the three changed *_atomics_float tests passed 3 of 3 on the RTX 5070 Ti (NVIDIA 617.42) and 3 of 3 on the Radeon iGPU (ANYPS5_GPU=AMD, 32.0.21042.62), with ANYPS5_REQUIRE_VULKAN=1.
  • Negative control: I put the 9 non-test sources back to main and kept the tests. The new test then fails on both GPUs with buffer, no float mode, lane 3 fmax stored 0x00000001, expected 0x00000000. The three updated tests still pass with main's sources, because they now set FLOAT_MODE 0xf0.
  • ctest -R "agc|shader|spirv|recomp" (824 tests). On NVIDIA, 3 failed: msaa_dcc_clear_4, pass_input_hazard and sgpr_pattern_fill_keys, which also fail on main here. On AMD, 5 failed: agc_trimmed_import, msaa_dcc_clear_4, layered_volume_vertex_no_gpl, draw_cache_reuse_off and stencil_replay_no_gpl, which also fail on main here (main additionally failed the flaky sgpr_pattern_fill_keys). No new failures.
  • check_conventions.py: 0 errors and 2 debt-length warnings, one of them the moved LDS float-atomic entry at 2457 characters.

AI-assisted: yes (Claude Code); results above were run on this machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6281519359 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8055#issuecomment-6281519359). Originally posted by [wachi35676](https://github.com/wachi35676) on 2026-10-20T01:56:30Z. --- Independent check on a second RDNA2 chip, plus Windows runs on NVIDIA and an AMD iGPU. **Hardware rule, gfx1036 (Ryzen 5 9600X iGPU, AMD Windows driver 32.0.21042.62).** I ran raw ISA through the driver's own comgr 2.9 and HIP runtime (`amd_comgr_2.dll` and `amdhip64_6.dll`). The harness is a small Windows loader around a kernel like `tools/hw-oracle/template.s`, with wave32, DX10_CLAMP 1, round to nearest and `hipMalloc` (coarse) memory. For each row it stores the old value, runs the atomic without `glc` and reads the dword or qword back. I compared every stored value with the rule in this PR's debt entry and with main's no-flush lowering: | forms | modes | rows | stored = this PR's rule | stored = no flush | |---|---|---|---|---| | `global_atomic_fmin/fmax`, `buffer_atomic_fmin/fmax` (32-bit) | denorm32 0-3, IEEE 0/1 | 384 | 384 | 256 (every miss is in field 0 or 2) | | `global_atomic_fcmpswap`, `buffer_atomic_fcmpswap` | denorm32 0-3, IEEE 0/1 | 128 | 128 | 88 | | `global/buffer_atomic_fmin_x2/fmax_x2` | denorm16 0-3 (denorm32 3), IEEE 0/1 | 384 | 384 | 256 | The operands were signed zeros, ±min and max denormals, ±1, the smallest normal and a quiet NaN on either side. The `fcmpswap` rows include comparand 0x80000001 against old +0, a denormal old against a comparand of +0, and a denormal source, which is stored unflushed. Two examples with denorm32 0: `fmax(old 0x7fc00000, data 0x00000001)` stores 0x00000000, and `fmax(old 0x00000001, data 0x7fc00000)` stores 0x00000000, the flushed old value, as the entry says. With denorm32 1 and 3 both store 0x00000001. Image and flat forms were not run here. Sources and raw rows: `winoracle.c`, `run.py`, `run64.py`, `model.py`, `gfx1036_results.txt` and `gfx1036_x2.txt` (available on request). **Emulator, Windows 11 26300, MinGW GCC 15.2 Release, `main` eb7500680 + this PR (285642c2b, merges cleanly):** - `agc_driver_memory_float_atomic_modes` and the three changed `*_atomics_float` tests passed 3 of 3 on the RTX 5070 Ti (NVIDIA 617.42) and 3 of 3 on the Radeon iGPU (`ANYPS5_GPU=AMD`, 32.0.21042.62), with `ANYPS5_REQUIRE_VULKAN=1`. - Negative control: I put the 9 non-test sources back to main and kept the tests. The new test then fails on both GPUs with `buffer, no float mode, lane 3 fmax stored 0x00000001, expected 0x00000000`. The three updated tests still pass with main's sources, because they now set `FLOAT_MODE` 0xf0. - `ctest -R "agc|shader|spirv|recomp"` (824 tests). On NVIDIA, 3 failed: `msaa_dcc_clear_4`, `pass_input_hazard` and `sgpr_pattern_fill_keys`, which also fail on main here. On AMD, 5 failed: `agc_trimmed_import`, `msaa_dcc_clear_4`, `layered_volume_vertex_no_gpl`, `draw_cache_reuse_off` and `stencil_replay_no_gpl`, which also fail on main here (main additionally failed the flaky `sgpr_pattern_fill_keys`). No new failures. - `check_conventions.py`: 0 errors and 2 `debt-length` warnings, one of them the moved LDS float-atomic entry at 2457 characters. AI-assisted: yes (Claude Code); results above were run on this machine.
thuanquang commented 2026-10-20 05:26:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-20T05:26:33Z.


@wachi35676 thank you, that's the second RDNA 2 chip this needed, and the NVIDIA and iGPU runs cover the hosts I can't. I added a pointer to your comment and a Khronos validation-layer A/B to the description (0 VUID- messages on main and with the PR, layer load confirmed).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6284082526 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8055#issuecomment-6284082526). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-20T05:26:33Z. --- @wachi35676 thank you, that's the second RDNA 2 chip this needed, and the NVIDIA and iGPU runs cover the hosts I can't. I added a pointer to your comment and a Khronos validation-layer A/B to the description (0 `VUID-` messages on `main` and with the PR, layer load confirmed).
DavidAmsellem commented 2026-10-20 19:00:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-20T19:00:37Z.


First Linux run of this PR, on AMD with RADV. Head 285642c2b merged onto main 2fee39f1b (clean merge), built in full and compared with the same main, on the same machine.

AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release.

Full suite (ANYPS5_REQUIRE_VULKAN=1 ctest -j8) at 66ff8e999: 1716/1717 with this PR, against 1715/1716 on main. The one failure is the same on both, so this PR adds none: agc_driver_guest_memory_lifetime (#7784, which #7849 addresses).

Comparing the JUnit output with main: the new entry, agc_driver_memory_float_atomic_modes, runs and passes (memory float atomic modes tests passed). No other entry is added, and none is skipped or removed. With the Khronos validation layer, it adds no VUID (the only message is VkDeviceCreateInfo-pNext-pNext, which my older 1.3.275 layer prints for every device because it doesn't know maintenance8).

One thing to keep in mind: on this device the float-controls probe reports f32 denormal flush: hardware (0 of 5472 probe results differ from the emulated flush). I haven't checked which path the new operand flush takes when the hardware flush is chosen, so this run may not exercise the emulated case.

GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6298822183 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8055#issuecomment-6298822183). Originally posted by [DavidAmsellem](https://github.com/DavidAmsellem) on 2026-10-20T19:00:37Z. --- First Linux run of this PR, on AMD with RADV. Head `285642c2b` merged onto `main` `2fee39f1b` (clean merge), built in full and compared with the same `main`, on the same machine. AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release. Full suite (`ANYPS5_REQUIRE_VULKAN=1 ctest -j8`) at `66ff8e999`: **1716/1717 with this PR**, against 1715/1716 on `main`. The one failure is the same on both, so this PR adds none: `agc_driver_guest_memory_lifetime` (#7784, which #7849 addresses). Comparing the JUnit output with `main`: the new entry, `agc_driver_memory_float_atomic_modes`, runs and passes (`memory float atomic modes tests passed`). No other entry is added, and none is skipped or removed. With the Khronos validation layer, it adds no VUID (the only message is `VkDeviceCreateInfo-pNext-pNext`, which my older 1.3.275 layer prints for every device because it doesn't know `maintenance8`). One thing to keep in mind: on this device the float-controls probe reports `f32 denormal flush: hardware (0 of 5472 probe results differ from the emulated flush)`. I haven't checked which path the new operand flush takes when the hardware flush is chosen, so this run may not exercise the emulated case. GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38 AI-assisted: yes
oneandonlydean commented 2026-10-21 02:28:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T02:28:04Z.


@thuanquang thanks. I looked into the Linux CI timeout of agc_driver_memory_float_atomic_modes on 285642c2b. It isn't a hang, but the test is too expensive to compile on llvmpipe, and that needs fixing before this can merge.

I ran it locally on lavapipe with the same Mesa as Linux CI (25.2.8, LLVM 20.1.2), merged into current main, 10 runs in a row with the shader caches kept between runs:

  • With this PR: 10/10 pass, no hang. Run 1 (cold caches) took 75 s; runs 2-10 (warm caches) took 3 s each. Nearly all of the cold time is in the three global cases (no float mode, 0xf0 and 0x00), each of which prints "recorded batch still running on the GPU after 15-20 s". So the cost is compiling those shaders on llvmpipe, not executing them.
  • With the production change reverted and the test kept: 10/10 fail at once in the first buffer case, so the test catches the change.

CI runners start with empty caches, so every Linux run pays the ~75 s under --timeout 120 and --test-load. On a busy runner that goes past the limit, which fits the timeout you saw and the green rerun. Raising the timeout isn't allowed (CONTRIBUTING), so could you cut the compile cost of the global cases instead? For example, use fewer distinct global shaders or float-mode combinations per run, or one shader that takes the mode from a buffer value instead of one shader per mode. Under about 20 s cold on llvmpipe would leave plenty of margin.

Separately, agc_driver_global_atomics_float went from about 0 s to 6 s on lavapipe with this PR, probably the same compile cost of the new compare/min/max sequence. Is that expected to be noticeable at pipeline compile time on real drivers? On an RTX 4090 the new test takes 5 s.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6306492137 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8055#issuecomment-6306492137). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T02:28:04Z. --- @thuanquang thanks. I looked into the Linux CI timeout of `agc_driver_memory_float_atomic_modes` on 285642c2b. It isn't a hang, but the test is too expensive to compile on llvmpipe, and that needs fixing before this can merge. I ran it locally on lavapipe with the same Mesa as Linux CI (25.2.8, LLVM 20.1.2), merged into current main, 10 runs in a row with the shader caches kept between runs: - With this PR: 10/10 pass, no hang. Run 1 (cold caches) took **75 s**; runs 2-10 (warm caches) took **3 s** each. Nearly all of the cold time is in the three `global` cases (no float mode, 0xf0 and 0x00), each of which prints "recorded batch still running on the GPU after 15-20 s". So the cost is compiling those shaders on llvmpipe, not executing them. - With the production change reverted and the test kept: 10/10 fail at once in the first buffer case, so the test catches the change. CI runners start with empty caches, so every Linux run pays the ~75 s under `--timeout 120` and `--test-load`. On a busy runner that goes past the limit, which fits the timeout you saw and the green rerun. Raising the timeout isn't allowed (CONTRIBUTING), so could you cut the compile cost of the global cases instead? For example, use fewer distinct global shaders or float-mode combinations per run, or one shader that takes the mode from a buffer value instead of one shader per mode. Under about 20 s cold on llvmpipe would leave plenty of margin. Separately, `agc_driver_global_atomics_float` went from about 0 s to 6 s on lavapipe with this PR, probably the same compile cost of the new compare/min/max sequence. Is that expected to be noticeable at pipeline compile time on real drivers? On an RTX 4090 the new test takes 5 s.
thuanquang commented 2026-10-21 03:38:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T03:38:55Z.


@oneandonlydean thank you for tracking that down, and for the reverted-change control. I'll fix both points in the next push:

  • Compile cost of the new test: buffer and image keep all six float modes, since those shaders compile fast. The global kind drops to one shader, FLOAT_MODE 0x00. Its flushed tables differ from the kept ones at both widths, so it still fails if the global path stops flushing, and it removes two of the three expensive global compiles. I'll measure it cold on lavapipe with the same Mesa as Linux CI before pushing, against your target of under 20 s.
  • agc_driver_global_atomics_float going from about 0 s to 6 s: that is the operand flush this PR adds to every global float atomic. I'll compare the SPIR-V size and compile time of that test between main and this head, shrink the sequence where I can, and post the numbers here. That includes a real-driver compile time on the RX 6700 XT.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6307437067 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8055#issuecomment-6307437067). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-21T03:38:55Z. --- @oneandonlydean thank you for tracking that down, and for the reverted-change control. I'll fix both points in the next push: - **Compile cost of the new test:** buffer and image keep all six float modes, since those shaders compile fast. The global kind drops to one shader, FLOAT_MODE 0x00. Its flushed tables differ from the kept ones at both widths, so it still fails if the global path stops flushing, and it removes two of the three expensive global compiles. I'll measure it cold on lavapipe with the same Mesa as Linux CI before pushing, against your target of under 20 s. - **`agc_driver_global_atomics_float` going from about 0 s to 6 s:** that is the operand flush this PR adds to every global float atomic. I'll compare the SPIR-V size and compile time of that test between `main` and this head, shrink the sequence where I can, and post the numbers here. That includes a real-driver compile time on the RX 6700 XT.
thuanquang commented 2026-10-21 03:51:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T03:51:55Z.


On the second point, agc_driver_global_atomics_float going from about 0 s to 6 s on lavapipe: the production change doesn't add that cost. The one line this PR adds to that test does: FLOAT_MODE 0xf0, which keeps denormals so the hardware-measured tables still apply.

Measured on the RX 6700 XT (AMD driver 32.0.21045.5002), all on main d0852defa:

  • SPIR-V. I dumped the compute pipelines (APS5_DUMP_COMPUTE_PIPELINES) of main with only the test's floatMode = 0xf0 line added, and of this PR rebased onto the same main. Both give the same 14 SPIR-V modules, byte for byte. At 0xf0 the operand flush is off, so the atomics emit what they did before.
  • Cold run time (renamed exe copies, so the driver cache starts empty, ANYPS5_NO_SHADER_CACHE=1, 3 runs each): about 1.0 s on main and about 1.05 s with the 0xf0 line. On this driver the float mode is barely noticeable at pipeline compile time.

So on lavapipe the 6 s should come from how 0xf0 compiles there, and you should see it on main with only that line added. I can't run lavapipe on this machine yet, so I haven't confirmed that.

For agc_driver_memory_float_atomic_modes, the plan above stands: one global shader instead of three. I'll measure it cold on lavapipe (Mesa 25.2.8, the same as Linux CI) before pushing.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6307600207 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8055#issuecomment-6307600207). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-21T03:51:55Z. --- On the second point, `agc_driver_global_atomics_float` going from about 0 s to 6 s on lavapipe: the production change doesn't add that cost. The one line this PR adds to that test does: `FLOAT_MODE 0xf0`, which keeps denormals so the hardware-measured tables still apply. Measured on the RX 6700 XT (AMD driver 32.0.21045.5002), all on `main` `d0852defa`: - **SPIR-V.** I dumped the compute pipelines (`APS5_DUMP_COMPUTE_PIPELINES`) of `main` with only the test's `floatMode = 0xf0` line added, and of this PR rebased onto the same `main`. Both give the same 14 SPIR-V modules, byte for byte. At 0xf0 the operand flush is off, so the atomics emit what they did before. - **Cold run time** (renamed exe copies, so the driver cache starts empty, `ANYPS5_NO_SHADER_CACHE=1`, 3 runs each): about 1.0 s on `main` and about 1.05 s with the 0xf0 line. On this driver the float mode is barely noticeable at pipeline compile time. So on lavapipe the 6 s should come from how 0xf0 compiles there, and you should see it on `main` with only that line added. I can't run lavapipe on this machine yet, so I haven't confirmed that. For `agc_driver_memory_float_atomic_modes`, the plan above stands: one global shader instead of three. I'll measure it cold on lavapipe (Mesa 25.2.8, the same as Linux CI) before pushing.
thuanquang commented 2026-10-21 06:19:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T06:19:23Z.


@oneandonlydean pushed 06c1c0300, rebased onto main 49c9bdf37. The production commit is unchanged; the test commit is new.

I had to go further than the plan above. Cutting the global kind to one float mode wasn't enough: that one shader still took most of the time, because llvmpipe is slow to compile global float atomics. The global kind now runs only FLOAT_MODE 0x00, with global_atomic_fmin and fmin_x2; their stored value depends on the flush in 13 of 32 rows at each width. Buffer and image keep all three operations in all six modes.

Cold on lavapipe with Mesa 25.2.8 and LLVM 20.1.2 (as on Linux CI), measured back to back on one heavily loaded machine:

Version Cold run
old head 232 s
one global mode 86–93 s
this head 22.5 s

On an idle runner it should be well under your 20 s.

The controls still hold on lavapipe:

  • With the global path's flush off, the test fails at global, FLOAT_MODE 0x00, lane 4 fmin stored 0x80000001, expected 0x80000000.
  • With the production change reverted, it fails at buffer, no float mode, lane 3 fmax stored 0x00000001, expected 0x00000000.

On the RX 6700 XT, the 8 float atomic tests pass 3 of 3, and the validation layer is clean on both sides. The description has the details.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309483773 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8055#issuecomment-6309483773). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-21T06:19:23Z. --- @oneandonlydean pushed `06c1c0300`, rebased onto `main` `49c9bdf37`. The production commit is unchanged; the test commit is new. I had to go further than the plan above. Cutting the global kind to one float mode wasn't enough: that one shader still took most of the time, because llvmpipe is slow to compile global float atomics. The global kind now runs only `FLOAT_MODE` 0x00, with `global_atomic_fmin` and `fmin_x2`; their stored value depends on the flush in 13 of 32 rows at each width. Buffer and image keep all three operations in all six modes. Cold on lavapipe with Mesa 25.2.8 and LLVM 20.1.2 (as on Linux CI), measured back to back on one heavily loaded machine: | Version | Cold run | |---|---| | old head | 232 s | | one global mode | 86–93 s | | this head | 22.5 s | On an idle runner it should be well under your 20 s. The controls still hold on lavapipe: - With the global path's flush off, the test fails at `global, FLOAT_MODE 0x00, lane 4 fmin stored 0x80000001, expected 0x80000000`. - With the production change reverted, it fails at `buffer, no float mode, lane 3 fmax stored 0x00000001, expected 0x00000000`. On the RX 6700 XT, the 8 float atomic tests pass 3 of 3, and the validation layer is clean on both sides. The description has the details.
oneandonlydean commented 2026-10-21 06:20:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T06:20:59Z.


@thuanquang thanks, 22.5 s cold on a loaded machine is well within range, and keeping both controls is what we needed. We will review the new test commit and then run full CI on 06c1c0300.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309506375 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8055#issuecomment-6309506375). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T06:20:59Z. --- @thuanquang thanks, 22.5 s cold on a loaded machine is well within range, and keeping both controls is what we needed. We will review the new test commit and then run full CI on `06c1c0300`.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!8055
No description provided.