fix(vk): emit strict f32 multiply in compute mesh fallback for AMD proprietary compiler #2086

Merged
HumanBean merged 1 commit from DYNMK/Longshot:fix/amd-mesh-fallback-strict-fmul into main 2026-11-21 17:24:20 +00:00
Contributor

Summary

Fixes #1710, Fixes #1799, Fixes #1934.

On Windows with AMD RDNA 1 and RDNA 2 GPUs (RX 5000 and RX 6000 series) running AMD's older Windows proprietary shader compiler, individual grass blade triangles randomly flash solid bright white for a single frame (most visibly in Death Mountain Trail, Kokiri Forest, and Lost Woods).

How to see the bug on main:

  1. Launch the game on Windows on an RX 5000 or RX 6000 GPU using AMD's older proprietary shader compiler (compute mesh fallback is active by default).
  2. Teleport to DeathMountainTrail_Child, walk slightly up the trail past the first grass clusters, and hold the camera looking at the grass.
  3. Single triangular grass blade tips flash bright white for one frame every ~10–20 frames (5–10 frames per 100 frames).

Root cause:
In the grass compute-fallback mesh shaders, the depth pre-pass (6afe3fda) computes fma(t, v * rsq, add) where v * rsq has only a single use, while the colour pass (d905f52b) reuses v * rsq for normals/lighting. Even though every floating-point op carries OpDecorate NoContraction and VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT is set on the pipeline, AMD's older Windows proprietary shader compiler ignores NoContraction on OpFMul and reassociates fma(t, v * rsq, add) into v37 = v_mul_f32(rsq, t); fma(v37, v, add) in the depth pass while keeping fma(v * rsq, t, add) in the colour pass. Because compute-fallback mesh stages write positions to storage buffers, gl_Position cannot be decorated Invariant. The resulting ±1 ULP shift on blade-tip vertices causes a few grass triangles per frame to fail the colour pass's VK_COMPARE_OP_EQUAL depth test and show the pre-drawn sky colour (white after tonemapping).

What this changes:

  • Adds DevicePolicy::mesh_fallback_strict_fmul (overrideable with RX_VK_MESH_STRICT_FMUL), defaulting on only for AMD's older Windows proprietary shader compiler (p.nan_bits, i.e., VK_DRIVER_ID_AMD_PROPRIETARY with "proprietary shader compiler" in driverInfo).
  • In EmitFPMul32, when ctx.mesh_fallback && mesh_fallback_strict_fmul && inst->Flags<IR::FpControl>().no_contraction, emits GLSL.std.450 Fma(a, b, -0.0f) with NoContraction instead of plain OpFMul. fma(a, b, -0.0f) is IEEE-754 bit-exact with a * b (including signed zero, subnormals, Inf, and NaN) and compiles to a single full-rate v_fmaak_f32 ..., 0x80000000 on RDNA 1/2, preventing the compiler from reassociating across the multiply.
  • Wires the policy flag into Shader::Backend::SPIRV::mesh_fallback_strict_fmul in coopmat_init() and folds it into translator_stamp() so cached programs rebuild cleanly when the flag changes.
  • Adds a game-free Sirit test (tests/test_mesh_fallback_strict_fmul.py) and updates tests/test_device_policy.py.

Result:
Depth-pass and colour-pass grass vertices match bit-for-bit (24,264/24,264 in fbrecs), and white grass triangle flashes drop to 0/100 frames with no measurable frame-time or register-pressure cost.

Files to read first:

  • gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp (EmitFPMul32)
  • gpu/vk/device_policy.h (DevicePolicy::mesh_fallback_strict_fmul, device_policy_env)
  • gpu/vk/vk_coopmat.cpp (coopmat_init) and gpu/vk/vk_shader.cpp (translator_stamp)
  • tests/test_mesh_fallback_strict_fmul.py

Testing

