Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4b9a891
fspx_unpack: code_range takes the 24-byte prologue of some pipeline-l…
Tyrannys Nov 24, 2026
1ea2ffb
rdna2spirv: s_bitreplicate_b64_b32 into VCC, s_flbit_i32_b64 of a lan…
Tyrannys Nov 24, 2026
ce98fbe
fix: rdna2spirv decodes scalar, image and buffer tuples that run into…
tedin7 Nov 23, 2026
f7a338b
rdna2spirv: clamp restore_vcc_tuples decode slice to code_end
jarvixaiassistant-glitch Nov 24, 2026
f8d0c75
Merge remote-tracking branch 'origin/main' into HEAD
DadaCap Nov 24, 2026
f605f8a
rdna2spirv: put back the instructions llvm-mc's junk swallowed after …
DadaCap Nov 24, 2026
6886740
test_vcc_tuple_fallback: cover where a resync starts and stops
DadaCap Nov 24, 2026
ebcb0ac
tools: decode the pipeline-library compute programs llvm-mc refuses
Kokonotcu Nov 24, 2026
bf0c4d9
tests: fspx_unpack takes the decoder listing when llvm-mc reports inv…
Kokonotcu Nov 24, 2026
bec14f2
tools: the last pipeline-library compute programs of 1.0.2.1
Kokonotcu Nov 24, 2026
091cd96
rdna2spirv: restrict restore_vcc_tuples to reachable offsets and prot…
jarvixaiassistant-glitch Nov 24, 2026
30450e0
Merge #596's head (091cd9680); restore_vcc_tuples decodes for the sha…
DadaCap Nov 24, 2026
bc245e5
Merge remote-tracking branch 'origin/main' into vcc-tuple-resync
DadaCap Nov 24, 2026
66cad1b
shader_library: keep each state of a compute program, select by code …
Moriz82 Nov 24, 2026
4e1ca11
fix: shader_disasm prints the v_dot4_i32_i8 op_sel 2 / op_sel_hi 5 wo…
tedin7 Nov 23, 2026
686f914
Merge main into vcc-tuple-resync: restore_vcc_tuples next to widen_wa…
DadaCap Nov 24, 2026
8e892ab
Merge pull request #674 (restore instructions after a tuple into vcc)
ubiquitarianism Nov 24, 2026
f33b25e
Merge pull request #593 (s_bitreplicate_b64_b32 into VCC, s_flbit_i32…
ubiquitarianism Nov 24, 2026
159166e
Merge pull request #583 (FSPX short prologue)
ubiquitarianism Nov 24, 2026
df0c53e
Merge pull request #1281 (shader library keeps each compute state, se…
ubiquitarianism Nov 24, 2026
37302d4
Merge pull request #1317 (print the v_dot4_i32_i8 op_sel words llvm-m…
ubiquitarianism Nov 24, 2026
9c36a30
Merge pull request #998 (pipeline-library compute programs llvm-mc re…
ubiquitarianism Nov 24, 2026
cc3aef8
test_vcc_tuple_fallback: widened scalar load with an SGPR offset, buf…
ubiquitarianism Nov 25, 2026
d4b2afe
rdna2spirv: a v_dot4_i32_i8 printed with default op_sel takes the sto…
ubiquitarianism Nov 25, 2026
65362a4
s_bitreplicate_b64_b32 of a lane-mask half into data: test and contra…
ubiquitarianism Nov 25, 2026
37f7d60
Merge #984 (RT-PROTON-STORY-LOAD) onto main
ubiquitarianism Nov 25, 2026
a39b3e4
runtime tests: build and pass on the merged Xbox device proxy
ubiquitarianism Nov 25, 2026
898bea5
rdna2spirv: remove widen_wave64_valu_masks, unused after the merge
ubiquitarianism Nov 25, 2026
70985db
semantic tests: model OpPhi, check the emulated wave64 swizzles
ubiquitarianism Nov 25, 2026
f1b27f7
Merge port/palmetto-translator: open translator decode PRs and palmet…
ubiquitarianism Nov 25, 2026
1dd7b32
d3d12_xs: null-resource texture barriers and null-view RTV clears on …
ubiquitarianism Nov 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ __pycache__/
*.exp
*.log
.vs/

