d3d12/vulkan: batch indirect clamp windows and lift default overflow cap (RT-INDIRECT-CLAMP-WINDOWS) #3331

Open
azsekazvamdimitar wants to merge 3 commits from upstream-pr/3331 into main
azsekazvamdimitar commented 2026-12-03 12:58:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by azsekazvamdimitar on 2026-12-03T12:58:26Z.


Claimed in the coordination issue as: RT-INDIRECT-CLAMP-WINDOWS (https://github.com/ProjectLeonida/mandy/issues/3312#issuecomment-7377256952)

What and why

Two changes to gta6rt (runtime/), both measured in the prologue cell on an RTX 3090 with Resizable BAR.

1. Clamp windows: the clamped indirect draws of a run share one clamp pass and one rendering scope.
Every indirect draw the title records goes through the GPU argument clamp. Until now each clamped draw ended the
rendering scope, recorded its own clamp pass with two full ALL_COMMANDS barriers and a graphics/compute switch, and
began rendering again (attachment transitions, LOAD/STORE of every target). The cell issues about 3,800 such draws
a frame, and this per-draw overhead was most of the mesh time.

emit_commands now gathers the clamps of consecutive raster draws into a window (detail::clamp_window). It records
them in one pass before the window's first draw (IndirectArgumentClamp::emit takes a span of calls: fills per call,
one wait, one bind, a dispatch per call, one stats copy barrier, one release barrier). The later clamped draws of the
window keep the rendering scope when their attachments match. A window ends:

  • at any command that is not a draw;
  • at a pipeline-statistics segment (the passes stay outside the queries);
  • after a draw whose pipeline may write buffers (writes_buffer) or storage (writes_storage, new: any stage
    declaring a writable storage image or buffer, spirv_declares_writable_storage);
  • before a clamped draw that may write buffers or storage, when it is not the window's first: it opens its own window,
    so the full barrier a clamp pass ends with still separates it from the draws before it, as on main.

Draws in one rendering scope get no barrier between them, so a later draw must not read what an earlier one of the
window wrote. Without the writes_storage break the cell's interior went black: some pixel shaders write storage
images, which writes_buffer does not cover. The clamp passes of a window charge the list's work budget in one
dispatch, so if a list ever exhausts it (0 records over budget in every boot measured) which draw goes empty is not
fixed. Non-clamped draws that share a rendering scope after a storage-writing draw get no barrier either; that is
the same on main and not changed here.

2. No default budget for overflow title-buffer windows.
#2865 added a default cap to external_window_cap (2 GiB unstaged, 4 GiB staged). At world load the arena (4094 MiB,
capped by maxMemoryAllocationSize) fills, and the overflow windows outside it need more than that. Each refusal logs
GPU address arena full ... title memory has no window and leaves title memory without a GPU copy. In the cell this
loses the walls, the bunk bed and the photos (50 refusals in one boot, with the overflow at 512 blocks of 4 MiB, the
whole 2 GiB). LEONIDA_EXTERNAL_WINDOWS_MB still sets a budget (a whole number of MiB; anything else is ignored);
unset, a window is refused only when memory runs out, which is what the code did before #2865
(parse_external_windows_budget, docs/d3d12_vulkan.md updated). Only a 24 GB card was measured; on a smaller one
the overflow competes with everything else for VRAM and host-visible memory either way.

Tested

Measured on an RTX 3090 24 GB, NVIDIA 590.48.01, Debian 13 (Linux 6.12), GE-Proton (gta6rt.exe built with
clang-cl/xwin), Resizable BAR on and the default arena placement. Series S profile (1920x1080 output, 1280x720
internal). Each run is one 360 s boot from cold start into the prologue cell with a fixed input script. The fps is the
median of the runtime's 10 s submit frame windows from t = 215 s (14 windows):

Build fps median (range) title memory has no window Cell
#2865 head (same runtime as main), default cap (2 GiB) 4.00 (3.90-4.20) 50 walls, bed and photos missing
this PR, cap fix only 4.00 (3.70-4.10) 0 complete
this PR (cap fix + clamp windows) 8.40 (6.70-8.60) 0 complete
clamp windows without the writes_storage break 8.60 0 interior black (rejected)