Tested:

  • In-game (Windows 11, AMD Radeon RX 6900 XT, AMD proprietary driver 26.11.2, version 0x800161):
    • Built longshot_vk.dll with python -I scripts/dev.py vk (llvm-mingw).
    • Interleaved A/B in DeathMountainTrail_Child (main @ 1dbf9150 vs this PR @ 0b86df87, 2 runs of 100 frames each, plus RX_VK_MESH_STRICT_FMUL=0 control): main reproduced 5/100 flash frames in both runs; this PR produced 0/100 in both runs; RX_VK_MESH_STRICT_FMUL=0 reproduced 10/100 flash frames.
    • Verified bit-exact fbrecs vertex output between depth pass (6afe3fda) and colour pass (d905f52b): 24,264/24,264 identical vertices with unoptimized pipelines and 24,164/24,164 identical vertices with optimized pipelines (matching RDNA 1 where mesh_no_optimizer is off).
    • Verified RDNA2 ISA disassembly via VK_KHR_pipeline_executable_properties on 6afe3fda: v_fmaak_f32 ..., 0x80000000 eliminates the illegal reassociation with identical VGPR/SGPR/LDS/scratch usage (45/16 unoptimized, 46/38 optimized, 0 scratch).
  • Game-free checks:
    • tests/test_mesh_fallback_strict_fmul.py: failed on main @ 1dbf9150 (FAIL: coopmat_init does not set Shader::Backend::SPIRV::mesh_fallback_strict_fmul), passes on 0b86df87.
    • Passed locally: tests/test_device_policy.py, tests/test_vendor_fixes.py, tests/test_switch_table.py, tests/test_program_stamp_knobs.py, tests/test_translator_stamp_text.py, tests/test_run_all_declarations.py, tests/test_utf8_paths.py, tests/test_log_levels.py, tests/test_thinlto_tls.py, tests/test_doc_anchors.py, scripts/check_third_party.py.
    • python -I -B tests/run_all.py --changed origin/main: 86 passed, 10 skipped (Linux-only spirv-val / optional zstandard), 11 failed — all 11 are pre-existing on main in untouched files (tests/test_recorder_sync.py and tests/test_pass_barrier.py on vk_colour_vision.cpp/vk_recorder.h; tests/test_dev_ab.py and tests/test_present_queue_default.py on vk_menu.cpp; tests/test_dev_packs.py on longshot_fsr4_pipelines.bin; tests/test_linux_pressure.py on vk_texture.cpp; tests/test_frame_overlap.py; tests/test_target_reuse_memory.py; tests/test_vk_occlusion_queries.py; tests/test_build_long_paths.py missing local capstone; tests/test_crash_dialog.py cp1252 decode on Windows).

Still to test:

  • Windows AMD RDNA 1 (RX 5700 / RX 5700 XT, AMD proprietary shader compiler): run DeathMountainTrail_Child and KokiriForest_Child, expecting mesh_fallback_strict_fmul=1 in vk: policy: driver fixes and no flashing white grass triangles (by hand).
  • Linux (RADV / NVIDIA) and Windows (NVIDIA / Intel / AMD RDNA 3–4 LLPC): build renderer and run game-free checks (mise run test including test_vendor_translation.py and test_mesh_fallback_strict_fmul.py), expecting mesh_fallback_strict_fmul=0 on non-affected drivers and zero regressions (@Beanstalk build and run game-free checks and Tier 1 smoke tests).

Measurements

Verdict: Fixes the flashing white grass triangles completely (median 5/100 -> 0/100 flash frames, 27.5 -> 0 flash pixels) with no measurable GPU frame-time regression (within run-to-run spread at 11.35 ms vs 11.6 ms, 60.0 fps cap) and zero VGPR/SGPR/LDS/scratch increase. RX_VK_MESH_STRICT_FMUL ships enabled by default on AMD's older Windows proprietary shader compiler (p.nan_bits) and disabled everywhere else because the fix eliminates all flashes on affected drivers at no cost while leaving unaffected drivers untouched.

Setup: Windows 11, AMD Radeon RX 6900 XT, AMD proprietary driver 26.11.2 (0x800161); DeathMountainTrail_Child (profile="test", 1280x720 headless capture, RX_VK_PRECOMPILE=0, RX_VK_NO_PROGRAM_CACHE=1, RX_VK_PCACHE_LOAD=0); 2 interleaved runs of 100 consecutive frames each after scene warm-up (main_1, pr_1, main_2, pr_2), plus a control run with RX_VK_MESH_STRICT_FMUL=0; white-blade flash count and steady-state vk: GPU time from log.txt, median reported.

