Files
mandy/runtime/test/dstorage_vectors.py
Moriz82 273b3bdf9d [integration] Linux/Proton and native Windows: boot through the story load (RT-PROTON-STORY-LOAD)
One squashed commit of a fork that was developed on a Linux/Proton machine and
tested on two native Windows machines. On all of them the retail 1.0.2.1
package now launches, shows its launch movie, first-run pages and landing
prompt, runs the story load to its end with the loading slideshow drawing its
artwork, and enters the world phase. A first world frame is not verified yet.
docs/linux_proton.md has the setup, a healthy boot's timeline, the machines
and where it stops.

Runtime: frames in the title's own window; DirectStorage pinned reads,
page-list scatter/gather, BCPack and unshuffle with a locally generated
predictor file; pooled, device-local and deferred image backing for streamed
and placed textures; enhanced barriers into LAYOUT_UNDEFINED; a bindless table
that degrades instead of refusing a submission; a descriptor hash finalizer
(off until a library carries it); directly indexed heap offsets for compute
dispatches and VS/PS/GS draws; title buffer windows outside a fragmented
arena; opt-in device-local copies of streamed buffer views; write-fault
retries under the tracker lock, shared trackers and write-watched title memory
for native Windows; device-loss, compute-input and memory probes.

Translator: loop bounds at structured exits, the eight FidelityFX programs
that use a packed-dot form the disassembler skips, buffer bounds modes per
view kind, a compaction option, the hash finalizer option.

Tools and scripts: Linux boot scripts (Wine/Proton, no network), a Windows
boot script, the paired compute translation script.

No game data. AI-assisted (Claude Code and Codex agents), reviewed and booted
by people on the machines named in docs/linux_proton.md.

Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-24 11:42:12 -06:00

94 lines
4.4 KiB
Python

"""Make synthetic DirectStorage requests with the test rANS encoder and the reference BCn decoder."""
from pathlib import Path
import sys
import zlib
root = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(root / "tests"))
import test_bcpack as enc
def build(codec):
block_count = 64
single = codec in (1, 4)
count = block_count if single else 2 * block_count
lanes = [[0] * count for _ in enc.bcpack.LANE_WIDTHS[codec]]
for k in range(2, 11 if codec >= 6 else 12):
for i in range(count):
lanes[k][i] = (i % 4 + k) % 5
if codec == 6:
for i in range(block_count):
mode = i % 14
lanes[15][2*i:2*i+2] = (mode, i % 32)
bits = 3 if mode < 10 else 4
# The initial half-range index needs a negative delta to reach zero.
if i:
lanes[1][2*i:2*i+2] = enc._deint4(1)
delta = 0 if i else (1 << bits) - 1
for y in range(4):
lanes[11+y][2*i:2*i+2] = [enc._pack_ix_pair(delta, delta, y)] * 2
if codec == 7:
# Use all eight modes with zero p-bits and legal anchor indices.
cfg = enc.bptc.load_bc7()
for i in range(block_count):
rank = next(r for r, v in enumerate(cfg["config"])
if v[0] == i % 8 and r not in cfg["inferred"])
lanes[15][2*i:2*i+2] = divmod(cfg["rank_of"].index(rank), 16)
for k in (2, 6, 7, 8, 10):
lanes[k] = [0] * count
# Select the smallest model encoding per lane so both bare and wrapped requests
# meet DirectStorage's requirement that the destination exceed the source.
widths = enc.bcpack.LANE_WIDTHS[codec]
q = [min(range(16), key=lambda q: len(enc._encode_fragment(symbols, w, w, q)[0]))
for symbols, w in zip(lanes, widths)]
raw = enc.encode_lanes(lanes, codec, q=q)
plain = enc.bcpack.decode(raw, codec, 8 * count)
assert len(raw) < len(plain) and len(zlib.compress(raw)) < len(plain)
return raw, plain
def write(out):
for codec in (1, 3, 4, 5, 6, 7):
raw, plain = build(codec)
for name, data in (("raw", raw), ("plain", plain), ("wrapped", zlib.compress(raw))):
print(f"static constexpr uint8_t {name}{codec}[] = {{", file=out)
for i in range(0, len(data), 24):
print(" " + ", ".join(map(str, data[i:i+24])) + ",", file=out)
print("};", file=out)
for codec in (6, 7):
lanes = [[0] * 64 for _ in range(16)]
cfg = enc.bptc.load_bc7()
rank = cfg["config"].index((6, 0, 0, 0))
for block in range(32):
lanes[1][2*block:2*block+2] = enc._deint4(1)
if codec == 7:
lanes[15][2*block:2*block+2] = divmod(cfg["rank_of"].index(rank), 16)
history = {"bc6h": {"endpointHistory": {255: [[4096, 0, 0, 0]] * 3}, "indexHistory": {255: [0]*16},
"endpointClass": {255: 3}, "indexClass": {255: 3}},
"bc7": {"historyEndpoints": {255: [64]*24}, "historyEndpointBits": {255: [8]*24},
"historyEndpointConfirmedBits": {255: [8]*24}, "historyIndices": {255: [0]*32},
"historyIndexBits": {255: [4]*32}, "historyIndexConfirmedBits": {255: [4]*32}}}
packed = enc.encode_lanes(lanes, codec, q=10)
expected = enc.bcpack.decode(packed, codec, 512, history=history)
assert expected[:16] * 32 == expected
for label, data in (("profile_raw", packed), ("profile_first", expected[:16])):
print(f"static constexpr uint8_t {label}{codec}[] = {{{', '.join(map(str, data))}}};", file=out)
seed = next(iter(enc.tables.BC1_HISTORY_PROVISIONAL))
lanes = [[0] * 64 for _ in range(12)]
distance = 256 - seed
lanes[0][0] = enc._zig(distance if distance < 128 else distance - 256)
raw = enc.encode_lanes(lanes, 1, q=12)
plain, info = enc.bcpack.decode_with_info(raw, 1, 512, allow_provisional=True)
assert info
print(f"static constexpr uint8_t fitted_raw[] = {{{', '.join(map(str, raw))}}};", file=out)
print(f"static constexpr uint8_t fitted_first[] = {{{', '.join(map(str, plain[:8]))}}};", file=out)
print("static constexpr Vector vectors[] = {", file=out)
for c in (1, 3, 4, 5, 6, 7):
print(f" {{{c}, raw{c}, plain{c}, wrapped{c}}},", file=out)
print("};", file=out)
if __name__ == "__main__":
with Path(sys.argv[1]).open("w", encoding="utf-8", newline="\n") as output:
write(output)