runtime: add opt-in LEONIDA_GATE_TIMEOUT_MS and LEONIDA_SKIP_GRAPHICS #3509

Code

Clone this repository

Checkout

From your project repository, check out a new branch and test the changes.

git fetch -u  "runtime-gate-timeout-and-skip-graphics:cheezy_poof-runtime-gate-timeout-and-skip-graphics"
git switch "cheezy_poof-runtime-gate-timeout-and-skip-graphics"
Open
leonida/mandy
cheezy_poof wants to merge 2 commits from cheezy_poof/mandy:runtime-gate-timeout-and-skip-graphics into main

This branch is out-of-date with the base branch

Conversation
Reviewers 0 approvals
  • No reviewers
Details
This pull request is blocked because it's outdated.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'runtime-gate-timeout-and-skip-graphics:cheezy_poof-runtime-gate-timeout-and-skip-graphics'
git switch 'cheezy_poof-runtime-gate-timeout-and-skip-graphics'
First-time contributor

Summary

Adds two strictly opt-in diagnostic environment variables (both off by default when unset, zero behavior change otherwise):

  1. LEONIDA_GATE_TIMEOUT_MS (runtime/shims/d3d12_xs_list_values.h)
    • Releases an unmet list-value wait gate after N milliseconds in choose_release().
    • Strictly restricted to the front-most (FIFO) non-action gate per queue, ensuring Vulkan timeline semaphores are never signaled out of order.
  2. LEONIDA_SKIP_GRAPHICS (runtime/shims/d3d12_vulkan_device.cpp, runtime/src/vulkan_replay.h)
    • Graphics/mesh counterpart to LEONIDA_SKIP_COMPUTE: comma-separated substrings (or all/*) matched against shader stage names at pipeline creation.
    • Matching pipelines are marked skipped = true, omitted from collect_unbuilt_pipelines(), never compiled, and dropped cleanly in prepare_draw().
  3. Documentation (runtime/README.md)
    • Documents both env vars in the runtime environment table.

Verification

  • Built gta6rt.exe cleanly on Linux (xwin-sdk / clang-cl + Ninja).
  • Tested on Arch Linux, NVIDIA RTX 4060 Ti 8 GB (driver 620.73.04), GE-Proton10-34, native Vulkan backend (LEONIDA_D3D12=vulkan):
    • LEONIDA_GATE_TIMEOUT_MS released stalled list-value gates cleanly with 0 backwards timeline semaphore warnings.
    • LEONIDA_SKIP_GRAPHICS allowed isolating multi-second mesh pipelines identified by LEONIDA_GPU_PROFILE=1 that were tripping NVIDIA Xid 109 context-switch timeouts, cutting world frame time 6-15x and sustaining a 72.7-minute continuous world run (39,059 submissions, 0 VK_ERROR_DEVICE_LOST, 0 Xid errors, clean exit).
### Summary Adds two strictly opt-in diagnostic environment variables (both off by default when unset, zero behavior change otherwise): 1. **`LEONIDA_GATE_TIMEOUT_MS`** (`runtime/shims/d3d12_xs_list_values.h`) - Releases an unmet list-value wait gate after `N` milliseconds in `choose_release()`. - Strictly restricted to the **front-most (FIFO) non-action gate per queue**, ensuring Vulkan timeline semaphores are never signaled out of order. 2. **`LEONIDA_SKIP_GRAPHICS`** (`runtime/shims/d3d12_vulkan_device.cpp`, `runtime/src/vulkan_replay.h`) - Graphics/mesh counterpart to `LEONIDA_SKIP_COMPUTE`: comma-separated substrings (or `all`/`*`) matched against shader stage names at pipeline creation. - Matching pipelines are marked `skipped = true`, omitted from `collect_unbuilt_pipelines()`, never compiled, and dropped cleanly in `prepare_draw()`. 3. **Documentation** (`runtime/README.md`) - Documents both env vars in the runtime environment table. ### Verification - Built `gta6rt.exe` cleanly on Linux (xwin-sdk / clang-cl + Ninja). - Tested on Arch Linux, NVIDIA RTX 4060 Ti 8 GB (driver `620.73.04`), GE-Proton10-34, native Vulkan backend (`LEONIDA_D3D12=vulkan`): - `LEONIDA_GATE_TIMEOUT_MS` released stalled list-value gates cleanly with **0 backwards timeline semaphore warnings**. - `LEONIDA_SKIP_GRAPHICS` allowed isolating multi-second mesh pipelines identified by `LEONIDA_GPU_PROFILE=1` that were tripping NVIDIA `Xid 109` context-switch timeouts, cutting world frame time 6-15x and sustaining a **72.7-minute continuous world run** (39,059 submissions, 0 `VK_ERROR_DEVICE_LOST`, 0 Xid errors, clean exit).
Adds two diagnostic opt-in env vars (both off by default):

- LEONIDA_GATE_TIMEOUT_MS: FIFO-only timeout release for the front-most non-action list-value gate per queue in choose_release(), preventing deadlocks without reversing Vulkan timeline semaphores.
- LEONIDA_SKIP_GRAPHICS: graphics/mesh counterpart to LEONIDA_SKIP_COMPUTE for isolating or bypassing slow/timeout mesh/graphics shaders during profiling.
First-time contributor

finding: no test in this PR, and both switches are testable on the host without the game.

CONTRIBUTING.md (review checklist) asks a pull request to bring "a new test that fails on main and passes with the pull request". This diff adds four files and no test, and both new paths are pure env parsing:

  • skip_graphics() (runtime/shims/d3d12_vulkan_device.cpp) splits LEONIDA_SKIP_GRAPHICS on , and matches all/*/substring — same shape as the existing skip_compute().
  • gate_timeout_ms (runtime/shims/d3d12_xs_list_values.h) is a getenv_s + strtoull read into a function-local static.

There is already a home for such a test: runtime/test/ builds unit tests through CTest (runtime/CMakeLists.txt:609 assert_skip_test, and :1687 notes "the routes are read once per process, so each override case is its own test" — the same caveat applies to the two statics here).

Two behaviours worth pinning with a fixture, from reading the diff:

  1. skip_graphics with all, with an empty string, with a trailing comma, and with a name that must not match.
  2. The timeout loop marks a queue as seen before the if (gates_[i].action) continue; check, so a queue whose front gate is an action is never a timeout candidate. That is the intended FIFO guard, and it is the kind of rule that a small table test would keep from regressing.

I did not run anything beyond reading the diff: there is no test here to run, and the two code paths need a device to exercise end to end. No game data and no card were involved.

AI-assisted: yes, Hy4 flash. Finding only, no approval implied.

finding: no test in this PR, and both switches are testable on the host without the game. `CONTRIBUTING.md` (review checklist) asks a pull request to bring "a new test that fails on `main` and passes with the pull request". This diff adds four files and no test, and both new paths are pure env parsing: - `skip_graphics()` (`runtime/shims/d3d12_vulkan_device.cpp`) splits `LEONIDA_SKIP_GRAPHICS` on `,` and matches `all`/`*`/substring — same shape as the existing `skip_compute()`. - `gate_timeout_ms` (`runtime/shims/d3d12_xs_list_values.h`) is a `getenv_s` + `strtoull` read into a function-local static. There is already a home for such a test: `runtime/test/` builds unit tests through CTest (`runtime/CMakeLists.txt:609` `assert_skip_test`, and `:1687` notes "the routes are read once per process, so each override case is its own test" — the same caveat applies to the two statics here). Two behaviours worth pinning with a fixture, from reading the diff: 1. `skip_graphics` with `all`, with an empty string, with a trailing comma, and with a name that must not match. 2. The timeout loop marks a queue as seen before the `if (gates_[i].action) continue;` check, so a queue whose front gate is an action is never a timeout candidate. That is the intended FIFO guard, and it is the kind of rule that a small table test would keep from regressing. I did not run anything beyond reading the diff: there is no test here to run, and the two code paths need a device to exercise end to end. No game data and no card were involved. AI-assisted: yes, Hy4 flash. Finding only, no approval implied.
Addresses review feedback on #3509: extracts skip_graphics.h and gate_timeout.h and adds host-runnable CTest coverage (skip_graphics_and_gate_timeout_test).

AI-assisted: yes (Antigravity Neon)
First-time contributor

Verified again at head 0feb2a45 (the earlier head 37b6d9f0 had no test; this one adds src/skip_graphics.h, src/gate_timeout.h and runtime/test/skip_graphics_and_gate_timeout_test.cpp).

  • The test is absent on the merge base: git grep -F skip_graphics_and_gate_timeout_test f4b0404e -- runtime -> exit 1.
  • The test drives the same code the shims call: d3d12_vulkan_device.cpp:39 includes ../src/skip_graphics.h, d3d12_xs_list_values.h:64 includes ../src/gate_timeout.h. Nothing is duplicated into the fixture.
  • Built and ran the fixture directly with MSVC 19.44.35228 (x64, /std:c++20 /EHsc /W4 /permissive- /utf-8, no warnings), no GPU, no Win32, no CMake:
cl /nologo /std:c++20 /EHsc /W4 /permissive- /utf-8 runtime\test\skip_graphics_and_gate_timeout_test.cpp
skip_test.exe   -> 25 ok, 0 FAIL, "ALL PASSED", exit 0

It covers exactly the two cases my earlier finding named: all/*/empty/trailing comma/substring, and the FIFO rule (front non-action gate past timeout is released, non-front gate on same queue is never released ahead of front, queue with action at front is skipped, picks oldest eligible front-most gate across queues).

  • git diff --check f4b0404e refs/pr/3509 -> clean. python -I scripts/check_no_game_data.py on the two new headers, the fixture and the three touched sources -> clean.

I compiled the fixture by hand instead of through CMake, so the add_test(NAME skip_graphics_and_gate_timeout ...) wiring is only read, not executed.

GPUs tested: none (host-only unit test). Driver: n/a. No game data, assets or extracted shaders were used or attached. End-to-end behaviour of the timeout still needs a device with a blocked gate, which this report does not claim.

AI-assisted: yes, Hy4 flash (verification only). No approval implied.

Verified again at head `0feb2a45` (the earlier head `37b6d9f0` had no test; this one adds `src/skip_graphics.h`, `src/gate_timeout.h` and `runtime/test/skip_graphics_and_gate_timeout_test.cpp`). - The test is absent on the merge base: `git grep -F skip_graphics_and_gate_timeout_test f4b0404e -- runtime` -> exit 1. - The test drives the same code the shims call: `d3d12_vulkan_device.cpp:39` includes `../src/skip_graphics.h`, `d3d12_xs_list_values.h:64` includes `../src/gate_timeout.h`. Nothing is duplicated into the fixture. - Built and ran the fixture directly with MSVC 19.44.35228 (x64, `/std:c++20 /EHsc /W4 /permissive- /utf-8`, no warnings), no GPU, no Win32, no CMake: ``` cl /nologo /std:c++20 /EHsc /W4 /permissive- /utf-8 runtime\test\skip_graphics_and_gate_timeout_test.cpp skip_test.exe -> 25 ok, 0 FAIL, "ALL PASSED", exit 0 ``` It covers exactly the two cases my earlier finding named: `all`/`*`/empty/trailing comma/substring, and the FIFO rule (`front non-action gate past timeout is released`, `non-front gate on same queue is never released ahead of front`, `queue with action at front is skipped`, `picks oldest eligible front-most gate across queues`). - `git diff --check f4b0404e refs/pr/3509` -> clean. `python -I scripts/check_no_game_data.py` on the two new headers, the fixture and the three touched sources -> clean. I compiled the fixture by hand instead of through CMake, so the `add_test(NAME skip_graphics_and_gate_timeout ...)` wiring is only read, not executed. GPUs tested: none (host-only unit test). Driver: n/a. No game data, assets or extracted shaders were used or attached. End-to-end behaviour of the timeout still needs a device with a blocked gate, which this report does not claim. AI-assisted: yes, Hy4 flash (verification only). No approval implied.
First-time contributor

Test report from an MSVC build (I changed no code). Not a review of the code.

  • Head 0feb2a45b merged onto main 93b9d90a2: clean merge.
  • MSVC (Visual Studio 2022), RelWithDebInfo, Windows 11, Intel i7-13700KF, RTX 3060 Ti 8 GB, driver 610.88.
  • cmake --build of the whole runtime: exit 0.
  • ctest -C RelWithDebInfo -j 2: 471 of 475 passed. The new skip_graphics_and_gate_timeout test passed.
  • The 4 failures also fail on main on this machine and are not from this change: d3d12_existing_heap and d3d12_existing_heap_write_watch (#3512), xbox_present (#3513), run_tiny_tls_ga with LEONIDA_TEST_DIR set (#3514).
  • Not run: the two switches in a real run, the clean-room check.

GPUs tested: RTX 3060 Ti 8 GB, driver 610.88. No game files were used.

AI-assisted: yes (Claude Code, Claude Fable 5.2; verification only).

Test report from an MSVC build (I changed no code). Not a review of the code. - Head `0feb2a45b` merged onto `main` `93b9d90a2`: clean merge. - MSVC (Visual Studio 2022), RelWithDebInfo, Windows 11, Intel i7-13700KF, RTX 3060 Ti 8 GB, driver 610.88. - `cmake --build` of the whole runtime: exit 0. - `ctest -C RelWithDebInfo -j 2`: **471 of 475 passed**. The new `skip_graphics_and_gate_timeout` test passed. - The 4 failures also fail on `main` on this machine and are not from this change: `d3d12_existing_heap` and `d3d12_existing_heap_write_watch` (#3512), `xbox_present` (#3513), `run_tiny_tls_ga` with `LEONIDA_TEST_DIR` set (#3514). - Not run: the two switches in a real run, the clean-room check. GPUs tested: RTX 3060 Ti 8 GB, driver 610.88. No game files were used. AI-assisted: yes (Claude Code, Claude Fable 5.2; verification only).
Sign in to join this conversation.
No description provided.