Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
273b3bd
[integration] Linux/Proton and native Windows: boot through the story…
Moriz82 Nov 24, 2026
39879ce
Merge main into RT-PROTON-STORY-LOAD (#984)
aslan2142 Nov 25, 2026
424a605
dxgi_swapchain_count_test: pass the diagnostics argument in the faile…
aslan2142 Nov 25, 2026
e011e10
CMake: build pso_stream_test only with the Windows runtime
aslan2142 Nov 25, 2026
432dae1
test_control_flow_branches: model OpPhi in the structured interpreter
aslan2142 Nov 25, 2026
4902178
test_ds_swizzle_b32: run the emulated wave64 swizzles instead of expe…
aslan2142 Nov 25, 2026
a713b30
test_valu_permlane16: run the emulated wave64 permlanes instead of ex…
aslan2142 Nov 25, 2026
a0d90b7
CMake: one target owns the translated vs_m15/ps_m15 files
aslan2142 Nov 25, 2026
48ba269
d3d12_xs: device slot 81 with no presenter answers as the measured bo…
aslan2142 Nov 25, 2026
c334e0a
docs: name the 32 environment variables #984's code reads
aslan2142 Nov 25, 2026
0fc7133
docs/runtime_imports.md: drop the reference to a note that is not in …
aslan2142 Nov 25, 2026
c17604d
build_dstorage_history.py: name the line ending of its text writes
aslan2142 Nov 25, 2026
ce39529
device_proxy_test: the depth-stencil negative control is for Microsof…
aslan2142 Nov 25, 2026
d125b36
Boot diagnostics behind LEONIDA_LOCAL_DIAGNOSTICS, off by default
aslan2142 Nov 25, 2026
1db0f67
d3d12: the proxy's reference count waits for the background pipeline …
aslan2142 Nov 25, 2026
e435715
d3d12_xs: the proxy's own presenter takes no reference on the proxy
aslan2142 Nov 25, 2026
501c7d5
d3d12: remove the unused B4G4R4A4-as-BGRA8 stand-in flag
aslan2142 Nov 25, 2026
869c889
Stage copies between the two A8_UNORM backings through a buffer
aslan2142 Nov 24, 2026
ea43b63
A8 render targets: guard test for device extensions, and the fallback…
aslan2142 Nov 25, 2026
428a746
Check 1D and 3D A8_UNORM textures next to A8 render targets
aslan2142 Nov 25, 2026
2d05d92
d3d12_xs_pso_stream.h: name the source of the derived-PSO record layout
aslan2142 Nov 25, 2026
595a147
xg_xs_THIRD_PARTY.md: TuxBox is Apache-2.0, not unlicensed
aslan2142 Nov 25, 2026
1d28e6e
device_proxy_test: made-up digests in the synthetic shader library case
aslan2142 Nov 25, 2026
7e3bfb4
PresentX: docs and a test state the one-slot-per-layout rule of the m…
aslan2142 Nov 25, 2026
8a242ef
Merge main into RT-PROTON-STORY-LOAD (#984): #396 and #403
aslan2142 Nov 25, 2026
307ea4a
vk_bindless_grow_test: no device-local fault where host memory is dev…
aslan2142 Nov 25, 2026
fb10298
d3d12: the poke experiment's table lookups only when it is on
aslan2142 Nov 25, 2026
e3ca930
docs/design.md: one contract row for a DPP operand on a VOPC compare
aslan2142 Nov 25, 2026
1d89b20
xs_present_lazy_test: the presenter the device proxy builds on PresentX
aslan2142 Nov 25, 2026
21877b1
test_rdna2spirv_decode: a gap word the translator does not recover
aslan2142 Nov 25, 2026
d033c3f
build_runtime.ps1: the cl.exe fallback compiles console_registry.cpp
aslan2142 Nov 25, 2026
68eee6b
gfx10_descriptors.h: the A8 row in the form the format table test reads
aslan2142 Nov 25, 2026
100fed1
#984's Python tools: encoding=, the stdout guard, and --help that wri…
aslan2142 Nov 25, 2026
8b14fc1
runtime.yml: the tools #984's runtime build reads trigger the workflow
aslan2142 Nov 25, 2026
709acc2
mem_diff.py: the reference model addresses memory as the translator n…
aslan2142 Nov 25, 2026
8223f28
d3d12: the console-heap probe is made only when a diagnostic reads it
aslan2142 Nov 25, 2026
2deadb0
xmem_test: view checks that hold under Wine, and say what Wine cannot…
aslan2142 Nov 25, 2026
461efcd
check_tls_index0.cmake: skip the failed-reservation half where TMP ca…
aslan2142 Nov 25, 2026
71a783e
main: the title's hang watchdog stays armed unless LEONIDA_TITLE_WATC…
aslan2142 Nov 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 12 additions & 0 deletions .github/workflows/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ on:
- ".gitattributes"
- "tools/hw_oracle/**"
- "tools/bary_fallback_gs.py"
- "tools/bcpack.py"
- "tools/bcpack_history_train.cpp"
- "tools/bcpack_tables.py"
- "tools/bcpack_tables_bptc.py"
- "tools/cf_diff.py"
- "tools/cf_ref.py"
- "tools/cfg_structure.py"
Expand All @@ -30,6 +34,7 @@ on:
- "tools/fspx_unpack.py"
- "tools/fssm_header.py"
- "tools/fssm_unpack.py"
- "tools/gen_bcpack_runtime_tables.py"
- "tools/gen_d3d12_stubs.py"
- "tools/gfx10_formats.json"
- "tools/lane_masks.py"
Expand All @@ -50,6 +55,7 @@ on:
- "tools/shader_stage_manifest.py"
- "tools/spirv_asm.py"
- "tools/spirv_asm_tables.py"
- "tools/spirv_loop_guard.py"
- "tools/spirv_opt.py"
- "tools/spirv_stubs.py"
- "tools/vk_subgroup_info.py"
Expand All @@ -65,6 +71,10 @@ on:
- ".gitattributes"
- "tools/hw_oracle/**"
- "tools/bary_fallback_gs.py"
- "tools/bcpack.py"
- "tools/bcpack_history_train.cpp"
- "tools/bcpack_tables.py"
- "tools/bcpack_tables_bptc.py"
- "tools/cf_diff.py"
- "tools/cf_ref.py"
- "tools/cfg_structure.py"
Expand All @@ -75,6 +85,7 @@ on:
- "tools/fspx_unpack.py"
- "tools/fssm_header.py"
- "tools/fssm_unpack.py"
- "tools/gen_bcpack_runtime_tables.py"
- "tools/gen_d3d12_stubs.py"
- "tools/gfx10_formats.json"
- "tools/lane_masks.py"
Expand All @@ -95,6 +106,7 @@ on:
- "tools/shader_stage_manifest.py"
- "tools/spirv_asm.py"
- "tools/spirv_asm_tables.py"
- "tools/spirv_loop_guard.py"
- "tools/spirv_opt.py"
- "tools/spirv_stubs.py"
- "tools/vk_subgroup_info.py"
Expand Down
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
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ 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. |
Expand Down
18 changes: 17 additions & 1 deletion 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.
package drive is read-only); the package itself is never written. Set `LEONIDA_WRITE_DIR` to override that folder
for one run (it wins over `--overlay`). 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
Loading