Skip to content

Bathyal: boots a newer retail title to its menu and intro on an RTX 4090 - #6

Merged
T-Crypt merged 45 commits into
mainfrom
bathyal/next2
Nov 23, 2026
Merged

T-Crypt merged 45 commits into
mainfrom
bathyal/next2

Conversation

@T-Crypt

@T-Crypt T-Crypt commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Supersedes #4 and #5. Everything from #4 (29 XCL PRs + rebrand) plus:

  • tests: skip hardware-only GPU tests on the runner's software adapter #5: hardware-only tests skip on GitHub's software adapter.
  • XCL main through the latest commits, and ivall/xcl PRs #259 #263 #264 #266 #268 #270 #289 #290 #293 #294 #299 #300 #303 #304 (bathyal/xcl-sync3, xcl-sync4).
  • #283 (made stricter): a GPU-view reservation reads its bytes from the CPU reservation it pairs with. Fixes the flat-green intro movie.
  • #294 and our audio work: the console audio path decodes Opus and plays it on XAudio2.
  • #150 (parts): disk pipeline cache, typed RTV/DSV formats.
  • #267, #269: draws wait at most 4 s a frame for pipelines; title textures on shared 64 KiB video-memory pages.
  • Format fixes: sRGB textures with UAV access; allocation and creation stand-ins for formats the PC lacks.
  • Write-watch: ranges merged across gaps under 16 MiB and a larger output buffer (fewer calls, same dirty set). Optional XCL_WATCH_PER_FRAME=1 / XCL_WATCH_THREADS.
  • Upstream process files (PR-description check, smoke script, CONTRIBUTING, CLAUDE.md) left out.

Tested on Windows 11, i9-14900K, RTX 4090: cargo test --workspace (test-title e2e skipped): 788 passed, 0 failed. A newer retail title boots to its menu, shows the copyright screen and plays its intro movie with a picture; after that it loads with a black screen at about 4 fps (open work: DirectStorage read failures, BCPack BC5/BC7, CopyMemoryToMemoryX outside unified memory, mesh pipelines with an MS in the AS slot). Content gate: 0 findings. AI-assisted.

1bugproof and others added 30 commits November 23, 2026 22:09
CONTRIBUTING.md: small single-purpose PRs (~400 changed lines, stacked
when dependent), Area: commit subjects as in the history, tests with
every logic change, licence and provenance rules, and an AI policy
(disclose tool and model, the author answers for every line, tests
actually run, AI test reports welcome).

AGENTS.md: the same rules as instructions for coding agents, plus build
and test commands and what an agent must never do. CLAUDE.md loads both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… title, checked by PR checks

CONTRIBUTING.md gets the merge requirements: both required checks green (CI, PR checks), the
whole suite run on a GPU with its counts, and for a runtime change (crates/xcl/src outside
tests) two xcl-smoke blocks from scripts/smoke.ps1 - built from main and from the PR's head
commit with no uncommitted changes - with no device removal or crash. The maintainer runs the
suite and a retail title again on every merged batch.

- scripts/smoke.ps1: runs a title for a fixed time (network off, XCL_ACTIVITY) and prints the
  xcl-smoke block: commit, GPU, exit, frames shown, presents, device removals, crashes, peak
  commit.
- .github/pull_request_template.md: Tested / Regression run / Not tested / AI use.
- .github/workflows/pr-check.yml: refuses a description without those sections, and a runtime
  change without a smoke block made on the PR's head commit.
