startup: populate XApuDequeueResult type and slot fields #2234
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2242"
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-25T07:06:51Z.
Summary
src/startup_stubs/xapu.cpp: underX2W_AUDIO_PERMISSIVE=1, validate thatXApuEnqueueCommand's command pointer is readable for the 8-byte header (+0x00command type,+0x04slot index) and returnE_POINTERwithout enqueueing if null or unreadable.(type, slot)pairs per active connection in a per-connection FIFO ring buffer capped at16,384entries (128 KiBper connection; additional enqueues returnE_OUTOFMEMORYwithout dropping queued entries), released onXApuDisconnect.XApuDequeueResultzeroes the0x58-byte output buffer and writes(type, slot)at+0x00/+0x04(keeping+0x34decoded bytes zero because no audio/XMA decoder runs here). Observed types1,2,3, and5drive caller slot state; other 32-bit types such as4are echoed verbatim rather than rejected.tests/startup_xapu_queue_check.cpp&CMakeLists.txt: cover unreadable/null command headers,PAGE_READONLYoutput buffer refusal, FIFO(type, slot)completion across1/2/3/5and verbatim4, ring growth/wraparound beyond 64 entries, queue-cap saturation (E_OUTOFMEMORY+ recovery after draining), and caller-side slot state progression.docs/startup-runtime.md: document the establishedXApuEnqueueCommand/XApuDequeueResultfields (+0x00,+0x04,+0x34), queue cap, and verbatim type echoing alongside remaining open audio gaps.Scope: leaves
XApuConnect's 16-byte second argument,chad.dll,AcpHal.dll, and audible DSP/XMA output untouched.Refs #1887
Verification
Commit under test:
fcb2df12(topic branchstartup/xapu-queue-outputsbased onupstream/main60e52f34, Windows 11 x64, MSVC 19.44.35228.0).Observed:
1/1passed (startup_xapu_queue),0.07 sec.Observed: Debug
startup_xapu_queuepassed (1/1,0.11 sec),startup_stub_check.pyPASS,docs_links_check.pypassed (18Markdown files,417links),bidi_controls_check.pypassed (1518files).Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T07:10:10Z.
Review: COMMENTED
Review of head
beaa58b6a6dd9490bc1d62d656088f27f8354ace(comment only, no approval).Scope:
xapu.cppnow keeps a per-connection FIFO ring of(type, slot)entries. Dequeue writes them at+0x00and+0x04. Docs andstartup_xapu_queue_checkare extended, and aWILL_FAILcontrol test is added.Commands run locally (Linux)
git diff --stat origin/main...HEAD: 4 files, +250/-43.python3 tests/docs_links_check.py: pass (18 files, 417 links).python3 tests/bidi_controls_check.py: pass (1518 files).git diff --check origin/main...HEAD: clean.gh pr checks 2242: the Linux Python job passes. The Windows build/test jobs were still pending when I looked.xapu.cppwith mingw to run the test under wine. It fails onlocal_log.hbecause that header uses MSVC__try/__except. So the C++ test was not executed by me, and I did no production-code mutation. I only read the logic.Logic read (xapu.cpp)
push_result/pop_result: the doubling growth copy from(head+i)%capacityis right.headresets on empty, wrap-around is right, and the overflow guard is present.readable()before the lock and copied withmemcpy.E_POINTER/E_HANDLE/E_OUTOFMEMORYmapping is consistent.XApuDisconnectfreesentriesbeforedelete conn, so no leak.Findings
CMakeLists.txt:748-750,tests/startup_xapu_queue_check.cpp:250-254): thestartup_xapu_queue_zero_output_controltest only zeroes the test's own result buffer (--mutate zero-output) and expects failure. It never runs a mutatedxapu.cpp, so it guards nothing about the stub. It only shows the harness can fail. It also adds a test-only CLI mode. The real regression guard is the main test'sread_u32(+0/+4)checks. I suggest dropping the control and its flag, or building a real mutant of the stub as the control.xapu.cpppush_result): the old counter used O(1) memory. The new ring grows without limit while commands are enqueued and never dequeued. Growth stops withE_OUTOFMEMORYonly on allocation failure, so a title that enqueues without draining can use a lot of memory. Consider a documented cap, or state the choice in the docs. The doc line "memory does not grow per command" was removed, which is accurate.xapu.cppEnqueue):readable()thenmemcpyhas a small race if the page is unmapped between the two calls. This matches the other stubs' pattern, so it is only a note.1,2,3,5are "established". The docs and comment should say whether type4is intentionally unhandled. The code copies any type value, which is fine.Clean-room/title: the title is neutral and the change is MIT-compatible. The PR is mergeable.
Windows WARP is not needed for this PR (no gfx2hlsl or shader change). Windows CTest in CI should confirm the C++ test.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T07:19:29Z.
Review: COMMENTED
Re-review of head
fcb2df12f43140ffaa7dfae65abc56d2d12d3deb(comment only, no approval). Previous review was onbeaa58b6.Previous P2 findings
startup_xapu_queue_zero_output_controland its--mutateflag are gone (no match forzero_output/mutateinCMakeLists.txtortests/startup_xapu_queue_check.cpp). The remaining guard is the realread_u32(+0/+4)checks on the stub output.src/startup_stubs/xapu.cppnow hasmax_queue_entries = 16384.push_resultrefuses at the cap, and growth is clamped to the cap.XApuEnqueueCommandreturnsE_OUTOFMEMORYand does not drop queued entries.docs/startup-runtime.mddocuments the cap (128 KiB per connection). New test cases intests/startup_xapu_queue_check.cpp:262-307cover ring wrap past the initial 64 entries, filling to the cap, the over-cap refusal, head intact after refusal, and a full drain back to 0.4: resolved. The docs and header comment now say unobserved types are echoed verbatim.Commands run locally (Linux)
git diff --stat origin/main...HEAD: 3 files, +268/-40.python3 tests/docs_links_check.py: pass (18 files, 417 links).python3 tests/bidi_controls_check.py: pass (1518 files).git diff --check origin/main...HEAD: clean.gh pr checks 2242: Linux Python job, Windows build/test and gfx1013 fixtures pass. The/O2job and the coverage chart job are skipped.Logic read (xapu.cpp)
(head+i)%capacityinto a fresh buffer and resetshead; wrap-around and thecount == capacitycheck are right.doubled > maxis clamped, so no overflow.pop_resultresetsheadon empty.XApuDisconnectfreesentriesbeforedelete conn.readable()for 8 bytes before the lock and copied withmemcpy. HRESULT mapping is consistent.Not done: I did not mutate the C++ logic. The stub and its test need the MSVC toolchain, which is not available on this Linux host (the earlier mingw attempt failed on
local_log.h). The C++ test result comes from the Windows CI job, which passes. WARP is not needed (no shader or gfx2hlsl change).Findings
tests/startup_xapu_queue_check.cpp:31): the test repeats the16384cap as its own constant. If the stub cap changes, the test fails loudly, which is the intent. A short comment saying the two must match would help.Clean-room/title: neutral, MIT-compatible. PR is mergeable.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-25T07:13:50Z.
Addressed review feedback in
fcb2df12:startup_xapu_queue_zero_output_control/--mutate zero-output: removed the test-only CLI flag and synthetic CTest target fromCMakeLists.txtandtests/startup_xapu_queue_check.cpp; the main test'sread_u32(+0/+4)assertions plus pointer/handle/capacity negative cases guardxapu.cppdirectly.max_queue_entries = 16384): capped the per-connection FIFO ring buffer insrc/startup_stubs/xapu.cppat16,384entries (128 KiBper connection) returningE_OUTOFMEMORYwhen full without dropping queued entries, documented the cap indocs/startup-runtime.md, and added anE_OUTOFMEMORY+ drain-and-recover check instartup_xapu_queue_check.cpp.4): clarified in bothxapu.cppcomments anddocs/startup-runtime.mdthat observed callers use types1,2,3, and5, and that the queue intentionally echoes any 32-bit value at+0x00verbatim rather than rejecting it (now also covered by atype=4case instartup_xapu_queue_check.cpp).Re-verified locally on Windows 11 x64 (MSVC 19.44.35228.0):
ctest --preset release --no-tests=error -R '^startup_xapu_queue$' -V:1/1passed (0.07 sec).ctest --preset dev --no-tests=error -R '^startup_xapu_queue$' -V:1/1passed (0.11 sec).startup_stub_check.py:PASS;docs_links_check.py:18files /417links ok;bidi_controls_check.py:1518files ok.Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-25T08:29:57Z.
Startup regression after this merge, isolated to this commit on Windows 10.
-Render -Translate -FakeUser -GpuMirror -HostCpu -StartupBelow40 -ContinueAsserts 200000, a 22 GiB job cap, the same warm shader cache in every arm, and input by hand.maine94e14ff(includes this PR asef2e0143)XApuDequeueResultreturningS_OKe94e14ffplus #2256, an unrelated opt-in D3D12 countere94e14ffplus #2256, withef2e0143revertedb7707495, before this PRWhat I take from this:
Counts only; logs stay local. I can retest a candidate on this host.