Skip to content

Bathyal next4: world-read race, BC5, memory copies, MWAITX on Intel - #7

Merged
T-Crypt merged 9 commits into
mainfrom
bathyal/next4
Nov 24, 2026
Merged

T-Crypt merged 9 commits into
mainfrom
bathyal/next4

Conversation

@T-Crypt

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

Copy link
Copy Markdown
Owner

Known-good build: ran 16+ minutes of loading on an RTX 4090 without a crash. 797 tests pass on galaxy.

  • DirectStorage: destination pages filled in after Submit no longer fail with E_DSTORAGE_ACCESS_VIOLATION
  • BCPack BC5 decode
  • CopyMemoryToMemoryX outside unified memory runs on the CPU after the fence
  • MONITORX/MWAITX rewritten in place on CPUs without them (no exception per spin iteration)

…s on the CPU

A title streams its world through command list #60 with a source in its own
memory (outside the windows) and a destination at a title GPU address: both
sides went unresolved and the copy was dropped.

Now either side outside the windows takes the CPU path: the copy is recorded
on the list and done by the cpu_writes worker once the queue is past the
submission's earlier work, reading the source at that moment (a source in a
sparse window is read back from its video memory first). A destination in a
sparse window is then sent to its video memory (sparse::flush_written) and the
title queues wait for it before their next work, which is also what the
write-watch would do at the next submit.

A range in a sparse window with no video memory (unmapped tiles, hole pages)
no longer takes the GPU copy either.

Tests: a copy outside unified memory is recorded and done (list_x), copies
land after the queue (cpu_writes), a copy the CPU cannot make changes nothing.
The BC5 stream is two symbols per lane per 16-byte block: lane 0 the
distance in BC3's bit-interleaved form, lanes 2/3 the endpoint residues
of the two channels, lanes 4-7 and 8-11 the 3-bit index pairs. Each
channel becomes a plain BC4 block.

The stream carries neither the 64-entry index-pair table nor the
255-slot endpoint history; the tables are the estimates of the
clean-room decoder leonida-asset-pipeline (MIT), generated into
bc5_tables.rs by scripts/gen_bcpack_bc5_tables.py. 214 slots are
fitted; an unknown slot ends the stream with Error::History rather than
a guess.

BC7 stays refused: its block layout is documented, but the rebuild
needs two 256-slot history tables and 10 of the 285 lane-15 signatures
that only GPL-3.0 sources carry, which this GPL-2.0-only crate cannot
take.

Tests (synthetic data only): a hand-built block with an in-stream
reference and a history slot, a round trip from blocks to symbols to
the fragment encoder to decoded blocks, the bc5 fixture, the fitted
tables, and a BC5 request through a DirectStorage queue.
The endpoint symbols of lane 2 and lane 3 are E at the even unit and O at
the odd unit, so O is symbols[12 + lane], not the next lane's E. The
round-trip test failed on this before the fix (endpoints off by one
lane).
…aited for

A retail title fills its streaming page tables from another thread right
after Submit. XCL's worker runs the request first, reads page 0 and
refused the request with E_ACCESS_VIOLATION (12288, 24576 bytes and
more, one per world-database file per run). The entries that were 0 at
enqueue are now read again at the request's turn, and a table still
holding 0 is given a few milliseconds before the request fails.
… as an address

A raw pointer is not Send; usize is.
…mulation

A title's spin-waits run them in a loop; on a CPU without them each iteration was an exception.
The faulting instruction becomes NOPs (MONITORX) or PAUSE and NOPs (MWAITX), as CLWB already is.
@T-Crypt
T-Crypt enabled auto-merge November 23, 2026 23:59
@T-Crypt
T-Crypt merged commit 87ca969 into main Nov 24, 2026
2 checks passed
@T-Crypt
T-Crypt deleted the bathyal/next4 branch November 24, 2026 00:01
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.

1 participant