Repository navigation
startup: name the causes of a refused placed build and accept PERFORM_UPDATE with a source structure - #1943
startup: name the causes of a refused placed build and accept PERFORM_UPDATE with a source structure#1943tedin7 wants to merge 13 commits into
Conversation
…_UPDATE with a source structure
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
R0Y00
left a comment
There was a problem hiding this comment.
The refusal diagnostics can land independently. The new accepted PERFORM_UPDATE cases currently stop at resolve_placed_build. Before accepting production updates, please build the source with ALLOW_UPDATE, record and submit at least one update through the placed path, then read back a changed ray result with the normal barriers and fence. Keep the existing resolver refusal controls. Also document the caller precondition for an update-capable source, or reject an initial build without it if the shim can track that provenance. D3D12 build flags
…LOW_UPDATE precondition Part of R0Y00#870, R0Y00#1758. Build the placed BLAS and TLAS with ALLOW_UPDATE, record the in-place update of both through resolve_placed_build, and read back four rays: the hit IDs change and equal the direct-address update and a fresh placed build.
|
Part of #870, #1758. Addressed the review in 8e402dc and 1c5de00 (head 1c5de00).
Verification (Win2025 node, AI-assisted; commands listed were executed locally. |
|
Closing this PR for now to keep the Windows test queue short. Nothing is wrong with it and the branch stays as it is. We will reopen it once the queue is clear, re-run the Win2025 WARP checks at its head, and post the result here. AI-assisted; commands listed were executed locally. |
|
Reopened and brought to date: Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
The earlier review round (build the source with AI-assisted; commands listed were executed locally. |
…source lacks it; name every cause in the device tests
…tate scratch controls; drop device controls a small structure cannot reach
|
The three gate findings are fixed (head
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
Stage-2 re-gate requested. This stays a Draft until it passes. AI-assisted; commands listed were executed locally. |
|
Independent re-review of head 5a79add: PASS. Verification (Windows Server 2025, D3D12 WARP, build and tests on the PR head, run through the repository's Win2025 pipeline on its own host):
AI-assisted; commands listed were executed locally. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@MasterDomino #1943 is tested and Ready as well (Win2025 dev 9/9 + release 9/9 at 5a79add). R0Y00's change request is covered: Full merge order from our side: #1408, #1251, #1939, #1940, #1943, #2782, #2794, #2766. |
|
Hardware result for head Environment: Windows 11 25H2 (26200), MSVC 19.42, Command Result (measured): 6/8 passed.
On Where it fails (measured): the failing check passes the TLAS scratch buffer as the destination. I printed the sizes once in a throwaway local copy (not part of the PR):
On WARP the TLAS result size fits in the scratch buffer. On NVIDIA it does not. Likely cause (hypothesis, from reading the code): Possible fix (tested only as a local patch): make the TLAS scratch buffer at least as large as the TLAS result, like the earlier change for With that one line, the same command gives 8/8 on this machine (hardware and WARP). The other must_reject controls that take a buffer as the destination may need the same care on other adapters. This is one physical adapter on one driver. An AMD or Intel result would show whether the sizes differ per vendor. AI-Assisted |
|
@SimSalabimse thank you for running this on NVIDIA and for the careful write-up. The size table and the place where it fails make the cause clear: the A fix is coming on this PR. It sizes the scratch buffer so the control reaches the state check on every adapter, along the lines you proposed. We will post the new head and the results here. A rerun of the same AI-assisted; commands listed were executed locally. |
…e sizes The controls that name a scratch buffer as a destination, use an acceleration-structure buffer as scratch, or read a 256-byte view at the scratch address sized those buffers to the minimum of one device (WARP). A GPU that reports a result size larger than the scratch size made the range check fail first, so the build named not_placed instead of wrong_state. The decoy buffers now cover the result size, the scratch size and the view.
|
@SimSalabimse the fix is on this PR now: head What changed: the decoy buffers in the fixture (the scratch buffer used as a destination in the Results on the new head:
Could you rerun the same command on your RTX 4070 Ti when you have a moment? AI-assisted; commands listed were executed locally. |
|
Rerun on head Environment: same as before. Windows 11 25H2 (26200), MSVC 19.42, Command Result (measured): 8/8 passed, ctest exit 0, in each of 3 runs. That includes Negative control: the old head AI-Assisted |
|
@SimSalabimse thank you for the rerun and for the negative control on the old head. 8/8 on the RTX 4070 Ti, 3 runs out of 3, confirms the fixture fix on AI-assisted; commands listed were executed locally. |
pigalot
left a comment
There was a problem hiding this comment.
Independently reviewed b09ac9dd integrated over main 5612e924 (tree 2fa7dbce). The merge is clean (CMakeLists.txt, docs/experiments.md and src/startup_stubs/d3d12_xs_device.cpp auto-merged) and git diff --cached --check origin/main is clean.
Earlier findings (R0Y00, changes requested on 9e8d04df): addressed.
- Build with
ALLOW_UPDATE, submit an update through the placed path, read back a changed ray result.check_placed_update(called fromcheck_dxr_placed_build) does this:- It builds the placed BLAS and TLAS with
ALLOW_UPDATEand resolves an in-placePERFORM_UPDATEof both throughresolve_placed_build, from the title addresses of the initial build. - It traces after the existing UAV barriers and fence.
- It requires the hit instance IDs to change from 7, 11, 0, 0 to 0, 0, 7, 11, and the rows to equal both the direct-address update and a fresh placed build of the updated scene.
- On this machine it prints
ray results changed and equal the direct-address update and a fresh placed buildon both WARP and hardware.
- It builds the placed BLAS and TLAS with
- Keep the resolver refusal controls. The three original
must_rejectcalls are still there: the unmapped destination, the short scratch, and the swapped states. Each now also has to name its cause, and four new destination and scratch controls sit next to them. - Document the precondition, or reject when provenance can be tracked. It takes the second option.
PlacedBuildLedgerrecords theALLOW_UPDATEflag of each build the resolver publishes, and an update is refused when its source was never built (source_not_built) or was built without the flag (source_not_updatable). The provenance check and the record happen under one SRW lock, after every lookup, so a refused call records nothing. The geometry-layout precondition that remains is stated indocs/experiments.md.
What I traced. In resolve_placed_build the update shape is checked before any lookup. The cases are:
PERFORM_UPDATEwithout a source, and a source withoutPERFORM_UPDATE;- an unaligned source;
- a source that partly overlaps the destination (in-place updates are still allowed).
The source then goes through the same placement lookup as the destination, with its causes renamed source_*. An update's scratch is sized by UpdateScratchDataSizeInBytes. When that size is 0 (as WARP reports), a null scratch is accepted, and a scratch that is passed must still be a placed UAV buffer, checked over one byte. On success the source is rewritten to its desktop GPU address. On refusal the descriptor is left as the caller gave it, which the fixture checks for the destination, the scratch and the source. The other caller, tests/cpu/placed_dxr_provider.cpp, keeps the default nullptr cause.
What I ran.
. .\tools\dev.ps1; cmake --preset <preset>
cmake --build --preset <preset> --target placed_build_causes_check offscreen_check cpu_placed_dxr_provider cpu_placed_dxr cpu_placed_dxr_lifted pe_map cpu_exe_io
$r = '^(placed_build_causes|dxr_placed_build_(warp|hardware)|dxr_slot70_as_(warp|hardware)|dxr_update_(warp|hardware)|dxr_update_pipeline_(warp|hardware)|cpu_placed_dxr_(warp|hardware))$'
ctest --test-dir out/build/<preset> --no-tests=error -j 4 -R $r -E '_hardware$'
python with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R $r -E '_warp$|^placed_build_causes$'- Results: 11/11 pass in
devand inrelease/O2, with no skips. That isplaced_build_causes, five WARP tests and five hardware tests, withdebug_layer=enabledon the hardware runs. In both presets,dxr_placed_build_hardwareanddxr_slot70_as_hardwarelog each named refusal once, fromnot_placedthroughsource_not_updatable. - Release setup note. A first
releasepass failed bothcpu_placed_dxr_*tests withFileNotFoundError ... cpu_placed_dxr_lifted.exe. That was my targeted build missing that test's other targets. Both pass oncecpu_placed_dxr,cpu_placed_dxr_lifted,pe_mapandcpu_exe_ioare built. - Before: on
main5612e924,placed_build_causesis not registered, and the resolver returnsE_INVALIDARGfor any source orPERFORM_UPDATE.
Mutants (each applied alone, the target rebuilt in dev, file restored from its raw bytes, git diff --quiet clean afterwards). Every one is killed:
| Mutant | Test | First failure |
|---|---|---|
ledger ignores the ALLOW_UPDATE flag |
placed_build_causes |
ledger.check_source(base + 8 * size) == Cause::source_not_updatable |
| a build does not replace overlapping records | placed_build_causes |
ledger.check_source(base) == Cause::source_not_built |
| partial-overlap rule removed | placed_build_causes |
check_update_shape(true, base + 256, base, size) == Cause::source_dest_partial_overlap |
last_byte one past the end |
placed_build_causes |
check_update_shape(true, base, base + size, size) == Cause::ok |
| translated-address alignment not checked | placed_build_causes |
gpu_range_cause(gpu, 1) == Cause::range |
| provenance check skipped | dxr_placed_build_warp |
Invalid DXR update was accepted or partially published: source never built |
every build recorded as ALLOW_UPDATE |
dxr_placed_build_warp |
… source built without ALLOW_UPDATE |
| null update scratch refused | dxr_placed_build_warp |
Resolve update without scratch failed (HRESULT 0x80070057) |
| update sized by the build scratch | dxr_placed_build_warp |
same |
| source address not translated | dxr_placed_build_warp |
An in-place update must translate source and destination to the same address |
Non-blocking notes.
- The ledger is never told when a placed buffer is released. Entries for freed memory stay until a later build overlaps them, so a reused title address keeps the old flags until then. A title that updates a structure it never rebuilt at that address is already invalid, so I don't think this changes any valid sequence. Clearing the overlapping records when a placed buffer is destroyed would bound the ledger's size and remove the stale case.
- The comment on
PlacedBuildScene::resolve_updatestill says "The caller keeps ALLOW_UPDATE from the initial build; the resolver cannot see it." Since3bdbf41cthe resolver records the flag and refuses a source built without it. - Out-of-place updates are resolved and checked by address but not dispatched, as the body states.
Verdict: approve on b09ac9dd.
Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10, D3D12 debug layer enabled for the hardware runs.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on b09ac9dd.
This reply was AI-assisted.
|
Thanks for this. I reviewed head
Suggestion (not blocking):
Nits: This comment was AI-assisted. |
|
Thanks @JohnConnorNPC. Pushed What changed:
Verification (Windows Server 2025, D3D12 WARP, PR head @MasterDomino this one is ready for a re-review and merge when you have time. The old changes-requested review by @R0Y00 was answered earlier in this thread (update path through AI-assisted; commands listed were executed locally. |
pigalot
left a comment
There was a problem hiding this comment.
Retested f8646309 integrated over main 212d4b5f (tree 570ff438). The merge is clean and git diff --cached --check origin/main is clean. I am not carrying my approval of b09ac9dd over to this head yet; the reason is the real-title run below, not the code I read.
What changed since b09ac9dd.
60748f14mergesmain8ecd30feinto the branch.git show --remerge-diff 60748f14is empty, so nothing was resolved by hand.f8646309rewrites one comment onPlacedBuildScene::resolve_updateintests/dxr_placed_build.h. That was the stale-comment note in my last review; it is addressed.- I compared the PR's own diff at both heads (
merge-base..b09ac9ddagainst8ecd30fe..f8646309): that comment line is the only difference. mainhas not changedplaced_build.h,tests/dxr_check.cpp,tests/dxr_placed_build.hortests/cpu/placed_dxr_provider.cppsince my last review, andplaced_buffer_rangestill has the signature the resolver uses.
Earlier findings. R0Y00's three requests on 9e8d04df (update through the placed path with a changed ray result, keep the refusal controls, track or document ALLOW_UPDATE provenance) were addressed at b09ac9dd as I described in my last review, and the code that addresses them is unchanged here. My other two notes (ledger entries are not cleared when a placed buffer is released; out-of-place updates are resolved but not dispatched) stand as non-blocking.
What I ran.
. .\tools\dev.ps1; cmake --preset <preset>
cmake --build --preset <preset> --target placed_build_causes_check offscreen_check cpu_placed_dxr_provider cpu_placed_dxr cpu_placed_dxr_lifted pe_map cpu_exe_io
$r = '^(placed_build_causes|dxr_placed_build_(warp|hardware)|dxr_slot70_as_(warp|hardware)|dxr_update_(warp|hardware)|dxr_update_pipeline_(warp|hardware)|cpu_placed_dxr_(warp|hardware))$'
ctest --test-dir out/build/<preset> --no-tests=error -j 4 -R $r -E '_hardware$'
python with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R $r -E '_warp$|^placed_build_causes$'- 11/11 pass in
devand inrelease/O2, with no skips:placed_build_causes, five WARP tests and five hardware tests. The hardware runs reportdebug_layer=enabledanddebug_errors=0 debug_warnings=0. - In both presets
dxr_placed_build_hardwareanddxr_slot70_as_hardwarelog each named refusal once, fromnot_placedtosource_not_updatable, anddxr_placed_build_hardwareprintsray results changed and equal the direct-address update and a fresh placed build.
Mutants (each applied alone in dev, the target rebuilt, the file restored from its raw bytes, git diff --quiet clean afterwards). 10 killed, 0 surviving, 0 equivalent.
| Mutant | Test | First failure |
|---|---|---|
ledger ignores the ALLOW_UPDATE flag |
placed_build_causes |
placed_build_causes_check.cpp:122 ledger.check_source(base + 8 * size) == Cause::source_not_updatable |
| a build does not replace overlapping records | placed_build_causes |
:132 ledger.check_source(base) == Cause::source_not_built |
| partial-overlap rule removed | placed_build_causes |
:57 check_update_shape(true, base + 256, base, size) == Cause::source_dest_partial_overlap |
last_byte one past the end |
placed_build_causes |
:50 check_update_shape(true, base, base + size, size) == Cause::ok |
| translated-address alignment not checked | placed_build_causes |
:104 gpu_range_cause(gpu, 1) == Cause::range |
| provenance check skipped | dxr_placed_build_warp |
Invalid DXR update was accepted or partially published: source never built |
every build recorded as ALLOW_UPDATE |
dxr_placed_build_warp |
... source built without ALLOW_UPDATE |
| null update scratch refused | dxr_placed_build_warp |
Resolve update without scratch failed (HRESULT 0x80070057) |
| update sized by the build scratch | dxr_placed_build_warp |
same |
| source address not translated | dxr_placed_build_warp |
An in-place update must translate source and destination to the same address |
Real-title run (why this is a comment and not an approval). A local startup run of a real title with a scripted input plan, compared against the same run of main 212d4b5f:
f8646309(the PR head):[fail] frames_present: 12 of 12 checkpoint frames captured, 8 black (baseline: 0 black).f8646309merged overmain212d4b5f(the trial merge above): the same line, 8 black.8ecd30fe(themaincommit this branch last merged, without the PR):[pass] frames_present: 12 of 12 checkpoint frames captured, 0 black (baseline: 0 black).- In all four runs the input plan finished and
input_responsepassed, 4 of 4.
So two runs that contain this PR show black frames, and two runs without it do not. I cannot explain that from the code: resolve_placed_build has no caller under src/ (its only callers are tests/dxr_placed_build.h and tests/cpu/placed_dxr_provider.cpp), and the rest of the diff is the header, tests, one CMake test target and docs. Four runs do not rule out run-to-run variation, and I have not shown that it is one. I have queued one more run of each side (main 212d4b5f, and the trial merge); they had not run when I posted this.
I am not asking for a code change: I have no reproducible input to give you, and nothing in the diff that I can point at. Until the black frames are either explained or shown to vary between runs of the same commit, I am leaving this head unapproved.
Not rerun at this head. JohnConnorNPC's suggestion (the device control for a source one stride past the destination takes its expected cause from check_update_shape, so it cannot pin the overlap rule on a device) is answered by the author as intended. The device-free check does pin that rule (third mutant above). I did not run the overlap mutant against the device tests.
Verdict: comment on f8646309. Code and tests are as I approved them at b09ac9dd; the title-run difference is open. R0Y00's changes request from 9e8d04df is still the review decision on the PR.
Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10, D3D12 debug layer enabled for the hardware runs.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on f8646309.
This reply was AI-assisted.
|
I re-checked Two small points from that review are still open. Both are optional: NIT
About pigalot's black-frame runs: R0Y00's change request on AI-assisted. |
Part of #1758 (and #870); no
Fixes.What this unblocks: a refused placed acceleration-structure build now says why (six causes were one opaque
E_INVALIDARG), and a placedPERFORM_UPDATEwith a source structure is accepted through the same placement lookup as the build.Source: DirectX-Specs, Raytracing, "Acceleration structure update" (
PERFORM_UPDATE,ALLOW_UPDATE,SourceAccelerationStructureData,UpdateScratchDataSizeInBytesfromGetRaytracingAccelerationStructurePrebuildInfo); Direct3D 12 documentation,D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS; and the earlier placed-build code of this repository (placed_build.h).resolve_placed_buildcollapsed six different refusals into one opaqueE_INVALIDARGand refused every update build. This names the causes and acceptsPERFORM_UPDATEwith a source structure.d3d12_memory_srv.inlandplaced_buffer_rangeare untouched.Reply to the 2026-11-24 review
The requested update path is covered by
check_placed_update(tests/dxr_check.cpp:512), called at the end ofcheck_dxr_placed_build(tests/dxr_check.cpp:581), so it runs indxr_placed_build_warpanddxr_placed_build_hardware.ALLOW_UPDATE: the fixture builds the BLAS and TLAS withALLOW_UPDATE(tests/dxr_check.cpp:231) through the placed resolver.placedScene->resolve_updatere-resolves the BLAS and the TLAS as in-placePERFORM_UPDATEbuilds (tests/dxr_check.cpp:384-386,tests/dxr_placed_build.h:246) and the translated builds are recorded after UAV barriers (:387-390).submit_and_wait,tests/desktop_gpu.cpp:81-91). The test requires the result to differ from the pre-update result (tests/dxr_check.cpp:532), to carry the expected hit instance IDs per ray (:534-538), and to equal both the same update on desktop addresses and a fresh placed build of the updated scene (:530-531).tests/dxr_placed_build.h), including an update whose source was built withoutALLOW_UPDATE(source_not_updatable) and one never built (source_not_built).docs/experiments.mdand now enforced by the resolver (it recordsALLOW_UPDATEper build and refuses an update without it).Changes
src/startup_stubs/placed_build.h: a standard-C++-only part withPlacedBuildCause(ok,unaligned,not_placed,wrong_state,range,update_without_source,source_without_update,source_unaligned,source_not_placed,source_wrong_state,source_range,source_dest_partial_overlap,source_not_built,source_not_updatable),cause_name,ranges_overlap,check_update_shape,gpu_range_causeandPlacedBuildLedger. The Windows declarations stay below, under_WIN32.resolve_placed_buildreturns the sameE_INVALIDARGand still publishes nothing on a refusal, and now logsx2w-dxr placed build refused: <cause> (<dest|scratch|source> at title 0x...)once per cause.PERFORM_UPDATE, the source goes through the same placement lookup as the destination, unchanged (a live placed buffer in the acceleration-structure state, 256-byte aligned). The scratch is sized byUpdateScratchDataSizeInBytes. The update may run in place (source == destination) or write another structure; a source that partly overlaps the destination is refused. Nothing is published unless all three addresses resolve. The resolver records theALLOW_UPDATEflag of every build it publishes (keyed by the structure's title address; a later build over the same memory replaces the record) and refuses an update whose source was recorded without it (source_not_updatable) or never seen built (source_not_built).resolve_placed_buildreports its cause through an optional out parameter.tests/placed_build_causes_check.cpp(registered asplaced_build_causes): the device-free rules, including both aliasing outcomes and the boundaries.tests/dxr_placed_build.h(used bydxr_placed_build_{hardware,warp}): six refused updates (no source, source without the flag, unaligned, unmapped, wrong state, partial overlap), an in-place update and an out-of-place one with its interior offset kept.docs/experiments.md.Verified (Linux)
g++ -std=c++17 -O2 -Wall -Wextra -fsanitize=address,undefinedontests/placed_build_causes_check.cpp: no warnings, passes.placed_build.h, each failing the check, original restored: in-place update refused, partial overlap accepted, overlap boundary off by one, source alignment unchecked, update flag without source accepted.-fsyntax-onlyond3d12_xs_device.cpp(only the MSVC-only__try/__exceptoflocal_log.h, as onmain) and ontests/cpu/placed_dxr_provider.cpp, which includes the fixture header.git diff --check origin/main...HEAD,tests/docs_links_check.py,tests/bidi_controls_check.py: pass.git merge-tree: no conflicts withmain, startup: prove slot 133 placements without walking the allocation #1766, startup: pass OMSetStencilRef (slot 24) to the desktop list #1787, startup: name the command list slots the noop log can state #1788, build: write the variants of each x87 fixture in one Python process #1789, startup: clear tables on root change and log dropped root constants #1744, startup: record SetGraphicsRoot32BitConstant (slot 38) #1726. startup-d3d12: run compute pipelines that are already desktop DXIL #1441 already conflicts withmainon its own.Verification (Windows Server 2025, D3D12 WARP, head 5a79add, after merging current
main)cmake --build --preset dev --target placed_build_causes_check offscreen_check -- -j 2, thenctest --preset dev -R '^(placed_build_causes|dxr_placed_build_|dxr_slot70_as_|dxr_update)' --no-tests=error --output-on-failure: 9/9 passed (placed_build_causes,dxr_placed_build_{warp,hardware},dxr_slot70_as_{warp,hardware},dxr_update_{warp,hardware},dxr_update_pipeline_{warp,hardware})./O2: the same build and ctest commands with--preset release: 9/9 passed, same nine tests.g++ -std=c++17 -O2 -Wall -Wextra -fsanitize=address,undefined tests/placed_build_causes_check.cpppasses; eight mutations ofplaced_build.h(allow-update ignored, unknown source accepted, overlap record not dropped, flag forced on, three variants of the address rule, a missing name) each fail the check.ALLOW_UPDATE).rangeandsource_rangecannot be triggered on a real device (buffers are placed 64 KB aligned), so the address rule is checked by value inplaced_build_causes.Not verified
PERFORM_UPDATEof the placed BLAS and TLAS (built withALLOW_UPDATE) is recorded and read back indxr_placed_build_{hardware,warp}.AI-assisted; commands listed were executed locally.
Replaces closed draft #1799 (rebased cleanly on origin/main and verified on Win2025: 3/3 Debug + 3/3 Release).
AI-assisted; commands listed were executed locally.