startup: wire per-reason refusal census into translated indirect draws #2325
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2333"
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 stan495 on 2026-11-25T12:41:48Z.
Refs #2274 (runtime follow-up to #2301).
Summary
x2w_startup::PerReasonRefusalCensus(indirect-draw) intosrc/startup_stubs/d3d12_xs_device.cppandsrc/startup_stubs/d3d12_draw.inlfor translatedExecuteIndirectdraw refusals (draw_translated_indirect):refusal_codetag alongside the existing proserefusalmessage onTranslatedIndirectDrawfor every refusal path indraw_translated(missing_guest_root,sampled_texture_mismatch,unsupported_resource_or_entry,incomplete_table_buffer,incomplete_vertex_stream,live_compute_pipeline,indexed_rect_unavailable,sampled_texture_unbindable,indexed_validation_failed,translation_not_ready,d16_srv_not_ready,pipeline_unavailable,sampler_heap_unavailable).(shader_key, refusal_code)inindirect_draw_refusal_census.note(...)and keep logging the first occurrence of each of the first 8 distinct(key, reason)pairs even after the 32-call refusal log budget is spent, while leaving the existing per-call log line format unchanged.indirect_draw_refusal_census.report(..., true)in the five-second heartbeat report.x2w-d3d12 indirect-draw refusals:block fromx2w_d3d12_census_report(...)wheneverindirect_draw_refusal_census.total() != 0, preserving the existing 4-line output contract for zero-refusal memory-SRV fixtures (startup_memory_srv_diag_*).tests/startup_indirect_draw_indexed.cppandCMakeLists.txt:startup_indirect_translated_refusal_census_{warp,hardware}interleavesmissing_guest_root(x2) andsampled_texture_mismatch(x1) on one translated pipeline key alongsideunsupported_resource_or_entry(x1) andincomplete_table_buffer(x2) on two other keys plus a valid draw, verifying exactx2w_d3d12_census_reporttotals (total 6; distinct keys 3, distinct pairs 4 (overflow calls 0)), all four per-(key, reason)rows, both per-call log lines for the shared key, and zero D3D12 debug layer errors.startup_indirect_translated_refusal_census_control_warpreplaces the second refusal on key 1 with a valid draw and asserts the mismatch reports the real counts (total 5; distinct keys 3, distinct pairs 3 (overflow calls 0)).docs/startup-runtime.mdto document the runtime wiring and exactctestcommands.Verification
ad3cf6cfMicrosoft Basic Render Driver, driver10.0.26100.9818, D3D12 debug layer enabled (0 errors)AMD Radeon RX 7900 XTX, driver32.0.32029.2010, D3D12 debug layer enabled (0 errors)Observed results:
AMD Radeon RX 7900 XTXhardware passed with debug layer enabled;startup_indirect_translated_refusal_census_control_warpreported the expected mismatchtotal 5; distinct keys 3, distinct pairs 3 (overflow calls 0);startup_memory_srv_diag_{warp,hardware,supported_control_warp}preserved the 4-line contract).offscreen_check: built cleanly with no errors.tests/docs_links_check.py: passed (18 Markdown files, 453 links).tests/bidi_controls_check.py: passed (1621 tracked files).git diff --check: clean.Scope note
These synthetic source-built fixtures verify per-
(key, reason)refusal counting, detail-budget preservation, heartbeat/export reporting, and negative controls ind3d12_xs_shimon WARP and an RX 7900 XTX. They do not establish full-game startup or execution of title CPU code.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:45:33Z.
Review: COMMENTED
Review of head
ad3cf6cf3136742e81c2eb04cfd8318704b2768e(comment only).What I checked
git diff --stat origin/main...HEAD: 5 files, +160/-12 (CMakeLists, docs, d3d12_draw.inl, d3d12_xs_device.cpp, startup_indirect_draw_indexed.cpp).python3 tests/docs_links_check.py-> self-test passed, 18 Markdown files, 453 links OK.python3 tests/bidi_controls_check.py-> 1621 files, no bidirectional controls.git diff --check origin/main...HEAD-> clean.Logic read-through
return falsepath indraw_translatedthat setsrefusalnow also sets a stablerefusal_code. The ternary paths (translation_not_ready/d16_srv_not_ready,pipeline_unavailable/sampler_heap_unavailable,incomplete_vertex_stream/incomplete_table_buffer) pick the right code. Theindexed_rect && !pipelinecase is excluded from the second assignment so it is not overwritten. Correct.census.note()is called only whenshader_key != 0, then logs on first (key, reason) pair OR the old 32-call budget. This keeps the old log budget and adds a line for each new reason. Good.x2w_d3d12_census_report(only when total > 0, so existing consumers see no change)....-control, expects a total of 5) is registered withPASS_REGULAR_EXPRESSION. This is a real GPU-path test on WARP and hardware backends, not a string check.Findings
shader_key == 0,!tr) are not counted in the census. That is the same gating as the old log, but the docs could say so in one sentence so the "total" is not read as "all indirect-draw refusals".refusal_codestrings are bare literals repeated at each site. A smallconstexprlist would prevent typos, but the test pins the three most important ones, so this is optional.Mutation
__declspec(dllimport), WARP/hardware), so I could not build or mutate them on Linux. I did not run Win2025 for this review. The Windows CI job built and ran the new CTest entries and passed. I make no claim about a mutation result.No blocking issues found.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:52:10Z.
Review: COMMENTED
Review of head
1c431de9560d24bdf4f0a7361e49790ebc959a7d(comment only, no approval).Scope read:
git diff --stat origin/main...HEAD= 5 files, +182/-12 (CMakeLists.txt, docs/startup-runtime.md, d3d12_draw.inl, d3d12_xs_device.cpp, tests/startup_indirect_draw_indexed.cpp). Title is neutral, PR is MERGEABLE. CI at review time: Linux Python job pass, Windows jobs still pending.Commands executed locally (Linux):
python3 tests/docs_links_check.py->Checked 18 Markdown files and 453 links.python3 tests/bidi_controls_check.py->no bidirectional controlsgit diff --check origin/main...HEAD-> cleang++ -std=c++17 -Isrc tests/startup_per_reason_refusal_census_check.cpp+ run ->PASS (distinct keys=2, pairs=4, detail=8, max=128)(the census header this PR wires in)Not run: the new
startup_indirect_translated_refusal_census_{warp,hardware}tests and the..._control_warpnegative control need D3D12, so they cannot run on Linux. I did not queue Win2025 here; the Windows CI jobs / a Stage-2 WARP run should confirm them. For the same reason I could not do a runtime mutation of the new logic; I checked it by reading instead.Findings
src/startup_stubs/d3d12_draw.inl(draw_translated, theindexed_rect && !pipelinebranch): it dereferencesindirectwithout a null check. This was already the case before the PR and the new line keeps it. Guarding withindirect &&would be a cheap hardening.d3d12_draw.inldraw_translated_indirect:note()now takes the census mutex on every refused indirect draw onceshader_key != 0, even after the 32-call log budget. The header comment says it is sized for refusal paths, which is fine. A storm of refusals per frame would contend on that lock, so it is worth keeping in mind.refusal_codenames and the proserefusalstrings are set at separate sites. A future refusal path that sets only the prose string would be counted aspipeline_or_target_unavailable(the default). A short comment at the struct, or a test that walks every code, would catch that drift.Checked by reading (OK):
draw_translatedsets a matching code. The!trpath leavesshader_key == 0, so it is correctly not counted.tr->state != 1->translation_not_ready, otherwised16_srv_not_ready, is correct for the guarded condition.!pipelinevssampler_heap_unavailablesplit is correct, and theindexed_rectcase keeps its own code.total() != 0guard inx2w_d3d12_census_report.PASS_REGULAR_EXPRESSION.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:11:38Z.
Review: COMMENTED
Review of head
7d355dd18b(comment only, no approval).Scope: 5 files, +198/-20. Wires
PerReasonRefusalCensusintodraw_translated_indirect, replaces ad-hoc refusal prose with aset_refusal(message, code)pair, adds a report line inqueue_presentandx2w_d3d12_census_report, plus a newtranslated-refusal-censustest and a negative control.Commands run locally (Linux, in a clean worktree of the PR head):
git diff --stat origin/main...HEAD: 5 files changed, 198 insertions, 20 deletionsgit diff --check origin/main...HEAD: cleanpython3 tests/docs_links_check.py: Self-test passed. Checked 19 Markdown files and 455 links.python3 tests/bidi_controls_check.py: Checked 1637 tracked files: no bidirectional controls.gh pr checks 2333: Linux Python checks, Windows build/test and gfx1013 fixtures were still pending when I looked, so I have no CI verdict. The Windows test is the only real proof for this C++ change.__declspec(dllimport),x2w_d3d12_census_report), so it does not build on Linux. I did not queue the Windows VM.Findings
P1: none.
P2-1
src/startup_stubs/d3d12_draw.inl(draw_translated_indirect): the log condition is nowfirst_pair || first_calls(refused, 32). Because of short-circuit evaluation,first_callsonly advances on non-first-pair refusals. The old code spent a 32-line budget on every refusal. The new behaviour looks intended, since every new (key, reason) pair gets a line and repeats keep the cap. Please say so in the PR text. Also confirm that a long run with many distinct pairs cannot flood the log. It is bounded by the censusmax_entries, but overflow calls still returnfirst_pair == false, so that part is fine.P2-2
d3d12_draw.inl, early return at!tr || tr->state != 1 || !d16_srvs_ready: hererefusal_codeis set butrefusalprose is not (it keeps the default "translated pipeline or target unavailable"). The log line therefore shows the same text fortranslation_not_readyandd16_srv_not_ready. The census row tells them apart, so this is not a bug. A short prose message would make the log match the census.P2-3
indirect_refusal_code::pipeline_or_target_unavailableis also the default for any early refusal that never callsset_refusal(!trwithshader_key == 0is not counted at all, as documented). Fine, but a comment next to the default would help.Nit: in the
indexed_rect && !pipelinebranch,set_refusalis guarded by the newindirect &&check. The old code dereferencedindirectunconditionally there, so this also fixes a latent null dereference for non-indirect indexed-rect draws. Good catch; mention it in the PR body.Nit: the test parses with
%63sand%16[0-9a-f]. A longer reason string would fail the parse with a clear "malformed" message, which is fine.Correctness notes
refusal_codeis set beforeReleaseSRWLockExclusiveon every path, andnote()runs outsidedraw_lock. The census has its own lock.missing_guest_rootandsampled_texture_mismatchindraw_translated, and dropping theindirect &&guard. Both should make the exact row assertions fail.Recommendation: wait for the Windows CI and a Win2025 WARP/hardware run of
startup_indirect_translated_refusal_census_*before merge.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:29:58Z.
Review: COMMENTED
Review of head
46fbcbdfeb9b95a37914d8ec901d0acdee03496f.Verdict: no blocking findings (P1=0, P2=0). The census wiring is correct and the new tests guard it.
What I checked
draw_translatedthat can run withindirectset now records a shortrefusal_code. The proserefusaltext is unchanged, andset_refusalkeeps the two in sync.if (indexed_rect && !pipeline) indirect->refusal = ...could dereference a nullindirect. It is now guarded withindirect &&. That is a good fix.x2w_d3d12_census_reportappends the block only whentotal() != 0, so the 4-line output of zero-refusal fixtures stays the same.Commands executed locally (Linux)
git diff --stat origin/main...HEAD: 5 files, +198/-20.python3 tests/docs_links_check.py: Self-test passed. Checked 19 Markdown files and 459 links.python3 tests/bidi_controls_check.py: no bidirectional controls in 1641 files.git diff --check origin/main...HEAD: clean.g++ -std=c++17 -Isrc tests/startup_per_reason_refusal_census_check.cpp && ./a.out: PASS (keys=2, pairs=4, detail=8, max=128).Windows (WARP),
python3 x2w_pipe.py win2025 2333 --wait 3600 --skip-releasestartup_indirect_translated_refusal_census_warpandstartup_indirect_translated_refusal_census_control_warp.startup_indirect_translated_draw_warp,startup_indirect_translated_indexed_rect_warp,startup_indirect_translated_indexed_upload_warpandstartup_indirect_counts_control_warp.--skip-release) because this change does not touch shader lowering.Mutation test
missing_guest_rootcode ind3d12_draw.inltosampled_texture_mismatch, and applied it with--patchon Win2025.startup_indirect_translated_refusal_census_warpFAILED, so the test kills it. The other 46 tests still passed.Nits (non-blocking)
draw_translated: fortranslation_not_ready,d16_srv_not_ready,pipeline_unavailableandsampler_heap_unavailable, onlyrefusal_codeis set. The prose log line then shows the generic default, "translated pipeline or target unavailable". That is fine, but a prose message per code would help log readers.live_compute_pipeline,indexed_validation_failedand so on) have no end-to-end check. A table-driven test could add them later.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:05:05Z.
@stan495 could you rebase this branch onto current
mainand force-push?GitHub reports head
1c431de9as conflicting withmain, so it cannot be merged as is.Files that conflict with current
main(4ea0c770):tests/startup_indirect_draw_indexed.cppCommands run locally:
Once it is rebased and CI is green it will be re-checked right away.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:20:05Z.
@stan495 could you rebase this branch onto current
mainand force-push?GitHub reports head
7d355dd1as conflicting withmain, so it cannot be merged as is.Files that conflict with current
main(214ed093):tests/startup_indirect_draw_indexed.cppCommands run locally:
Once it is rebased and CI is green it will be re-checked right away.
AI-assisted; commands listed were executed locally.