581 Commits

Author SHA1 Message Date
Austin Ayers f4ce27ceb6 Merge pull request #347 from Kalmarv/fix/write-watch-resume
D3D12.X: a full write-watch buffer goes on after its last page
2026-11-23 22:39:11 -05:00
Austin Ayers 72a97d87db Merge pull request #490 from imnicho/vram-idle-sweep
D3D12.X: a placement on title pages sweeps the idle ones, not every page
2026-11-23 22:39:02 -05:00
Austin Ayers d852f9abc2 Merge pull request #443 from Kalmarv/fix/sparse-state-replace-outside-lock
D3D12.X: the sparse state is replaced outside its lock
2026-11-23 22:38:54 -05:00
Austin Ayers 1387b4b545 Merge pull request #348 from Kalmarv/fix/sparse-free-decommit-first
Memory: a freed sparse block is decommitted before its address is reused
2026-11-23 22:38:46 -05:00
Austin Ayers 82c233d7dc Merge pull request #484 from XaviFortes/title-textures-safe-read-committed
D3D12.X: tolerate concurrent page decommits in title texture reads
2026-11-23 22:38:38 -05:00
Austin Ayers a8db4b024b Merge pull request #690 from theaustinayers/pso-preload
D3D12.X: pipelines an earlier run used are built ahead of their first use
2026-11-23 22:38:31 -05:00
theaustinayers 7296a8bd42 D3D12.X: pipelines an earlier run used are built ahead of their first use
A lazy pipeline is built at its first use: until then a graphics one
draws nothing and a compute one is waited for on the title's thread. A
retail title's first frames of its world use hundreds of pipelines for
the first time at once.

The pipelines a title uses are now kept by a hash of their shaders
(used-pipelines.txt beside the DXIL cache), and a lazy pipeline of
shaders an earlier run used is sent to workers of its own when it is
made: two to four threads at the lowest priority, apart from the ones a
bind sends to, so a pipeline that is bound is not held up by the ones
made ahead. XCL_PSO_PRELOAD=0 turns it off. Pipelines no run used stay
lazy, as before (the memory of ~51 000 built pipelines was the reason
for making them lazy).

Measured on an RTX 5090 with a build that skips a dispatch instead of
waiting for its pipeline: ~2 170 dispatches skipped in the title's first
world frames without this, 94 - 150 with it.

Assisted-by: Claude Code (Claude Fable 5.2)
2026-11-23 22:29:11 -05:00
Mavix 91f9a5e9f0 Update README.md 2026-11-23 20:16:06 -07:00
Austin Ayers 63cdc25bc0 Merge pull request #634 from theaustinayers/driver-pso-cache
D3D12.X: the driver's compile of a compute pipeline is kept on disk
2026-11-23 22:07:49 -05:00
theaustinayers 9182f275c0 D3D12.X: the driver's blob of a compute program is kept on disk
#636 keeps the driver's blob of a translated compute program in memory:
its second build in one run is made from it. The first build of every
run still goes through the driver's compiler. On an NVIDIA GPU (RTX
5090) that is 5 - 27 s for each of a retail title's larger compute
programs when its world loads: the title dispatches without them
meanwhile and is ended by its watchdog before all are built, so the
next run starts the same compiles again.

A blob whose build took 250 ms or longer is also written to the DXIL
cache directory (driver\, under the hash of the DXIL and the flags),
and a build that finds none in memory reads it from there. A blob the
driver refuses (another driver, adapter or root signature) is dropped
and the program compiled as before. XCL_PSO_DISK_CACHE=0 turns it off.

