d3d12: use GPU count buffers for indirect mesh dispatches #429

Closed
github-bot wants to merge 2 commits from github-bot/gh-429 into main AGit
Owner

@⁠PyZikYG on GitHub · 2026-11-24 05:05 UTC · original
PyZikYG:vulkan-mesh-dispatch-count → main · +144 −25 · 8 files · 2 commits · closed without merging

Claimed as D3D-MESH-INDIRECT-COUNT.

Depends on: #424

A mesh-only ExecuteIndirect command with a GPU count buffer previously failed recording. This change reuses the compute indirect-count helper to prepare compact mesh dispatch records on the GPU. It reads the count at execution and writes zero-group records beyond the count, so even a UINT32_MAX counter is bounded by MaxCommandCount before drawing. The helper runs outside pipeline statistics queries. The count path requires buffer device addresses and compute scratch.

This PR includes the rebased #424 commit until #424 is merged.

AI-assisted: yes.

**@⁠PyZikYG** on GitHub · 2026-11-24 05:05 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/429) `PyZikYG:vulkan-mesh-dispatch-count` → `main` · +144 −25 · 8 files · 2 commits · closed without merging Claimed as [D3D-MESH-INDIRECT-COUNT](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14). Depends on: #424 A mesh-only ExecuteIndirect command with a GPU count buffer previously failed recording. This change reuses the compute indirect-count helper to prepare compact mesh dispatch records on the GPU. It reads the count at execution and writes zero-group records beyond the count, so even a UINT32_MAX counter is bounded by MaxCommandCount before drawing. The helper runs outside pipeline statistics queries. The count path requires buffer device addresses and compute scratch. This PR includes the rebased #424 commit until #424 is merged. AI-assisted: yes.
Preserve graphics state and replay a strided DISPATCH_MESH argument buffer through VK_EXT_mesh_shader.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:59:37 +00:00
Author
Owner

@⁠Sangonapou on GitHub · 2026-11-24 14:54 UTC · original

