startup: gate the BVH builder compute stages all or none #2920
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2920"
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 R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-26T20:33:43Z.
What changed
The console BVH structure builder's compute stages feed each other through title memory. A stage that runs on data a missing stage never wrote computes store offsets from garbage; the observed failure ran 14 of 35 translated stages and the title died within a second on pointers that had become bounding-box bit patterns.
This adds an opt-in all-or-none gate:
X2W_COMPUTE_BUILDER_GATE=1, off by default.XboxBvhBuilder.dll. An unresolved caller is left untracked rather than guessed.compute_request_key. It is called at both public Dispatch paths: list slot 14Dispatchand list slot 61ExecuteIndirectwith a Dispatch signature.builder gate refused N.The pure classifier and state machine are in
src/startup_stubs/compute_builder_gate.h; the runtime wiring is covered by a source-built module namedXboxBvhBuilder.dllthat calls the public slot 62 vtable entry.Tests
Passed locally on WARP:
startup_compute_builder_gate: 106 cases, 0 failures (classifier, gate off, all present, one missing, on-the-spot creation, permanent off after a failure, non-builder unaffected, full table refusal).startup_compute_builder_gate_runtime: two builder pipelines created through the source-builtXboxBvhBuilder.dll; a directDispatchand an indirectExecuteIndirectare both refused with the gate enabled; the same direct call through a non-builder slot 62 wrapper produces no gate refusal.startup_compute_builder_gate_request_warp: the existing slot 67 request check passes withX2W_COMPUTE_BUILDER_GATE=1, so request publication keeps its normal path.d3d12_xs_shimbuilds with the hook.Limits
The runtime helper uses a fake console container. It proves the caller-module tag and that both public Dispatch paths reach the gate; it does not claim a completed translated builder set. A console DXIL program still fails desktop PSO creation by name and turns the builder off, which is the intended conservative result until real translations exist. A real-title run with the gate on must report either
all have a desktop PSOor one named reason.Refs #870, #1758.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T05:30:13Z.
Review: COMMENTED
PR #2920 by @lambirou -- startup: gate the BVH builder compute stages all or none
What works
Issues
Recommendations
Overall
A well-researched, well-tested implementation. The linear layout extension is cleanly separated from tiled modes. Minor concern about BC format handling in linear mode, but the existing refusal behavior is safe. Ready for merge.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T07:03:06Z.
Review: CHANGES_REQUESTED
The runtime gate cannot see the pipelines it tracks at
160b21d9. Slot 62 marks the wrapper asbuilder_pipeline, but neither it nornote_compute_binding_pipelinesetscompute_request_key. The only assignment to that field is in the slot 67 specialization, which never records a builder pipeline. Bothlist_dispatchand the Dispatch arm oflist_execute_indirectrequire a nonzero request key before callingcompute_builder_dispatch_allowed. A slot 62 builder wrapper therefore bypasses both gates, and the helper unit test cannot catch that wiring gap.Please exercise the public creation and dispatch paths with a source-built helper DLL whose basename matches the builder module. The fixture should show that an incomplete builder set refuses both direct and indirect Dispatch with the flag enabled, while a non-builder path and request publication keep their normal behavior. If the experimental flag is intended as a diagnostic cutoff only, describe that limit and still verify that it actually reaches the intended caller.
Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-27T08:59:30Z.
Fixed in
1dfaeeec, on top of currentmain3e9542a6.The wiring gap was real: the gate was behind
compute_request_key, which slot 62 never sets. The gate now keys on the slot 62 wrapper'sbuilder_pipelinetag and is called at both public Dispatch paths, independent of the request key:Dispatch(list slot 14);ExecuteIndirectwith a Dispatch signature (list slot 61), before the signature/argument checks.Added a source-built runtime fixture:
XboxBvhBuilder.dllhelper that calls the public slot 62 vtable entry, so the gate's caller-module lookup resolves the matching basename;Dispatchand an indirectExecuteIndirectare refused with the gate enabled;X2W_COMPUTE_BUILDER_GATE=1and passes.Local CTest:
startup_compute_builder_gate(106 cases),startup_compute_builder_gate_runtime, andstartup_compute_builder_gate_request_warpall pass. The fixture uses a fake console container, so it proves the tag and both Dispatch wirings; it does not claim a completed translated builder set.Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-27T09:12:39Z.
The fix is on
3e10c525, rebased on currentmaine446b072, with CI green.startup_compute_builder_gate,startup_compute_builder_gate_runtimeandstartup_compute_builder_gate_request_warppass locally and on CI. The staleCHANGES_REQUESTEDreview predates the new head; could you take another look?Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-27T09:49:18Z.
@R0Y00 the gate wiring and the runtime helper-DLL fixture are on
3e10c525, rebased on currentmainand green. TheCHANGES_REQUESTEDreview predates this head; could you re-review when you have a moment?Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T10:08:25Z.
Review: CHANGES_REQUESTED
The new wrapper tag routes slot 62 through the gate. The completed-set path still drops the first Dispatch. On
3e10c525, a source-built WARP control passed two valid desktop DXIL compute shaders through the slot 62 helper and bound one placeholder. The log first said2 tracked pipelines, all have a desktop PSO; Dispatch allowed, then refused the sameDispatch(1, 1, 1)withrequires a desktop compute pipeline and root. The three existing focused tests passed in both Debug and Release/O2at that head.The same state transition is present in the latest head
9b2bcc67:make_compute_builder_pipelinepublishes the PSO and metadata on the wrapper, whilecompute_builder_dispatch_allowedreturns without rebinding that PSO or refreshing the command list's cached compute pipeline and root. The downstream direct and indirect paths still use that cached state. Please refresh and bind the current pipeline on the list when the gate completes the set, and add a completed-set control that verifies the first direct Dispatch and an indirect Dispatch with valid arguments reach the GPU.Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-27T10:17:15Z.
Fixed in
b163d809, on currentmain.When the gate completes the set it now refreshes the recording's cached compute state (
pipeline_real,compute_pipeline,compute_pipeline_root) and binds the new desktop PSO on the list; when the title's bound root equals the pipeline root, it also re-binds that root. The caller's subsequentDispatchdecision therefore sees the completed pipeline instead of the placeholder bound before the gate ran.The runtime fixture now has a completed-set mode: two valid desktop DXIL compute shaders created through the source-built
XboxBvhBuilder.dll, an empty desktop root, the first directDispatch(1,1,1)and an indirectExecuteIndirectwith a placedD3D12_DISPATCH_ARGUMENTS{1,1,1}. The log reportsall have a desktop PSOfor the set and neither path is refused. The incomplete-set, non-builder and slot 67 request controls still pass.Local CTest:
startup_compute_builder_gate(106 cases),startup_compute_builder_gate_runtime,startup_compute_builder_gate_request_warpall pass.Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-27T10:28:09Z.
Windows dev + release receipt on
b163d809:All three run on WARP: the 106-case unit test, the runtime fixture (incomplete set refused direct + indirect; completed set direct + indirect reaches the list; non-builder untouched), and the slot 67 request check with the gate enabled.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T10:59:14Z.
Review: APPROVED
The first-dispatch state issue is resolved at
b163d809. The gate now updates the list's cached pipeline/root state and binds the PSO before either caller continues. I rebuilt the gate unit test, runtime fixture, builder module and slot-67 consumer on local integration tree7d83e45aagainstmain98007de5.ctest --preset <dev|release> --no-tests=error -V -R '^startup_compute_builder_gate($|_)'passed 3/3 in Debug/Z7and 3/3 in Release/O2, with no skips (Windows 11 26200.9974, SDK 10.0.26100, WARP 10.0.26100.9818). The completed set gets past the first direct dispatch and the valid indirect dispatch without the previous refusal, the incomplete set still refuses both paths, and the slot-67 request control still matches. This fixture checks command recording with a source-built no-op shader and does not measure shader output or original EXE behavior.