- AGENTS.md / CLAUDE.md (from #212): the same rules for agents; AI use is disclosed in the PR's
  AI use section, a commit trailer is not required.
…ses them in AI use

XCL is low-level code (a recompiler, a console runtime, D3D12 memory and synchronisation):
small and local models get it subtly wrong, and every wrong PR costs a review. CONTRIBUTING.md
and AGENTS.md: code comes from frontier models; PRs written with Qwen, DeepSeek, Llama,
Mistral, Gemma, Phi or their distills are closed without a review. The PR checks workflow
refuses a description whose AI use names one of them (and now reads CRLF descriptions).
… read at the request's turn

A retail title keeps its destination page arrays in its own tables and fills an entry after EnqueueRequest. The array is snapshotted at enqueue (titles also pass it on the stack), so such a request wrote to page 0 and was refused with E_ACCESS_VIOLATION: over 8,000 of them in the first 100 s of the title's streaming, and what they carried never arrived. An entry that is 0 in the snapshot (no page has that number) is read again when the request runs; entries that had a page keep the snapshot's.

Measured on the title (RTX 5090, 170 s): 16,384 such requests found their page at their turn, 2,227 still had 0 and are refused as before.

Assisted-by: Claude Code (Claude Fable 5.2)
A retail title reserves its video memory twice: one reservation it can write
(its Bink decoder puts the frames there), then one of the same size with no
CPU access, where it places the textures its YUV -> RGB pixel shader samples.
On the console the second is the GPU's view of the first. Under XCL it was
separate, empty memory: the four planes read as zeros, which the conversion
turns into a flat green picture for the whole intro movie.

kernelx pairs an inaccessible reservation with the last accessible one of the
same size (dropped when either goes); title_textures reads a texture's bytes,
and watches its CPU writes, at the address the pairing names. Textures without
such a view are unchanged (src == va).
Upstream docs only. Drop upstream's pr-check.yml: this fork runs ci.yml.
# Conflicts:
#	crates/xcl/src/hle/d3d12x/title_textures.rs
…om main; game data refused

From a review of the check: it looked for crashes and device removals anywhere in the
description, so a PR fixing a crash on main failed on main's run, and nothing made the two
runs come from different commits. The checker is now scripts/pr_check.py: the PR's xcl-smoke
block must be its head commit with no uncommitted changes, the other a commit on main (the
compare API), both of the same title for the same time; crashes and device removals count in
the PR's run only, which must keep 80 % of main's frames and stay under 125 % of its peak
commit.

The workflow runs as pull_request_target with main's checker: a PR can no longer change what
checks it, and nothing of the PR is checked out or run (only its description and file list are
read through the API).

Game data: .gitignore keeps game packages, archives, executables, video, audio banks,
textures and dumps out, and the check refuses a PR adding one, a MicrosoftGame.config other
than the test title's, or any binary outside tests/data/ or over 1 MB.
An R9G9B9E5 target with unordered access became R16G16B16A16_FLOAT, which
holds the values exactly but leaves no way to write the packed 32 bits (an
R32_UINT view of it is an invalid format pair). It is R32_TYPELESS now, the
console's 32 bits a texel: R32_FLOAT for the shaders that write values,
R32_UINT for those that write the packed bits.

An sRGB texture with unordered access is typeless on the PC (it has no sRGB
UAV): the UAV views take the UNORM format, the SRV / RTV views keep sRGB.

A UAV / SRV / RTV without a description of a typeless resource gets a typed
one, which the console's own format describes.

GetResourceAllocationInfo answers a format the PC has no layout for with the
console's layout of a same-bits-per-texel stand-in instead of u64::MAX.
…the CPU view (retail intro video, no green screen)

From ivall/xcl#283 by @jessenic, squashed.

The squash also carries #252, which #283 is stacked on (write-watched fallback for GPU-visible
title memory outside the windows).

Pairing is stricter than the PR: a no-access graphics reservation of 64 KiB pages is the GPU
view of a same-size CPU reservation only when that one is the immediately preceding reservation
and the only same-size CPU view without a GPU view; otherwise the reservation stays unpaired and
a log line says so. Our `Entry::seq` from #269 is kept (uploads in placement order).
The console audio path is xapu (the hardware Opus decoder) into SHAPE (the
console mixer). XCL answered every xapu Process command with silence and
never ran SHAPE, so a title that mixes through the console stayed mute.

