Skip to content

startup: name the causes of a refused placed build and accept PERFORM_UPDATE with a source structure - #1943

Open
tedin7 wants to merge 10 commits into
R0Y00:mainfrom
tedin7:x2w-frontier-placed-update
Open

tedin7 wants to merge 10 commits into
R0Y00:mainfrom
tedin7:x2w-frontier-placed-update

Conversation

@tedin7

@tedin7 tedin7 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

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 placed PERFORM_UPDATE with 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, UpdateScratchDataSizeInBytes from GetRaytracingAccelerationStructurePrebuildInfo); Direct3D 12 documentation, D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS; and the earlier placed-build code of this repository (placed_build.h).

resolve_placed_build collapsed six different refusals into one opaque E_INVALIDARG and refused every update build. This names the causes and accepts PERFORM_UPDATE with a source structure. d3d12_memory_srv.inl and placed_buffer_range are 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 of check_dxr_placed_build (tests/dxr_check.cpp:581), so it runs in dxr_placed_build_warp and dxr_placed_build_hardware.

  • Source built with ALLOW_UPDATE: the fixture builds the BLAS and TLAS with ALLOW_UPDATE (tests/dxr_check.cpp:231) through the placed resolver.
  • Update through the placed path: placedScene->resolve_update re-resolves the BLAS and the TLAS as in-place PERFORM_UPDATE builds (tests/dxr_check.cpp:384-386, tests/dxr_placed_build.h:246) and the translated builds are recorded after UAV barriers (:387-390).
  • Changed ray result: the instances move and the geometry changes, rays are traced and read back after a UAV barrier, a queue signal and a fence wait (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).
  • Refusal controls stay: every resolver refusal is asserted by cause in the same test (tests/dxr_placed_build.h), including an update whose source was built without ALLOW_UPDATE (source_not_updatable) and one never built (source_not_built).
  • Precondition: documented in docs/experiments.md and now enforced by the resolver (it records ALLOW_UPDATE per build and refuses an update without it).

Changes

  • src/startup_stubs/placed_build.h: a standard-C++-only part with PlacedBuildCause (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_cause and PlacedBuildLedger. The Windows declarations stay below, under _WIN32.
  • resolve_placed_build returns the same E_INVALIDARG and still publishes nothing on a refusal, and now logs x2w-dxr placed build refused: <cause> (<dest|scratch|source> at title 0x...) once per cause.
  • With 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 by UpdateScratchDataSizeInBytes. 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 the ALLOW_UPDATE flag 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_build reports its cause through an optional out parameter.
  • tests/placed_build_causes_check.cpp (registered as placed_build_causes): the device-free rules, including both aliasing outcomes and the boundaries. tests/dxr_placed_build.h (used by dxr_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.
  • Notes in docs/experiments.md.

Verified (Linux)

Verification (Windows Server 2025, D3D12 WARP, head 5a79add, after merging current main)

  • Debug: cmake --build --preset dev --target placed_build_causes_check offscreen_check -- -j 2, then ctest --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}).
  • Release /O2: the same build and ctest commands with --preset release: 9/9 passed, same nine tests.
  • Linux: g++ -std=c++17 -O2 -Wall -Wextra -fsanitize=address,undefined tests/placed_build_causes_check.cpp passes; eight mutations of placed_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.
  • The device tests require the named cause for every refusal a device can trigger (destination and scratch not placed, unaligned, wrong state; no source, source without the flag, unaligned, not placed, wrong state, one stride past the destination, never built, built without ALLOW_UPDATE). range and source_range cannot be triggered on a real device (buffers are placed 64 KB aligned), so the address rule is checked by value in placed_build_causes.

Not verified

  • An out-of-place update is resolved but not dispatched. The in-place PERFORM_UPDATE of the placed BLAS and TLAS (built with ALLOW_UPDATE) is recorded and read back in dxr_placed_build_{hardware,warp}.
  • The ledger records builds that go through this resolver; a structure built another way has no record and an update from it is refused.

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-26T11:49:41.635633Z
We couldn’t complete this review. Comment @codex review to try again.
5a79add Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@tedin7

tedin7 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Part of #870, #1758. Addressed the review in 8e402dc and 1c5de00 (head 1c5de00).

  • dxr_placed_build_{hardware,warp} now builds the placed BLAS and TLAS with ALLOW_UPDATE, records an in-place PERFORM_UPDATE of both through resolve_placed_build (source = the title address of the initial build), and reads back four rays after the normal UAV barriers and fence. The hit instance IDs change from 7, 11, 0, 0 to 0, 0, 7, 11, and the rows equal the same update on desktop addresses and a fresh placed build of the updated scene. The resolver refusal controls are unchanged.
  • Found by the new test: WARP reports UpdateScratchDataSizeInBytes = 0, and the resolver refused that as an unplaced scratch. A null scratch is now accepted when no update scratch is needed, and a scratch that is passed anyway must still be a placed buffer. Covered by new controls in the fixture.
  • docs/experiments.md now states the caller precondition: the shim does not track provenance, so a source structure must have been built with ALLOW_UPDATE.
  • Out-of-place updates are resolved but not dispatched.

