Skip to content

cache compiled shaders between pso requests - #61

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
Mavixot:shader-compile-time
Nov 23, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
Mavixot:shader-compile-time

Conversation

@Mavixot

@Mavixot Mavixot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

caches finished vs/ps/cs shaders in memory so repeated pso requests skip translation and disk reads. bounded to 64mb/128 entries, with debug overrides bypassing the cache. synthetic warm-cache debug test dropped from ~8.3s to under 1ms for 100 requests, same dxil. build + tests pass; first-time compiles are unchanged, retail samples weren't available.

@ivall
ivall merged commit f112834 into xcl-dev:main Nov 23, 2026
ivall added a commit that referenced this pull request Nov 23, 2026
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Merged (f112834). It conflicted with #67 (wave64 programs on 32-lane GPUs), which turned console_to_dxil into console_to_dxil_for(…, split_wave64): the cache now sits there and its key has split_wave64 too (the split and native forms are different DXIL). Nice side effect: gpu_pso_e2e with the retail pack went from ~28 s to ~9 s here. Tested on Windows 11 with an RX 9070: cargo test --workspace green with the retail samples (shader pack, console DLLs, texture archive), and Unicorn Overlord reaches its title screen with everything from this round merged. Thanks!

ivall added a commit that referenced this pull request Nov 23, 2026
…ommandListsX, big pipelines in the background

The frame clock fired one event type per deadline; a title scheduling the origin and
type 2 at the same offset waited on type 2 for ever after two frames. Now every type
due fires. Newer console layout: queue #35 is ExecuteCommandListsX, list #61 is
ExecuteIndirect (the shift by two from #59 on). Bottom-of-pipe writes into memory the
GPU does not see are done by the CPU after the queue's work, waits there read it on the
CPU. Compute pipelines of 256 KB of DXIL or more are built in the background (2 at a
time), a bind of one not started builds it itself. DXC -O1 from 1 MB of HLSL.
`xcl shaders --precompile --pipelines` warms the driver's cache.
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]>
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).
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.

2 participants