xapu now decodes each Process command's Opus packet with hle::opus (Windows'
Media Foundation decoder; libopus from opus.dll where Windows has none) into
the title's float32 output buffer, honoring first_frame (the pre-skip), and
hle::xaudio2::console_pcm plays each decoder stream on a system XAudio2
engine of its own, one float voice per stream. SHAPE is still not run: the
streams play without the console mixer's volumes, panning and effects.

report.json gets xapu_* and console_pcm_* counters; xcl.log a summary line
every 5 s. XCL_TRACE_APU=1 logs the commands and their structures.

Ported from ivall/xcl#294 (simnJS). Unit tests cover the pre-skip copy and
the Process output contract.
…aches creation

Revert the R9G9B9E5_SHAREDEXP targets from R32_TYPELESS back to
R16G16B16A16_FLOAT, as on the base: an SRV of the typeless resource was
R32_FLOAT over the packed bits, and its RTV lost G, B and A.

A shader view with no description of a texture `pc_resource_desc` made
typeless now names the format the title created it with (recorded per
resource at creation), so an sRGB texture with UAVs is read as sRGB
instead of naming a typeless format or format 0.

CreatePlacedResourceX creates a format the PC has no layout for (5..8,
66, 68, 69) with the same stand-in its allocation query answered for,
so creation no longer fails after the query succeeded.

Tests: srgb_uavs_and_unsupported_allocation_formats,
unsupported_formats_are_created_with_the_query_standin,
typeless_resources_get_typed_uav_descs.
GetWriteWatch walks each range in the kernel, one range after another, before every submit; on a
newer retail title that walk held the submitting thread for most of each frame (194 s of
write-watch in one session, the CPU and GPU both near idle). Large sets are split over up to 8
long-lived threads (XCL_WATCH_THREADS, 1 = the serial loop). Each range is still read and reset by
one call, so the dirty set is unchanged.
T-Crypt and others added 15 commits November 23, 2026 15:51
…every submit)

Measured on a newer retail title: about 15 ms of GetWriteWatch per submit over 2.7 GB of mapped
sparse tiles, at about 5 submits a frame. The thread pool did not help (the kernel serialises the
walks), so XCL_WATCH_THREADS now defaults to 1.
…thyal/next2

# Conflicts:
#	crates/xcl/src/hle/acphal.rs
…next2

# Conflicts:
#	crates/xcl/src/hle/d3d12x/title_textures.rs
…next2

# Conflicts:
#	crates/xcl/src/hle/d3d12x/title_textures.rs
#	crates/xcl/src/hle/kernelx.rs
DirectStorage: a destination page array entry that is 0 at enqueue is read at the request's turn
# Conflicts:
#	.github/workflows/pr-check.yml
#	.gitignore
…L_WATCH_PER_FRAME=1

gpu_sparse_vram_descriptors_buffers_and_xmem showed the cost: descriptors written between two
submits of one frame missed the second submit. The parts test takes the thread count as an
argument instead of the environment.

(cherry picked from commit b267707)
GetWriteWatch costs a fixed part per call and a part per page. Measured
on a 2 GiB write-watched reservation on the RTX 4090 machine: about
6.9 us a call plus 0.35 us a MiB (512 MiB in one call: 0.28 ms; the same
bytes in 512 calls of 1 MiB: 3.79 ms). A look over 3 GiB of tiles in
hundreds of ranges is therefore mostly call overhead. WATCH_GAP rises
from 1 MiB to 16 MiB, under the break-even gap of about 19 MiB, so a
gap is walked only where that is cheaper than the call it removes.

A call whose output buffer fills leaves the rest dirty and the next
call walks the whole range again; the buffer now grows (4x, up to 4M
entries) so one call holds what a range has.

The timing line now prints ranges and bytes watched, and a Windows test
runs watch_into with more dirty pages than the buffer starts with.
@T-Crypt
T-Crypt merged commit 4cd5ef4 into main Nov 23, 2026
2 checks passed
@T-Crypt
T-Crypt deleted the bathyal/next2 branch November 23, 2026 23:17
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.

4 participants