Assisted-by: Claude Code (Claude Fable 5.2)
2026-11-23 21:57:58 -05:00
Mavix dd2ae9a70a Merge pull request #636 from ofc0urse/perf/compute-pso-driver-blob
D3D12.X: a translated compute program built again gets the driver's blob of its first build
2026-11-23 19:49:38 -07:00
Mavix 18c105af86 Merge pull request #507 from ZekkJJ/codex/test-only-pr-checks
CI: allow reviewed test-only diffs without retail smoke
2026-11-23 19:44:35 -07:00
Mavix 372f3ab25c Merge pull request #302 from ZekkJJ/codex/ps-flat-integer-inputs
Recompiler: preserve flat pixel parameter bits
2026-11-23 19:44:18 -07:00
Austin Ayers cedf8cee4e Merge pull request #574 from ryosen0/ei-test
D3D12.X: ExecuteIndirect with a pipeline still being built is skipped (Austin's fork fix, upstreamed)
2026-11-23 21:43:20 -05:00
Mavix bdab19492a Merge pull request #602 from dns54/perf/title-bytes-in-place
Title textures: detile and hash the title's memory in place, not a copy
2026-11-23 19:41:01 -07:00
Austin Ayers 3db536ebe2 Merge pull request #435 from Cattn/tiling-swizzle-table-size
Textures: a layout's high-coordinate tables hold one period, not 65536 entries
2026-11-23 21:34:11 -05:00
Austin Ayers cb868b2005 Merge pull request #300 from AAigars/kernelx-timer-resolution
kernelx: the finest system timer for the title (choppy audio, #260)
2026-11-23 21:19:24 -05:00
ofc0urse b9f3d0f3a7 D3D12.X: a translated compute program built again gets the driver's blob of its first build
A retail title creates some of its big compute pipelines more than once while loading (14 programs
of 105 - 222 KB DXIL, each twice). Every creation went through the driver's compiler again: 3 - 6 s
the first time, 13 - 30 s the second, with the title's thread waiting. After a translated compute
PSO of 16 KB of DXIL or more is built, its GetCachedBlob is kept (by DXIL hash, root signature and
flags; 512 MB at most) and passed as CachedPSO when the same program is built again. A blob the
driver does not take is dropped and the program is compiled as before. The PSO log line now says
how long the build took and whether a blob was used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 03:08:01 +01:00
Deividas Nastajus 3984bf1671 Title textures: detile and hash the title's memory in place, not a copy
Before each upload of a title texture, and before hashing it to see whether
it changed, its memory was copied into a new zeroed buffer of its size
(read_committed). The copy, a fresh allocation and its page faults every
time, cost as much as the detile itself: GTA VI's intro video re-uploads
its 3840x2160 and 1920x1080 R8 planes several times a frame.

title_bytes now hands out the title's memory where it is when the whole
range is readable (gpu::shader::readable), and the page-by-page copy as
before when it is not. The 2D slices, 3D textures and the unchanged-content
hash take it.

Measured on an RX 5700 XT / Ryzen 5 2600 during the video (release, a
local counter around the upload batches, with a row-at-a-time detile like
the one #451 merged): reading and detiling 0.9 -> 0.4 s of every 2 s,
36 -> 54 presents per 2 s.

Assisted-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 04:00:06 +02:00
Austin Ayers 9ce2070ecc Merge pull request #451 from 1984742628/perf/reuse-upload-memory
D3D12.X: faster title texture uploads (reused upload memory, faster detiling)
2026-11-23 20:56:08 -05:00
Bloxive b74867be73 CI: allow reviewed test-only diffs without retail smoke (#452)
Use the maintainer label event for the checked PR snapshot and verify it against live metadata. Keep the regular smoke requirement for later revisions and preserve the description and asset checks.
2026-11-23 21:54:28 -04:00
ryosen0 86a5d0b3b7 Tests: ExecuteIndirect's pending-pipeline skip gate
Assisted-by: DSH (GPT-6.2 Astra)
2026-11-24 04:51:44 +03:00
theaustinayers 2d9a9fe2a8 D3D12.X: ExecuteIndirect with a pipeline still being built is skipped
With the limit on waits for a background pipeline, ExecuteIndirect could reach the PC call with the pipeline's stand-in while the list held XCL's ABI root signature from a translated draw: debug layer 953 (root signature does not match the pipeline state), six times as a retail title's world started, and then the device hung (0x887a0006). Such a call is skipped like a draw or dispatch of that pipeline; a PC pipeline gets the title's root signature first, as graphics_bound does. With it the same run shows no 953 and no device removal.

Assisted-by: Claude Code (Claude Fable 5.2)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 04:50:19 +03:00
Kalmarv d96812a91d D3D12.X: the sparse state is replaced outside its lock
sparse::init installed its state with *STATE.lock() = Some(s): the
state it replaced was dropped while the guard was held. Once used, that
state holds the last references to buffers of its own (readback,
staging, zeros), all made through the adopted device; their release goes
through real::res_release, which calls sparse::forget_buffer, which
locks STATE again - the thread waited for itself, and every later user
of the sparse windows behind it. The windows are set up again when two
first real::init calls overlap, as GPU tests starting together do: a
suite run hung in four GPU tests until it was killed.

The old state is now taken out under the lock and dropped after it.

Fixes #344

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-23 20:23:58 -05:00
Mavix 508a0c74d7 Merge pull request #516 from Mavixot/present-fps-counter
D3D12.X: show live FPS in the game window title
2026-11-23 18:14:59 -07:00
Frs 9783066756 Merge branch 'ivall:main' into title-textures-safe-read-committed 2026-11-24 02:11:35 +01:00
Mavixot b86fba483e D3D12.X: show live FPS in the game window title
Sample successfully presented frames over at least one second using the existing window timer. Keep FPS visible alongside shader compilation progress and report zero when presentation stops. Cover irregular sampling, sample intervals, stalls and recovery with unit tests.
2026-11-23 18:07:11 -07:00
Austin Ayers 7ebf1b8044 Merge pull request #486 from theaustinayers/texture-skip-unchanged
D3D12.X: a title texture whose memory is as at its last upload is not uploaded again
2026-11-23 20:00:51 -05:00
theaustinayers 69f06357bc D3D12.X: a title texture whose memory is as at its last upload is not uploaded again
The write watch is per page, and a title writes next to its textures and rewrites what it wrote: every texture with a written page was detiled and uploaded again before each submit. With a retail title's intro video that was about 25 MB a presented frame where about 3 MB had changed, and the title's submits spent their time in the refresh. The texture's memory is hashed first (four multiply-rotate lanes over 8-byte words, ~4.5 GB/s measured); the same hash as at the last upload of that texture object leaves it out. A texture that is released, or whose address is registered again, starts over. XCL_TEXTURE_SKIP_UNCHANGED=0 turns it off.

Assisted-by: Claude Code (Claude Fable 5.2)
2026-11-23 19:50:38 -05:00
Xavi Fortes 27c3571784 D3D12.X: tolerate concurrent page decommits in title texture reads
read_committed previously called VirtualQuery followed by std::ptr::copy_nonoverlapping. When a title streaming thread concurrently decommits or unmaps a page in a GPU-viewed CPU memory pool between VirtualQuery and memcpy, the submit thread hits an unhandled 0xC0000005 read access violation (observed at ~462 s / 7500 frames on a retail title).

Copy committed regions via ReadProcessMemory(GetCurrentProcess(), ...) instead. Because Windows can return 0 with bytes_read == 0 when a later page in the span faults, binary-split failed multi-page spans at 4 KiB boundaries so still-committed pages are copied intact in O(log N) calls and only unreadable pages stay zeroed. Also guard against at + len overflow and zero-sized VirtualQuery regions.

Assisted-by: Antigravity (Gemini 4 Neon)
2026-11-24 01:49:06 +01:00
emirduran707 1f282c737b Textures: linear levels are detiled a row at a time
Chain::detile_level computed the address of every element and copied it
on its own. A linear level (mode 0) keeps each row's elements contiguous,
so its rows are now copied whole; which elements are copied when the
source is cut short is unchanged. Swizzled modes, a base swizzle and
levels in a mip tail keep the per-row form of the previous commit.

A retail title's intro video is three linear R8 planes per frame
(3840x2160 and two 1920x1080), uploaded on every frame through the
kept-in-step title textures: release, one plane 56.9 ms -> 1.2 ms and
14.4 ms -> 0.3 ms, about 85 ms -> 2 ms a frame. The video played at
3.5 fps on an RX 9060 XT with the element-by-element form.

Test: linear levels give the same bytes by rows as by elements, for
every element size, padded rows, every mip and a cut-short source.

From #440 (be722a7), placed in front of the per-row loop of this PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 01:44:21 +01:00
nicho 76955398ea D3D12.X: a placement on title pages sweeps the idle ones, not every page
Every placement of a texture on the title's pages of video memory
(Pages::bind) looked at every page of both maps for the ones idle for 2 s.
A retail game streaming its world places textures by the ten thousand over
more than 100 000 pages: on an i7-7700K, by its 36 864th placement (213 s
into the run, 113 460 + 17 088 pages) the sweeps had looked at
2 922 636 089 page entries and taken 14.5 s of the title's thread that
creates its resources - with PAGES held, which the title's queues wait for
before their work (before_execute).

The pages whose last user went are queued with that moment, oldest first,
and a sweep takes the ones idle for IDLE from the front (sweep_idle); an
entry whose page was used again since is dropped. The same run with it:
3 ms in the sweeps by the 36 864th placement, 38 067 queue entries looked
at. Which pages go back, and when, is unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 01:40:32 +01:00
Mavix 2997c9aca6 updated discord link 2026-11-23 17:28:46 -07:00
1984742628 2cefc88956 D3D12.X: the title textures of a big batch are detiled on several threads
`title_textures::upload_all` read and detiled each texture of a batch
one after another, inside the title's own submit and present. Batches of
1 MB or more are now detiled on up to 8 threads (half the cores), each
taking the next texture; the results keep the batch's order. Smaller
batches stay on the calling thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 01:26:17 +01:00
1984742628 7d60a48492 Textures: detiling a mip level computes column and row parts once
`Chain::detile_level` called `element_at` / `Layout::offset_z` for every
element: a `div_ceil`, several divisions and modulos and six table
lookups each. Once the upload buffers were reused, it was most of a
retail title's render thread while the title streamed textures the CPU
writes (thread samples, frames named from a symbol build).

The parts of the offset that depend on x alone (block column and the
x and high-x pattern bits) are now computed once per level, those that
depend on y and the slice once per row, leaving two lookups and an XOR
per element. The result is the same: a new test compares it with
`element_at` for every mode, element size, pipe configuration and level
(mip tails too), with a base swizzle, two slices and a source cut short.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 01:26:17 +01:00
1984742628 c55783e7a5 D3D12.X: title texture uploads reuse their queue's buffer and list
`gpu::texture::upload_batch` made a new upload buffer for every texture
and a new command allocator, command list and fence for every batch,
and released them all again. Each of these D3D12 calls waits for the
video memory manager. While a retail title streamed textures the CPU
writes, they took 200 - 650 ms apiece (timed in the title's runs), and
its frames fell to 1 - 3 a second.

Each upload queue now keeps an `Uploader`: one persistently mapped
upload buffer that the batch's textures share (each at a 512-byte
aligned offset; it grows only when a batch needs more room), an
allocator and list that are reset, and a fence whose value counts up.
When the wait for a batch times out, the uploader is retired and kept
alive instead of released: the GPU may still read the buffer and run
the list, and releasing them under it removed the device.

`record_upload_states` is split into `layout` and `record_into`; it
keeps its behaviour (a buffer of its own) for its other callers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 01:26:16 +01:00
Logan a94e1511e0 Textures: a layout's high-coordinate tables hold one period, not 65536 entries
Layout::from_bits built the tables for the coordinates above a block (hx, hy,
hz) over the whole 16-bit range. For a 2D surface the z table alone is
65536 u32 entries – 256 KiB – and every xg::Texture builds its own Layout,
so each live tiled title texture carried about 256 KiB of CPU memory.

The entries depend only on the coordinate bits the block's pattern masks use.
Each table now covers the power of two above the highest such bit (one
entry when no bit is used); offset_z already indexes the tables modulo their
length, so every offset is unchanged.

The test compares every 2D and thick 3D mode, element size and pipe
configuration against the full-range tables, for coordinates up to and past
16 bits, and fails before the change (a 2D z table of 65536 entries).
2026-11-23 19:10:42 -05:00
ivall a6f5f7a74c Title textures test: skipped on an adapter that makes no reserved cube with mips
GitHub's runner adapter reports tiled resources tier 2 but refuses a reserved 256x256x6
cube with 9 mips, and further steps of placed_title_textures_share_vram_and_preserve_pixels
(PR #288) then expected shared pages it never got. The test now probes that one resource
and is SKIPPED, like the other GPU tests the runner cannot run; on a GPU it runs whole.
2026-11-24 01:02:38 +01:00
ivall ef5312fb1d Memory: readable answers a short range from the working set (PR #332, Vaximous)
gpu::shader::readable checked title pointers with VirtualQuery, which sizes the whole region
around the address by walking it, so its cost follows the region, not the range. In a retail
game's world load the page arrays of its DirectStorage requests (8-32 bytes, checked at
enqueue and again at execute) live in a 2 GB block of committed memory: each check took
20-25 ms. readable now asks K32QueryWorkingSetEx about up to 16 pages first, in one call; only
a page not valid in the working set falls back to the walk.
2026-11-24 00:58:27 +01:00
SandimL fa9ad89afa Scripts: run smoke.ps1 on Windows PowerShell 5.1
(cherry picked from commit f52ae3d372)
2026-11-24 00:58:17 +01:00
Graham Calihan 97dc49c6a7 Scripts: smoke.ps1 names the adapter XCL ran on, from report.json
The gpu line took the first Win32_VideoController that is not the basic
display adapter. On a machine with an iGPU and a discrete GPU that is often
the iGPU: on an RTX 3080 + AMD RDNA2 iGPU machine the block said
"AMD Radeon(TM) Graphics" while XCL ran on the RTX 3080.

The line now comes from d3d12.adapter in the run's report.json (next to the
log; XCL removes the previous run's report at start), without the VRAM
suffix. The Win32 query stays as the fallback when the report or the field
is missing.

(cherry picked from commit c756051df6)
2026-11-24 00:58:17 +01:00
ivall a8072aac1d Merge PR #338 2026-11-24 00:58:17 +01:00
ivall 0fdefe4e17 Merge PR #330 2026-11-24 00:58:17 +01:00
ivall da28099252 Merge PR #331 2026-11-24 00:58:17 +01:00
ivall 1efacca013 Merge PR #322 2026-11-24 00:58:17 +01:00
ivall f673b547a6 Merge PR #335 2026-11-24 00:58:17 +01:00
ivall 3516080d53 Title textures test: an array or cube a driver will not make reserved is committed, not a failure
placed_title_textures_share_vram_and_preserve_pixels (PR #288) asserted every shape went to
shared video-memory pages. GitHub's runner adapter refuses the 256x256x6 cube with 9 mips as a
reserved resource (arrays with packed mips are a lower tiled tier's limit); the texture is
then committed, which is correct - the test failed and its panic poisoned the lock two other
tests share. Arrays and cubes now note the fallback; their pixels are checked either way.
2026-11-24 00:56:31 +01:00
Prime1997 bb436a08b4 Tests: read back mirrored textures across writes and page remapping
Exercise the merged GPU-view mirror path end to end on a synthetic R8 texture. Force watched Windows reservations outside the UMA windows, verify CPU rewrites reach the GPU, then verify a later lazy physical mapping overrides the mirror and unmapping restores it. Keep the GPU-view title address throughout and clean up reservations, physical pages and texture registration on failure. No retail data or runtime changes.
2026-11-23 15:52:52 -08:00
ivall 2b4bb431e4 xapu: decode the title's Opus packets into its output buffer; libopus where Windows has none (PR #294, simnJS)
A retail game is mute under XCL: it does not use XAudio2 but sends its sound to the
console's audio decoder (xapu), and XCL answered every xapu command with silence. Everything
goes to stream 0 through XApuEnqueueCommand: Activate (kind 1) with the channel count and
48 kHz, Process (kind 3) with one raw Opus packet (CELT fullband 20 ms) and a float output
buffer, Deactivate (kind 2). The title reads the decoded PCM back, mixes it and plays its
mix itself through Windows Spatial Audio, so XCL only decodes into its buffer.

- hle/acphal.rs: the first Activate of a stream makes its decoder, a later one with the same
  layout resets it; Process decodes into the title's output and returns the frames written;
  a packet that does not decode, or a stream not connected, still gets silence. report.json
  gets xapu counters, the log a summary every 5 s; XCL_TRACE_APU=1 traces the commands.
- hle/opus.rs: when Media Foundation has no Opus decoder (Wine), libopus is loaded at run
  time from %XCL_OPUS_DIR% or next to xcl.exe (not distributed; THIRD_PARTY.md); Windows
  keeps its own decoder.
2026-11-24 00:42:08 +01:00
Xavi Fortes 44038872d9 D3D12.X: resolve GPU timestamps targeting memory outside unified memory
Write64BitValueBottomOfPipeX and Write64BitValueTopOfPipeX with timestamp flags previously rejected any target address outside unified memory (for example, a title's own VirtualAlloc memory on a first run before the coherent window grows), even though non-timestamp writes already fall back to cpu_writes after the queue fence completes.

Resolve non-UMA timestamp queries into a lazily allocated, persistently mapped READBACK buffer per device (4096 slots, 32 KiB) and copy the 64-bit GPU tick atomically to the title's address in the cpu_writes worker once the submission's fence completes. Also separate the 8-byte alignment check from the unified-memory check so warnings report the actual reason.

Assisted-by: Antigravity (Gemini 4 Neon)
2026-11-24 00:41:48 +01:00