mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:15:51 +01:00
[PR #1933] rdna2spirv, shader_ir: route v_div_fixup_f64, v_div_fmas_f64, v_cmp(x)_*_f64, and v_cmp(x)_class_f64 through f64_source_words (SHADER-F64-LITERAL-SOURCES) #1939
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#1939
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/1933
Author: @ShotTechOp
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/f64-literal-sources📝 Commits (1)
b14335erdna2spirv, shader_ir: route div/cmp f64 literals through f64_source_words (SHADER-F64-LITERAL-SOURCES)📊 Changes
5 files changed (+335 additions, -65 deletions)
View changed files
📝
docs/design.md(+1 -1)➕
tests/semantic/test_f64_literal_sources.py(+280 -0)📝
tests/test_shader_ir_parse.py(+36 -0)📝
tools/rdna2spirv.py(+5 -60)📝
tools/shader_ir.py(+13 -4)📄 Description
Claimed as
SHADER-F64-LITERAL-SOURCESin #1608.What changed and why
Four binary64 instruction families in
tools/rdna2spirv.pybypassedGen.f64_source_words()and were omitted fromtools/shader_ir.py's binary64 literal tagging (f64_literal/literal_hex_digits):v_div_fixup_f64(tools/rdna2spirv.py) andv_div_fmas_f64(tools/rdna2spirv.py):d64_words/f64) placed 32-bit hex literals such as0x3ff00000(+1.0),0x40000000(+2.0),0x7ff00000(+inf),0x7ff80000(qNaN),0x80000000(-0.0), and0x1into the low dword (lo = v, hi = 0, turning them into tiny subnormals) instead of bits[63:32](lo = 0, hi = v) per the RDNA2 ISA anddocs/design.md("f64 literal sources").v_div_fmas_f64withVCC=1, a 32-bit literal0x40000000(2.0) inS2also fell below the|S2| >= 2.0threshold and scaled down by2^-128instead of up by2^128.compare_f64_cond(v_cmp(x)_*_f64) andcmp_class_f64(v_cmp(x)_class_f64) (plus the fallback f64 branch incmp_class):sv.get("literal")key (never set bytools/shader_ir.py, which setsf64_literalandliteral_hex_digits) and checked value bounds instead of printed hex width (f64_literal_one_dword).-16..64(e.g.0x1) were misread as inline integers ((1, 0)instead of(0, 1)), sov_cmp_gt_f64_e64 s4, 0x1, 1returned0instead of1.tools/f64_diff.py(e.g.0x000000003ff00000,0x0000000080000000,0x000000007ff00000) were shifted into bits[63:32]instead of decoded as whole 64-bit subnormals, makingv_cmp_class_f64classify0x000000003ff00000as+normalinstead of+denormalandv_cmp_eq_f64report0x000000003ff00000 == 1.0.Fix:
tools/shader_ir.py: tagf64_literalandliteral_hex_digits(case-insensitive0x/0X) onv_div_fixup_f64,v_div_fmas_f64,v_cmp(x)_class_f64(src0only, leaving the trailing 10-bit integer class mask untagged), andv_cmp(x)_*_f64(last two operands, covering both 2-operand and 3-operand forms).tools/rdna2spirv.py: routecompare_f64_cond,cmp_class(f64 branch),cmp_class_f64,v_div_fixup_f64, andv_div_fmas_f64throughself.f64_source_words(...), removing 60 lines of duplicated ad-hoc operand decoding.docs/design.md: document these four op families in the existingf64 literal sourcescontract row.tests/semantic/test_f64_literal_sources.py&tests/test_shader_ir_parse.py: add semantic execution, SPIR-V constant-pair,spirv_asm.assemble,f64_diff.ref_programcross-check, and parser tests.Negative control (RED on
origin/mainb0f3d39-> GREEN on this branch)LEONIDA_TOOLS_DIR=<origin/main tools> python -I tests/semantic/test_f64_literal_sources.py: FAILED (11 failures across all 7 tests) —v_div_fixup_f64andv_div_fmas_f64built(0x40000000, 0)instead of(0, 0x40000000);v_cmp_*_f64andv_cmp_class_f64misdecoded0x1and 16-digit padded literals.Tests run (Windows 11, Python 3.12.10, CPU / standard library only; no GPU or game files)
python -I tests/semantic/test_f64_literal_sources.py -v-> 7/7 OK (alsopython -m unittest discover -s tests/semantic -p test_f64_literal_sources.py-> OK)python -I tests/test_shader_ir_parse.py -v-> 4/4 OKpython -I tests/semantic/test_f64_literal_whole.py-> 5/5 OKpython -I tests/semantic/test_alu_div_fixup.py-> 6/6 OKpython -I tests/semantic/test_alu_div_fmas.py-> 9/9 OKpython -I tests/semantic/test_cmp_f64.py-> 5/5 OKpython -I tests/semantic/test_cmp_class_f64.py-> 6/6 OKpython -I tests/semantic/test_alu_cmp_class_f16_f64.py-> 5/5 OKpython -m unittest discover -s tests/semantic -p test_f64_round.py-> OKpython -I tests/semantic/test_alu_frexp_f64.py-> 9/9 OKpython -I tests/semantic/test_alu_ldexp_f64.py-> OKpython -I tests/semantic/test_vop3_const_mods.py-> OKpython -I tests/test_f64_diff.py-> OKpython -I tests/test_text_write_line_endings.py-> OKtests/test_docs_*.pysuites -> 12/12 OKpython -m compileall -q tools/shader_ir.py tools/rdna2spirv.py tests/test_shader_ir_parse.py tests/semantic/test_f64_literal_sources.py-> OKpython -I scripts/check_no_game_data.py tools/shader_ir.py tools/rdna2spirv.py docs/design.md tests/test_shader_ir_parse.py tests/semantic/test_f64_literal_sources.py-> OKgit diff --check-> cleanAI-assisted: yes.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.