GPU split with LEONIDA_GPU_PROFILE=1 (ms per frame, mean of the reports after t = 250 s). Without the clamp windows,
the same runtime on a shader farm of the same speed (the profiler's own scope splits cost fps, so compare the split):

without clamp windows this PR
direct-queue busy 250.2 141.1
mesh 180.5 64.6
compute 64.7 73.1
graphics 10.6 8.5
mesh calls per frame 7,853 7,803

The heaviest pipeline (ped mesh + deferred ped pixel shader) went from 19.9 to 1.2 ms a frame. Screenshots of the last
minute of each boot show the cell complete (walls, window and yard, photos, bunk bed). They show game content, so they
are not attached.

Tests (Linux clang build of the portable subset, plus the Windows build of gta6rt and d3d12_indirect_rt_test):

  • replay_state_cache_test case 5c-2: windows end at a buffer-writing draw, a storage-writing draw and a
    dispatch, and a later clamped writer opens its own window. Case 5c-3: a skipped draw stays inside a window, and
    inside a pipeline-statistics query each clamped draw gets its own pass between two segments. Red, each by one edit
    of detail::clamp_window in a copy of the source: one-draw windows (the former behaviour) fail 5c-2 and 5c-3; a
    writer joining the window fails 5c-2; no statistics break fails 5c-3.
  • indirect_clamp_test (live Vulkan, RTX 3090): four calls in one pass, three sharing a list budget, clamp like four
    separate passes; validation errors 0.
  • arena_staging_test test_external_windows_budget: red with the former 2 GiB default (unset, empty and invalid
    values give no budget, 2048 gives 2 GiB, 2G is ignored).
  • replay_dropped_indirect_clamp_test and ctest pass. The exception is console_list_records, which does not
    compile with Linux clang on main either (-Wc++11-narrowing in console_list_records_test.cpp:147-159, a file this
    PR does not touch).
  • python -m unittest discover -s tests -p "test_docs_*.py" (59 tests pass).
  • python -I scripts/check_no_game_data.py on the changed files.

GPUs tested: NVIDIA RTX 3090 24 GB, driver 590.48.01, Linux 6.12 + GE-Proton (Wine).

AI-assisted: yes. The changes were written with Claude Opus 5.5 and Gemini 4 Neon (OpenCode / oh-my-opencode) and
reviewed by a separate read-only reviewer agent (oh-my-opencode oracle).

Not in this PR (pre-existing, found while measuring):

  • Forcing LEONIDA_DEVICE_LOCAL_ARENA=1 on a Resizable BAR card loses walls and window frames in the cell. This
    happens with or without this PR, and with builds from before #2865's last commit. The default (auto) is not
    affected.
  • TitleBufferWindows: a destroyed block keeps its Published::staged pointer, and commit_uploads/staging_stats
    check only that pointer. Published slots are never reused, so after 4,096 block creations new blocks go
    unpublished. No log of ours shows the churn needed to reach that.

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (no translator change)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5626969089 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3331). Originally posted by [azsekazvamdimitar](https://github.com/azsekazvamdimitar) on 2026-12-03T12:58:26Z. --- Claimed in the coordination issue as: RT-INDIRECT-CLAMP-WINDOWS (https://github.com/ProjectLeonida/mandy/issues/3312#issuecomment-7377256952) ### What and why Two changes to gta6rt (`runtime/`), both measured in the prologue cell on an RTX 3090 with Resizable BAR. **1. Clamp windows: the clamped indirect draws of a run share one clamp pass and one rendering scope.** Every indirect draw the title records goes through the GPU argument clamp. Until now each clamped draw ended the rendering scope, recorded its own clamp pass with two full `ALL_COMMANDS` barriers and a graphics/compute switch, and began rendering again (attachment transitions, `LOAD`/`STORE` of every target). The cell issues about 3,800 such draws a frame, and this per-draw overhead was most of the mesh time. `emit_commands` now gathers the clamps of consecutive raster draws into a window (`detail::clamp_window`). It records them in one pass before the window's first draw (`IndirectArgumentClamp::emit` takes a span of calls: fills per call, one wait, one bind, a dispatch per call, one stats copy barrier, one release barrier). The later clamped draws of the window keep the rendering scope when their attachments match. A window ends: - at any command that is not a draw; - at a pipeline-statistics segment (the passes stay outside the queries); - after a draw whose pipeline may write buffers (`writes_buffer`) or storage (`writes_storage`, new: any stage declaring a writable storage image or buffer, `spirv_declares_writable_storage`); - before a clamped draw that may write buffers or storage, when it is not the window's first: it opens its own window, so the full barrier a clamp pass ends with still separates it from the draws before it, as on `main`. Draws in one rendering scope get no barrier between them, so a later draw must not read what an earlier one of the window wrote. Without the `writes_storage` break the cell's interior went black: some pixel shaders write storage images, which `writes_buffer` does not cover. The clamp passes of a window charge the list's work budget in one dispatch, so if a list ever exhausts it (0 records over budget in every boot measured) which draw goes empty is not fixed. Non-clamped draws that share a rendering scope after a storage-writing draw get no barrier either; that is the same on `main` and not changed here. **2. No default budget for overflow title-buffer windows.** #2865 added a default cap to `external_window_cap` (2 GiB unstaged, 4 GiB staged). At world load the arena (4094 MiB, capped by `maxMemoryAllocationSize`) fills, and the overflow windows outside it need more than that. Each refusal logs `GPU address arena full ... title memory has no window` and leaves title memory without a GPU copy. In the cell this loses the walls, the bunk bed and the photos (50 refusals in one boot, with the overflow at 512 blocks of 4 MiB, the whole 2 GiB). `LEONIDA_EXTERNAL_WINDOWS_MB` still sets a budget (a whole number of MiB; anything else is ignored); unset, a window is refused only when memory runs out, which is what the code did before #2865 (`parse_external_windows_budget`, `docs/d3d12_vulkan.md` updated). Only a 24 GB card was measured; on a smaller one the overflow competes with everything else for VRAM and host-visible memory either way. ### Tested Measured on an RTX 3090 24 GB, NVIDIA 590.48.01, Debian 13 (Linux 6.12), GE-Proton (`gta6rt.exe` built with clang-cl/xwin), Resizable BAR on and the default arena placement. Series S profile (1920x1080 output, 1280x720 internal). Each run is one 360 s boot from cold start into the prologue cell with a fixed input script. The fps is the median of the runtime's 10 s `submit frame` windows from t = 215 s (14 windows): | Build | fps median (range) | `title memory has no window` | Cell | |---|---:|---:|---| | #2865 head (same runtime as `main`), default cap (2 GiB) | 4.00 (3.90-4.20) | 50 | walls, bed and photos missing | | this PR, cap fix only | 4.00 (3.70-4.10) | 0 | complete | | this PR (cap fix + clamp windows) | **8.40** (6.70-8.60) | 0 | complete | | clamp windows without the `writes_storage` break | 8.60 | 0 | interior black (rejected) | GPU split with `LEONIDA_GPU_PROFILE=1` (ms per frame, mean of the reports after t = 250 s). Without the clamp windows, the same runtime on a shader farm of the same speed (the profiler's own scope splits cost fps, so compare the split): | | without clamp windows | this PR | |---|---:|---:| | direct-queue busy | 250.2 | **141.1** | | mesh | 180.5 | **64.6** | | compute | 64.7 | 73.1 | | graphics | 10.6 | 8.5 | | mesh calls per frame | 7,853 | 7,803 | The heaviest pipeline (ped mesh + deferred ped pixel shader) went from 19.9 to 1.2 ms a frame. Screenshots of the last minute of each boot show the cell complete (walls, window and yard, photos, bunk bed). They show game content, so they are not attached. Tests (Linux clang build of the portable subset, plus the Windows build of `gta6rt` and `d3d12_indirect_rt_test`): - `replay_state_cache_test` case 5c-2: windows end at a buffer-writing draw, a storage-writing draw and a dispatch, and a later clamped writer opens its own window. Case 5c-3: a skipped draw stays inside a window, and inside a pipeline-statistics query each clamped draw gets its own pass between two segments. Red, each by one edit of `detail::clamp_window` in a copy of the source: one-draw windows (the former behaviour) fail 5c-2 and 5c-3; a writer joining the window fails 5c-2; no statistics break fails 5c-3. - `indirect_clamp_test` (live Vulkan, RTX 3090): four calls in one pass, three sharing a list budget, clamp like four separate passes; validation errors 0. - `arena_staging_test` `test_external_windows_budget`: red with the former 2 GiB default (unset, empty and invalid values give no budget, `2048` gives 2 GiB, `2G` is ignored). - `replay_dropped_indirect_clamp_test` and `ctest` pass. The exception is `console_list_records`, which does not compile with Linux clang on `main` either (`-Wc++11-narrowing` in `console_list_records_test.cpp:147-159`, a file this PR does not touch). - `python -m unittest discover -s tests -p "test_docs_*.py"` (59 tests pass). - `python -I scripts/check_no_game_data.py` on the changed files. GPUs tested: NVIDIA RTX 3090 24 GB, driver 590.48.01, Linux 6.12 + GE-Proton (Wine). AI-assisted: yes. The changes were written with Claude Opus 5.5 and Gemini 4 Neon (OpenCode / oh-my-opencode) and reviewed by a separate read-only reviewer agent (oh-my-opencode `oracle`). Not in this PR (pre-existing, found while measuring): - Forcing `LEONIDA_DEVICE_LOCAL_ARENA=1` on a Resizable BAR card loses walls and window frames in the cell. This happens with or without this PR, and with builds from before #2865's last commit. The default (`auto`) is not affected. - `TitleBufferWindows`: a destroyed block keeps its `Published::staged` pointer, and `commit_uploads`/`staging_stats` check only that pointer. Published slots are never reused, so after 4,096 block creations new blocks go unpublished. No log of ours shows the churn needed to reach that. ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (no translator change)
merzleckeier commented 2026-12-03 13:04:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T13:04:43Z.


I tested 444a7509 on b053a181 with native Vulkan on an RTX 4070 SUPER (620.73.04) and the Ryzen 7800X3D iGPU (RADV 26.3.1). indirect_clamp_test passed on both with Khronos synchronization validation enabled and zero validation errors. The replay-state-cache suite, SPIR-V storage classifier, arena-staging tests, and dropped-clamp test passed. A separate CPU replay fixture also verified that two read-only indirect draws can share a clamp pass across different attachments and still open separate rendering scopes. A direct storage-writing draw ended that window so the following draw got its own clamp pass.

One small parser issue in parse_external_windows_budget: std::strtoull accepts a leading minus sign and negates in the unsigned result type. On this head, -18446744073709551615 sets a 1 MiB cap, and -18446744073709551614 sets a 2 MiB cap. Both should take the documented invalid-value path. The earlier parser used the same conversion. In a local test, rejecting a minus sign after leading whitespace fixed both cases and preserved the positive, zero, unset, and out-of-range controls.

Synthetic CPU and GPU tests. AI-assisted (Codex).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7379280120 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3331#issuecomment-7379280120). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T13:04:43Z. --- I tested `444a7509` on `b053a181` with native Vulkan on an RTX 4070 SUPER (620.73.04) and the Ryzen 7800X3D iGPU (RADV 26.3.1). `indirect_clamp_test` passed on both with Khronos synchronization validation enabled and zero validation errors. The replay-state-cache suite, SPIR-V storage classifier, arena-staging tests, and dropped-clamp test passed. A separate CPU replay fixture also verified that two read-only indirect draws can share a clamp pass across different attachments and still open separate rendering scopes. A direct storage-writing draw ended that window so the following draw got its own clamp pass. One small parser issue in `parse_external_windows_budget`: `std::strtoull` accepts a leading minus sign and negates in the unsigned result type. On this head, `-18446744073709551615` sets a **1 MiB** cap, and ` -18446744073709551614` sets a **2 MiB** cap. Both should take the documented invalid-value path. The earlier parser used the same conversion. In a local test, rejecting a minus sign after leading whitespace fixed both cases and preserved the positive, zero, unset, and out-of-range controls. Synthetic CPU and GPU tests. AI-assisted (Codex).
azsekazvamdimitar commented 2026-12-03 13:13:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by azsekazvamdimitar on 2026-12-03T13:13:49Z.


Thanks for testing on the 4070 SUPER and RADV with sync validation, and good catch on strtoull wrapping signed inputs.

Fixed in bc5969f0a: parse_external_windows_budget now skips leading whitespace and requires a leading digit before calling std::strtoull (rejecting - and +). Added -1, -18446744073709551615, -18446744073709551614, and +2048 cases to test_external_windows_budget (verified red on 444a7509d at -18446744073709551615, green after the fix; rebuilt Windows gta6rt and ran check_no_game_data.py).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7379503813 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3331#issuecomment-7379503813). Originally posted by [azsekazvamdimitar](https://github.com/azsekazvamdimitar) on 2026-12-03T13:13:49Z. --- Thanks for testing on the 4070 SUPER and RADV with sync validation, and good catch on `strtoull` wrapping signed inputs. Fixed in bc5969f0a: `parse_external_windows_budget` now skips leading whitespace and requires a leading digit before calling `std::strtoull` (rejecting `-` and `+`). Added `-1`, `-18446744073709551615`, ` -18446744073709551614`, and `+2048` cases to `test_external_windows_budget` (verified red on `444a7509d` at `-18446744073709551615`, green after the fix; rebuilt Windows `gta6rt` and ran `check_no_game_data.py`).
Kal0s-design commented 2026-12-03 14:46:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-03T14:46:49Z.


Ran natively on Windows 11, head bc5969f0a merged into current main (128579e9e, clean merge).

Nothing broke. I have one small Windows point about the env parser.

LEONIDA_EXTERNAL_WINDOWS_MB with a trailing space. In cmd, set LEONIDA_EXTERNAL_WINDOWS_MB=64 && gta6rt ... stores the value as 64 , with the space (measured: echo [!VAR!] prints [64 ]). parse_external_windows_budget("64 ") returns no budget. Before, that line gave a 64 MiB cap. 64MB behaves the same way. This matches the comment ("anything but a whole number of MiB: no budget"), but the failure direction has flipped. A sloppy value used to still give you a cap, and now it removes the cap without saying so. Trimming trailing whitespace, or one log line when the variable is set but rejected, would cover it.

Parser values (measured by calling the header function directly). The "before" column is main's strtoull + mb > 0 logic, reproduced in the same probe.

value this PR before
unset, empty, spaces only no budget default (2/4 GiB)
0, 00 no budget default
1, 010, 4096 1, 10, 4096 MiB same
64, \t64 64 MiB 64 MiB
64 , 64\n no budget 64 MiB
64MB, 64M, 1.5, 1e3 no budget 64, 64, 1, 1 MiB
0x10 no budget default
17592186044415 (largest that fits after << 20) that many MiB same
17592186044416 up to past u64 no budget shift overflows

Read, not run: the shim reads the variable into a 32-byte buffer, so a value of 32 chars or more is "no budget" too.

Tests (measured). MSVC, Ninja, RelWithDebInfo, only the five targets this PR touches. Validation on with LEONIDA_VK_VALIDATION=1 (the tests add sync validation through VkValidationFeaturesEXT), plus VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and VK_LAYER_VALIDATE_SYNC=1. This SDK's layer flags VK_LAYER_ENABLES as deprecated and says it overrides the new settings, so I didn't use it for these runs.

test main merge validation messages, merge (3 runs) and main
indirect_clamp_test pass, 91 records clamped in 4120 calls pass, 92 in 4124 (the new span case) 0 / 0
replay_state_cache_test ALL PASS ALL PASS 0 / 0
d3d12_indirect_rt_test PASS PASS 0 / 0
same, LEONIDA_UPLOAD_SYSMEM=1 PASS PASS 0 / 0
arena_staging_test OK OK n/a (no Vulkan instance)
replay_dropped_indirect_clamp_test ok ok n/a (no Vulkan instance)

The GPU tests picked the discrete NVIDIA card. The PR's test files don't compile against main's sources. All five fail on the API change (emit taking a span, writes_storage, parse_external_windows_budget), so I couldn't show red/green by swapping files. MSVC /W4: a clean rebuild of the five targets gives 276 warnings on both, with the same count for every warning code.

Window edge cases (measured). Throwaway cases in the trace fixture of replay_state_cache_test, with the PR's reads_only pipeline unless the row says otherwise:

sequence events
ind, direct read-only draw, ind (end of list) clamp2 begin_rp draw_ind draw draw_ind end_rp
ind, direct writing draw, ind clamp1 begin_rp draw_ind draw end_rp clamp1 begin_rp draw_ind end_rp
ind, indexed ind, ind clamp3 begin_rp draw_ind draw_idx_ind draw_ind end_rp
skipped ind first, ind, ind clamp2 begin_rp draw_ind draw_ind end_rp
writing ind first, ind, ind clamp1 ... end_rp clamp2 begin_rp draw_ind draw_ind end_rp
ind, BeginQuery occlusion, ind, ind, EndQuery clamp1 ... end_rp begin_q clamp2 begin_rp draw_ind draw_ind end_rp end_q
ind, ind with max_count 0, ind clamp2 begin_rp draw_ind draw_ind end_rp (no draw recorded for the middle one)
ind, SetPredication, ind, ind clamp1 ... end_rp begin_pred end_pred clamp2 begin_pred begin_rp draw_ind draw_ind end_rp end_pred
ind, ind writing a storage image, direct read-only draw, ind clamp1 ... clamp1 begin_rp draw_ind draw end_rp clamp1 begin_rp draw_ind end_rp

All match the rules in the docs. A direct draw that writes closes the window the same way an indirect one does, so the next clamp still gets its full barrier.

Read, not run: the replay records no secondary command buffers and no suspending/resuming rendering scopes, so a window can't cross one. Clears, BeginQuery and SetPredication are commands, so a window ends before them, and a load op can't change mid-window. A statistics query starting mid-sequence is the BeginQuery case, and the PR's 5c-3 covers the per-draw segments.

Conflicts: four open PRs touch the same files. #3142 and #3160 merge cleanly on top of this. #3228 and #2580 have the same conflicts with this PR as with main. This PR adds none.

Not checked: the game, and the frame-time numbers in the docs. What "no budget" does once VRAM is full. A GPU count that clamps to zero inside a pass with several jobs. A counted indirect draw inside a window (in my fixture case the counted draw recorded nothing).

GPUs tested: one NVIDIA desktop card (native Vulkan).
AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7382019157 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3331#issuecomment-7382019157). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-03T14:46:49Z. --- Ran natively on Windows 11, head `bc5969f0a` merged into current `main` (`128579e9e`, clean merge). Nothing broke. I have one small Windows point about the env parser. **`LEONIDA_EXTERNAL_WINDOWS_MB` with a trailing space.** In cmd, `set LEONIDA_EXTERNAL_WINDOWS_MB=64 && gta6rt ...` stores the value as `64 `, with the space (measured: `echo [!VAR!]` prints `[64 ]`). `parse_external_windows_budget("64 ")` returns no budget. Before, that line gave a 64 MiB cap. `64MB` behaves the same way. This matches the comment ("anything but a whole number of MiB: no budget"), but the failure direction has flipped. A sloppy value used to still give you a cap, and now it removes the cap without saying so. Trimming trailing whitespace, or one log line when the variable is set but rejected, would cover it. Parser values (measured by calling the header function directly). The "before" column is `main`'s `strtoull` + `mb > 0` logic, reproduced in the same probe. | value | this PR | before | |---|---|---| | unset, empty, spaces only | no budget | default (2/4 GiB) | | `0`, `00` | no budget | default | | `1`, `010`, `4096` | 1, 10, 4096 MiB | same | | ` 64`, `\t64` | 64 MiB | 64 MiB | | `64 `, `64\n` | **no budget** | 64 MiB | | `64MB`, `64M`, `1.5`, `1e3` | **no budget** | 64, 64, 1, 1 MiB | | `0x10` | no budget | default | | `17592186044415` (largest that fits after `<< 20`) | that many MiB | same | | `17592186044416` up to past u64 | no budget | shift overflows | Read, not run: the shim reads the variable into a 32-byte buffer, so a value of 32 chars or more is "no budget" too. **Tests** (measured). MSVC, Ninja, RelWithDebInfo, only the five targets this PR touches. Validation on with `LEONIDA_VK_VALIDATION=1` (the tests add sync validation through `VkValidationFeaturesEXT`), plus `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` and `VK_LAYER_VALIDATE_SYNC=1`. This SDK's layer flags `VK_LAYER_ENABLES` as deprecated and says it overrides the new settings, so I didn't use it for these runs. | test | `main` | merge | validation messages, merge (3 runs) and `main` | |---|---|---|---| | `indirect_clamp_test` | pass, 91 records clamped in 4120 calls | pass, 92 in 4124 (the new span case) | 0 / 0 | | `replay_state_cache_test` | ALL PASS | ALL PASS | 0 / 0 | | `d3d12_indirect_rt_test` | PASS | PASS | 0 / 0 | | same, `LEONIDA_UPLOAD_SYSMEM=1` | PASS | PASS | 0 / 0 | | `arena_staging_test` | OK | OK | n/a (no Vulkan instance) | | `replay_dropped_indirect_clamp_test` | ok | ok | n/a (no Vulkan instance) | The GPU tests picked the discrete NVIDIA card. The PR's test files don't compile against `main`'s sources. All five fail on the API change (`emit` taking a span, `writes_storage`, `parse_external_windows_budget`), so I couldn't show red/green by swapping files. MSVC `/W4`: a clean rebuild of the five targets gives 276 warnings on both, with the same count for every warning code. **Window edge cases** (measured). Throwaway cases in the trace fixture of `replay_state_cache_test`, with the PR's `reads_only` pipeline unless the row says otherwise: | sequence | events | |---|---| | ind, direct read-only draw, ind (end of list) | `clamp2 begin_rp draw_ind draw draw_ind end_rp` | | ind, direct writing draw, ind | `clamp1 begin_rp draw_ind draw end_rp clamp1 begin_rp draw_ind end_rp` | | ind, indexed ind, ind | `clamp3 begin_rp draw_ind draw_idx_ind draw_ind end_rp` | | skipped ind first, ind, ind | `clamp2 begin_rp draw_ind draw_ind end_rp` | | writing ind first, ind, ind | `clamp1 ... end_rp clamp2 begin_rp draw_ind draw_ind end_rp` | | ind, BeginQuery occlusion, ind, ind, EndQuery | `clamp1 ... end_rp begin_q clamp2 begin_rp draw_ind draw_ind end_rp end_q` | | ind, ind with `max_count` 0, ind | `clamp2 begin_rp draw_ind draw_ind end_rp` (no draw recorded for the middle one) | | ind, SetPredication, ind, ind | `clamp1 ... end_rp begin_pred end_pred clamp2 begin_pred begin_rp draw_ind draw_ind end_rp end_pred` | | ind, ind writing a storage image, direct read-only draw, ind | `clamp1 ... clamp1 begin_rp draw_ind draw end_rp clamp1 begin_rp draw_ind end_rp` | All match the rules in the docs. A direct draw that writes closes the window the same way an indirect one does, so the next clamp still gets its full barrier. Read, not run: the replay records no secondary command buffers and no suspending/resuming rendering scopes, so a window can't cross one. Clears, `BeginQuery` and `SetPredication` are commands, so a window ends before them, and a load op can't change mid-window. A statistics query starting mid-sequence is the `BeginQuery` case, and the PR's 5c-3 covers the per-draw segments. Conflicts: four open PRs touch the same files. #3142 and #3160 merge cleanly on top of this. #3228 and #2580 have the same conflicts with this PR as with `main`. This PR adds none. Not checked: the game, and the frame-time numbers in the docs. What "no budget" does once VRAM is full. A GPU count that clamps to zero inside a pass with several jobs. A counted indirect draw inside a window (in my fixture case the counted draw recorded nothing). GPUs tested: one NVIDIA desktop card (native Vulkan). AI-assisted: yes (Claude Code).
moffington commented 2026-12-03 15:11:56 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by moffington on 2026-12-03T15:11:56Z.


Ran synthetic tests only on PR 3331 at bc5969f0a: native Linux clang build, RTX 3060 12GB, driver 615.78.08.

  • Full ctest: 154 passed, 5 skipped, and console_list_records didn't compile (the PR already notes this).
  • indirect_clamp, indirect_clamp_safety, replay_state_cache, replay_dropped_indirect_clamp, arena_staging and spirv_stores passed with the Khronos validation layer and sync validation on, with no validation errors in the log.
  • The sync validation self-test, skipped in the full run, passed when enabled.
  • Not tested: the game, fps, VRAM use with the cap removed, or the Windows build (including d3d12_indirect_rt_test).

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7382731723 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3331#issuecomment-7382731723). Originally posted by [moffington](https://github.com/moffington) on 2026-12-03T15:11:56Z. --- Ran synthetic tests only on PR 3331 at bc5969f0a: native Linux clang build, RTX 3060 12GB, driver 615.78.08. - Full ctest: 154 passed, 5 skipped, and console_list_records didn't compile (the PR already notes this). - indirect_clamp, indirect_clamp_safety, replay_state_cache, replay_dropped_indirect_clamp, arena_staging and spirv_stores passed with the Khronos validation layer and sync validation on, with no validation errors in the log. - The sync validation self-test, skipped in the full run, passed when enabled. - Not tested: the game, fps, VRAM use with the cap removed, or the Windows build (including d3d12_indirect_rt_test). AI-assisted (Claude Code).
azsekazvamdimitar commented 2026-12-03 15:50:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by azsekazvamdimitar on 2026-12-03T15:50:23Z.


Thanks for the Windows run, the edge-case fixture table and the conflict check. The trailing-space case is a real trap with set VAR=64 && ....

Fixed in cc6a1acc0:

  • parse_external_windows_budget now accepts whitespace on both sides, so 64 and \t64\n give a 64 MiB budget again.
  • Any other set value (64MB, 1.5, 1e3, 0x10, signed values, a number too large to shift, or a value too long for the 32-byte read) is still ignored, but no longer silently: the shim prints one [rt] d3d12: LEONIDA_EXTERNAL_WINDOWS_MB is not a whole number of MiB; ignored, ... line. Unset, blank and 0 still mean no budget, with no message.
  • test_external_windows_budget covers the trimmed values, the largest value that fits, and the rejected flag for each of those inputs. It fails at "64 " with the trim removed and passes with it. Rebuilt Windows gta6rt; the docs line says the same.

AI-assisted (Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7383818490 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3331#issuecomment-7383818490). Originally posted by [azsekazvamdimitar](https://github.com/azsekazvamdimitar) on 2026-12-03T15:50:23Z. --- Thanks for the Windows run, the edge-case fixture table and the conflict check. The trailing-space case is a real trap with `set VAR=64 && ...`. Fixed in cc6a1acc0: - `parse_external_windows_budget` now accepts whitespace on both sides, so `64 ` and `\t64\n` give a 64 MiB budget again. - Any other set value (`64MB`, `1.5`, `1e3`, `0x10`, signed values, a number too large to shift, or a value too long for the 32-byte read) is still ignored, but no longer silently: the shim prints one `[rt] d3d12: LEONIDA_EXTERNAL_WINDOWS_MB is not a whole number of MiB; ignored, ...` line. Unset, blank and `0` still mean no budget, with no message. - `test_external_windows_budget` covers the trimmed values, the largest value that fits, and the rejected flag for each of those inputs. It fails at `"64 "` with the trim removed and passes with it. Rebuilt Windows `gta6rt`; the docs line says the same. AI-assisted (Claude Opus 5.5).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3331:upstream-pr/3331'
git switch 'upstream-pr/3331'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3331'
git switch 'upstream-pr/3331'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3331'
git switch 'upstream-pr/3331'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3331'
git switch 'main'
git merge --squash 'upstream-pr/3331'
git switch 'main'
git merge --ff-only 'upstream-pr/3331'
git switch 'main'
git merge 'upstream-pr/3331'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!3331
No description provided.