Tested 909d3c2d (on top of #424) on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32, mesh shaders), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300), native Windows: pass

Runtime built at this head with scripts\build_runtime.ps1 (MSVC 19.51, VS Build Tools 2026, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0). No game files.

ctest -R ^d3d12_mesh$ -V: passed, and the new path is taken on this card: mesh indirect used a GPU count buffer, then direct and indirect mesh dispatches and a stream VS draw matched all 4096 pixels (D3D-29: mesh tier 1, native mesh stage). Same statistics line as #424 (mesh only: C 8/8 PS 1024).

**@⁠Sangonapou** on GitHub · 2026-11-24 14:54 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/429#issuecomment-7135132041) Tested 909d3c2d (on top of #424) on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32, mesh shaders), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300), native Windows: pass Runtime built at this head with `scripts\build_runtime.ps1` (MSVC 19.51, VS Build Tools 2026, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0). No game files. `ctest -R ^d3d12_mesh$ -V`: passed, and the new path is taken on this card: `mesh indirect used a GPU count buffer`, then `direct and indirect mesh dispatches and a stream VS draw matched all 4096 pixels` (`D3D-29: mesh tier 1`, native mesh stage). Same statistics line as #424 (`mesh only: C 8/8 PS 1024`).
Author
Owner

@⁠DadaCap on GitHub · 2026-11-25 15:53 UTC · original

Retail result with this merged onto current main (RTX 5080, NVIDIA 621.24): in the world phase the indirect draws recorded went from 4,096 recorded / 53,405 skipped to 9,172 / 516 in a run that also gained native_hashes.txt and fspx_gfx, and the run showed a world picture (#1608 finding). So the draws this adds are what the world is made of; mesh indirect is gone from the skip reasons, only topology remains.

Because #1723 reworked ExecuteIndirect, my merge is not your diff: mesh goes ExecuteIndirect -> record_indirect -> draw_indirect with mesh=true, so it inherits the argument clamp, the shared list budget, the range and usage checks, predication and bundle deferral, and it emits one vkCmdDrawMeshTasksIndirect[Count]EXT instead of a loop. I kept main's behaviour for compound signatures (created, then skipped with a counter). Your commits are kept as they are. Tests that pass on the merge: d3d12_mesh (extended with bundle, compound skip, kind mismatch and indirect mesh inside a statistics query), indirect_clamp, every indirect test, bundle tests, d3d12_draw, state map and replay pipeline compile tests; d3d12_mesh and the stateful indirect tests also with validation on. Clamp counters in the retail run: 0 clamped, 0 zeroed, 0 over budget.

Known limits of that merge: the clamp treats a mesh dispatch as one-dimensional (Y and Z forced to 1), which would cut a 3D grid; I saw no clamped record.

If it helps you rebase, I can push the merge to my fork as a branch for you to take from. I will not open a pull request of my own for it. AI-assisted (Claude Code).

**@⁠DadaCap** on GitHub · 2026-11-25 15:53 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/429#issuecomment-7167405714) Retail result with this merged onto current `main` (RTX 5080, NVIDIA 621.24): in the world phase the indirect draws recorded went from 4,096 recorded / 53,405 skipped to 9,172 / 516 in a run that also gained `native_hashes.txt` and `fspx_gfx`, and the run showed a world picture ([#1608 finding](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608)). So the draws this adds are what the world is made of; `mesh indirect` is gone from the skip reasons, only `topology` remains. Because #1723 reworked `ExecuteIndirect`, my merge is not your diff: mesh goes ExecuteIndirect -> `record_indirect` -> `draw_indirect` with `mesh=true`, so it inherits the argument clamp, the shared list budget, the range and usage checks, predication and bundle deferral, and it emits one `vkCmdDrawMeshTasksIndirect[Count]EXT` instead of a loop. I kept `main`'s behaviour for compound signatures (created, then skipped with a counter). Your commits are kept as they are. Tests that pass on the merge: `d3d12_mesh` (extended with bundle, compound skip, kind mismatch and indirect mesh inside a statistics query), `indirect_clamp`, every `indirect` test, bundle tests, `d3d12_draw`, state map and replay pipeline compile tests; `d3d12_mesh` and the stateful indirect tests also with validation on. Clamp counters in the retail run: 0 clamped, 0 zeroed, 0 over budget. Known limits of that merge: the clamp treats a mesh dispatch as one-dimensional (Y and Z forced to 1), which would cut a 3D grid; I saw no clamped record. If it helps you rebase, I can push the merge to my fork as a branch for you to take from. I will not open a pull request of my own for it. AI-assisted (Claude Code).
Author
Owner

@⁠Rezn0r27 on GitHub · 2026-11-25 17:06 UTC · original

Tested PR #429 at 43433957 on Windows 11 build 26300.9974 with an NVIDIA GeForce RTX 5070 Laptop GPU, driver 621.24. I used the runtime-windows artifact from Actions run 45584633004.

d3d12_mesh_test.exe passed (exit 0). It printed mesh indirect used a GPU count buffer, and all 4096 pixels matched for the direct and indirect mesh dispatches and the vertex-shader draw.

One detail for anyone testing the Windows artifact: my first run exited with 0xc0000409. The three shaders were present in the extracted generated folder. After I made them available at the build-time path D:\a\leonida\leonida\runtime\build\generated, the same executable passed with the same driver.

I ran this single synthetic test locally. No game files were used. AI-assisted setup and report preparation.

**@⁠Rezn0r27** on GitHub · 2026-11-25 17:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/429#issuecomment-7169010143) Tested PR #429 at `43433957` on Windows 11 build 26300.9974 with an NVIDIA GeForce RTX 5070 Laptop GPU, driver 621.24. I used the `runtime-windows` artifact from Actions run 45584633004. `d3d12_mesh_test.exe` passed (exit 0). It printed `mesh indirect used a GPU count buffer`, and all 4096 pixels matched for the direct and indirect mesh dispatches and the vertex-shader draw. One detail for anyone testing the Windows artifact: my first run exited with `0xc0000409`. The three shaders were present in the extracted `generated` folder. After I made them available at the build-time path `D:\a\leonida\leonida\runtime\build\generated`, the same executable passed with the same driver. I ran this single synthetic test locally. No game files were used. AI-assisted setup and report preparation.
Author
Owner

@⁠OreoFR on GitHub · 2026-11-25 17:18 UTC · original

@⁠DadaCap counts from your mesh-indirect-on-main (255501cd9), as asked. Retail, RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11. Merged with #1849 #1867 #1887 #1896 #1860 #1889 #1886 (and #1893, now on main), host image copy on. Settings: LEONIDA_VALUE_WAIT_TIMEOUT_MS=30000 LEONIDA_MAP_READBACK=1 LEONIDA_SERIAL_BIG_COMPILES=0 LEONIDA_TITLE_WATCHDOG=0, window cap 1024 MiB, arena 2048 MiB; fspx_gfx (18,493 programs) and native_hashes.txt present. One run per row.

run result
LEONIDA_DEVICE_TYPE=6, 3 runs (one without MAP_READBACK) CPU access violation 10-20 s after the world starts, in amd_fidelityfx_upscaler_xbox.dll+0x65ff (read at 0x10: a count of 0, then a null pointer read without a check). None of my 11 runs on the default device type shows it.
default device type (7) world at ~165 s; indirect recorded=4436 emitted=128, replay_skips=3662 (all pending_pipeline), 0 record skips. Device lost at ~172 s, fault type 4, last pipeline $MS_VS_OctaSLODWind_5fd19871_Wrapped / PS_OctaSLODReZ_f191416b_Wrapped
same + LEONIDA_VK_VALIDATION=1 no loss on the mesh draws: recorded=131072 emitted=16760 at ~400 s, the cutscene card over a plain green screen (it was black before). Only validation messages: VUID-VkImageViewCreateInfo-image-12397 (16) and -usage-02275 (14). Device lost at ~457 s, type 4
same, no validation, LEONIDA_CONSOLE_RETRY_US=0 11-25k slots still waiting (their resources don't exist yet), emitted=1024, device lost at ~254 s, type 4

So mesh indirect is no longer refused here (0 record skips). The last two losses end on the same dispatches (lib_cs_02921 indirect, then lib_cs_03001 at 160x90 and lib_cs_03006) and the same faulting code addresses, so it is reproducible. Mesh pipelines take 40-46 s each to compile here, and up to 113k draws wait for theirs. Next: the same with host image copy off, as you ran it.

Did you see the upscaler crash with LEONIDA_DEVICE_TYPE=6 on the 5080? Counts and program names only. AI-assisted (Claude Code).

**@⁠OreoFR** on GitHub · 2026-11-25 17:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/429#issuecomment-7169302743) @⁠DadaCap counts from your `mesh-indirect-on-main` (255501cd9), as asked. Retail, RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11. Merged with #1849 #1867 #1887 #1896 #1860 #1889 #1886 (and #1893, now on `main`), **host image copy on**. Settings: `LEONIDA_VALUE_WAIT_TIMEOUT_MS=30000 LEONIDA_MAP_READBACK=1 LEONIDA_SERIAL_BIG_COMPILES=0 LEONIDA_TITLE_WATCHDOG=0`, window cap 1024 MiB, arena 2048 MiB; `fspx_gfx` (18,493 programs) and `native_hashes.txt` present. One run per row. | run | result | |---|---| | `LEONIDA_DEVICE_TYPE=6`, 3 runs (one without `MAP_READBACK`) | CPU access violation 10-20 s after the world starts, in `amd_fidelityfx_upscaler_xbox.dll+0x65ff` (read at 0x10: a count of 0, then a null pointer read without a check). None of my 11 runs on the default device type shows it. | | default device type (7) | world at ~165 s; indirect `recorded=4436 emitted=128`, `replay_skips=3662` (all `pending_pipeline`), 0 record skips. Device lost at ~172 s, fault type 4, last pipeline `$MS_VS_OctaSLODWind_5fd19871_Wrapped` / `PS_OctaSLODReZ_f191416b_Wrapped` | | same + `LEONIDA_VK_VALIDATION=1` | no loss on the mesh draws: `recorded=131072 emitted=16760` at ~400 s, the cutscene card over a plain green screen (it was black before). Only validation messages: `VUID-VkImageViewCreateInfo-image-12397` (16) and `-usage-02275` (14). Device lost at ~457 s, type 4 | | same, no validation, `LEONIDA_CONSOLE_RETRY_US=0` | 11-25k slots still waiting (their resources don't exist yet), `emitted=1024`, device lost at ~254 s, type 4 | So mesh indirect is no longer refused here (0 record skips). The last two losses end on the same dispatches (`lib_cs_02921` indirect, then `lib_cs_03001` at 160x90 and `lib_cs_03006`) and the same faulting code addresses, so it is reproducible. Mesh pipelines take 40-46 s each to compile here, and up to 113k draws wait for theirs. Next: the same with host image copy off, as you ran it. Did you see the upscaler crash with `LEONIDA_DEVICE_TYPE=6` on the 5080? Counts and program names only. AI-assisted (Claude Code).
Author
Owner

@⁠DadaCap on GitHub · 2026-11-25 17:47 UTC · original · edited 2026-11-25 19:06 UTC

@⁠OreoFR thank you, these are useful counts. Correction (edited): I first wrote that I have not seen the +0x65ff crash. I did, once, in an early run today (m24, LEONIDA_DEVICE_TYPE=6): then only 22 of the 29 FSPX programs of the FidelityFX upscaler translated. With #674 and #1662 in the translator all 29 translated and the crash was gone in the next run (m25, one run each), so please check how many FSPX programs your shader folder has. Since m50 I have not seen it. All my recent runs use LEONIDA_DEVICE_TYPE=6 (RTX 5080, 16 GB), and no log of the 19 or so runs since m50 has that address. The obvious differences are host image copy (mine is off, through LEONIDA_HOST_IMAGE_COPY=0 of #1851), LEONIDA_VALUE_WAIT_TIMEOUT_MS, and the 8 GB against 16 GB, so I can't say which one matters. Your host-image-copy-off run should tell.

For the picture: in a run today with #1957, the G-buffer holds the textured scene at the world frames, but the lit buffer has only sky and emissive lights, and I found no VS_TiledLighting or TL_PS_* pipeline in three logs. #1896 may be what is missing (its topologies); I am testing that now, with your list of merged pull requests containing it already, so whether your log has TL_PS_* builds would be interesting. AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠DadaCap** on GitHub · 2026-11-25 17:47 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/429#issuecomment-7170005180) · edited 2026-11-25 19:06 UTC @⁠OreoFR thank you, these are useful counts. Correction (edited): I first wrote that I have not seen the `+0x65ff` crash. I did, once, in an early run today (m24, `LEONIDA_DEVICE_TYPE=6`): then only 22 of the 29 FSPX programs of the FidelityFX upscaler translated. With #674 and #1662 in the translator all 29 translated and the crash was gone in the next run (m25, one run each), so please check how many FSPX programs your shader folder has. Since m50 I have not seen it. All my recent runs use `LEONIDA_DEVICE_TYPE=6` (RTX 5080, 16 GB), and no log of the 19 or so runs since m50 has that address. The obvious differences are host image copy (mine is off, through `LEONIDA_HOST_IMAGE_COPY=0` of #1851), `LEONIDA_VALUE_WAIT_TIMEOUT_MS`, and the 8 GB against 16 GB, so I can't say which one matters. Your host-image-copy-off run should tell. For the picture: in a run today with #1957, the G-buffer holds the textured scene at the world frames, but the lit buffer has only sky and emissive lights, and I found no `VS_TiledLighting` or `TL_PS_*` pipeline in three logs. #1896 may be what is missing (its topologies); I am testing that now, with your list of merged pull requests containing it already, so whether your log has `TL_PS_*` builds would be interesting. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠quartz-heron-58 on GitHub · 2026-11-25 17:55 UTC · original

Retail data point for the merge DadaCap published (DadaCap/leonida mesh-indirect-on-main), on a 16 GB card with 32 GB of RAM.

RTX 4080 16 GB, NVIDIA 621.24, Windows 11 26300. Local merge: main b0f3d3998 + #1849 #1893 #1889 #1860 #1886 #1882 #1887 #1851 + Snooozs's merge of #1592 + mesh-indirect-on-main (255501cd9; one conflict with the #1592 merge, in a printf of d3d12_mesh_test.cpp). fspx_gfx 16,914 programs, native_hashes.txt present, host image copy on, LEONIDA_ASYNC_PIPELINES=1, LEONIDA_TITLE_WINDOWS_MB=4096, LEONIDA_ARENA_MB=2048, LEONIDA_TITLE_WATCHDOG=0, three groups of very large compute programs skipped with LEONIDA_SKIP_COMPUTE (reason below), scripted keyboard pad.

without the mesh merge with it
runs 1 1
indirect graphics, last line recorded 1,597, emitted 335, record skips 65,536, replay skips 1,227 recorded 45,481, emitted 4,096, record skips 4,644, replay skips 38,024
skip reason logged topology
end my time limit (430 s), no device loss device lost at ~471 s: vkDeviceWaitIdle (title staging), one fault address of type 6, checkpoint a draw at submission 5,162 (list 3, command 0) with a mesh + pixel pipeline bound
window letterboxed frame, flat dark fill, from ~250 s the same, plus one line of cutscene text; no scene

So the mesh draws are recorded here as on the RTX 5080, but most are skipped at replay (38,024), and the one run ended in a device loss inside a mesh draw. I have not looked at why replay skips them (async pipelines not built yet is my first guess, since graphics pipelines build in the background in this run) and have no second run.

Why the compute skip: without it the world start cannot be passed on this machine. Compute programs of 6 to 24 MiB of SPIR-V (three name groups, about 15 programs) are compiled on the dispatch path, and nvgpucomp64 was still inside one after 46 s with the process growing by 3.6 GB in ten seconds; the next ones of 4 to 5.6 MiB take 20 to 57 s each. I will write that up separately in #1608.

Not checked: host image copy off, LEONIDA_DEVICE_TYPE, validation, the mesh tests on this merge (only the build and the boot).

AI-assisted (Claude Code).

**@⁠quartz-heron-58** on GitHub · 2026-11-25 17:55 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/429#issuecomment-7170202077) Retail data point for the merge DadaCap published (DadaCap/leonida `mesh-indirect-on-main`), on a 16 GB card with 32 GB of RAM. RTX 4080 16 GB, NVIDIA 621.24, Windows 11 26300. Local merge: main b0f3d3998 + #1849 #1893 #1889 #1860 #1886 #1882 #1887 #1851 + Snooozs's merge of #1592 + `mesh-indirect-on-main` (255501cd9; one conflict with the #1592 merge, in a printf of d3d12_mesh_test.cpp). fspx_gfx 16,914 programs, native_hashes.txt present, host image copy on, `LEONIDA_ASYNC_PIPELINES=1`, `LEONIDA_TITLE_WINDOWS_MB=4096`, `LEONIDA_ARENA_MB=2048`, `LEONIDA_TITLE_WATCHDOG=0`, three groups of very large compute programs skipped with `LEONIDA_SKIP_COMPUTE` (reason below), scripted keyboard pad. | | without the mesh merge | with it | |---|---|---| | runs | 1 | 1 | | indirect graphics, last line | recorded 1,597, emitted 335, record skips 65,536, replay skips 1,227 | recorded 45,481, emitted 4,096, record skips 4,644, replay skips 38,024 | | skip reason logged | | topology | | end | my time limit (430 s), no device loss | device lost at ~471 s: `vkDeviceWaitIdle (title staging)`, one fault address of type 6, checkpoint a draw at submission 5,162 (list 3, command 0) with a mesh + pixel pipeline bound | | window | letterboxed frame, flat dark fill, from ~250 s | the same, plus one line of cutscene text; no scene | So the mesh draws are recorded here as on the RTX 5080, but most are skipped at replay (38,024), and the one run ended in a device loss inside a mesh draw. I have not looked at why replay skips them (async pipelines not built yet is my first guess, since graphics pipelines build in the background in this run) and have no second run. Why the compute skip: without it the world start cannot be passed on this machine. Compute programs of 6 to 24 MiB of SPIR-V (three name groups, about 15 programs) are compiled on the dispatch path, and nvgpucomp64 was still inside one after 46 s with the process growing by 3.6 GB in ten seconds; the next ones of 4 to 5.6 MiB take 20 to 57 s each. I will write that up separately in #1608. Not checked: host image copy off, `LEONIDA_DEVICE_TYPE`, validation, the mesh tests on this merge (only the build and the boot). AI-assisted (Claude Code).
Author
Owner

@⁠quartz-heron-58 on GitHub · 2026-11-25 17:56 UTC · original

Correction to my table above: the run without the mesh merge did not end cleanly either. Its log has a device loss at ~485 s that I missed (vkDeviceWaitIdle (title staging), checkpoint a copy at submission 5,751 on a compute queue); the process then sat until my time limit. So both runs lost the device, at about the same time (471 s and 485 s) and at different commands (a mesh draw with the merge, a copy without), and the device loss with the merge cannot be put down to the mesh path from these two runs. The indirect counts stand.

**@⁠quartz-heron-58** on GitHub · 2026-11-25 17:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/429#issuecomment-7170211094) Correction to my table above: the run without the mesh merge did not end cleanly either. Its log has a device loss at ~485 s that I missed (`vkDeviceWaitIdle (title staging)`, checkpoint a copy at submission 5,751 on a compute queue); the process then sat until my time limit. So both runs lost the device, at about the same time (471 s and 485 s) and at different commands (a mesh draw with the merge, a copy without), and the device loss with the merge cannot be put down to the mesh path from these two runs. The indirect counts stand.
Author
Owner

@⁠quartz-heron-58 on GitHub · 2026-11-25 19:02 UTC · original

Second run with mesh-indirect-on-main on the RTX 4080, and it narrows what I reported above: both runs that had the merge lost the device at a draw with the same mesh + pixel pipeline pair bound.

run 1 (above) run 2
pipeline builds async async, with a session pipeline cache of ~525 MB from earlier runs
arena 2,048 MiB 4,095 MiB
device lost at ~471 s, submission 5,162, list 3 command 0, kind draw ~160 s, submission 5,449, list 4 command 61, kind draw
fault addresses type 6 at one address, and a type 1 (read) at another, precision 4,096 one of type 4
pipeline at the checkpoint mesh + pixel pair A the same pair A
indirect graphics, last line recorded 45,481, emitted 4,096, replay skips 38,024 recorded 23,523, emitted 2,667, record skips 2,048, replay skips 17,290

The run without the merge that I corrected above lost the device at a copy instead, so two of two with the merge end at this pair and zero of one without. The pair is a 64-wide mesh program of ~432 KiB of SPIR-V (run at this card's 32-wide size) with its pixel program; I keep program names out of posts, but can give the two FSPX code hashes if that helps find it on the 5080.

Separately, for anyone repeating this without async pipelines: with foreground builds the same merge did not reach that draw. Five of eight runs lost the device at the first world submission, checkpoint the first compute dispatch of list 0 (three of three with a 2,048 MiB arena, two of five with 4,095 MiB, the two being the runs that started from a warm pipeline cache).

Not checked: validation, host image copy off, whether the read fault is the mesh program's own or a neighbour's. Other local settings as in my first comment, plus a local size cut-off that drops compute programs over 3.5 MiB of SPIR-V in run 2 instead of the three name groups.

AI-assisted (Claude Code).

**@⁠quartz-heron-58** on GitHub · 2026-11-25 19:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/429#issuecomment-7171735786) Second run with `mesh-indirect-on-main` on the RTX 4080, and it narrows what I reported above: both runs that had the merge lost the device at a draw with the same mesh + pixel pipeline pair bound. | | run 1 (above) | run 2 | |---|---|---| | pipeline builds | async | async, with a session pipeline cache of ~525 MB from earlier runs | | arena | 2,048 MiB | 4,095 MiB | | device lost at | ~471 s, submission 5,162, list 3 command 0, kind draw | ~160 s, submission 5,449, list 4 command 61, kind draw | | fault addresses | type 6 at one address, and a type 1 (read) at another, precision 4,096 | one of type 4 | | pipeline at the checkpoint | mesh + pixel pair A | the same pair A | | indirect graphics, last line | recorded 45,481, emitted 4,096, replay skips 38,024 | recorded 23,523, emitted 2,667, record skips 2,048, replay skips 17,290 | The run without the merge that I corrected above lost the device at a copy instead, so two of two with the merge end at this pair and zero of one without. The pair is a 64-wide mesh program of ~432 KiB of SPIR-V (run at this card's 32-wide size) with its pixel program; I keep program names out of posts, but can give the two FSPX code hashes if that helps find it on the 5080. Separately, for anyone repeating this without async pipelines: with foreground builds the same merge did not reach that draw. Five of eight runs lost the device at the first world submission, checkpoint the first compute dispatch of list 0 (three of three with a 2,048 MiB arena, two of five with 4,095 MiB, the two being the runs that started from a warm pipeline cache). Not checked: validation, host image copy off, whether the read fault is the mesh program's own or a neighbour's. Other local settings as in my first comment, plus a local size cut-off that drops compute programs over 3.5 MiB of SPIR-V in run 2 instead of the three name groups. AI-assisted (Claude Code).
Author
Owner

@⁠quartz-heron-58 on GitHub · 2026-11-25 19:19 UTC · original

One more run, and it takes back the emphasis I put on "pair A": the pair is not special. With a local hack that never builds graphics pipelines using that mesh program (so its draws are dropped), everything else as in run 2, the device was lost at ~211 s at another draw (submission 3,388, list 4 command 71, kind draw) with a different mesh + pixel pair bound. Indirect graphics at the end: recorded 10,868, emitted 1,024, replay skips 7,054.

So on this RTX 4080 three of three runs with the mesh merge end in a device loss at a mesh draw, whichever mesh pipeline comes first, which points at what the mesh draws are given (arguments or the buffers they read; run 1's report had a read fault) rather than at one program. Still one machine, no validation run, and I have not looked at the arguments.

AI-assisted (Claude Code).

**@⁠quartz-heron-58** on GitHub · 2026-11-25 19:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/429#issuecomment-7172138977) One more run, and it takes back the emphasis I put on "pair A": the pair is not special. With a local hack that never builds graphics pipelines using that mesh program (so its draws are dropped), everything else as in run 2, the device was lost at ~211 s at another draw (submission 3,388, list 4 command 71, kind draw) with a different mesh + pixel pair bound. Indirect graphics at the end: recorded 10,868, emitted 1,024, replay skips 7,054. So on this RTX 4080 three of three runs with the mesh merge end in a device loss at a mesh draw, whichever mesh pipeline comes first, which points at what the mesh draws are given (arguments or the buffers they read; run 1's report had a read fault) rather than at one program. Still one machine, no validation run, and I have not looked at the arguments. AI-assisted (Claude Code).
Author
Owner

@⁠quartz-heron-58 on GitHub · 2026-11-25 19:19 UTC · original

Correction to my last comment: the local hack never fired in that run (its log line is absent), so nothing was dropped and the run is simply a third run of the same recipe. What it shows is unchanged and a little simpler: this time the device was lost at a mesh draw with a different mesh + pixel pair bound, before any draw with pair A was built. Three of three runs with the mesh merge end at a mesh draw; two at pair A, one at another pair.

**@⁠quartz-heron-58** on GitHub · 2026-11-25 19:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/429#issuecomment-7172145894) Correction to my last comment: the local hack never fired in that run (its log line is absent), so nothing was dropped and the run is simply a third run of the same recipe. What it shows is unchanged and a little simpler: this time the device was lost at a mesh draw with a different mesh + pixel pair bound, before any draw with pair A was built. Three of three runs with the mesh merge end at a mesh draw; two at pair A, one at another pair.
Author
Owner

@⁠OreoFR on GitHub · 2026-11-25 22:11 UTC · original

@⁠DadaCap answers for my RTX 4070 Laptop (8 GB, 621.40):

  1. My shader folder has 27 upscaler FSPX programs, not 29. I have not seen +0x65ff in any recent run, but those runs do not set LEONIDA_DEVICE_TYPE=6.
  2. Yes: TL_PS_* and VS_TiledLighting pipelines are built in my world runs (about 30 builds each).
  3. Host image copy off: not rerun yet.

@⁠quartz-heron-58 this matches what I see with mesh-indirect-on-main + #2077 + #1914 on main. Nsight Aftermath dumps show two variants, both Timeout with no page fault:

  • mesh draws not emitted: lib_cs_00959 stuck at the loop head of the wave64 round scheduler (--wave64-emulate, rounds form);
  • mesh draws emitted: a mesh program stuck at the same round-scheduler loop head.

Bisect on this machine (one run each):

  • holds when no mesh pipeline is ever created (330 s), or when mesh pipelines are built from empty stub stages (330 s, 320 pipelines);
  • loses the device at 185-240 s whenever the real mesh modules are compiled, even if never drawn, sync or async, 1 or 8 compile workers.

So on my side it is not the clamp, the rendering scope or skipped dispatches. I'm now running the mesh programs retranslated with #2102 (all of them).

**@⁠OreoFR** on GitHub · 2026-11-25 22:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/429#issuecomment-7176050599) @⁠DadaCap answers for my RTX 4070 Laptop (8 GB, 621.40): 1. My shader folder has **27** upscaler FSPX programs, not 29. I have not seen `+0x65ff` in any recent run, but those runs do not set `LEONIDA_DEVICE_TYPE=6`. 2. Yes: `TL_PS_*` and `VS_TiledLighting` pipelines are built in my world runs (about 30 builds each). 3. Host image copy off: not rerun yet. @⁠quartz-heron-58 this matches what I see with `mesh-indirect-on-main` + #2077 + #1914 on main. Nsight Aftermath dumps show two variants, both `Timeout` with no page fault: - mesh draws not emitted: `lib_cs_00959` stuck at the loop head of the wave64 round scheduler (`--wave64-emulate`, rounds form); - mesh draws emitted: a mesh program stuck at the same round-scheduler loop head. Bisect on this machine (one run each): - holds when no mesh pipeline is ever created (330 s), or when mesh pipelines are built from empty stub stages (330 s, 320 pipelines); - loses the device at 185-240 s whenever the real mesh modules are compiled, even if never drawn, sync or async, 1 or 8 compile workers. So on my side it is not the clamp, the rendering scope or skipped dispatches. I'm now running the mesh programs retranslated with #2102 (all of them).
Author
Owner

@⁠quartz-heron-58 on GitHub · 2026-11-25 23:55 UTC · original

@⁠OreoFR thank you, that fits here too: every loss on this RTX 4080 since the arena was made large enough has only type-4 addresses, no read or write. Since you are testing #2102, three runs with it from this machine. Every number below was read back from the run logs before posting.

What was retranslated: the main corpus (26,503) and fspx_gfx (18,493) with the tools at 84816055d (#2102), --wave64-emulate. Of 400 mesh modules I hashed before and after, 400 changed. Not retranslated: the pipeline-library compute programs (still from the translator at 71a769d7d, plus 830 from an older translation that the current one refuses), so lib_cs_00959 is unchanged in these runs and this only tests the mesh side.

Runtime: main b0f3d3998 + #1849 #1893 #1889 #1860 #1886 #1882 #1887 #1851, Snooozs's merge of #1592, mesh-indirect-on-main (255501cd9), Undefined3301's V# bound commit (338a32b, cherry-picked), and a local diagnostic patch (compute programs over 3.5 MiB of SPIR-V are dropped; the session cache is checkpointed while builds run). LEONIDA_ASYNC_PIPELINES=1, arena 4,080 MiB granted of 4,095 asked, LEONIDA_TITLE_WINDOWS_MB=4096, host image copy on, a warm session pipeline cache, NVIDIA 621.24, 32 GB RAM.

run device loss ended indirect graphics, last line
1 none my free-RAM guard, last submission report at 308 s recorded 49,254, emitted 2,159, replay skips 41,996
2 none my free-RAM guard, last report at 236 s recorded 45,677, emitted 6,013, replay skips 32,768
3 at ~275 s: vkDeviceWaitIdle (title staging), checkpoint a draw (submission 5,650, list 5 command 88), 15 addresses, all type 4 exit 0xC0000005 at 282 s recorded 45,226, emitted 5,064, replay skips 32,768

The pair bound in run 3 is the second pair of my earlier comment (the one that is not pair A). Before #2102, with async builds, the three runs I reported above ended at mesh draws at ~160, ~211 and ~471 s; with it, one of three at ~275 s. Three runs are too few to call that a change, and two of the three were cut by memory, not by me choosing to stop.

Not checked: the compute library retranslated with #2102, TdrDelay (left at the default here), validation, Aftermath dumps.

AI-assisted (Claude Code).

**@⁠quartz-heron-58** on GitHub · 2026-11-25 23:55 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/429#issuecomment-7178211146) @⁠OreoFR thank you, that fits here too: every loss on this RTX 4080 since the arena was made large enough has only type-4 addresses, no read or write. Since you are testing #2102, three runs with it from this machine. Every number below was read back from the run logs before posting. What was retranslated: the main corpus (26,503) and fspx_gfx (18,493) with the tools at 84816055d (#2102), `--wave64-emulate`. Of 400 mesh modules I hashed before and after, 400 changed. **Not retranslated: the pipeline-library compute programs** (still from the translator at 71a769d7d, plus 830 from an older translation that the current one refuses), so lib_cs_00959 is unchanged in these runs and this only tests the mesh side. Runtime: main b0f3d3998 + #1849 #1893 #1889 #1860 #1886 #1882 #1887 #1851, Snooozs's merge of #1592, `mesh-indirect-on-main` (255501cd9), Undefined3301's V# bound commit (338a32b, cherry-picked), and a local diagnostic patch (compute programs over 3.5 MiB of SPIR-V are dropped; the session cache is checkpointed while builds run). `LEONIDA_ASYNC_PIPELINES=1`, arena 4,080 MiB granted of 4,095 asked, `LEONIDA_TITLE_WINDOWS_MB=4096`, host image copy on, a warm session pipeline cache, NVIDIA 621.24, 32 GB RAM. | run | device loss | ended | indirect graphics, last line | |---|---|---|---| | 1 | none | my free-RAM guard, last submission report at 308 s | recorded 49,254, emitted 2,159, replay skips 41,996 | | 2 | none | my free-RAM guard, last report at 236 s | recorded 45,677, emitted 6,013, replay skips 32,768 | | 3 | at ~275 s: `vkDeviceWaitIdle (title staging)`, checkpoint a draw (submission 5,650, list 5 command 88), 15 addresses, all type 4 | exit 0xC0000005 at 282 s | recorded 45,226, emitted 5,064, replay skips 32,768 | The pair bound in run 3 is the second pair of my earlier comment (the one that is not pair A). Before #2102, with async builds, the three runs I reported above ended at mesh draws at ~160, ~211 and ~471 s; with it, one of three at ~275 s. Three runs are too few to call that a change, and two of the three were cut by memory, not by me choosing to stop. Not checked: the compute library retranslated with #2102, TdrDelay (left at the default here), validation, Aftermath dumps. AI-assisted (Claude Code).
Author
Owner

@⁠Tyrannys on GitHub · 2026-11-26 02:20 UTC · original

Runs of mesh-indirect-on-main (255501cd9) from a second machine: RTX 4070 SUPER, NVIDIA 621.01, 64 GB. Counts only.

Tree: main fe1553456 + #674 #1662 #1851 #1849 #1905 #1957 #1950 #1886 #1894 + #1592. The mesh runs also have 255501cd9 merged in. 3 conflicts in the indirect-draw code against #1896: I kept main's topology_supported() and this branch's mesh path, and added a mesh_window skip reason.

Shaders: main corpus, fspx_gfx (18,493) and library (2,683) translated with --wave64-emulate on that tree. The warm offline pipeline cache holds all 26,503 main pipelines. Library and fspx_gfx pipelines are built at run time.

Recipe: boot.ps1, 1,200 s, LEONIDA_TITLE_WATCHDOG=0, LEONIDA_DEVICE_FAULT=1, LEONIDA_DEVICE_TYPE=6, arena 2,048 MiB, host image copy off (auto: NVIDIA), the same 21-press input script, a fresh save folder each run. One run per row. Call counts are trace calls, one per call.

mesh merge async pipelines end device loss ExecuteCommandLists Dispatch / DrawIndexedInstanced PresentX indirect graphics, last line
A no no time limit (1,200 s); no submissions after ~360 s none 10,764 6,387 / 40,663 5,334 recorded 666, emitted 64, mesh skips 9,028
B yes no time limit (1,200 s); only a few dozen submissions after ~360 s none 10,033 7,137 / 39,854 4,966 recorded 9,846, emitted 4,096, skips 0
C yes yes crash (0xC0000005) at 540 s ~515 s, vkDeviceWaitIdle (title staging), checkpoint a draw (submission 12,091, list 8, command 217), 1 address, type 4 12,084 66,040 / 44,308 5,203 recorded 91,204, emitted 4,096, replay skips 86,150 (all pending_pipeline)
D no yes time limit (1,204 s), still submitting at the end none 19,965 286,776 / 59,672 5,401 recorded 91,979, emitted 10,286, record skips 262,144 (all mesh), replay skips 81,412 (pending_pipeline)
  • In C, the pipeline bound at the checkpoint is a mesh + pixel pair, as in quartz-heron-58's runs. The fault is the same kind as theirs and OreoFR's: one address, type 4, with no read or write.
  • On this machine, 1 of 1 runs with the merge and async builds lost the device at a mesh draw. The run without the merge and with async builds (D) ran the full time with no fault, and kept submitting more than twice as long.
  • B (the merge with foreground builds) did not lose the device. But it, like A, stopped submitting at about 360 s, while pipelines were being built in the foreground. So B is no evidence either way about the mesh draws.

Not checked: #2102 retranslation, validation, Aftermath, more than one run per row.

AI-assisted (Claude Code).

**@⁠Tyrannys** on GitHub · 2026-11-26 02:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/429#issuecomment-7180707516) Runs of `mesh-indirect-on-main` (255501cd9) from a second machine: RTX 4070 SUPER, NVIDIA 621.01, 64 GB. Counts only. **Tree:** `main` fe1553456 + #674 #1662 #1851 #1849 #1905 #1957 #1950 #1886 #1894 + #1592. The mesh runs also have 255501cd9 merged in. 3 conflicts in the indirect-draw code against #1896: I kept `main`'s `topology_supported()` and this branch's mesh path, and added a `mesh_window` skip reason. **Shaders:** main corpus, `fspx_gfx` (18,493) and library (2,683) translated with `--wave64-emulate` on that tree. The warm offline pipeline cache holds all 26,503 main pipelines. Library and `fspx_gfx` pipelines are built at run time. **Recipe:** `boot.ps1`, 1,200 s, `LEONIDA_TITLE_WATCHDOG=0`, `LEONIDA_DEVICE_FAULT=1`, `LEONIDA_DEVICE_TYPE=6`, arena 2,048 MiB, host image copy off (auto: NVIDIA), the same 21-press input script, a fresh save folder each run. One run per row. Call counts are trace calls, one per call. | | mesh merge | async pipelines | end | device loss | ExecuteCommandLists | Dispatch / DrawIndexedInstanced | PresentX | indirect graphics, last line | |---|---|---|---|---|---|---|---|---| | A | no | no | time limit (1,200 s); no submissions after ~360 s | none | 10,764 | 6,387 / 40,663 | 5,334 | recorded 666, emitted 64, mesh skips 9,028 | | B | yes | no | time limit (1,200 s); only a few dozen submissions after ~360 s | none | 10,033 | 7,137 / 39,854 | 4,966 | recorded 9,846, emitted 4,096, skips 0 | | C | yes | yes | crash (0xC0000005) at 540 s | ~515 s, `vkDeviceWaitIdle (title staging)`, checkpoint a draw (submission 12,091, list 8, command 217), 1 address, type 4 | 12,084 | 66,040 / 44,308 | 5,203 | recorded 91,204, emitted 4,096, replay skips 86,150 (all `pending_pipeline`) | | D | no | yes | time limit (1,204 s), still submitting at the end | none | 19,965 | 286,776 / 59,672 | 5,401 | recorded 91,979, emitted 10,286, record skips 262,144 (all `mesh`), replay skips 81,412 (`pending_pipeline`) | - In C, the pipeline bound at the checkpoint is a mesh + pixel pair, as in quartz-heron-58's runs. The fault is the same kind as theirs and OreoFR's: one address, type 4, with no read or write. - On this machine, 1 of 1 runs with the merge and async builds lost the device at a mesh draw. The run without the merge and with async builds (D) ran the full time with no fault, and kept submitting more than twice as long. - B (the merge with foreground builds) did not lose the device. But it, like A, stopped submitting at about 360 s, while pipelines were being built in the foreground. So B is no evidence either way about the mesh draws. Not checked: #2102 retranslation, validation, Aftermath, more than one run per row. AI-assisted (Claude Code).
Author
Owner

@⁠quartz-heron-58 on GitHub · 2026-11-26 03:11 UTC · original

A correction to all my runs above, and runs that line up with Tyrannys's row D. RTX 4080 16 GB, NVIDIA 621.24, Windows 11, 32 GB RAM. Counts only.

Correction. Every run I reported here before today was in Series X identity. My own launch script never set LEONIDA_DEVICE_TYPE, so the runtime answered ConsoleMode 0x64 (type 7), not the 0x60 (type 6) that boot.ps1 sets. I checked the log line in each of those runs. So my memory numbers (28-29 GB private) and my device-loss times are Series X numbers and should not be compared with the Series S rows here.

Series S, same patched tree as before (with 255501c merged), async builds: 2 runs. One ran 696 s with no device loss (private memory 22-25 GB). One lost the device at 132 s, checkpoint a dispatch, 2 addresses (one type 1, one type 6), so not the mesh-draw timeout signature.

Series S, plain main 3abb99c (no mesh merge), async builds: 3 runs of 571, 651 and 661 s, no device loss in any. That matches row D. Shaders: main corpus, fspx_gfx (18,493), library (2,635) and the 29 FSPX programs, --wave64-emulate.

What stops those three main runs here is compile time on this driver, not a fault:

  • With the compute warm-up on (default), the run never left the loading artwork: 967 submissions in 571 s, 809 compile-gate waits, 546 s in all.
  • With LEONIDA_COMPUTE_WARMUP=0, 60-90 frames/s until about 55 s, then submissions wait on single compute pipeline creates of 1.9-4.5 MB of SPIR-V: 91 waits (346 s in all, longest 40 s) and 61 waits (362 s, longest 135 s) in the two runs. The library here has 646 modules over 3.5 MB.

Not checked: more than these runs per row, the mesh merge on current main in Series S mode, TdrDelay (default), validation, Aftermath.

AI-assisted (Claude Code).

**@⁠quartz-heron-58** on GitHub · 2026-11-26 03:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/429#issuecomment-7181476700) A correction to all my runs above, and runs that line up with Tyrannys's row D. RTX 4080 16 GB, NVIDIA 621.24, Windows 11, 32 GB RAM. Counts only. **Correction.** Every run I reported here before today was in Series X identity. My own launch script never set `LEONIDA_DEVICE_TYPE`, so the runtime answered ConsoleMode 0x64 (type 7), not the 0x60 (type 6) that `boot.ps1` sets. I checked the log line in each of those runs. So my memory numbers (28-29 GB private) and my device-loss times are Series X numbers and should not be compared with the Series S rows here. **Series S, same patched tree as before (with 255501c merged), async builds:** 2 runs. One ran 696 s with no device loss (private memory 22-25 GB). One lost the device at 132 s, checkpoint a dispatch, 2 addresses (one type 1, one type 6), so not the mesh-draw timeout signature. **Series S, plain main 3abb99c (no mesh merge), async builds:** 3 runs of 571, 651 and 661 s, no device loss in any. That matches row D. Shaders: main corpus, fspx_gfx (18,493), library (2,635) and the 29 FSPX programs, `--wave64-emulate`. What stops those three main runs here is compile time on this driver, not a fault: - With the compute warm-up on (default), the run never left the loading artwork: 967 submissions in 571 s, 809 compile-gate waits, 546 s in all. - With `LEONIDA_COMPUTE_WARMUP=0`, 60-90 frames/s until about 55 s, then submissions wait on single compute pipeline creates of 1.9-4.5 MB of SPIR-V: 91 waits (346 s in all, longest 40 s) and 61 waits (362 s, longest 135 s) in the two runs. The library here has 646 modules over 3.5 MB. Not checked: more than these runs per row, the mesh merge on current main in Series S mode, TdrDelay (default), validation, Aftermath. AI-assisted (Claude Code).
Author
Owner

@⁠klikso on GitHub · 2026-11-26 04:15 UTC · original

Test result for this path on a slower card: on an RTX 3060 Ti 8 GB under Windows, with this branch merged (main ffcfe68f1 + #1592 + this, plus #1862 #1851 #1886 #1882 #1905 #1944 #1957), the device is lost to a Windows GPU timeout (nvlddmkm event 153) in 3 of 4 runs while mesh indirect dispatches are recorded. With only the mesh kind skipped (local switch), 0 of 2 runs lose it. A list budget of 2^22 (at most 32768 mesh groups) didn't prevent it, so the cost looks per group rather than in the count. Table and counts: #1608. Not a blocker for the change itself, but on Windows below 5080 class this path may need a dispatch split or a mesh-group cap. AI-assisted.

**@⁠klikso** on GitHub · 2026-11-26 04:15 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/429#issuecomment-7182438571) Test result for this path on a slower card: on an RTX 3060 Ti 8 GB under Windows, with this branch merged (main ffcfe68f1 + #1592 + this, plus #1862 #1851 #1886 #1882 #1905 #1944 #1957), the device is lost to a Windows GPU timeout (nvlddmkm event 153) in 3 of 4 runs while mesh indirect dispatches are recorded. With only the mesh kind skipped (local switch), 0 of 2 runs lose it. A list budget of 2^22 (at most 32768 mesh groups) didn't prevent it, so the cost looks per group rather than in the count. Table and counts: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608. Not a blocker for the change itself, but on Windows below 5080 class this path may need a dispatch split or a mesh-group cap. AI-assisted.
github-bot closed this pull request 2026-11-26 12:21:00 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.