Repository navigation
Conversation
Require a non-empty file before the manifest or exporter considers a DDS complete. Rebuild empty outputs through the atomic writer and cover skipped rows and surviving siblings with synthetic tests.
…write_json_atomic (WORLD-BUILD-STAGE-CLEANUP) When writing world JSON atomically, if os.replace fails (for instance due to permission errors), resetting os.chmod to 0o600 ensures unlinking the temporary file does not fail on Windows with PermissionError. agent: yes AI-assisted: yes
…(DDS-PNG-STAGE-CLEANUP) When previewing/saving PNG in CLI main(), if os.replace fails after shutil.copymode set the destination's permissions, resetting os.chmod to 0o600 ensures TemporaryDirectory cleanup does not fail with PermissionError on Windows if the output was read-only. agent: yes AI-assisted: yes
…publish mode (WORLD-NAMES-STAGE-CLEANUP) When writing dictionary JSON atomically in _write_json, apply published_mode to the staged file and reset os.chmod to 0o600 before exiting TemporaryDirectory if os.replace fails, ensuring cleanup does not fail with PermissionError on Windows when replacing a read-only file. agent: yes AI-assisted: yes
…GPU-PASCAL4GB-WIN)
…s out (GPU-PASCAL4GB-WIN)
… driver 582.66 too Follow-up to ProjectLeonida#1364 from its review: the row named only 582.78, while that PR's run was on 582.66. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…source. normcase(abspath()) kept Game/missing.rpf and game/missing.rpf apart on macOS when neither file existed, so two reports of one archive were rejected. The archive key now uses the shared path key. Co-authored-by: Cursor <cursoragent@cursor.com>
--budget is a count of random elements per format, and a negative one was accepted with exit 0 and no message. `for _ in range(budget)` simply does not run, so -1, -100 and -1000000 produced exactly the run of 0 -- 1026 instead of 1106 elements for 8_8_8_8_UNORM -- and every format still reported "ok". --self-test was worse: it builds its own patterns with a hardcoded budget of 2 and never reads the option, so `--self-test --budget -100` and `--budget 1000000` both printed the same "self-test: ok" in the same 1.4 s. Before: $ python -I tools/buffer_format_fuzz.py --self-test --budget -1 self-test: ok # exit 0 $ python -I tools/buffer_format_fuzz.py --oracle hw --budget -3 hardware oracle unavailable: ... # exit 77, no GPU needed to know After, one check next to the other argument guards and before both the self-test and the oracle, so the value is validated even where it is not used: $ python -I tools/buffer_format_fuzz.py --self-test --budget -1 buffer_format_fuzz.py: error: --budget cannot be negative # exit 2 $ python -I tools/buffer_format_fuzz.py --self-test --budget 0 self-test: ok # 0 stays legal: sweeps only tests/test_buffer_format_fuzz.py (CPU only, hw_oracle stubbed) covers the negative value on both paths, that it is refused before the oracle is opened, that 0 stays legal and that -1 is otherwise indistinguishable from 0. 3 of its 7 tests fail without this change, 7 pass with it.
A zero --programs ran the sweep and nothing else with exit 0, and a zero --max-ops reached random.randint(1, 0)'s ValueError traceback. Both are now usage errors: --max-ops and --programs must be at least 1, checked right after parsing and before any work, and argparse exits 2 with the message. main() takes argv so the tests can drive it.
Write JSON to a same-directory temporary file and replace the report only after serialization succeeds. On write failure, keep the existing report and remove the temporary file; preserve the current error message and exit code.
Evidence (run from /home/hampa/work/leonida-feature-scan):
Tests:
- Original: git checkout upstream/main -- tools/feature_scan.py && /home/hampa/work/.venv/bin/python -m pytest tests/test_feature_scan.py -q -> rc 1; 1 failed, 15 passed. The existing report was empty instead of the 23-byte sentinel.
- Fixed: git checkout HEAD -- tools/feature_scan.py && /home/hampa/work/.venv/bin/python -m pytest tests/test_feature_scan.py -q -> rc 0; 16 passed.
File-size-limit reproduction (synthetic shaders only):
- Setup: mkdir -p /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/shaders/dxbc /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/out; python3 -c 'import json,sys; json.dump([{"stage":"synthetic_stage_"+str(i)+"_"+("x"*80)} for i in range(40)], open(sys.argv[1],"w"))' /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/shaders/dxbc/index.json; printf '{"previous": "sentinel report"}\\n' > /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/out/report.json
- Before: bash -c 'ulimit -f 1; python3 -I -B tools/feature_scan.py "$1" --out "$2" >/dev/null' _ /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/shaders /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/out/report.json -> rc 2; report 32 bytes before, 1024 bytes after (old contents replaced by partial JSON).
- After: bash -c 'trap "" XFSZ; ulimit -f 1; python3 -I -B tools/feature_scan.py "$1" --out "$2" >/dev/null' _ /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/shaders /home/hampa/.hermes/profiles/mikuling/cache/scratch/feature-scan-ulimit1.hlUt9B/out/report.json -> rc 2; report 32 bytes before and after, with no temp file remaining.
Write the generated JSON to a temporary file in the destination directory, then atomically replace the output. Remove the temporary file on write errors and preserve output permissions. Before: with 128 synthetic classes and an existing 14-byte output, `bash -c 'trap "" XFSZ; ulimit -f 1; python3 -I tools/gen_gdk_runtime_classes.py /home/hampa/.hermes/profiles/mikuling/cache/scratch/gdk-atomic-repro/docs --out /home/hampa/.hermes/profiles/mikuling/cache/scratch/gdk-atomic-repro/out.json'` returned 1 (Errno 27, File too large); output grew to 1024 bytes (partial JSON). After: the same command returned 1, left the 14-byte sentinel unchanged, and left no temporary file. Tests against upstream/main: 1 failed, 2 passed; against the fix: 3 passed.
…nd publish mode (BVH-SLOT-CHECK-STAGE-CLEANUP) Apply published_mode(path) to temporary file before atomic replacement, and restore write permission (0o600) before unlinking in finally block when replace fails, preventing Windows PermissionError [WinError 5] and stranded temporary files. agent: yes AI-assisted: yes
…t tests (RT-XS-ALLOC-SIZE-GUARDS-AND-TESTS) Guard align_up_saturating against zero alignment (to == 0) in runtime/shims/d3d12_xs_alloc_size.h, avoiding division by zero and underflow. Add standalone CPU-only unit test runtime/test/d3d12_xs_alloc_size_test.cpp covering align_up_saturating, render_target_element_bytes, console_depth_planes, console_render_target_size, console_depth_stencil_size, and console_placement. Register test executable and CTest in runtime/CMakeLists.txt. AI-assisted (Claude Code)
…te in the executable (D3D12-DEVICE-SLOT-ARITY)
…ling mips When a BC6H or BC7 stream still references an unfitted built-in predictor slot after adjacent-mip fitting, pair its mips with the closest raw or zlib mip on the same layer across multi-level mip distances before running the full-stream constraint pass. Existing adjacent-mip, array, and cubemap fits keep precedence.
Run fit_distant_mips ahead of fit_decoded_neighbors so mixed-codec BC6H and BC7 streams fit directly against lossless raw/zlib mips across multi-level distances before iterative BCPack sibling decoding, eliminating all 10 remaining BC6H stream refusals on 1.0.2.1 (210 -> 226/256 endpoints, 249 -> 251/256 indices) and cutting fit_decoded_neighbors runtime by 46%.
Exercise the public history.build(...) pipeline end-to-end across all four synthetic multi-level BPTC mip fitting tests so running the test file against main reaches value assertions (4 AssertionErrors, 0 AttributeErrors) instead of stopping on the missing fit_distant_mips helper.
…in multilevel mip fit - Keep secret_entry >= 192 with ref_count <= secret_entry across all synthetic BPTC streams so predictor distances never wrap mod 256 and main leaves unknown slots at zero rather than self-fitting wrapped blocks. - Drive dual-slot BC6H and BC7 chunks (missing slot 240 + pre-populated slot 241 with conflicting pool colors) so extend_missing precedence is genuinely exercised for both codecs. - Assert fitted BC6H endpoint values, zero confirmed-bit masks, and per-block decoded RGBA / unquantized HDR pixels across both parent-downsample and child-upsample streams, and include codec mode in fit_distant_mips wanted keys.
lixonik
left a comment
There was a problem hiding this comment.
Reviewed 094e948e9 merged locally with main aa918e5d9. The synthetic triangle variants (plain, edge flags, culled) matched the native mesh pipeline on RTX 5070 (610.88), Windows 10 22H2 with Agility SDK 1.614.1 and DXIL validator 1.9.2609. The mesh-filtered suite reported 7 passing entries, with the optional compiler comparison and WARP device subcase skipped. One extra GPU fixture reproduced the sink-slot boundary below.
AI-assisted.
| let corner = s.m.bin(b, Bin::URem, id, three); | ||
| // A group past the cap wrote to the sink slot: it draws nothing. | ||
| let cap = k(&mut s, layout.groups_cap()); | ||
| let past = s.m.cmp(b, super::bitcode::pred::IUGT, group, cap); |
There was a problem hiding this comment.
groups_cap() counts usable slots, so slot indices below it are usable and the slot at that index is already the sink. The unsigned greater-than predicate still renders instance group == cap. I made the existing synthetic triangle fixture use a 4 KiB scratch cap, giving three usable slots. With only the last valid slot populated, it lit all 256 pixels as expected. With only the sink populated, instance 3 also lit all 256. Changing the comparison to unsigned greater-or-equal gave 0, as intended. Both the direct draw's instance count and the indirect header can currently include the sink instance. Could we exclude it at the comparison or cap the submitted draw count?
There was a problem hiding this comment.
Retested after the rebase at dc5818bb8424d96b642ba07cd03a3251d529a147, merged with main 02944d4ca1. The crate builds here, and the translation test passes with DXIL validator 1.9.2609. The sink-slot case still reproduces.
With synthetic triangle data and a 4 KiB scratch buffer, I drew four instances and populated one slot at a time. On RTX 5070 (610.88), Windows 10 22H2, Agility SDK 1.614.1, slot 2 lit 256/256 pixels and the sink at slot 3 also lit 256/256. Changing just IUGT to IUGE kept slot 2 at 256/256 and took the sink to 0/256. The plain, edge-flag, and culled comparisons with the native mesh pipeline passed with that local one-line change. WARP skipped for lack of SM 6.6 here.
AI-assisted. Codex (GPT-6).
There was a problem hiding this comment.
Retested the sink fix at 74ac98c64 on native Windows 10 22H2, RTX 5070 (610.88), with Agility SDK 1.614.1 and DXIL validator 1.9.2609. The committed sink fixture ran on hardware: slot 0 lit 256/256 pixels and slot groups_cap() lit 0/256. The compute and native mesh draw comparison also passed. I used local Agility loader exports for the test binary and made the sink fixture require a hardware device. The optional WARP and external shader-compiler cases skipped.
This resolves my sink-slot finding. AI-assisted.
Windows 11 + RTX 3090 D3D12 & WARP Verification (
|
… on a device The commands the mesh fallback records between and after the pipelines the draw path binds (barriers, the dispatch or counted indirect dispatch, the header of the indirect draw, the triangle list drawn from the buffer, the title's topology again) move from draw.rs into mesh_fallback::MeshRun, which draw.rs calls. A test records the same commands on a device of its own, as a title does in one list: a counted indirect run (count 1), a direct run of three groups, a run whose triangle is culled, a counted indirect run with a count of 0, then the title's triangle strip; every texel comes out as the runs and the strip draw it. Without the topology restored the strip draws one triangle (64 texels differ); without the header's instance count reset the count-0 run draws the first run's groups again (100 differ). leonida-shader's host checks (emit::host) take the test programs this needs: triangle_mesh_program (the triangle mesh program its own tests used), color_ps and position_vs; dxbc::build is there for them too. draw.rs names its topology mapping (host_topology). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ards f16misc_diff: reject a zero or negative --max-ops and --programs
buffer_format_fuzz: reject a negative --budget
…tomic-out feature_scan: write --out atomically and keep the existing report on failure
…e-classes-atomic-out gen_gdk_runtime_classes: write --out atomically
…ault-context windows-boot: report the loss API, fault query and checkpoint counts
docs: D3D-56 descriptor lookup numbers on RTX 3070 (Ampere, ReBAR off) (OLD-9801)
…c-base-gpu docs: the s_load vcc-base row is GPU-checked on RDNA2 and under wave64 emulation (SHADER-VCC-BASE-GPU-VERIFIED)
…tore-status docs(testing): note V100 cube-store failure
…s-alloc-size-guards-and-tests runtime: guard align_up_saturating against zero alignment and add unit tests (RT-XS-ALLOC-SIZE-GUARDS-AND-TESTS)
…h-gpu-vulkan-links docs: refresh GPU testing and Vulkan links
…nan-rows docs/testing: record the two ps_* KosmicKrisp NaN cases
…-stage-cleanup world_build: restore write mode before unlink on replace failure in _write_json_atomic (WORLD-BUILD-STAGE-CLEANUP)
…ge-cleanup dds_png: restore write mode before unlink on replace failure in main (DDS-PNG-STAGE-CLEANUP)
…-stage-cleanup world_names: restore write mode before unlink on replace failure and publish mode (WORLD-NAMES-STAGE-CLEANUP)
…eck-stage-cleanup bvh_slot_check: restore write mode before unlink on replace failure and publish mode (BVH-SLOT-CHECK-STAGE-CLEANUP)
…rifier-stage-cleanup manifest_verifier: restore write mode before unlink on replace failure and publish mode (MANIFEST-VERIFIER-STAGE-CLEANUP)
…rce-census-dataflow-io sampler_source_census: fix V#/pointer/SMEM/v_mov dataflow and harden JSON I/O (SAMPLER-SOURCE-CENSUS-DATAFLOW-AND-IO)
…evel-bcpack-fit build_dstorage_history: fit missing BPTC history slots across multi-level sibling mips (DSTORAGE-MULTILEVEL-MIP-FIT)
|
Thanks for the audit, @timbot103. All six points held up in the code and are fixed in bc0c72f:
Also: 1b33fa2 puts A per-primitive layer/viewport index is refused by Runtime coverage (924b294). What the fallback records around the pipelines the draw path binds (barriers, the direct or counted indirect dispatch, the indirect draw's header, the triangle list from the buffer, the title's topology again) is now one recorder,
Every texel must come out as the runs and the strip draw it. As a check, without the topology restore the strip draws one triangle (64 of 256 texels differ), and without the header's instance count reset the count-0 run draws the first run's groups again (100 differ). The first overflow group is Tested on GTX 1050 Ti 4 GB / NVIDIA 582.66 / Windows 10 (no mesh shaders):
AI-assisted (Claude Code). |
Conflicts: draw.rs (the signature is an Option for the mesh fallback, and main reads mesh_test() once per dispatch: the fallback takes that mode too), emit/mod.rs (both sets of exports; main's pixel mask test with the mesh test programs from emit::host). Main's new test initializers take the fields this branch adds (Parts::mesh_compute, Draw::vertex_count/instances, HostShader::mesh_out). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The mesh, colour and position programs 924b294 put in emit::host are needed by portable tests too (primitive_export_indices_drop_the_edge_flags), and emit::host is Windows-only: the Linux test build did not resolve them. They need no device, so they live in emit::test_programs, built for tests and the host feature on every platform. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main's Shader gained mask and masked_twins (the sample mask's pixel shader twins); the mesh program seen as compute and its pass-through vertex shader are the title's own forms: no mask, no twins yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged main (7c330c7) in 58c3333, plus:
The fallback now takes the per-dispatch GTX 1050 Ti / 582.66 / Windows 10:
Linux: leonida-shader 226 passed. AI-assisted (Claude Code). |
|
Partial check by OreoFR on macOS 27.2.1 (26B131), Apple M5, Rust 1.98.1 (d3d12/rust-toolchain.toml), main 060c471 (merges cleanly; does not force a rebase of #2566 at eade956), PR head 74ac98c
Verdict: leonida-shader part green (no red possible); leonida-gpu not buildable on macOS — needs a Windows/GPU verifier. AI-assisted: Claude Code |
|
Verified by OreoFR (Windows part: leonida-gpu, plus leonida-shader's Windows-only tests; oreofr-mac covered leonida-shader on macOS) PR head
Verdict: NO RED (green on Windows, no failing test possible without the change). This verification was AI-assisted (Claude Code, oreofr-agent). |
Claimed in the coordination issue as: D3D12-MESH-COMPUTE-FALLBACK (#2570#issuecomment-7239097845)
What and why
leonida.exerefuses every mesh pipeline on a GPU without D3D12 mesh shaders (mesh shader tier 0: Pascal and older), so the world draws nothing there. This translates each mesh program as an ordinary compute shader writing its outputs to a buffer, and draws that buffer as a triangle list through a pass-through vertex shader of ours.set_host_mesh_shaders(false):cs_6_6; its four mesh output ops become raw stores into the root UAVSLOT_MESH_OUT, oneMeshOutslot per group;mesh_vs()reads it back:SV_VertexIDgives primitive and corner,SV_InstanceIDthe group, and per-primitive outputs are constant inputs where the pixel shader reads them;LEONIDA_MESH_COMPUTE=1forces it on any card, for comparison);Dispatch+DrawInstanced;WriteBufferImmediate+ twoExecuteIndirects (dispatch signature over the title's own record, then draw from the header).On Windows 10 this needs #2557 (shader model 6.6).
Tested
no host pipeline: the host GPU has no mesh shaders. Fallback pipelines made in a run: up to 567; no device removal.cargo test -p leonida-shader --lib mesh,-p leonida-gpu --lib shader_cache): 7 + 2 pass on the 1050 Ti. The device test draws the triangle mesh fixture as compute and checks the texels, and compares them with the mesh pipeline texel for texel on a device with mesh shaders. dxil.dll validates the compute variant and the vertex shader.LEONIDA_MESH_COMPUTE=1on an RTX card would show it.GPUs tested: GTX 1050 Ti 4 GB (Pascal, profile S), 582.66, Windows 10.
AI-assisted (Claude Code).
🤖 Generated with Claude Code