Repository navigation
feat(shader): track MODE rounding changes through the control flow graph - #5180
Conversation
|
@iDiesIrae-Req could you run vkQuake (PPSA99010) with this branch on your RTX 4070 setup, with RT shadows on (the default, no What I'd like to know is what happens after that point on this branch:
Either line settles whether this PR unblocks the title. Why I couldn't check it myself: my box has no GPU. On lavapipe (Mesa 25.0.7) under Xvfb, on AI-assisted: yes |
|
@semirkabir Ran it. Setup: Windows 11, RTX 4070 Laptop (driver 32.0.16.1714), WinLibs GCC 15.2.0 r7 Release, vkQuake (PPSA99010) with the Quake 1.06 shareware
So on this title the PR moves the stop but doesn't unblock it, because the shader reaches the recompiler with no As a local experiment only (not proposing it as is), I fell back to the live register when the shader isn't registered, decoded the same way [&]() -> std::optional<ShaderRecompiler::ShaderFloatMode> {
if (auto registered = RegisteredFloatMode(snapshot)) return registered;
const auto found = queue.shader.find(0x212u);
if (found == queue.shader.end()) return std::nullopt;
const auto value = found->second;
return ShaderRecompiler::ShaderFloatMode{(value >> 12u) & 0xffu, ((value >> 21u) & 1u) != 0u, ((value >> 23u) & 1u) != 0u, ((value >> 26u) & 1u) != 0u};
}()With that on top of this PR, 4/4 runs no longer throw. Happy to run another build here if useful. AI-assisted: yes (Claude Code); all runs were on my machine. |
|
@semirkabir Follow-up from the same RTX 4070 setup, now on
The stall isn't a hidden failure. One thread runs at 100% inside NVIDIA's shader compiler ( AI-assisted: yes (Claude Code); all runs were on my machine. |
|
On PPSA99010 this only moves the stop (iDiesIrae-Req's runs above): |
6b9fbeb to
c48628c
Compare
|
Added in c48628c: a dispatch whose shader was never registered now takes its FLOAT_MODE from the live COMPUTE_PGM_RSRC1. Registered shaders still read their registered state. Rebased on 75690a1.
This is the fallback @iDiesIrae-Req ran on PPSA99010: there's no throw at pc 316 anymore. The title then stalls in NVIDIA's shader compiler at submission 18. That's separate from this PR, and I can't reach it here because this box has no GPU. AI-assisted: yes |
|
Checked the MODE rounding tracking against gfx1035 (s_round_mode, s_setreg_imm32_b32 fields, s_getreg read-back), the agc_shader_mode_register and agc_driver tests (they fail to build without the change), and the RSRC1 fallback requested above; confirmed on PPSA99010 by @iDiesIrae-Req (no throw at pc 316). Merging once the full Build is green. |
|
Rebased onto current |
c48628c to
e511d12
Compare
|
Rebased onto current |
e511d12 to
ee1e341
Compare
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
What
Addresses #981 for immediate rounding writes. The recompiler threw on any
s_round_modeors_setreg_imm32_b32that changed the MODE rounding fields from the shader's initialFLOAT_MODE. vkQuake (PPSA99010) stops there on Windows,mainc13dc7e (iDiesIrae-Req on #1578 and #981, 7 of 9 runs on an RTX 4070, RT shadow path):ACO emits this shape: it sets a rounding mode around the instructions that need it and restores it afterwards (
aco_insert_fp_mode.cpp,set_mode:s_round_modeon GFX10+,s_setreg_imm32_b32before).RoundingMode.cppcomputes the rounding fields (MODE bits 0-3) at the entry of every block. It walks the control flow graph from the initialFLOAT_MODE, applies immediate writes, and joins the paths. Bits that differ between paths, or that are written from an SGPR (s_setreg_b32), become unknown.FLOAT_MODErounding (v_cvt_f32_i32/u32,v_ldexp_f32, the f16 conversions,v_ldexp_f16with f16 denormals kept, and the mix/interp/packed f16 instructions that check their own mode) follow the current value.s_getreg_b32of the rounding bits returns the tracked value.FLOAT_MODEmetadata still throws on any rounding change.docs/dev/debt/shader.mdis updated.Tested
Linux (GCC), lavapipe, on current
maine152ba8:agc_shader_mode_register_testscover:s_getreg_b32;s_round_mode0-15 from every initial rounding;s_round_mode(follows the mode);agc_driver_f16_to_f32_unpack, which needs a feature lavapipe lacks).tools/check_conventions.py --base origin/mainpasses.Not tested on the title. Under lavapipe here, vkQuake stops earlier than this shader: SDL cannot open Vulkan on the offscreen driver, and the title's error path then faults in its own libunwind. So I can't show that it gets past pc 316.
s_round_mode 8sets f16/f64 rounding toward -inf. If the RT shader runs an f16/f64 instruction outside the modelled set in that mode, it will now throw at that instruction, with its pc, instead of at thes_round_mode. A run on a GPU would settle it.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)