# Predictor profiles are fitted from the user's own texture pools.
*.bcph
*.bcph.stamp
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ work on booting can start as soon as one is available to a developer.
| Audio banks (AWC: Opus, XMA2) | ✅ Exported whole. Opus repackaged **losslessly** as Ogg Opus; PCM (codec 0/2) as WAV; XMA2 decoded with ffmpeg. `--wav` adds 16-bit PCM WAV ([notes](docs/audio.md)) |
| Music/radio config | ? Measured. **1,589** audio-config records with exact durations and AWC stream ids; station grouping and content-id lists; no per-track start offsets ([notes](docs/audio_config.md)) |
| PE loader and import shims | ⚠️ Runs a stand-in executable end to end (`gta6rt --run`: CRT startup, statics, heap, files, threads, GDK imports through the shims, exit code back). Controllers through a GameInput shim on SDL3 (any controller SDL supports, rumble, DualSense trigger effects and lightbar; built when SDL3 is installed or with `-DLEONIDA_SDL3_FETCH=ON`, [notes](docs/gameinput.md)). `--trace-d3d12` logs every D3D12 call and its outcome for the first boot. Untested against the real executable |
| Xbox D3D12 → Vulkan | ⚠️ In progress. A Vulkan-backed device behind the Xbox-ABI proxy creates queues, command lists, fences, descriptor heaps, committed, placed and reserved resources, render-target and depth views (3D targets included), texture views and samplers (2D, cube, 1D and 3D views, the depth and stencil planes of depth-stencil textures, packed formats such as B5G6R5, B4G4R4A4 and R9G9B9E5, buffer SRVs — raw, structured and typed; they go into the bindless set), root signatures, pipelines and query heaps, and draws run on Vulkan. Barriers, clears, uploads, copies (BC included), colour resolves, predication, CPU-side texture reads and writes, and occlusion, timestamp and pipeline-statistics queries run on Vulkan, checked on one GPU. The console-shaped command-list proxy, the measured `PresentX` queue slots (30/32, layout-detected) wired to the presentation core, and `AllocateUploadMemory` (list slot 148, a mapped-upload arena whose addresses translate to buffer device addresses in root descriptors and IA/SO views) cover the console-ABI surface the package measures. Still open: the console list tail and the descriptor-table record model ([plan](docs/d3d12_vulkan.md)) |
| Xbox D3D12 → Vulkan | ⚠️ In progress. A Vulkan-backed device behind the Xbox-ABI proxy creates queues, command lists, fences, descriptor heaps, committed, placed and reserved resources, render-target and depth views (3D targets included), texture views and samplers (2D, cube, 1D and 3D views, the depth and stencil planes of depth-stencil textures, packed formats such as B5G6R5, B4G4R4A4 and R9G9B9E5, buffer SRVs — raw, structured and typed; they go into the bindless set), root signatures, pipelines and query heaps, and draws run on Vulkan. Barriers, clears, uploads, copies (BC included), colour resolves, predication, CPU-side texture reads and writes, and occlusion, timestamp and pipeline-statistics queries run on Vulkan, checked on one GPU. The console-shaped command-list proxy, the measured `PresentX` queue slots (30/32, layout-detected) wired to the presentation core, and `AllocateUploadMemory` (list slot 148, a mapped-upload arena whose addresses translate to buffer device addresses in root descriptors and IA/SO views) cover the console-ABI surface the package measures. Still open: the console list tail and the descriptor-table record model ([plan](docs/d3d12_vulkan.md), [console ABI](docs/d3d12_xs_console_abi.md)) |
| Ray tracing (BVH) | ⚠️ In progress. `BuildRaytracingAccelerationStructure` builds BLASes and TLASes on the GPU in the console's XDXR BVH4 layout (the default; `LEONIDA_RT_AS=khr` uses Vulkan's own acceleration structures instead), which the translated shaders walk themselves through `image_bvh_intersect_ray` (all four triangle node types, TRI0-TRI3, with the barycentric remap byte); the GPU builder writes TRI0 and TRI1 leaves. Updates refit instead of rebuilding, and clone, compaction and the compacted/current postbuild sizes work; checked against a CPU reference on synthetic scenes. The build descriptions are recovered from the package's `XboxBvhBuilder.dll` ([notes](docs/xdxr.md)). The game's `*_bvh4.rpf` packs are measured: offline-built, dehydrated BLASes that rehydrate through that DLL with their geometry from the drawables in `levels.rpf` (measured on 8 of the 10 sampled BLAS; [notes](docs/bvh.md)). Not done in the builder: serialization. TRI1 pairing (no memory saved yet) and BOX16 nodes for `MINIMIZE_MEMORY` BLASes (an assumed switch) are in ([notes](docs/bvh.md)). Open: whether the game rehydrates the packs or rebuilds them ([#313](https://github.com/ItsNotRexed/Leonida/issues/313)) |

The table above is written by hand. To measure it on your own checkout (unit and runtime tests, which rows of
Expand Down
4 changes: 4 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,18 @@ method, scope and caveats. No game data is included.
| [descriptor_lookup_intel.md](descriptor_lookup_intel.md) | Intel UHD Graphics 770 (Xe-LP, Windows, driver 101.6129) timings for the same lookups at 1k–100k live entries; both memory placements within 0.6% of each other. |
| [d3d12_xs_surface.md](d3d12_xs_surface.md) | The 116-slot `d3d12_xs.dll` export surface; 83/83 standard GUIDs match the PC SDK. |
| [xdxr.md](xdxr.md) | `BATCHED_DESC2` (`0x50`) and `XDXR_STREAM_DESC` (`0x10`) from `XboxBvhBuilder.dll`'s reads; stream records' offsets and defaults; offline statistics not in the package. |
| [d3d12_xs_console_abi.md](d3d12_xs_console_abi.md) | The D3D12.X console ABI the `d3d12_xs` shim must reproduce: device/queue/list vtable slots, command-list object fields and record encodings, root-argument SGPR rules, unified memory; sibling-layer measurements marked unverified here. |
| [d3d12_command_objects.md](d3d12_command_objects.md) | Measured command queue/list/fence/`PresentX` surface; verified vs prior art vs open. |
| [xbox_d3d12_xs.md](xbox_d3d12_xs.md) | The `d3d12_xs` graphics ABI quoted from Microsoft's public GDK reference: root signatures, state objects, DXIL libraries, hit groups, shader cache sessions; which pages are missing or NDA-gated. |
| [runtime_imports.md](runtime_imports.md) | The 16 shipped modules' measured imports and shim/host/unimplemented split. |
| [linux_proton.md](linux_proton.md) | Building and booting under Proton/Wine on Linux, a healthy boot's timeline, and the test report of one Linux and two Windows machines |
| [xmem_exe_calls.md](xmem_exe_calls.md) | How the retail executable calls `xmem.dll`: call sites and constant arguments per import (`tools/import_call_sites.py`), the 23 `XMemVirtualAlloc` calls that all pass an attribute word, and the inferred shape of the physical-page family. |
| [exe_fail_fast.md](exe_fail_fast.md) | Where the retail executable stops itself (`int3`) on an import's result: 78 sites over 27 imports (`tools/import_fail_fast.py`), grouped by how `main` binds each import (all 13 non-host fatal-checked imports now bind to shims; 0 unbound). |
| [audio_hal_exe_calls.md](audio_hal_exe_calls.md) | How the retail executable calls the 22 audio coprocessor, texture layout and DirectStorage imports that have no shim: call sites, constant arguments, and the four calls with a negative-result branch. |
| [directstorage.md](directstorage.md) | Console DirectStorage: the DLL and ABI the title is expected to use (`DStorageGetFactory`, `dstorage_xs`, `XCRDAPI`), how sure that is and the evidence for it, and what `runtime/shims/dstorage.cpp` serves on the PC. The executable's own imports are unmeasured. |
| [cpu_features.md](cpu_features.md) | CPU instructions in the executable a desktop CPU may lack (`tools/cpu_feature_scan.py`): 19 SSE4a, 10 CLZERO and 4 MONITORX/MWAITX sites (AMD only) and 8 CLWB sites (Intel since Ice Lake), all real code; `#UD` on hosts without them. |
| [xcl_compare.md](xcl_compare.md) | XCL's synthetic test title under `gta6rt --run` and under XCL (`tools/xcl_compare.py`): 5 of 50 checks pass here, both hangs are the documented manual-queue terminate deadlock, and each other difference mapped to an open item or a lead. |
| [directstorage.md](directstorage.md) | DirectStorage for the console title: the evidence for the DLL (`dstorage_xs.dll`, also `xcrdapi.dll`, `dstorage.dll`) and the console ABI with its confidence, and the shim: `GAME:` file open, queues, file and memory reads, status arrays, fences, events, cancel and errors, zlib requests inflated with their `E_DSTORAGE_ZLIB_*` errors; BCPack, swizzle and physical pages still open. |
| [gameinput.md](gameinput.md) | The GameInput shim on SDL3: `GameInputCreate` and the v0 `IGameInput`/`IGameInputDevice`/`IGameInputReading`/`IGameInputDispatcher` surface on any SDL gamepad, DualSense adaptive-trigger approximation and lightbar, force-feedback motors and trigger haptics through SDL's haptic API; 261 checks on virtual joysticks and a fake haptic backend; by hand on an Xbox Series X pad (Bluetooth) and a DualSense (USB). 261 checks on virtual joysticks and a fake haptic backend, not yet tried on a real pad. |
| [saves.md](saves.md) | Save containers: `JSAV` (index + JSON story save, byte-exact rebuild), `ASAV` header, `SLAYER1` packed copy (not decoded); `tools/saves.py` and import into the offline `XGameSave` folder; key hashes are case-sensitive joaat (`tools/save_keys.py`). |
| [pipeline_check.md](pipeline_check.md) | Driver-level corpus check: the full corpus, 26,503 of 26,503 modules and pipelines, 0 failures (RTX 4060 Ti); an earlier 10/12-shard run, 22,092 modules and 2,217 compute pipelines, also had 0 failures. Driver-level corpus check: 10/12 shards, 22,092 modules, 2,217 compute pipelines, 0 failures. |
Expand Down
16 changes: 16 additions & 0 deletions docs/boot.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,29 @@ Useful switches:
`int3_skipped` event, so a boot can be followed past soft asserts (an int3 followed by code that carries on).
Diagnostic only: a correct run reaches none, so each skipped address is a finding, not a fix. A failed guest file
open is always traced as `file_open_failed` (path, error, caller) when `--trace` is on.
* `LEONIDA_STUB_PIPELINES=1` creates a pipeline whose translated shader is missing (no shader library, or no entry
for its program) as a no-op stub instead of failing `CreateGraphicsPipelineState` / `CreateComputePipelineState`.
The stub is never registered, so `SetPipelineState` binds no PSO and its draws and dispatches are no-ops (D3D-482).
Diagnostic only, like `LEONIDA_SKIP_INT3`: it follows a boot past every pipeline the title creates without
translating or running a game shader, so nothing the title draws reaches the screen. Each stub is logged with a
power-of-two count.
* During `--run` on Vulkan, the runtime paints the package shell splash when the title shows its window. The first
direct queue presents it on the window's swapchain. Startup clears keep the splash visible until the first
non-black output replaces it. The runtime reads `ShellVisuals/SplashScreenImage` from
`MicrosoftGame.Config` or `SplashScreen/Image` from `appxmanifest.xml`, preserves the image's aspect ratio and
uses the same swapchain for PresentX. A surface without readback hands off at the first title present.
Set `LEONIDA_PACKAGE_SPLASH=0` to disable the splash.
* `LEONIDA_VK_VALIDATION=1` enables the Khronos validation layer with the Vulkan backend (startup overhead; it is a
diagnostic).
* `LEONIDA_DEVICE_FAULT=1` enables Vulkan device-loss diagnostics and checkpoints where available. The first
observed loss prints a `[rt] device-fault:` report to stderr.
* `DISABLE_RTSS_LAYER=1` and `DISABLE_VULKAN_OBS_CAPTURE=1` when MSI Afterburner or OBS is installed; their
implicit layers add swapchain usage that shows up as validation errors ([testing.md](testing.md), "Known
problems").
* `--overlay DIR` sends the guest's writes to DIR instead of the default `<game-dir>\overlay` (useful when the
package drive is read-only); the package itself is never written.
Set `LEONIDA_WRITE_DIR` to override that folder for one run. For a fresh first-run profile,
also set `LEONIDA_SAVE_DIR` to a separate empty directory for the local game-save provider.

## 3. Triage order

Expand Down
4 changes: 4 additions & 0 deletions docs/buffer_bounds.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ measured natively on AMD GPUs (SHADER-116). The translator reads this field and
| 2 disabled | `N == 0` | same | same |
| 3 raw | `offset + soffset + 4 > N`; `index * stride` moves the address but is not checked | `offset >= N`: differs | `offset + 4 > N`, without `soffset` |

The runtime writes mode 3 for raw SRVs/UAVs, mode 0 for structured views and mode 1 for typed views.
API-created CBVs mirror the observed inline console descriptor (mode 0, 16-byte rows).
`LEONIDA_CBV_RAW=1` selects mode 3 with a byte count. Root views carry a GPU VA.

- **RDNA2 follows Mesa's GFX11 column**, not the GFX10 one: of 732 cases, 729 match GFX11 and 696 match GFX10.
Every GFX10 miss is an access that only partly fits, for example a raw buffer with `N = 3` read at offset 0.
- **In raw mode `soffset` is part of the checked offset.** The 3 cases that match neither column are raw reads at
Expand Down
7 changes: 7 additions & 0 deletions docs/cpu_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ in the image.
`insertq`/`extrq` are bit-field operations on the low quadword. `cpu_emulation_test` checks each form against the
CPU on a host that has it and against the handler on one that does not (an i7-10700K: all four lacking, all checks
pass).
- The CLZERO routine is too hot for the #UD path: one exception and two `VirtualQuery` calls per 64-byte line. On an
i9-13900K the routine held one thread at ~99% for the whole boot (sampled: `VirtualQuery` under
`cpu_emulation::apply`) and the title presented ~3 frames a second. On a CPU without CLZERO the loader therefore
rewrites the routine's loops before any image code runs (`runtime/src/clzero_patch.h`): each of the two loop shapes
(6 + 4 sites) jumps to a stub within 2 GiB of the image that zeroes the line with eight 8-byte stores and keeps the
loop's registers and flags. Same boot afterwards: 164,946 PresentX in 300 s against 869 in 420 s, no CLZERO left on
the #UD path. `LEONIDA_CLZERO_PATCH=0` keeps the emulation; `clzero_patch_test` runs both shapes on any CPU.
- The CPUID sites see the host's vendor, family and features, not the console's. What the game does with the
answers is not measured here.

Expand Down
15 changes: 11 additions & 4 deletions docs/d3d12_command_objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,10 @@ section 3.5a), and the console list has methods well past the PC tail: 71, 73, 8
FSR DLL.

Slot 148 matters beyond the builder: the address it returns is written by the CPU and passed unchanged to the GPU
as a root SRV address, so console upload memory has the same address for the CPU and the GPU. A replacement must
return memory whose CPU pointer is also a valid GPU address (for this layer: inside the arena of
[d3d12_vulkan.md §3.3](d3d12_vulkan.md)).
as a root SRV address, so console upload memory has the same address for the CPU and the GPU. On a PC the two
address spaces differ, so `d3d12_xs_device.cpp` carves a bump arena out of persistently-mapped UPLOAD-heap
buffers: the title writes the mapped memory and the six root descriptor setters and the IA/SO view setters
translate the CPU pointer to the chunk's buffer device address before forwarding.

The function at `0xd580` uses the 71/73 pair instead of the slot-146 barrier when the byte at RVA `0xd773c` is set.
That byte is one of seven bools at `0xd7738`–`0xd773e` in zero-initialised `.bss`. The only accesses to them in
Expand Down Expand Up @@ -764,6 +765,12 @@ Queues and fences are wrapped the same way.
object implements but the proxy does not model is logged once and refused.
- **The refused tail.** A slot past the public chain, up to the end of the proxy's own table (128 queue and
64 fence slots, every one a thunk), logs its first four argument words once and returns `E_NOTIMPL`.
- **Fence slot 12.** The one served slot past the chain. The retail executable calls it as
`(value, descriptor, flags)` and reads the return as a pointer to the fence's 64-bit completed value: it
compares that value with `~0` (device removed) and subtracts the value it waits for. The proxy returns a
per-fence mirror. Completion events refresh it immediately. A 10 ms wait timeout also refreshes it if the
fence rewinds below the pending event's threshold. Slot 12 and the CPU `Signal` (10) refresh it synchronously.
The descriptor's second word is a code pointer, which is not called.
- **The guard region.** Each table sits at the end of the first page of a 64 KiB reservation, and the rest
of that reservation is never committed. A slot past the table therefore faults on the vtable read itself,
inside the reservation, and a vectored handler logs the slot before the fault goes on. A vtable read that
Expand Down Expand Up @@ -830,7 +837,7 @@ command object.
| Item | Why it is blocked |
|---|---|
| `PresentX` | No slot, signature, plane struct or swapchain/plane parameters. Prior art gives only names, the 2-plane/8-view limits and four flag names. |
| `CreateCommandQueueX` | No slot or parameter layout; only the UMD message and an inferred shape. |
| `CreateCommandQueueX` | No slot or parameter layout; only the UMD message and an inferred shape. The retail title calls device slot 48 as (desc, riid, out) with a 32-byte desc (#6954), which differs from the (pDesc, pShaderQueueParams, riid, out) shape inferred above. |
| `SuspendX` / `ResumeX` | No slot or signature. |
| Xbox queue/list/fence/allocator slot deviations | No runtime binary and no game executable; the package has no queue, fence or allocator client, and its only command-list client is the BVH builder. |
| Builder's list field `+0x350` | Read once (`0x1d877`) and not explained by the inline buffer of section 3.5a, which covers `+0x18`, `+0x28`, `+0x30`, `+0x140`, `+0x141`, `+0x344` and `+0x544`. |
Expand Down
Loading