Repository navigation
hle/xaudio2: enforce XAudio2 play/loop region invariants in clamp_regions and silent_buffer - #89
Merged
Conversation
…ions and silent_buffer
Contributor
|
Tested locally against the Windows 11 system XAudio2 2.9 engine — all 9 tests pass cleanly. Key improvements verified:
Solid bugfix with thorough live-API test coverage. |
Collaborator
|
Merged. Tested on Windows 11 with an RX 9070 (RDNA4): |
Michael-Glaser
added a commit
to Michael-Glaser/xcl
that referenced
this pull request
Nov 24, 2026
…cl-dev#104) On newer GDK runtimes (QUEUE_SHIFTED), 20 command list console methods shift up by +2 via NEWER_LIST_SLOTS, leaving 11 older slots (xcl-dev#59, xcl-dev#60, xcl-dev#68, xcl-dev#69, xcl-dev#78, xcl-dev#81, xcl-dev#84, xcl-dev#88, xcl-dev#89, xcl-dev#93, xcl-dev#94) without another shifted method taking their old index. Those slots remained wired directly to the older layout's handlers, so a newer-layout call hit the wrong method. Wrap those orphaned slots in make_layout_split so newer-layout title calls go to a logged stub while older-layout titles keep the handler and non-title callers keep their PC target (including cl_execute_indirect at xcl-dev#59 and the original base-table stub for slots >= scanned). Slot xcl-dev#10 (Reset) stays Reset on both layouts and is not orphaned. Assisted-by: Antigravity (Gemini 4 Neon)
vincentes
added a commit
to vincentes/xcl-wasm
that referenced
this pull request
Nov 24, 2026
The null device becomes `win::d3d12x`, a device that does the memory side of D3D12.X for real and still renders nothing: - Unified memory, as on the console: a resource's GPU address is its address in the title's address space. Committed resources and heaps get graphics memory, placed resources lie in their heap, and CreatePlacedResourceX (xcl-dev#44) puts one on memory the title allocated; Map returns that address. Read-back buffers up to 64 MiB come from the fourth 4 GiB of the region, where XCL's Windows runtime keeps them. - Command lists record; a queue runs what it is given, in order, at every turn of the scheduler (`pump`): buffer copies, the console's memory commands (CopyMemoryToMemoryX xcl-dev#60, FillMemoryWith32BitValueX xcl-dev#61, Write32 / 64BitValue…X xcl-dev#69 / xcl-dev#70 / xcl-dev#89 with the GPU timestamp) and Wait32 / 64BitValueX (xcl-dev#71 / xcl-dev#72), which hold the queue until another thread writes the value. KickoffX (xcl-dev#93) starts a list before it is closed. A fence moves, and its events are signalled, when the queue gets to its Signal. - The console's layouts: device extensions from slot 44 (CreateCommandQueueX, CreateCommandListX with the DMA engine's own list interface, page pools, pipeline-state creation as objects, …), the graphics command list's console slots, AllocateUploadMemory (xcl-dev#148). - CheckFeatureSupport zeroes the whole structure; a raytracing acceleration structure view writes the console's descriptor words. Draws, pipelines, other views, PresentX and the frame clock do nothing or are missing. Dev builds optimise `xcl-emu` (the title test: 37 s → 3.3 s). Measured on macOS (aarch64): the test title passes 40 of its checks (9 of D3D12.X's 16); the 6 that fail before it aborts in its XG texture check need HLSL compilation and rendering, the frame clock, or DirectStorage. `cargo test -p xcl-guest`: 38 passed, 0 failed (the title test now checks every check by name; the staged tree was built and tested apart from the working tree). Inside the wasm64 module (1.2 MB, Node 24) the same run takes 4.4 s: 115 M instructions, most of them the 80 MiB upload check. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Michael-Glaser
added a commit
to Michael-Glaser/xcl
that referenced
this pull request
Nov 24, 2026
…vall#104) On newer GDK runtimes (QUEUE_SHIFTED), 20 command list console methods shift up by +2 via NEWER_LIST_SLOTS, leaving 11 older slots (ivall#59, ivall#60, ivall#68, ivall#69, ivall#78, ivall#81, ivall#84, ivall#88, ivall#89, ivall#93, ivall#94) without another shifted method taking their old index. Those slots remained wired directly to the older layout's handlers, so a newer-layout call hit the wrong method. Wrap those orphaned slots in make_layout_split so newer-layout title calls go to a logged stub while older-layout titles keep the handler and non-title callers keep their PC target (including cl_execute_indirect at ivall#59 and the original base-table stub for slots >= scanned). Slot ivall#10 (Reset) stays Reset on both layouts and is not orphaned. Assisted-by: Antigravity (Gemini 4 Neon)
rootw0rm
pushed a commit
to rootw0rm/xcl
that referenced
this pull request
Nov 27, 2026
The null device's plain lists ran the console memory slots (xcl-dev#60/xcl-dev#61/ xcl-dev#69-xcl-dev#72/xcl-dev#89/xcl-dev#93) as logging stubs, so the title's console_list_methods check read back 0x0 on the null backend while the identical immediate host writes already passed on Vulkan lists. The vtable now wires the same VulList_* functions into Kind::CommandList; GetDevice (xcl-dev#7), the UAV barrier (xcl-dev#146) and AllocateUploadMemory (xcl-dev#148) stay Vulkan-only with their slices (barrier/upload ride with raytracing, which still fails on null at the OPTIONS5 tail-zero assert). Failing-first: the new null_list_shares_the_console_memory_methods test fails pre-route (slot 69 stub writes nothing) and passes now (write32/fill/copy/timestamp land, pre-satisfied wait returns, kickoff is a silent no-op), mirroring the title's asserts. Gates: check -p xcl --tests EXIT 0; check --workspace EXIT 0; lib 797 passed/0 failed/1 ignored (--test-threads=4). Title e2e, fresh roots: null 12->11 FAILs (Write32 fixed, byte-identical remainder), Vulkan 9 unchanged with the real present (640x360 token 0x1 on Intel Arc). Retail HOLDS (SIGSEGV exe+0x2237320, exit 139, called_stubs 20, 0 d3d12).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardens
hle::xaudio2::clamp_regionsandhle::xaudio2::silent_bufferso decoded and fallback buffers always satisfy XAudio2IXAudio2SourceVoice::SubmitSourceBuffer(XAUDIO2_BUFFER) play/loop region invariants instead of failing withXAUDIO2_E_INVALID_CALL:clamp_regions:play_length > total_frames - play_begininstead ofplay_begin.saturating_add(play_length) > total_frames, preventing au32overflow/panic whentotal_frames == u32::MAX.play_length = total_frames - play_beginwhenplay_begin > 0 && play_length == 0(XAudio2 documentsPlayLength == 0requiresPlayBegin == 0).loop_begin/loop_lengthwhenloop_count == 0.play_end(play_begin + play_lengthwhenplay_length > 0, elsetotal_frames) rather than justtotal_frames:loop_begin = loop_length = loop_count = 0) whenloop_begin >= play_endorloop_begin + loop_length <= play_begin.loop_length = play_end - loop_beginwhenloop_length == 0and eitherloop_begin > 0orplay_end < total_frames(XAudio2 requiresLoopBegin == 0whenLoopLength == 0).loop_begin < play_beginwithloop_begin + loop_length > play_begin && <= play_end).silent_buffer:loop_begin > 0 && loop_length == 0allocates at leastloop_begin + 1frames.max_framestoXAUDIO2_MAX_BUFFER_BYTES(0x8000_0000) /frame_bytes.clamp_regions(&mut nb, frames as u32)before returning, so both normal and truncated/zero-byte silence buffers obey allXAUDIO2_BUFFERinvariants (including clearingloop_countwhenmax_bytes == 0).Verification
cargo test -p xcl --lib hle::xaudio2 -- --test-threads=1: 9 passed; 0 failed (live Windows system XAudio2 2.9)clamp_regions_enforces_play_end_and_loop_invariants(includingu32::MAXoverflow andloop_end == play_beginboundary).silent_buffer_clamps_regions_and_zero_max_bytes.clamped_and_silenced_buffers_accepted_by_windows_xaudio2, which creates a real Windows PCM16IXAudio2SourceVoiceand verifiesSubmitSourceBufferreturnsS_OKacross all clamped and silenced edge cases.