xshader: saturate v_cvt_flr_i32_f32 and v_cvt_rpi_i32_f32 #591
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/591"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from brcly/TuxBox. Originally posted by KainanP on 2026-11-30T16:11:36Z.
v_cvt_flr_i32_f32andv_cvt_rpi_i32_f32were emitted as(int)floor(x)and(int)round(x). In DXIL that cast is undefined outside the i32 range, so the result depends on the driver. With a constant source, DXC folds it toundefand the shader fails validation ("Assignment of undefined values to UAV"). Both now go throughtb_cvt_i32_f32, the same saturating helperv_cvt_i32_f32uses. This also matches whatcheck_basic_alu_gpu.pyalready expects for both instructions: NaN gives 0, out-of-range values clamp.Test:
test_floor_and_round_conversions_saturateintests/test_float_to_integer.pychecks the value DXC folds for 2^31, FLT_MAX, -2^31, the float just below -2^31, -FLT_MAX, and some in-range values. DXC doesn't fold floor or round of an infinity or a NaN, so the test leaves those out.Ran (Windows 11, DXC 1.9.2609, CPU only):
TUXBOX_XSHADER=… DXC=… python -m unittest tests.test_float_to_integer tests.test_rpi_rounding: OK. Without the translator change, the new test fails on all 8 out-of-range cases (4 per instruction); the in-range ones pass both ways.cargo test --release -p tuxbox-xshader: passed, with no change to the host profile records.cargo fmt --all --check: clean.python -m unittest discover -s tests -q(translator and DXC set): 778 tests, 186 skipped, and 10 that fail the same way onmainon this Windows host (test_host.MesaShaderCache,test_stage_baseline,test_prefix_pool,test_scarlett_prep,test_translator_choice,test_verify: launcher and sandbox tests).Not run: the GPU translator checks (they need Proton, and I only have Windows here) and the game. Programs that use these two instructions get new HLSL, so their cached shaders compile again.
AI-assisted: Claude Code (Claude Opus 5.5) found the issue, wrote the change and the test, and ran the commands above.
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-30T19:04:53Z.
@KainanP the GPU checks, full
python tuxbox.py checkat9977e6a2, GE-Proton11-14:10de:2b85, 620.70.10): 203 pass, 0 fail.1002:13c0, RADV): 202 pass, 0 fail.The check includes the translator's GPU checks (ALU and float forms). I haven't run the game with it.
Evidence: TuxBox check of
9977e6a20d, no uncommitted changes, GPU 10de:2b85: 17 passed, 0 failed, 0 not runEvidence: TuxBox check of
9977e6a20d, no uncommitted changes, GPU 1002:13c0: 17 passed, 0 failed, 0 not run