Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 18 additions & 3 deletions docs/d3d12_vulkan.md
Original file line number Diff line number Diff line change
Expand Up @@ -2641,8 +2641,9 @@ Pipeline creation:
`pipelineCreationCacheControl` feature unless `LEONIDA_PIPELINE_COMPILE=cache-only` asks for it. A cache-only create
(`cache-only`) is left as it is.
`LEONIDA_SKIP_COMPUTE=<part of a name>[,<part>...]` (`all`: every compute program) never builds the matching
compute programs and drops their dispatches, direct and indirect; the first dropped dispatch of each is logged.
It is a way past a program that hangs the GPU while the program or its input is fixed, not a fix.
compute programs at play and drops their dispatches, direct and indirect; the first dropped dispatch of each is
logged. It is a way past a program that hangs the GPU while the program or its input is fixed, not a fix.
`--precompile-pipelines` (below) builds them anyway unless it is given `--skip-listed`.
`LEONIDA_STARTUP_CACHE_CHECKPOINTS=1` also schedules a snapshot after a successful pipeline build,
at most once per 120 seconds. It starts on the compile worker when queued builds have drained and the device
has no active builds. The driver fills a mapped staging
Expand Down Expand Up @@ -2681,7 +2682,8 @@ Pipeline creation:
folders can share one; the file names and the driver's checks keep a pipeline from one build from being taken
for another's.
`gta6rt --precompile-pipelines [--threads N] [--big-threads N] [--all] [--smallest-first] [--limit N]
[--min-bytes N] [--max-bytes N] [--filter PART]... [--list]` fills the journal ahead of play, with no game: it
[--min-bytes N] [--max-bytes N] [--filter PART]... [--skip-listed] [--list]` fills the journal ahead of play, with
no game: it
creates the Vulkan device as `--run` does (so the same environment gives the same journal names and driver keys:
LEONIDA_SHADERS, LEONIDA_PIPELINE_CACHE_DIR, and LEONIDA_DEVICE_FAULT/LEONIDA_AFTERMATH, whose diagnostics config
makes other pipelines) and builds every compute entry of the library through the dispatch path
Expand All @@ -2691,6 +2693,19 @@ Pipeline creation:
4 threads: modules of 3.6-5.8 MB took 46-145 s each, 12 in 312 s, about 3.5 GB of host memory each while in the
driver (14.5 GB peak for four). Graphics pipelines are not covered: they are built at a title's draw from its PSO
description and the bound formats, and take milliseconds.
`LEONIDA_SKIP_COMPUTE` does not narrow the build: it is a play-time setting, players run the pre-compile with the
game's environment, and a program left out here would stay out of the journal after the list is shortened. The run
says how many entries the list names and builds them; `--skip-listed` leaves them out on purpose. The last line
counts what was built (compiled, or found in a cache), what was journaled already or being built by another
process, what failed, and what was left out and why: by `--skip-listed`, not buildable on this device (no SPIR-V,
set-0 bindings without a bindless set, workgroup memory over the limit), or filtered out (`--filter`, the size
bounds, `--limit`). The 89-167 s per program behind the skip list of the large `library/` programs came from
wave64-emulated packs. Measured with a native wave64 pack on an RX 7900 XTX (RADV, Mesa 26.3.1, Wine): all 721
programs of 2 MiB or more built, 360 of them in 170 s on 32 threads, 2.5-32 s each, the largest (13 MiB) in 28.5 s
alone, at a peak of 14 GiB of RAM for the process. With all of them in the journal and no skip list, two world runs
took them all from the journal (none built in the game) and ended as runs with the skip list do, in an idle-queue
device loss or a stop with the GPU idle ([running.md](running.md#settings-every-platform-needs)); whether their
output is correct is not measured.
`LEONIDA_COMPILE_HELPER=1` (`shims/d3d12_compile_helper.h`) keeps first-ever compiles out of the title's process:
the driver's locks, which a long `vkCreateComputePipelines` holds and a `vkQueueSubmit` of the same process waits
for, are per process. A compute build of `LEONIDA_COMPILE_HELPER_MIN_BYTES` or more (128 KiB) with no journal file
Expand Down
17 changes: 13 additions & 4 deletions docs/linux_proton.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ they were found.
with the environment of the game run (`LEONIDA_SHADERS`, `LEONIDA_PIPELINE_CACHE_DIR`, `LEONIDA_DEVICE_FAULT`;
`--precompile-pipelines` in [d3d12_vulkan.md](d3d12_vulkan.md)). It built 3,693 compute pipelines; the next boot took
1,900 of them from the journal in 0.1 s of driver time, and the menus ran at 30 frames/s instead of under one.
That run left out the programs `LEONIDA_SKIP_COMPUTE` named, which kept them out of the journal; the pre-compile
now builds them too unless it is given `--skip-listed`.
The `pipeline_cache.bin` that `make_game.py`'s pipelines stage writes with `vk_pipeline_check` gave no hits: 0 of
5,526 journal pipeline keys were in its 29,861 objects (9 shader binaries were identical, so the machine code
matched and the keys did not). Each of three differences is enough for a miss on RADV:
Expand All @@ -212,10 +214,17 @@ they were found.
hashes the whole set layout and the stage flags. Graphics would miss anyway: the checker pairs each stage with a
stub and fixed state, and RADV hashes the full graphics state.
4. **Leave out the ray-tracing programs.** 724 library compute programs have 2 MiB of SPIR-V or more (676 of them
ray-tracing resolve) and take 89-167 s each in the driver. `LEONIDA_RT_AS=off` drops acceleration-structure builds
and copies, and `LEONIDA_SKIP_COMPUTE=<name>,<name>,...` with those programs' `lib_cs_NNNNN` names (picked by
module size from `library/index.json`) never builds or dispatches them. The picture then lacks whatever those
passes draw.
ray-tracing resolve). The 89-167 s each in the driver were measured with wave64-emulated packs; with the native
pack of step 2 they build in seconds, so compile time is not the reason any more. Measured afterwards on the same
machine (RX 7900 XTX, RADV, Mesa 26.3.1, Wine): all 721 such programs of that pack built, 360 of them in 170 s on 32
threads, 2.5-32 s each, the largest (13 MiB) in 28.5 s alone, at a peak of 14 GiB of RAM. Two world runs with all
of them in the journal and no skip list (one run per build) took them all from the journal and got no further
than runs with the skip list: one stopped submitting after 404 s with the GPU idle, the other lost the device
about 214 s in with every queue idle, a loss that also happens with the skip list set
([running.md](running.md#settings-every-platform-needs)). Whether their output is correct is not measured, so the
longest runs still leave them out. `LEONIDA_RT_AS=off` drops acceleration-structure builds and copies, and
`LEONIDA_SKIP_COMPUTE=<name>,<name>,...` with those programs' `lib_cs_NNNNN` names (picked by module size from
`library/index.json`) drops their dispatches at play. The picture then lacks whatever those passes draw.
5. **Keep the title's hang watchdog kicked.** The title exits on purpose (a write to address 0) when its main loop has
not reported for 30 s, which a world load under the runtime exceeds. `LEONIDA_TITLE_WATCHDOG=0` defuses it only
together with `LEONIDA_TITLE_WATCHDOG_KICK=<trap RVA>,<kick RVA>` (hex; `runtime/src/main.cpp`); the two values are
Expand Down
28 changes: 22 additions & 6 deletions docs/running.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,21 @@ Paths are placeholders: `<checkout>` is the repository, `<build>` the folder wit
- **The GPU timeout.** World frames take seconds each. The OS's GPU timeout must be longer, or the driver resets the
GPU: amdgpu's `lockup_timeout` on Linux, `TdrDelay` on Windows (sections below).
- **Large ray-tracing programs.** 724 library compute programs have 2 MiB of SPIR-V or more (676 of them ray-tracing
resolve) and take 89-167 s each in the driver ([reported by others](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7184700506);
the count of 724 also measured by us). `LEONIDA_RT_AS=off` drops acceleration-structure builds and
`LEONIDA_SKIP_COMPUTE=<name>,<name>,...` with those programs' names (picked by module size from
`<work>/shaders/spirv/library/index.json`) never builds or dispatches them. The picture then lacks what they draw.
resolve). With wave64 emulation they took 89-167 s each in the driver ([reported by others](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7184700506);
the count of 724 also measured by us). With a native wave64 pack compile time is no reason to leave them out: on an
RX 7900 XTX (RADV, Mesa 26.3.1, Wine) all 721 such programs of that pack built, 360 of them in 170 s on 32 threads,
2.5-32 s each, the largest (13 MiB) in 28.5 s alone, at a peak of 14 GiB of RAM (measured by us). The pipeline
pre-compile builds them with the rest. Dispatched at play (measured by us, one run per condition: RX 7900 XTX 24 GB,
`LEONIDA_RT_AS=off`, no skip list, all 721 in the journal), they all came from the journal (2,700 compute
pipelines from it against 1,900 with the skip list set; none built in the game) and the load reached the world.
One run (a local build of `main` with four then-open pull requests) stopped submitting after 404 s with the GPU idle
and no GPU fault; the other (`main` `bd6ba97ab`) lost the device about 214 s in, after a read page fault, with
every queue idle in the dispatch markers. The same idle-queue device loss also happens with the skip list set, so
it is not shown to come from these programs, and running them got no further than the skip list's best runs
(about 11 minutes, ending on a title breakpoint). Whether their output is correct is not measured. Our longest
runs used `LEONIDA_SKIP_COMPUTE=<name>,<name>,...` with those programs' names (picked by module size from
`<work>/shaders/spirv/library/index.json`), which drops their dispatches at play, and `LEONIDA_RT_AS=off`, which
drops acceleration-structure builds. The picture then lacks what they draw.

## Linux, Wine, AMD RX 7900 XTX (RADV)

Expand All @@ -39,6 +50,8 @@ reasons behind each step: [linux_proton.md](linux_proton.md#amd-on-linux-what-go
- **Pipeline pre-compile:** `wine <build>/gta6rt.exe --precompile-pipelines --threads 16` with the run's
`LEONIDA_SHADERS`, `LEONIDA_PIPELINE_CACHE_DIR` and `LEONIDA_DEVICE_FAULT`, before the first run. It built 3,693
compute pipelines. Not `make_game.py --stages pipelines`: its cache never matches the runtime's driver keys.
The pre-compile builds the programs `LEONIDA_SKIP_COMPUTE` names too (`--skip-listed` leaves them out) and ends
with one line that counts what it built, what was journaled already and what it left out.
- **Driver and OS:** `amdgpu.lockup_timeout=30000,60000,10000,10000` on the kernel command line (the default is
2000 ms; reboot needed).
- **Environment:**
Expand All @@ -52,7 +65,7 @@ reasons behind each step: [linux_proton.md](linux_proton.md#amd-on-linux-what-go
| `LEONIDA_STARTUP_CACHE_CHECKPOINTS=1` | session cache snapshots during the boot |
| `LEONIDA_ASYNC_PIPELINES=0` | draws wait for their pipeline instead of being skipped |
| `LEONIDA_SERIAL_BIG_COMPILES=0`, `LEONIDA_COMPUTE_WARMUP_MAX_BYTES=8388608` | warm-up limits, as in the NVIDIA report below |
| `LEONIDA_RT_AS=off`, `LEONIDA_SKIP_COMPUTE=<list>` | the large ray-tracing programs ([above](#settings-every-platform-needs)) |
| `LEONIDA_RT_AS=off`, `LEONIDA_SKIP_COMPUTE=<list>` | the large ray-tracing programs, left out at play as in our longest runs ([above](#settings-every-platform-needs)) |
| `LEONIDA_TITLE_WATCHDOG=0`, `LEONIDA_TITLE_WATCHDOG_KICK=<trap RVA>,<kick RVA>` | the title's hang watchdog ([above](#settings-every-platform-needs)) |
| `LEONIDA_DEVICE_TYPE=6`, `LEONIDA_MAP_READBACK=1`, `LEONIDA_FRAME_PACING=1`, `LEONIDA_PRESENT_NO_TEAR=1` | taken over from the NVIDIA report below; their effect on AMD was not measured one by one |
| `LEONIDA_ARENA_MB=4095`, `LEONIDA_TITLE_WINDOWS_MB=4096`, `LEONIDA_GEOMETRY_MB=6144` | room for the title's buffers in the world |
Expand Down Expand Up @@ -96,7 +109,10 @@ Reported by others: [#1608, comment 7184700506](https://github.com/ubiquitariani
`LEONIDA_DEVICE_TYPE=6`, `LEONIDA_TITLE_WATCHDOG=0`, `LEONIDA_MAP_READBACK=1`, `LEONIDA_HOST_IMAGE_COPY=0`,
`LEONIDA_ARENA_MB=4095`, `LEONIDA_TITLE_WINDOWS_MB=4096`, `LEONIDA_SERIAL_BIG_COMPILES=0`, `LEONIDA_FRAME_PACING=1`,
`LEONIDA_PRESENT_NO_TEAR=1`. The report gives the reason for the skip list only: without it the world start waits
hours on the ray-tracing programs; with asynchronous pipelines instead the screen stayed black.
hours on the ray-tracing programs; with asynchronous pipelines instead the screen stayed black. Those compile times
are the report's pack; a native wave64 pack builds them in seconds each ([above](#settings-every-platform-needs)).
Where they still take minutes, `gta6rt --precompile-pipelines --big-threads N` bounds how many build at once (each
held about 3.5 GB of host memory on an RTX 4070 Ti) and `--skip-listed` leaves the listed ones out.
- **Command:** TBD.
- **What to expect:** the opening night street from about 650 s, at 0.1-0.2 frames/s, no device loss through 934 s.
The black stretch before it is graphics pipelines of 1-2.6 MB SPIR-V compiling one at a time, 5-10 s each.
Expand Down
12 changes: 12 additions & 0 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4363,6 +4363,18 @@ if(TARGET Vulkan::Headers)
target_link_libraries(gta6rt PRIVATE gta6rt_d3d12_com user32) # user32: the PresentX window
target_compile_definitions(gta6rt PRIVATE LEONIDA_VULKAN_DEVICE)

# gta6rt --precompile-pipelines builds the programs LEONIDA_SKIP_COMPUTE names unless --skip-listed is given,
# and its last line counts both (shims/d3d12_precompile.h). Two synthetic compute modules, three runs.
if(TARGET gta6rt_compute_journal_shader)
add_dependencies(gta6rt gta6rt_indirect_count_shader gta6rt_compute_journal_shader)
add_test(NAME precompile_skip_list COMMAND ${CMAKE_COMMAND}
"-DGTA6RT=$<TARGET_FILE:gta6rt>" "-DRUNNER=${CMAKE_CROSSCOMPILING_EMULATOR}"
"-DSPV_A=${_indirect_count_spv}" "-DSPV_B=${_journal_second_spv}"
"-DTEST_DIR=${CMAKE_CURRENT_BINARY_DIR}/precompile_skip_list"
-P "${CMAKE_CURRENT_SOURCE_DIR}/test/check_precompile_skip_list.cmake")
set_tests_properties(precompile_skip_list PROPERTIES TIMEOUT 240 SKIP_REGULAR_EXPRESSION "SKIP: ")
endif()

# A stand-in title that imports d3d12_xs.dll!D3D12XboxCreateDevice and runs a clear and a readback on the
# device it gets, mapped and run by `gta6rt --run` with LEONIDA_D3D12=vulkan: the loader, the game thread, the
# proxies and the Vulkan device in one process. check_tiny_frame.py reads the verdict, the binding and the
Expand Down
6 changes: 6 additions & 0 deletions runtime/shims/d3d12_precompile.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
// (src/pipeline_cache_journal.h) under the name the game looks it up by, and in the driver's own disk cache, which
// NVIDIA keys by the executable's name. Entries whose journal file is there are skipped, so a run can be stopped at
// any time and started again.
//
// LEONIDA_SKIP_COMPUTE (the play-time list of compute programs whose dispatches are dropped) does not narrow the
// build: a player runs this with the game's environment, and a program kept out of the journal here would stay out
// after the list is shortened. --skip-listed leaves the listed entries out on purpose. The last line counts what was
// built, what was journaled already and what was left out, and why.
#pragma once

#include <cstddef>
Expand All @@ -25,6 +30,7 @@ struct PrecompileOptions {
std::size_t limit = 0; // at most this many entries (0: all)
std::size_t min_bytes = 0, max_bytes = 0; // SPIR-V size bounds (0: none)
std::vector<std::string> filters; // only entries whose name contains one of these
bool skip_listed = false; // --skip-listed: leave out the entries LEONIDA_SKIP_COMPUTE names
bool dry_run = false; // --list: print the plan, build nothing
bool via_helper = false; // --via-helper: as a title does with LEONIDA_COMPILE_HELPER=1 (a test)
};
Expand Down
Loading
Loading