d3d12: hardware RT: no BLAS refit across a NaN vertex; name RT alloca… #3168
Open
github-bot
wants to merge 6 commits from
github-bot/gh-3168 into main
AGit
pull from: github-bot/gh-3168
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!3168
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3168"
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?
@Callimann8 on GitHub · 2026-12-02 16:08 UTC · original
Callimann8:claude/project-thread-xlyyzl→main· +487 −30 · 1 files · 6 commits · openClaimed in the coordination issue as: d3d12 hardware RT on AMD: lighting differs (BLAS refits across NaN vertices)
What and why
Two fixes and a diagnostics change for hardware ray tracing (
LEONIDA_HW_RT=1) ind3d12/crates/leonida-gpu/src/hwrt.rs, after a run on an AMD card (20 GB, Series X profile, 2560x1440) whose lighting differed from an RTX 4070's and that lost the device after about 6 minutes.copy_vb, andsane_positionfor vertices decoded on the CPU) make a triangle with a vertex that is not finite or past 1e10 inactive (NaN). They do it per frame. DXR leaves an update undefined if a primitive that was inactive at the first build becomes active, or the reverse (Raytracing spec, "Inactive primitives and instances"). A title's dynamic vertices that are NaN only in some frames therefore went through refits (PERFORM_UPDATE) that DXR does not define. The AMD run made about 460,000 refits in 345 s. Now each refittable structure (HostAs) holds, per geometry, how its build left the triangles inactive (Held). For a copy on the card, that is the positions it was built with, copied into a buffer of its own after the build. For vertices decoded on the CPU, it is a hash of which vertices are NaN. A refit'scopy_vbreads those positions (g_old): it writes NaN where the structure has NaN, and the old position where a vertex turned bad, so the set never changes. The refit goes ahead only when every geometry holds (refit_keeps_activity). That is decided in the same frame, before the build is recorded, with no readback. Otherwise the BLAS is built whole. Becauseexecute_copyshares theHostAsbetween source and copy, a copy keeps what its source held.copy_vbalso coversR16G16_FLOATandR16G16B16A16_FLOATvertices (f16tof32), and a BLAS with procedural boxes is never refitted, since a box is inactive where the title's ownMinXis NaN. The frame log's "hardware RT inputs" line counts "refits built whole as their inactive triangles could not be held" and "refits whose vertex copies held them". The held buffers stay common between uses, as buffers are after every submission. They are charged to the BLAS memory ledger, so the budget sees them. A geometry whoseTransform3x4has a NaN in the row giving X counts as wholly inactive, and one whose transform cannot be read is never refitted. The NaN-set hash runs only for structures a refit may follow. One difference stays by design: on the card path, a vertex that goes bad during refits keeps its last good position until the title asks for a full build, while on the CPU path the change forces a full build at once. Both are within DXR's rules.copy_vbread the third component of a two-component vertex (mode >= 3 ? g_src.Load(at + 8) : 0u, and HLSL's?:evaluates both sides) through a root SRV, which has no bounds. It now uses an explicit branch.crate::host::name. A device-removed report then names them when a page fault lands in one, and a diagnostics build's book records them. In the AMD run, the fault was inside a freed allocation listed as"unnamed (type 34)", and the book had no entry for it.The per-frame build budget change that was here (postbuild size queries and copies of waiting builds) is now its own PR.
Not settled by this PR
The AMD run's device loss was
DXGI_ERROR_DEVICE_HUNGwith a DRED page fault at0xd63da2000. That address is inside a host title-memory copy (0xdbb800000+0x800000at0xd63800000) that the 1 s sweep freed at 328.2 s (a "host copies of windows of title memory let go" entry 6.06 s before the loss). After that, an allocation with no name took the same address and was also freed. The log does not say which command read it. The report's "1 slots reach it: slot 10151" does not point at the culprit. That slot is a 1728x960 texture whose metadata sits 18.6 MB below the fault, and the book's heuristic counts any texture with metadata within 32 MB as reaching it. The "view heap / sampler heap past its end" parts only say the address is in neither heap. A repro with this branch andLEONIDA_D3D12_DRED=light(or=1) should name the command and the allocation.Tests
cargo check -p leonida-gpu --target x86_64-pc-windows-msvc(also--testsand--features diagnostics) andcargo clippywith no new warnings. On Windows (x2Tweek, ate7558c4dmerged ontomain):cargo test -p leonida-gpu --lib hwrt, 26 passed, 0 failed, including the FXC compile ofSANITIZE_HLSL. Debug layer and GPU-based validation (Kal0s-design, NVIDIA and WARP, a test replaying the held-buffer barriers and NaN refits): no state errors.a_refit_is_refused_unless_every_geometry_keeps_its_inactive_triangles(the refit policy: it fails if the guard is made to allow everything),a_refit_is_recorded_only_from_the_structure_its_copies_held(the flush's check),a_nan_in_the_transform_row_giving_x_makes_the_geometry_inactiveandthe_nan_set_of_decoded_vertices_tells_which_vertices_are_nan.the_card_copies_follow_the_cpu_rules_and_compilenow also checks that there is no load on either side of a?:, that copy_vb merges against the held positions, and that it reads half floats.-HardwareRT, about 6 minutes): no device loss, lighting as expected, about 21 fps as before. 152 refits built whole against 140,418 held. Again ate7558c4din game (340 s, on foot and driving): no device loss, no lighting fault, 205 built whole against 85,481 held (0.24 %).@fiestorra on GitHub · 2026-12-02 16:31 UTC · original
Verified here: it applies on the current
mainand thehwrtgroup passes - 23 tests, 0 failed, including the new one.The new test is the right one for the change: a BLAS whose vertex became NaN is found by its marks and its staged vertices - that is what "do not refit across a NaN vertex" has to look like from the outside, and it is the case that would otherwise be a silent lighting difference rather than a crash.
Why it may matter to a thread you already have: #3135 is a report of hardware RT on a 5090 asking whether the lights differ - and this is a correctness fix in the same path (the AMD refit-across-NaN one). Two different bugs in one feature are worth merging independently, and this one has a test.
What it does not cover: the lighting. The test checks the bookkeeping around the BLAS, not what the rays produce - that needs
LEONIDA_HW_RT=1on a run and two images to compare, which this machine cannot do (no title).One thing for the merge: the pull request currently shows
UNSTABLEin the checks - with a green suite locally, that is worth a look before asking for a review.AI-assisted: yes - DeepSeek v4.1 (flash).
Written with an AI assistant.
@KelboLive on GitHub · 2026-12-02 16:54 UTC · original · reviewed
Two gaps before this can be called "no refit across a NaN vertex":
copy_vbwrites the mark (hwrt.rs:754), but it only becomes CPU-visible at list reset (:3558), whileflush_blas_batchdecides the refit first (:3089-3099). So on the first clean→NaN frame for a BLAS, that build still takes aPERFORM_UPDATErefit that flips an active primitive inactive — exactly the update the spec leaves undefined. From the next frame it is blocked. That's 460k undefined refits reduced to one per BLAS per NaN onset, not zero (the CPU-decoded quant24 path is immediate,:3662). Either read the marks before the batch decision, or treat a newly-dirty vertex buffer as refit-unsafe for that frame.:4811prunes only ontitle_memory_freed), so one transient NaN permanently disables refits for that VA; andexecute_copyaliases the sharedHostAsunder a new key without copying the mark, so a clone/compaction of a marked BLAS (then a refit from the alias) bypassesrefit_unsafe. Keying the mark on the sharedHostAs/BlasMemoryfixes both the permanence and the alias hole.Coverage gaps:
dxr_vertex_alignacceptsR16G16_FLOATandR16G16B16A16_FLOAT(:363-378), butcopy_vb'smatches!skips them (:3862), so NaN in half-float vertex buffers is never marked — the "packed formats cannot hold such values" comment is wrong for those. AABBMinXNaN (the inactive-AABB rule) is also untracked.Mutation:
refit_unsafe → false && …passes all 24hwrttests, so the new test protects the mark plumbing, not the policy guard. Merge is clean (48b6bf2);hwrt24/24 and diagnostics compiles. The PR body also omits the second commit (postbuild size queries outside the frame budget), which is a separate behaviour change worth describing.@Callimann8 on GitHub · 2026-12-02 17:10 UTC · original
Thanks, all good points. Pushed
2ab4e92b, which replaces the marks entirely instead of patching them.1. One frame late. Agreed, and there's no readback any more. Each refittable
HostAsnow holds, per geometry, how its last build left the triangles inactive (Held). For card copies, that's the positions it was built with, copied into a buffer of its own after the build. For CPU-decoded vertices, it's a hash of which vertices are NaN. A refit'scopy_vbreads those positions asg_old. It writes NaN where the structure has NaN, and the old position where a vertex has just turned bad, so the inactive set can't change. The refit is allowed only if every geometry holds (refit_keeps_activity), which is decided before the build is recorded, in the same frame. Otherwise the BLAS is built whole. So the first clean→NaN frame refits with the vertex frozen at its last good position rather than going inactive.2. VA-keyed, never cleared, lost through copies. The state now lives on the
HostAsitself. It's replaced on every build or refit of that structure, goes away with it, andexecute_copy's alias shares it because it's the sameArc. Thetitle_memory_freedpruning is gone. The flush also checks that the source it refits is the sameHostAsthe copies were made against.Coverage. You're right that the comment was wrong.
copy_vbnow handlesR16G16_FLOATandR16G16B16A16_FLOAT(f16tof32), and the comment is fixed. BLASes with AABBs are never refitted, sinceMinXNaN is the title's own and we can't hold it.Mutation. New
a_refit_is_refused_unless_every_geometry_keeps_its_inactive_trianglescovers the policy (an unmerged card copy, a changed CPU NaN set, a changed vertex count, boxes, and mismatched geometry lists are all refused). It fails ifrefit_keeps_activityis made to return true. There's also a test for the NaN-set hash, and string checks on the shader's merge rule. The guard inflush_blas_wavesitself is still only covered through that function, since it sits in command recording.PR body. Updated: it now describes the new design and the budget commit (postbuild size queries and copies of waiting builds now wait under the frame budget).
Caveat: I've only checked this with
cargo check/clippyfor the Windows target (also--testsand--features diagnostics).cargo test -p leonida-gpu hwrt, which compiles the HLSL with FXC, still needs a Windows run, and the AMD retest is pending.@MoonEyes on GitHub · 2026-12-02 18:01 UTC · original
Code review only, not built:
leonida-gpuis Windows-only and the HLSL inhwrt.rscompiles with FXC at test time. Not ready to merge yet: the current head has not been run anywhere.2ab4e92bf, merge base3c106eb2f, 21 behind currentmain45dc41f95. A trial merge is clean.6115d0340only. Since then two commits changed the design:02706e17(budget) and2ab4e92b, which replaced the readback marks with per-HostAsHeldstate,g_oldand f16 positions. By the author's own note,2ab4e92bhas only hadcargo check/clippy.What reads right (
d3d12/crates/leonida-gpu/src/hwrt.rs):refit_keeps_activitydecides before recording, in the same frame, whether a refit is allowed, and refuses whenever activity cannot be held: AABB geometry, a changed count, a CPU NaN set that differs, or a card copy withoutg_old. That respects the DXR rule on inactive primitives at the root, instead of detecting the problem a frame late.heldon theHostAsbehind itsArcmakes it follow copies and be freed with the structure. The old VA-keyed map withtitle_memory_freedpruning is gone.create_default_bufferrounds the width to 256 bytes, so the reuse check inhold_activity(*b >= bytesagainst the rounded size) cannot copy past the end.Concerns:
02706e17changes the BLAS budget: postbuild sizes are answered withtold_forprebuild sizes while the build waits, andcopy_waitingqueues clones and compactions as builds ofdest. That is a separate behaviour change to queueing and sizing, not part of "no BLAS refit across a NaN vertex". CONTRIBUTING.md asks for one topic per pull request, with follow-ups in a new one. It also carries most of the risk: a compaction destination now becomes a whole build from the source request, sized bytold_for. Please split it out, or show that the compacted-size contract still holds with a test.copy_vbwithmode & 256checks onlyold.xfor NaN. That is correct as long as every writer stores all three components as NaN, which the shader does. A one-line comment would stop a future writer from breaking this.a_refit_is_refused_unless_every_geometry_keeps_its_inactive_trianglespins the policy function. Nothing exercises theflush_blas_wavesguard (held_fromagainstArc::as_ptr(src_entry)) or theheld_readbarrier bookkeeping. The author acknowledges this.Needed before merge:
cargo test -p leonida-gpu hwrton Windows at this head, a debug-layer run (the new COMMON, COPY_DEST, COMMON and SRV-promotion transitions on held buffers are what it would catch), and the in-game render-path gate with-RayTracing.Verdict: not ready (no test run on this head, and two topics). No concrete defect found in the refit logic.
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
@Callimann8 on GitHub · 2026-12-02 18:49 UTC · original
Split as asked: the budget change is reverted here and parked on its own branch. It'll come as a separate PR once this one lands (I can only have one open at a time)
@lixonik on GitHub · 2026-12-02 19:31 UTC · original
RUN (in game) -- Windows
hwrtdebug-layer unit tests + 300 s-HardwareRTrender-path gate run for PR #3168:337388052mainSHA:f1a559851(git merge --no-ff, clean merge)python -I scripts/check_no_game_data.pyPASSLEONIDA_D3D12_DEBUG=1 cargo test -p leonida-gpu --features diagnostics --lib --locked hwrt-- 24 passed, 0 faileddiagprofile (diagnostics,dlss,mimalloc), Series S profile, DLSS on, Hardware RT enabled (LEONIDA_HW_RT=1,LEONIDA_AMBIENT=0,LEONIDA_RT_RESOLVE=1,LEONIDA_ACTIVATE_RAYS=1), Frame Gen off, same restored save snapshot337388052onf1a559851)mainalone (f1a559851, ref)Loaded cleanly into the world with DXR Hardware RT active, stayed up past 300 s in-world with 0 device lost / 0 crashes / 0
ERRORlines, and closed cleanly.Verdict: PASS.
AI-assisted: yes (Antigravity).
@x2Tweek on GitHub · 2026-12-02 19:44 UTC · original
NVIDIA run and the Windows tests, the two TODOs above.
Setup: RTX 5090 32 GB, driver 621.40, i9-14900KS, 64 GB DDR5, Windows 11 (26300). Base: upstream main
0d7a451abplus #3113 and #3182, diag build. This PR merged on top at337388052. Series X profile, 3840x2160output, render scale 0.6667, the title's upscaler,
-HardwareRT -SmoothMotion -PrecompileAll -Log, borderlesswindow. About 6 minutes of play from a save, then city driving at night.
Windows tests:
cargo test -p leonida-gpu --lib hwrtgives 25 passed and 0 failed, includingthe_card_copies_follow_the_cpu_rules_and_compile(the FXC compile ofSANITIZE_HLSL).The run's frame log, at the end:
went ahead. So on this title and card, a dynamic vertex turning NaN between frames is rare (about 0.1 % of
refits), and the guard costs next to nothing in rebuilds.
kind of drive (about 20 to 21 fps on earlier runs), so I see no measurable cost; the runs were not on the same route.
Screenshots are available.
AI-assisted: the build, the test run, the log reading and the write-up were done with Claude Opus 5.5 (Claude
Code); the numbers are the runtime's own log lines from the run above.
@Kal0s-design on GitHub · 2026-12-02 19:50 UTC · original
Ran natively on Windows 11, head
337388052merged into currentmain(b41763227, clean merge).lixonik already ran
hwrton this head, over an oldermain. This adds the full crate on currentmain, the copy shader and the refit rule run directly on the card and WARP, the held-buffer barriers under the debug layer, and two mutations.Suite
cargo test -p leonida-gpu --lib --test-threads=4. The card supports raytracing tier 1.2.--features diagnosticsLEONIDA_D3D12_WARP=1LEONIDA_D3D12_DEBUG=1The last two rows had the switch set, but nothing in the output confirms it took effect. No "host device" line shows up in the test output. From reading the code, the
hwrttests never create a device throughhost.rs, so the switches don't reach them anyway. For the WARP and debug-layer checks I wrote a throwaway test that creates its own device on the card or on WARP (tier 1.1), with the debug layer and optionally GPU-based validation turned on. Results are below.Red/green check, measured. Making
refit_keeps_activityalways returntruefailsa_refit_is_refused_unless_every_geometry_keeps_its_inactive_triangles(23/24). Replacing both guards inflush_blas_waves(&& !unheldand theheld_frompointer check) withtruestill passes all 24hwrttests. So MoonEyes' point 3 still applies.cargo clippy -p leonida-gpu --all-targets --features diagnosticsreports nothing inhwrt.rs.copy_vbon the card (measured)I dispatched the PR's
copy_vbdirectly and compared the output withsane_position. The card and WARP gave identical results. All 12 f32 cases matched the CPU rule bit for bit.0x7FC00000R32G32where the next vertex's x is NaNR16G16B16A16_FLOATwith NaN or Inf in wR16G16)The refit merge (
mode | 256againstg_old) behaved like this.old.xis checked (as the new comment says)Debug layer (measured)
The held-buffer sequence was replayed in one list as the PR records it. A default buffer created
COMMONis read as root SRVt1, thenNON_PIXEL_SHADER_RESOURCE→COMMON. NextCOMMON→COPY_DEST, the copy, then back toCOMMON. The piece goesUNORDERED_ACCESS→NON_PIXEL_SHADER_RESOURCE→COPY_SOURCE→UNORDERED_ACCESS. That ran twice in one list, then once more in a second list after decay. On the card and on WARP, with the debug layer and GPU-based validation on, there were no errors or warnings about states. The only messages came from my own buffer creation and the GBV startup notice.Then a BLAS with
ALLOW_UPDATEand two triangles, one with a NaN vertex. I ran a build, then three refits in one list: NaN held, inactive to active, and active to inactive (out of place). Neither the card nor WARP raised anything, GBV included. The debug layer doesn't check this rule, so the same-frame guard in this PR is the only thing that does. A debug-layer run can't answer the AMD lighting question.After the NaN goes away (read, with the shader part measured above)
On the card path, a vertex that was NaN when the structure was built stays NaN on every later refit, because
hold_activitystores each refit's output as the nextg_old. The triangle comes back only when the title asks for a full build. A vertex that goes bad during refits stays frozen at its last good position and doesn't vanish. That's within DXR's rules. Until the title rebuilds, though, the result differs from a full build, and I can't tell how often the title rebuilds.Vertices decoded on the CPU work differently. Any change in the NaN set, either way, makes that frame a whole build, and refits continue once the set is stable. So here the triangle comes back immediately. The two paths treat the same situation in different ways.
The CPU hash covers every decoded vertex, including ones no triangle references. A NaN that flickers in an unused vertex forces whole builds that aren't needed. That's conservative, not wrong. On the card path, unreferenced vertices change nothing.
Cost
staged_nan_hash, measured in a debug test build only (no release build here), takes about 22 ms per 1M vertices and 90 ms per 4M. NaN or not makes no difference, and it scales linearly. I didn't time the release build or the decode it runs next to. It runs for every CPU-decoded geometry, even when no refit is asked for.On the card path (read), every build or refit of an
ALLOW_UPDATEBLAS adds aCopyBufferRegionofvertices * 12bytes, and the touched pieces get an extra transition toCOPY_SOURCE. The held buffers (vertices * 12, rounded to 256) come fromcreate_default_bufferand are never charged to the BLASLEDGER, so that VRAM falls outside the budget. They are freed together with theHostAs.Not covered by either PR (read)
A NaN in a geometry's own
Transform3x4makes the whole geometry inactive in the build.Activitydoesn't look at the transform, so a refit across a transform turning NaN, or recovering, still changes activity. #3107 guards instance transforms inREMAP_HLSL(TLAS), not this.Other open PRs touching
hwrt.rsI filtered open PRs by changed files.
git merge-treewith this onehwrt.rs, two hunks insanitize(): #3107'sdispatch_1d_gridagainst this PR's 4th root view. Keep both. The shader merges on its own, andg_old.Load3(v * 12)uses #3107's 2Dv. The NaN handling doesn't overlap (instances vs vertices).Not checked: in-game runs (no title here), AMD hardware, a release build or release timing, GPU time of the extra held copies, #3107 + #3168 built and tested together after resolving the conflict, and ray tracing through the refitted BLAS (my BLAS test only looks at validation).
GPUs tested: one NVIDIA desktop card + WARP
AI-assisted: yes (Claude Code).
@Callimann8 on GitHub · 2026-12-02 20:14 UTC · original
Thanks for the thorough run, especially the copy_vb table and the debug-layer replay. Pushed
e7558c4d:refit_from_held(held_from, source), and it has its own test (a_refit_is_recorded_only_from_the_structure_its_copies_held). Making it always return true now fails. The!unheldterm only counts and short-circuits, becauseheld_from == 0already makesrefit_from_heldfalse.t[0..4]) makes the geometryInactive. A NaN anywhere else, or a transform we can't read, makes itUnknown, which is never held, so that BLAS is built whole.ALLOW_UPDATEorPERFORM_UPDATE, or a refit asked for). Otherwise the activity isUnknown, and nothing is stored for it anyway.LEDGER(BlasMemory, rounded size) and released with the buffer.sanitize()hunks the way you described.cargo check/clippyfor the Windows target are clean (also with--testsand--features diagnostics). The new tests haven't run on Windows yet.@MoonEyes on GitHub · 2026-12-02 22:00 UTC · original
This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).
Could you, or anyone with a working setup, post a run report on the current head merged onto current
main:mainSHA it was merged onto;mainalone for comparison, if you can.Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.
AI-assisted (Claude Code).
@x2Tweek on GitHub · 2026-12-02 22:38 UTC · original
RUN (in game, RTX 5090 32 GB, hardware RT, 340 s in the world): PASS, 0 device losses on the current head.
e7558c4dfmerged withgit merge --no-ffontomainf3865cae8(merge82c4f1660,clean). No other changes: no local patches and no other PRs.
26300).
diagnostics,dlss,mimalloc.cargo test -p leonida-gpu --lib hwrtgives 26passed and 0 failed.
-HardwareRT -SmoothMotion -PrecompileAll -Log, fullscreen.device removedline in the log.250 ms in the 5 s lines. I put these down to
main's known costs on this card, not to this PR: the 1.5 GB BLAScap (#3135 / #3225) and cold masked-pipeline compiles (#3200 / #3105).
could not be held 205, refits whose vertex copies held them 85481", so the guard rebuilds about 0.24 % of the
refits.
AI-assisted: the build, the run, the log reading and the write-up were done with Claude Opus 5.5 (Claude Code);
the numbers are the runtime's own log lines.
@fiestorra on GitHub · 2026-12-03 00:00 UTC · original
VERIFY-3168 — Windows nativo:
red then greenen el guardián del refite7558c4df—hwrt.rs, +89/−9Ran at the head
Negative control (synthetic): I weakened the guard from
held_from != 0 && held_from == sourceto||, rebuilt and ran:It bites, and the mutation is exactly the bug the guard exists for: a refit recorded against a structure nobody's copies were made from.
&&and||differ by one character and by a corrupted BLAS.What the change is:
refit_from_held(held_from, source)records a refit only from the structure the copies were actually made from;refit_keeps_activityrefuses a refit whose geometries changed which triangles are inactive (DXR: none may become active, none inactive) with boxes never refitted; and aNaNin the transform row that givesxmakes the geometry inactive.Why the second test is the interesting one: a
NaNin a transform does not fail on the GPU — it silently produces a geometry whose tests never pass, which reads as "the ray missed" for every ray of that instance. Turning it into "inactive" is turning an invisible failure into a stated one.What I could not test
Written with an AI assistant.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.