mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:30:53 +01:00
[PR #1277] [CLOSED] rdna2spirv: test each legacy multiply operand once (SHADER-LEGACY-MUL-SUBNORMAL) #1309
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1309
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1277
Author: @Moriz82
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:split/shader-legacy-mul-subnormal📝 Commits (1)
819cc92rdna2spirv: test each legacy multiply operand once (SHADER-LEGACY-MUL-SUBNORMAL)📊 Changes
3 files changed (+27 additions, -1 deletions)
View changed files
📝
docs/design.md(+1 -1)📝
tests/semantic/test_valu_mul_legacy_denorm.py(+23 -0)📝
tools/rdna2spirv.py(+3 -0)📄 Description
Rebased onto
bfef489cat819cc921. Main already combines the operand denormal checks. This diff keeps the operation-count regression test and explains the calculation. All five focused tests passed.Claimed in the coordination issue as: SHADER-LEGACY-MUL-SUBNORMAL (claim).
Part of the split of #984 into small pull requests.
Depends on: none
Overlaps: none found. #984 is the parent integration. Searched open and merged pull requests for
v_mul_legacy_f32,mul_legacy,legacy mul,legacy f32,denorm,subnormalandflush_f32: #642 (merged, a clamped NaN gives +0) is in the base and itsclamp_modsis used unchanged; #1039 adds GPU fixtures for thev_mad_f32flush and #637 decodesv_mac_legacy_f32, neither touches this lowering or its test. The current diffs of #811, #829, #858, #1039, #1068 and #1112 apply cleanly on this branch (git apply --check).What and why
v_mul_legacy_f32is the DX9 multiply: zero times anything is +0, and under the game'sMODEan f32 subnormal reads as zero (the contract row "v_mul_legacy_f32default-mode f32 denormal flushing"). For every such instruction the translator emitted:FAbs, a compare withFLT_MIN, the sign bit, a bitcast and a select),A subnormal operand ends as +0 whatever its sign, so the signed zero made for it is never seen:
|x| < FLT_MINis the override condition itself. This changemul:2,mul:4ordiv:2, the one step that can make a new subnormal. A clamp of +0, a flushed product or a NaN cannot.No result changes. The emitted code gets shorter. For one multiply in the test's pixel shader, in assembly lines over the same program without it:
clampmul:2mul:2 clampThe three GPU fixtures with four legacy multiplies each go from 7,324 to 6,140 bytes (
ps_legacy_mul), 7,196 to 6,012 (ps_mul_legacy_denorm) and 7,616 to 6,840 (ps_mul_legacy_denorm_mods, three of its four with an output multiplier).docs/design.mdcounts 147,499 instructions of the formv_mul_legacy_f32 … clampalone in the game's listings, so the instruction is common enough for its length to matter.The contract row now says how the software test is laid out. The rule itself is unchanged.
Tested
CachyOS (kernel 7.3.5), Python 3.14, LLVM
llvm-mc23.1.5 and SPIRV-Tools v2026.4. GPU fixtures on an NVIDIA GeForce RTX 4070, driver 620.73.04.python3 -I tests/semantic/test_valu_mul_legacy_denorm.py: 5 tests pass. With the base commit's translator (LEONIDA_TOOLS_DIR=<export of the base's tools>) the newtest_each_operand_is_tested_oncefails in all 4 of its subtests: 4 magnitude tests where 3 are expected without an output multiplier, and 3 compares with zero where 1 is expected with one. The other 4 tests pass on the base, including the two operand pairs added here (an infinity times the largest subnormal of the other sign): they pin theFLT_MINboundary of the new test and do not show a fault in the base.FLT_MIN, normals,FLT_MAX, infinities and NaNs of both signs) in every pair, under 7 modifier sets (none,mul:2,mul:4,div:2,clamp,mul:2 clamp,div:2 clamp), run throughspirv_mini_interpwith each translator: the same word in all 3,703 cases. This sweep is a local script, not part of the pull request.python3 -I scripts/run_semantic_tests.py tests/semantic -p <file>fortest_negative_controls.py(1 test),test_ps_semantics.py(7),test_value_semantics.py(41) andtest_valu_f32_min3_max3_mad.py(22), andpython3 -Iontest_mutations.py(3),test_vop3_clamp_nan.py(12),test_alu_vop3_mods_hw.py(2),test_bitcast_round_trip.py(3) andtests/test_f32_fuzz.py(29, 1 skipped): all pass.test_mutations.pystill catches the translator with the zero override removed.python3 -I scripts/run_gpu_tests.py --filter legacy: 3 shaders translate and passspirv-val;ps_legacy_mul,ps_mul_legacy_denormandps_mul_legacy_denorm_modseach give 4096/4096 exact pixels, with the base commit's translator and with this one. The harness programs are from a native Linux build of 2026-11-23 on this machine and were not rebuilt.python3 -I scripts/run_semantic_tests.py tests/semantic -j 2: 470 files, 6,169 tests, 0 files failed (the base: 470 files, 6,168 tests, 0 failed).tests/the wayci.ymlruns them, andpython3 -I -m compileall -q make_game.py tools tests: 520 files, 519 pass.tests/test_imhex_patterns.pyfails (6 of its 9 tests) and fails the same way on the base commit, so it is not from this change.compileallpasses.python3 -I scripts/check_no_game_data.py: passes.Not run: native Windows, macOS, an AMD or Intel GPU, the full GPU suite, the
tools/hw_oracleprobe (the hardware rule is not changed, so nothing new was measured), the runtime build and a game boot.GPUs tested: NVIDIA GeForce RTX 4070, driver 620.73.04, Linux (the three legacy multiply fixtures only).
AI-assisted: yes (Claude Code). The numbers above come from runs on the machine named.
Checklist
6293c1c4f, one commit.docs/design.mddescribes the new layout and names the test that pins it.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.