Before: main @ 1dbf9150 After: this PR @ 0b86df87 After, RX_VK_MESH_STRICT_FMUL=0: this PR @ 0b86df87 Δ
Flashing grass frames / 100 (run 1 / run 2) 5 / 5 (median 5) 0 / 0 (median 0) 10 -100%
Total flashing white grass pixels / 100 frames (run 1 / run 2) 43 / 12 (median 27.5) 0 / 0 (median 0) 55 -100%
Steady-state GPU time (run 1 / run 2) 11.3 / 11.4 ms (median 11.35 ms) 11.8 / 11.4 ms (median 11.6 ms) 11.6 ms within spread (+0.25 ms)
Frame rate (60 fps cap) 60.0 fps 60.0 fps 60.0 fps 0.0 fps
6afe3fda RDNA2 ISA VGPRs / SGPRs / Scratch (unopt; opt) 45 / 16 / 0; 46 / 38 / 0 45 / 16 / 0; 46 / 38 / 0 45 / 16 / 0; 46 / 38 / 0 0 / 0 / 0
# Before: main @ 1dbf9150 (run 1 / run 2)
[hos MainThread] vk: policy: driver fixes on driver version 0x800161: fetch_bounds=1 nan_bits=1 gather_offset=1 frag_shuffle_fallback=1 position_invariant=1 ... task_mesh_fallback=1(seen on 0x800161) ...
[hos host] vk: 3840 presents, 60.0 fps; ... | vk: GPU time 11.3 ms a frame (the longest submission 5.3 ms)
[hos host] vk: 3720 presents, 60.0 fps; ... | vk: GPU time 11.4 ms a frame (the longest submission 5.4 ms)

# After: this PR @ 0b86df87 (run 1 / run 2)
[hos MainThread] vk: policy: driver fixes on driver version 0x800161: fetch_bounds=1 nan_bits=1 mesh_fallback_strict_fmul=1(seen on 0x800161) gather_offset=1 frag_shuffle_fallback=1 position_invariant=1 ... task_mesh_fallback=1(seen on 0x800161) ...
[hos host] vk: 3720 presents, 60.1 fps; ... | vk: GPU time 12.0 ms a frame (the longest submission 5.9 ms) [run 1 steady median 11.8 ms]
[hos host] vk: 3960 presents, 60.0 fps; ... | vk: GPU time 11.4 ms a frame (the longest submission 5.6 ms) [run 2 steady median 11.4 ms]

# Control: this PR @ 0b86df87 with RX_VK_MESH_STRICT_FMUL=0
[hos MainThread] vk: policy: driver fixes on driver version 0x800161: fetch_bounds=1 nan_bits=1 mesh_fallback_strict_fmul=0* gather_offset=1 ...
[hos host] vk: 3600 presents, 60.1 fps; ... | vk: GPU time 11.6 ms a frame (the longest submission 5.8 ms)

Screenshots of the same spot (DeathMountainTrail_Child, frame 94) are attached in the comment below showing the bright white grass blade tip at bottom center on main @ 1dbf9150 and clean rendering on this PR @ 0b86df87.