Verification (Win2025 node, x2w_pipe.py win2025 1943 --regex '^(placed_build_causes|dxr_)' at 1c5de00): placed_build_causes, dxr_placed_build_warp, dxr_placed_build_hardware and the other dxr_* WARP tests pass (20/21). dxr_opacity_hardware fails (candidate handling vs CPU reference). That test does not use the placed path, and I did not run it on main to confirm it was already failing.

AI-assisted; commands listed were executed locally.

@tedin7
tedin7 requested a review from R0Y00 November 25, 2026 11:18
@tedin7

tedin7 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

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.

@tedin7 tedin7 closed this Nov 25, 2026
@tedin7 tedin7 reopened this Nov 26, 2026
@tedin7
tedin7 marked this pull request as draft November 26, 2026 10:37
@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

Reopened and brought to date: main is merged into the branch (merge commit, no force push, head 047f6f0c). One conflict, in tests/dxr_placed_build.h, where main added the slot-70 acceleration-structure view publishing and this branch the update checks; both are kept.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 047f6f0cc35aca3f34df5dff87d253053e7bf5a0:

  • Debug (--preset dev): cmake --build --preset dev --target placed_build_causes_check offscreen_check -- -j 2, then ctest --preset dev -R '^(placed_build_causes|dxr_placed_build_|dxr_slot70_as_)' --no-tests=error --output-on-failure: 5/5 passed (placed_build_causes, dxr_placed_build_warp, dxr_placed_build_hardware, dxr_slot70_as_warp, dxr_slot70_as_hardware).
  • Release /O2 (--preset release): the same build and ctest commands: 5/5 passed, same five tests.
  • Linux: g++ -std=c++17 -Wall -Wextra tests/placed_build_causes_check.cpp passes; git diff --check is clean.

The earlier review round (build the source with ALLOW_UPDATE, record and read back an update, document the caller precondition) was already addressed on this branch before the merge. The PR body now has the Source: line and the verification above. An independent Stage-2 review is requested; this stays a Draft until it passes.

AI-assisted; commands listed were executed locally.

@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

The three gate findings are fixed (head 5a79addf, main merged, no force push).

  1. ALLOW_UPDATE provenance: the resolver records the flag of every build it publishes and refuses an update whose source was built without it (source_not_updatable) or that it never saw built (source_not_built; unknown provenance is refused). A refused call records nothing; a later build over the same memory replaces the record, and an update's destination is recorded with the update's flags.
  2. Named causes at device level: resolve_placed_build reports its cause through an optional out parameter, and every refusal in dxr_placed_build_{warp,hardware} now requires the exact cause, not only E_INVALIDARG.
  3. A triggering control for each cause a device can reach: destination and scratch (not placed, unaligned, wrong state), and for an update no source, a source without the flag, an unaligned, not placed or wrong-state source, a source one stride past the destination (partial overlap on a device that sizes the structure over 256 bytes), a source never built, and a source built without ALLOW_UPDATE. range and source_range cannot be triggered on a real device (buffers are placed 64 KB aligned), so the translated-address rule is checked by value in placed_build_causes, with the ledger rules; eight mutations of placed_build.h each fail that check.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 5a79addf711b8934ee45a77906fd4be1be98f8ad:

  • Debug (--preset dev): cmake --build --preset dev --target placed_build_causes_check offscreen_check -- -j 2, then ctest --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}).
  • Release /O2 (--preset release): the same build and ctest commands: 9/9 passed, same nine tests.
  • Linux: the device-free check passes under address and undefined-behaviour sanitizers; git diff --check and the docs link check are clean.

Stage-2 re-gate requested. This stays a Draft until it passes.

AI-assisted; commands listed were executed locally.

@tedin7
tedin7 marked this pull request as ready for review November 26, 2026 11:49
@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

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):

  • ctest -R '^(placed_build_causes|dxr_placed_build_|dxr_slot70_as_|dxr_update)': dev 9/9 and release 9/9 (placed_build_causes, dxr_placed_build_warp, dxr_placed_build_hardware, dxr_slot70_as_warp, dxr_slot70_as_hardware, dxr_update_warp, dxr_update_hardware, dxr_update_pipeline_warp, dxr_update_pipeline_hardware).
  • Extra control, run on top of the head: the TLAS rebuilt without ALLOW_UPDATE is refused as source_not_updatable for an in-place update, and the same update is accepted after the TLAS is rebuilt with ALLOW_UPDATE (dxr_placed_build_warp 1/1).
  • Linux: g++ -std=c++17 -O2 -Wall -Wextra -fsanitize=address,undefined tests/placed_build_causes_check.cpp: no warnings, passes; git diff --check origin/main...HEAD clean.
  • Each refusal control now asserts the named cause, not only E_INVALIDARG. range / source_range are checked by value through gpu_range_cause only, because a real device places buffers 64 KB aligned (stated in the header).

AI-assisted; commands listed were executed locally.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants