image_bvh_census: fix v_cmpx/v_rcp/SDWA/CFG bugs and harden JSON I/O (IMAGE-BVH-CENSUS-DATAFLOW-CFG-AND-IO) #1534
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1534"
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 ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T03:42:58Z.
What changed
v_cmpx_*operand handling (tools/image_bvh_census.py:sgpr_step,mask_writes,source_args):v_cmpx_*_e32takes 2 source operands with an implicitEXECdestination (a[0]is a source, not a destination). Previously,sgpr_step()andmask_writes()treateda[0]as an SGPR write, wiping literal descriptor words and saved EXEC masks whenever a 2-operandv_cmpx_*read an SGPR ina[0].v_cmpx_*_e64(len(a) > 2) puts its destination ina[0]and sources ina[1:];source_args()now excludesa[0], soproduct_reader()reportsv_cmpx_gt_i32 with 0instead ofwith 2 other operands.v_rcp_f32before taggingR1(tools/image_bvh_census.py:site_transfer): alignsite_transfer()withclassify()by checkingplain(a[1]),not ins.get("mods"), and no_sdwa/_dppsuffix sov_rcp_f32_e64 v20, |v5|/-v5/clampdoes not falsely classify downstreamv_mul_f32asratio.high_half_operand()and handle dual high-half operands (tools/image_bvh_census.py:high_half_operand,site_transfer): prevent SGPR operands (e.g.sext(s5)) from reading VGPRv5, prevent immediate operands (sext(1)) from raisingKeyError: 'r', and select the operand holding word 1 when both SDWA operands useWORD_1.tools/image_bvh_census.py:is_copy,imm32): check single-VGPR operands andplain(a[0])onv_swap_b32inis_copy(), and catchOverflowErrorinimm32()for out-of-range float32 literals.tools/image_bvh_census.py:blocks_of,analyse,load_program): start a new block on non-contiguous PCs and requirenext_pc(last) == starts[n + 1]before adding a fall-through edge (avoiding phantom fall-through across embedded data gaps), handle emptyinsnscleanly, and convert invalid hex encodings (parse_file/bytes.fromhexValueError) toSkip.--outoverwrite guards,OSErrorhandling, and atomic JSON output (tools/image_bvh_census.py:main): usereport_paths.same_report_path(plusos.path.samestatfor hardlinks) to refuse overwriting scanned listings,index.json, orfssm/*.fssm; catchOSErrorduring directory scanning with exit code 2; write--outatomically through a sibling temp file withfile_mode.published_mode,replace_retry.replace,allow_nan=False, and a trailing LF.tests/test_image_bvh_census.py): added 6 synthetic unit/CLI regression tests covering every fix above.Claimed in the coordination issue as:
IMAGE-BVH-CENSUS-DATAFLOW-CFG-AND-IO(https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7152125566)How it was tested
python3 -I -W error tests/test_image_bvh_census.py: 21/21 passed (0 warnings).python3 -I tests/test_text_write_line_endings.py: 3/3 passed.python3 -I scripts/check_no_game_data.py tools/image_bvh_census.py tests/test_image_bvh_census.py: passed.python3 -m compileall -q tools/image_bvh_census.py tests/test_image_bvh_census.py: passed.main:tools/image_bvh_census.py: all 6 new tests fail (FAILED (failures=4, errors=2)), all 15 baseline tests pass.Metadata
Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T03:43:10Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from ubiquitarianism/leonida. Originally posted by klikso on 2026-11-25T17:10:37Z.
Ran on a real corpus, since the description's tests are synthetic: my own 1.0.2.1, the 26,503 listings that
make_game.pydisassembles (<work>/shaders/dxbc/disasm, llvm-mc 23.1.6,main3d4f66123), Windows 11, Python 3.13.python -I tools/image_bvh_census.py <work>/shaders/dxbc/disasm --out census.json, once withmainfe1553456's tool and once with this branch'stools/image_bvh_census.pyon the same tree.mainhas no commit to that file since this branch's base, so only the change differs.image_bvh*sites in 64 compute shaders (638image_bvh_intersect_ray, 78image_bvh64_intersect_ray). The printed report is identical line for line, and the JSON is identical key for key (292 values). The only byte that differs is a final newline, which this branch now writes.v_cmpx_*operands, a modifiedv_rcp_f32, an SGPR or immediate high-half operand, PC gaps and out-of-range float literals each either don't occur on these call paths or classify the same either way. For example,v_cmpx_gt_i32reads of the high-half product are counted aswith a constant 0/5in both runs. The fixes guard edge cases the corpus doesn't have, and they don't move the published numbers.main, 15 min 24 s with the branch (one run each, single process).python -I tests/test_image_bvh_census.pywith the branch's file: OK.Counts only; the listings and the JSON stay on my machine.
AI-assisted: yes (Claude Code; run on the machine above)
Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T11:26:52Z.
#1534 | head
c2d32249e6845782f96495606652b346e851cfe0|python3 -I tests/test_image_bvh_census.py -v| red: 21 run, 4 failures, 2 errors | green: 21 passed | Red → greenThe baseline failed synthetic dataflow, CFG and input/output cases. All 21 methods passed with main merged.
Copied the PR tests onto clean main
4a54aedcb6b66525e0c9f72a6ea10263337c9141for the baseline, then merged that main into the recorded PR head and reran those files. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Unittest failure/error counts include subtests where applicable. AI-assisted with OpenAI Codex. Batch claim.Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T11:42:19Z.
Merged, thank you @IlyassRS3! This PR (image_bvh_census: fix v_cmpx/v_rcp/SDWA/CFG bugs and harden JSON I/O (IMAGE-BVH-CENSUS-DATAFLOW-CFG-AND-IO)) passed its own tests with main merged in during sodove's verification of this shader batch, so it went in with the batch.
AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.