Risks

  • Scope: Only affects NoContraction 32-bit float multiplies inside compute-fallback mesh stages (ctx.mesh_fallback) when mesh_fallback_strict_fmul is enabled (by default, only AMD's older Windows proprietary shader compiler on RDNA 1/2). All other GPUs, Linux/RADV, AMD RDNA 3/4 LLPC, and native mesh shader stages emit identical SPIR-V to main.
  • How to turn it off: Launch with RX_VK_MESH_STRICT_FMUL=0, or revert this commit.
  • What players notice after updating: Because translator_stamp() changes when mesh_fallback_strict_fmul is active, Windows AMD RDNA 1/2 players will see a normal one-time program/pipeline cache rebuild on first launch after updating. Saves, longshot_options.ini, and caches on unaffected GPUs are unchanged.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • A check under tests/ that reads changed source is updated, not weakened.
  • Screenshots of the same spot on main and here, for a change that shows on screen.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

Assisted-by: Antigravity

## Summary Fixes #1710, Fixes #1799, Fixes #1934. On Windows with AMD RDNA 1 and RDNA 2 GPUs (RX 5000 and RX 6000 series) running AMD's older Windows proprietary shader compiler, individual grass blade triangles randomly flash solid bright white for a single frame (most visibly in Death Mountain Trail, Kokiri Forest, and Lost Woods). **How to see the bug on `main`:** 1. Launch the game on Windows on an RX 5000 or RX 6000 GPU using AMD's older proprietary shader compiler (compute mesh fallback is active by default). 2. Teleport to `DeathMountainTrail_Child`, walk slightly up the trail past the first grass clusters, and hold the camera looking at the grass. 3. Single triangular grass blade tips flash bright white for one frame every ~10–20 frames (5–10 frames per 100 frames). **Root cause:** In the grass compute-fallback mesh shaders, the depth pre-pass (`6afe3fda`) computes `fma(t, v * rsq, add)` where `v * rsq` has only a single use, while the colour pass (`d905f52b`) reuses `v * rsq` for normals/lighting. Even though every floating-point op carries `OpDecorate NoContraction` and `VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT` is set on the pipeline, AMD's older Windows proprietary shader compiler ignores `NoContraction` on `OpFMul` and reassociates `fma(t, v * rsq, add)` into `v37 = v_mul_f32(rsq, t); fma(v37, v, add)` in the depth pass while keeping `fma(v * rsq, t, add)` in the colour pass. Because compute-fallback mesh stages write positions to storage buffers, `gl_Position` cannot be decorated `Invariant`. The resulting ±1 ULP shift on blade-tip vertices causes a few grass triangles per frame to fail the colour pass's `VK_COMPARE_OP_EQUAL` depth test and show the pre-drawn sky colour (white after tonemapping). **What this changes:** - Adds `DevicePolicy::mesh_fallback_strict_fmul` (overrideable with `RX_VK_MESH_STRICT_FMUL`), defaulting on only for AMD's older Windows proprietary shader compiler (`p.nan_bits`, i.e., `VK_DRIVER_ID_AMD_PROPRIETARY` with `"proprietary shader compiler"` in `driverInfo`). - In `EmitFPMul32`, when `ctx.mesh_fallback && mesh_fallback_strict_fmul && inst->Flags<IR::FpControl>().no_contraction`, emits `GLSL.std.450 Fma(a, b, -0.0f)` with `NoContraction` instead of plain `OpFMul`. `fma(a, b, -0.0f)` is IEEE-754 bit-exact with `a * b` (including signed zero, subnormals, Inf, and NaN) and compiles to a single full-rate `v_fmaak_f32 ..., 0x80000000` on RDNA 1/2, preventing the compiler from reassociating across the multiply. - Wires the policy flag into `Shader::Backend::SPIRV::mesh_fallback_strict_fmul` in `coopmat_init()` and folds it into `translator_stamp()` so cached programs rebuild cleanly when the flag changes. - Adds a game-free Sirit test (`tests/test_mesh_fallback_strict_fmul.py`) and updates `tests/test_device_policy.py`. **Result:** Depth-pass and colour-pass grass vertices match bit-for-bit (`24,264/24,264` in `fbrecs`), and white grass triangle flashes drop to `0/100` frames with no measurable frame-time or register-pressure cost. **Files to read first:** - `gpu/vk/eden/shader_recompiler/backend/spirv/emit_spirv_floating_point.cpp` (`EmitFPMul32`) - `gpu/vk/device_policy.h` (`DevicePolicy::mesh_fallback_strict_fmul`, `device_policy_env`) - `gpu/vk/vk_coopmat.cpp` (`coopmat_init`) and `gpu/vk/vk_shader.cpp` (`translator_stamp`) - `tests/test_mesh_fallback_strict_fmul.py` ## Testing **Tested:** - **In-game (Windows 11, AMD Radeon RX 6900 XT, AMD proprietary driver `26.11.2`, version `0x800161`):** - Built `longshot_vk.dll` with `python -I scripts/dev.py vk` (llvm-mingw). - Interleaved A/B in `DeathMountainTrail_Child` (`main @ 1dbf9150` vs `this PR @ 0b86df87`, 2 runs of 100 frames each, plus `RX_VK_MESH_STRICT_FMUL=0` control): `main` reproduced 5/100 flash frames in both runs; this PR produced 0/100 in both runs; `RX_VK_MESH_STRICT_FMUL=0` reproduced 10/100 flash frames. - Verified bit-exact `fbrecs` vertex output between depth pass (`6afe3fda`) and colour pass (`d905f52b`): `24,264/24,264` identical vertices with unoptimized pipelines and `24,164/24,164` identical vertices with optimized pipelines (matching RDNA 1 where `mesh_no_optimizer` is off). - Verified RDNA2 ISA disassembly via `VK_KHR_pipeline_executable_properties` on `6afe3fda`: `v_fmaak_f32 ..., 0x80000000` eliminates the illegal reassociation with identical VGPR/SGPR/LDS/scratch usage (`45/16` unoptimized, `46/38` optimized, `0` scratch). - **Game-free checks:** - `tests/test_mesh_fallback_strict_fmul.py`: failed on `main @ 1dbf9150` (`FAIL: coopmat_init does not set Shader::Backend::SPIRV::mesh_fallback_strict_fmul`), passes on `0b86df87`. - Passed locally: `tests/test_device_policy.py`, `tests/test_vendor_fixes.py`, `tests/test_switch_table.py`, `tests/test_program_stamp_knobs.py`, `tests/test_translator_stamp_text.py`, `tests/test_run_all_declarations.py`, `tests/test_utf8_paths.py`, `tests/test_log_levels.py`, `tests/test_thinlto_tls.py`, `tests/test_doc_anchors.py`, `scripts/check_third_party.py`. - `python -I -B tests/run_all.py --changed origin/main`: 86 passed, 10 skipped (Linux-only `spirv-val` / optional `zstandard`), 11 failed — all 11 are pre-existing on `main` in untouched files (`tests/test_recorder_sync.py` and `tests/test_pass_barrier.py` on `vk_colour_vision.cpp`/`vk_recorder.h`; `tests/test_dev_ab.py` and `tests/test_present_queue_default.py` on `vk_menu.cpp`; `tests/test_dev_packs.py` on `longshot_fsr4_pipelines.bin`; `tests/test_linux_pressure.py` on `vk_texture.cpp`; `tests/test_frame_overlap.py`; `tests/test_target_reuse_memory.py`; `tests/test_vk_occlusion_queries.py`; `tests/test_build_long_paths.py` missing local `capstone`; `tests/test_crash_dialog.py` cp1252 decode on Windows). **Still to test:** - Windows AMD RDNA 1 (RX 5700 / RX 5700 XT, AMD proprietary shader compiler): run `DeathMountainTrail_Child` and `KokiriForest_Child`, expecting `mesh_fallback_strict_fmul=1` in `vk: policy: driver fixes` and no flashing white grass triangles (by hand). - Linux (RADV / NVIDIA) and Windows (NVIDIA / Intel / AMD RDNA 3–4 LLPC): build renderer and run game-free checks (`mise run test` including `test_vendor_translation.py` and `test_mesh_fallback_strict_fmul.py`), expecting `mesh_fallback_strict_fmul=0` on non-affected drivers and zero regressions (@Beanstalk build and run game-free checks and Tier 1 smoke tests). ## Measurements **Verdict:** Fixes the flashing white grass triangles completely (median `5/100` -> `0/100` flash frames, `27.5` -> `0` flash pixels) with no measurable GPU frame-time regression (within run-to-run spread at `11.35 ms` vs `11.6 ms`, 60.0 fps cap) and zero VGPR/SGPR/LDS/scratch increase. `RX_VK_MESH_STRICT_FMUL` ships enabled by default on AMD's older Windows proprietary shader compiler (`p.nan_bits`) and disabled everywhere else because the fix eliminates all flashes on affected drivers at no cost while leaving unaffected drivers untouched. Setup: Windows 11, AMD Radeon RX 6900 XT, AMD proprietary driver `26.11.2` (`0x800161`); `DeathMountainTrail_Child` (`profile="test"`, 1280x720 headless capture, `RX_VK_PRECOMPILE=0`, `RX_VK_NO_PROGRAM_CACHE=1`, `RX_VK_PCACHE_LOAD=0`); 2 interleaved runs of 100 consecutive frames each after scene warm-up (`main_1`, `pr_1`, `main_2`, `pr_2`), plus a control run with `RX_VK_MESH_STRICT_FMUL=0`; white-blade flash count and steady-state `vk: GPU time` from `log.txt`, median reported. | | Before: main @ 1dbf9150 | After: this PR @ 0b86df87 | After, RX_VK_MESH_STRICT_FMUL=0: this PR @ 0b86df87 | Δ | |---|---|---|---|---| | Flashing grass frames / 100 (run 1 / run 2) | 5 / 5 (median 5) | 0 / 0 (median 0) | 10 | -100% | | Total flashing white grass pixels / 100 frames (run 1 / run 2) | 43 / 12 (median 27.5) | 0 / 0 (median 0) | 55 | -100% | | Steady-state GPU time (run 1 / run 2) | 11.3 / 11.4 ms (median 11.35 ms) | 11.8 / 11.4 ms (median 11.6 ms) | 11.6 ms | within spread (+0.25 ms) | | Frame rate (60 fps cap) | 60.0 fps | 60.0 fps | 60.0 fps | 0.0 fps | | `6afe3fda` RDNA2 ISA VGPRs / SGPRs / Scratch (unopt; opt) | 45 / 16 / 0; 46 / 38 / 0 | 45 / 16 / 0; 46 / 38 / 0 | 45 / 16 / 0; 46 / 38 / 0 | 0 / 0 / 0 | ```text # Before: main @ 1dbf9150 (run 1 / run 2) [hos MainThread] vk: policy: driver fixes on driver version 0x800161: fetch_bounds=1 nan_bits=1 gather_offset=1 frag_shuffle_fallback=1 position_invariant=1 ... task_mesh_fallback=1(seen on 0x800161) ... [hos host] vk: 3840 presents, 60.0 fps; ... | vk: GPU time 11.3 ms a frame (the longest submission 5.3 ms) [hos host] vk: 3720 presents, 60.0 fps; ... | vk: GPU time 11.4 ms a frame (the longest submission 5.4 ms) # After: this PR @ 0b86df87 (run 1 / run 2) [hos MainThread] vk: policy: driver fixes on driver version 0x800161: fetch_bounds=1 nan_bits=1 mesh_fallback_strict_fmul=1(seen on 0x800161) gather_offset=1 frag_shuffle_fallback=1 position_invariant=1 ... task_mesh_fallback=1(seen on 0x800161) ... [hos host] vk: 3720 presents, 60.1 fps; ... | vk: GPU time 12.0 ms a frame (the longest submission 5.9 ms) [run 1 steady median 11.8 ms] [hos host] vk: 3960 presents, 60.0 fps; ... | vk: GPU time 11.4 ms a frame (the longest submission 5.6 ms) [run 2 steady median 11.4 ms] # Control: this PR @ 0b86df87 with RX_VK_MESH_STRICT_FMUL=0 [hos MainThread] vk: policy: driver fixes on driver version 0x800161: fetch_bounds=1 nan_bits=1 mesh_fallback_strict_fmul=0* gather_offset=1 ... [hos host] vk: 3600 presents, 60.1 fps; ... | vk: GPU time 11.6 ms a frame (the longest submission 5.8 ms) ``` Screenshots of the same spot (`DeathMountainTrail_Child`, frame 94) are attached in the comment below showing the bright white grass blade tip at bottom center on `main @ 1dbf9150` and clean rendering on `this PR @ 0b86df87`. ## Risks - **Scope:** Only affects `NoContraction` 32-bit float multiplies inside compute-fallback mesh stages (`ctx.mesh_fallback`) when `mesh_fallback_strict_fmul` is enabled (by default, only AMD's older Windows proprietary shader compiler on RDNA 1/2). All other GPUs, Linux/RADV, AMD RDNA 3/4 LLPC, and native mesh shader stages emit identical SPIR-V to `main`. - **How to turn it off:** Launch with `RX_VK_MESH_STRICT_FMUL=0`, or revert this commit. - **What players notice after updating:** Because `translator_stamp()` changes when `mesh_fallback_strict_fmul` is active, Windows AMD RDNA 1/2 players will see a normal one-time program/pipeline cache rebuild on first launch after updating. Saves, `longshot_options.ini`, and caches on unaffected GPUs are unchanged. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] Screenshots of the same spot on `main` and here, for a change that shows on screen. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. --- Assisted-by: Antigravity
fix(vk): emit strict f32 multiply in compute mesh fallback for AMD proprietary compiler
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 6s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval not approved yet
0b86df87b9
AMD's older Windows proprietary shader compiler (RDNA 1 and 2, RX 5000 and
RX 6000) ignores SPIR-V NoContraction on OpFMul inside compute-fallback mesh
stages even with VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT, reassociating
fma(t, v * rsq, add) into fma(rsq * t, v, add) in depth-only passes while
keeping fma(v * rsq, t, add) in colour passes. The resulting 1 ULP shift on
grass blade tips fails EQUAL depth testing and flashes white triangles
(issues #1710, #1799, #1934).

Emit NoContraction FPMul32 as GLSL.std.450 Fma(a, b, -0.0f) when inside a
compute-fallback mesh stage and DevicePolicy::mesh_fallback_strict_fmul is
enabled (default on for AMD's older Windows proprietary shader compiler,
overrideable via RX_VK_MESH_STRICT_FMUL). Fold the policy flag into
translator_stamp().

Assisted-by: Antigravity
Author
Contributor

Before / After Screenshots (DeathMountainTrail_Child, frame 94)

Same PC, save, camera, and settings (Windows 11, AMD Radeon RX 6900 XT, AMD proprietary driver 26.11.2 / 0x800161, 1280x720).

Before: main @ 1dbf9150 (white grass triangle at bottom centre) After: this PR @ 0b86df87 (clean)
Before: main @ 1dbf9150 After: this PR @ 0b86df87
### Before / After Screenshots (`DeathMountainTrail_Child`, frame 94) Same PC, save, camera, and settings (Windows 11, AMD Radeon RX 6900 XT, AMD proprietary driver `26.11.2` / `0x800161`, 1280x720). | Before: `main @ 1dbf9150` (white grass triangle at bottom centre) | After: `this PR @ 0b86df87` (clean) | |---|---| | ![Before: main @ 1dbf9150](https://git.magicbean.dev/attachments/5cd0b46a-89b1-47dc-b78c-eb95ee4c6ab2) | ![After: this PR @ 0b86df87](https://git.magicbean.dev/attachments/6208f0cc-f7e7-45e9-93dd-6caaea2c5461) |
Author
Contributor

@Beanstalk Please build and test this PR against main on windows+amd, linux+amd, steamdeck, and windows+nvidia:

  • Run game-free checks (mise run test, including tests/test_mesh_fallback_strict_fmul.py, tests/test_device_policy.py, and tests/test_vendor_translation.py).
  • On windows+amd with AMD's older proprietary shader compiler (RDNA 1 / RDNA 2, RX 5000 / RX 6000): confirm mesh_fallback_strict_fmul=1 in vk: policy: driver fixes and no flashing white grass triangles in DeathMountainTrail_Child / KokiriForest_Child.
  • On windows+amd (RDNA 3 / 4 LLPC), linux+amd (Mesa RADV), steamdeck, and windows+nvidia: confirm mesh_fallback_strict_fmul=0 in vk: policy: driver fixes and no regressions.
@Beanstalk Please build and test this PR against `main` on `windows+amd`, `linux+amd`, `steamdeck`, and `windows+nvidia`: - Run game-free checks (`mise run test`, including `tests/test_mesh_fallback_strict_fmul.py`, `tests/test_device_policy.py`, and `tests/test_vendor_translation.py`). - On `windows+amd` with AMD's older proprietary shader compiler (RDNA 1 / RDNA 2, RX 5000 / RX 6000): confirm `mesh_fallback_strict_fmul=1` in `vk: policy: driver fixes` and no flashing white grass triangles in `DeathMountainTrail_Child` / `KokiriForest_Child`. - On `windows+amd` (RDNA 3 / 4 LLPC), `linux+amd` (Mesa RADV), `steamdeck`, and `windows+nvidia`: confirm `mesh_fallback_strict_fmul=0` in `vk: policy: driver fixes` and no regressions.
Member

@DYNMK only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@DYNMK only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
HumanBean deleted branch fix/amd-mesh-fallback-strict-fmul 2026-11-21 17:24:21 +00:00
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 6s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval not approved yet
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2086
No description provided.