GPU: number bounded indirect mesh groups consecutively #2994
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2996"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T02:48:04Z.
Indirect mesh commands carry three group counts. VIctory's translated mesh input
MeshGroupreads the host'sSV_GroupID.xand applies the shader's stride. Flattening every record to its original X count loses work. Passing the full grid through leaves X repeated across Y and Z.The clamp now uses
[x*y*z, 1, 1]for grids within the existing 65,535-group per-record ceiling. This gives each translated group its own index. Oversized records keep the original bounded fallback. The list budget still uses the work charged to each record.9a851cd, through the ordinaryState::execute_indirectpath: an atomic counter for eachMeshGrouprecords eight hits in each of the first three slots and zero in the remaining 21.5385cc6, each of the 24 slots receives one hit. Six paired WARP runs agreed. The argument-buffer test covers empty and oversized inputs plus list budget exhaustion.This covers VIctory's translated indirect mesh path. #2624 covers direct mesh calls, whose translated group-index behavior needs its own check. #2472's batched clamp needs the same indirect rule if combined.
Coordination · D3D12 mesh indirect argument specification
If you move the patch, please keep its Git author. If you combine it with another commit, please include:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
AI-assisted with Codex. Synthetic GPU inputs.
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T02:58:04Z.
Review: APPROVED
LGTM — the fallback
min(g, uint3(65535,1,1))is elementwise, so oversized grids collapse to (x,1,1) not (65535,1,1) — the test's (257,256,1)→(257,1,1) and (u32::MAX,2,3)→(65535,1,1) both confirm. Overflow analysis holds: the per-axis check makes the product check unreachable when x or y exceeds 65535, so g.xg.y ≤ 65535² fits u32; dividing the ceiling by z avoids xyz overflow. Kept grids charge xyz128 — same 65535-group ceiling, so the budget semantics are preserved exactly (the test's 65532-group records → 16 of 18 run). Theclamped_wordsrefactor assertingfields <= perkeeps the read-back honest.Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T03:01:59Z.
Confirmed the missing groups at execution time on both RTX 5080 and Microsoft WARP. I ran a mesh shader that increments a separate counter for each
SV_GroupID. I compared nativeDispatchMeshwith the production clamp followed byExecuteIndirect, then checked all 64 coordinate counters against CPU enumeration. The largest grid dimension was four.63bcca439a851cd3(3,2,4), 12-byte stride(2,3,1)and(1,1,2), 16-byte strideBoth adapters gave the same results. At the PR head, every coordinate matched direct dispatch, including both visits to the origin in the two-record case. The input argument buffers also remained byte-identical.
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-26T03:02:28Z.
Independent Windows WARP test run of
9a851cd3c00d94fcf13b9825d1b98673a1de0cf5, compared with its exact parent63bcca43c6a00a758510398fa43096ce7e4f7df0. This reports test results only, not a review verdict.Setup. Software only.
VICTORY_D3D12_WARP=1andVICTORY_WARP=1, built with--features diagnostics(WARP selection in victory-gpu is behind that feature).VICTORY_DXILpointed at the Windows SDK 10.0.26100.0 x64dxil.dll, but the victory-gpu lib tests never loaded it: a probe found nodxil.dllmodule in the process. Before any dispatch, each probe checked that the host device's adapter LUID matchesEnumWarpAdapter:Microsoft Basic Render Driver, vendor0x1414, device0x8c, software flag set. No hardware GPU was used. No game files, dumps or shader data, only synthetic arguments.Command.
cargo test --locked -j 4 -p victory-gpu --features diagnostics --lib -- --test-threads=1, plus filtered runs (probe_attest,probe_,indirect::).Local probes (not pushed). They run the production clamp through
bound/doneand read back all three words of every mesh record:63bcca49a851cd3[5,7,9],[2,2,2],[255,257,1](exactly 65,535),[1,1,65535]and[3,5,4369](the z-division edge),[0,9,9],[65535,65535,0]. Over-ceiling or over-axis grids fall back:[256,256,1]→[256,1,1],[2,1,65535]→[2,1,1],[1,1,65536]→[1,1,1],[70000,2,2]andu32::MAX³→[65535,1,1][5,1,1], …,[65535,1,0])[32,32,32](32,768 groups each) against the 2^20-group list budget: exactly 32 run, 8 run empty[32,1,1][64,64,8]: the second call has 12 left[65535,2,1]charged at the fallback size, 16 runCounts.
indirect::on the head: 11 passed (the 7 module tests, includingmesh_clamp_keeps_group_grid_and_charges_all_axes, plus the 4 probes).benchmark_private_data_release). The suite total also included the WARP attestation probe and 4 unrelated local ClearState probes for #2984, which fail here as they do on the parent.AI-assisted: Claude Code (Claude Opus 5.5), coordinated by Codex (gpt-6.2-sol).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T03:07:55Z.
Review: CHANGES_REQUESTED
Code review on
9a851cd3(static source inspection; no runtime GPU execution):SV_GroupID.xacross all Y/Z slices (crates/victory-gpu/src/indirect.rs,crates/victory-shader/src/emit/lower.rs:1498-1504):(x, y, z)in the clamped argument buffer passes multi-axis grids directly toExecuteIndirect(draw.rs:1811).emit/lower.rs:1498-1504still lowersInput::MeshGroupstrictly asgroupId.i32(0) * mesh_stride(SV_GroupID.x * mesh_stride), ignoringSV_GroupID.yandSV_GroupID.z.(3, 2, 4), the host launches 24 threadgroups, but every(y, z)slice receives the same threeMeshGroupindices (0, 1, 2×mesh_stride), processing the first three meshlets 8 times instead of 24 distinct groups. The new unit test reads back only the clamped argument buffer and does not execute a mesh shader consumingInput::MeshGroup.Input::MeshGroupacross(x, y, z)or linearize the grid before launching multi-axisDispatchMeshgrids (with a mesh-shader execution test consumingInput::MeshGroup).[PR #2996] GPU: keep the group grid in bounded indirect mesh dispatchesto [PR #2996] GPU: number bounded indirect mesh groups consecutivelyImported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T03:37:21Z.
I reproduced the repeated indices from your review using a translated mesh program that reads
Input::MeshGroupand atomically adds to a counter for that group. The program runs through VIctory's normal indirect execution path. The same3×2×4record touches only the first three counters, eight times each, on9a851cd.5385cc6 gives one hit to each of the 24 counters by dispatching the bounded count along X. The test verifies the supported VIctory scalar input path. Console hardware numbering for multidimensional calls remains unverified. The oversized fallback and work limits are covered separately by GPU argument-buffer readback tests.
Six paired WARP runs agreed. Full GPU suite 248 passed and one ignored, both strict GPU Clippy configurations and policy passed. The branch also merges cleanly with #2624 and current
main.Please preserve the Git author if you cherry-pick this follow-up, or add this trailer if the fix or fixture is folded into another commit.
Co-authored-by: andrewpozdnakov7-jpg [email protected]
AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T04:07:02Z.
@andrewpozdnakov7-jpg I verified
5385cc6with the batch path from #2472. Inline handed a translated(3,2,4)mesh 24 distinct scalar group indices. Our previous batch integration still repeated three indices eight times each. I carried your normalization into the batch kernel and retained your original commit and authorship. RTX 5080 and WARP now agree on all 64 counters for each of the three record sets, including 66 records across the batch boundary. Full results and combined branchupstream-sync referenced this pull request2026-11-26 06:03:45 +00:00
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T05:44:57Z.
Automated triage for the maintainers.
Verdict: needs work. The change is in the mesh arm of the clamp shader in
crates/victory-gpu/src/indirect.rs. In-budget records now become[x*y*z, 1, 1]instead of[min(x, 65535), 1, 1]. Oversized records keep the old fallback, and the list budget is charged for every axis. The new testindirect_mesh_visits_each_translated_group_index(pipeline/host.rs) shows each translatedMeshGroupindex visited once for a(3,2,4)record. The HLSL looks right:x*ycan't overflow once each axis is at most 65,535, and the total is checked by dividing byz.What's missing is evidence about the console. The comment this replaces on
mainsays the console's mesh dispatches are one-dimensional. If that holds,y = z = 1and this PR changes nothing for the title. If it doesn't, the result depends on how the console numbers the groups of a multi-dimensional dispatch. Your own follow-up says that numbering is unverified. Row-major linearisation is a guess the test can't confirm, because the test only checks that VIctory's own scalar index is unique.To change the verdict, show one of:
yorzabove 1, for example fromVICTORY_DUMP_ARGUMENTS-style logging or the frame trace;With either, this is a clear fix. The budget accounting part is independently sound.
CI: passing (
check).Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T09:05:15Z.
Review: APPROVED
5385cc62cleanly addresses theInput::MeshGroupaliasing issue from the earlier review on9a851cd3:[g.x * g.y * g.z, 1, 1]incrates/victory-gpu/src/indirect.rs, giving each translatedMeshGroupa distinct consecutive index while preserving overflow-safe bounds checks (g.x * g.yfits inu32onceg <= 65535, zero axes yield[0, 1, 1]with cost0, oversized grids keep the existing fallback, and the list budget charges128per group).pipeline::host::tests::indirect_mesh_visits_each_translated_group_indexexecutes a translated GFX10 mesh shader readingInput::MeshGroupthroughState::execute_indirectand verifies all 24 slots for a(3, 2, 4)grid receive exactly one hit.Verified locally on Windows 11 (RTX 5090 + WARP + D3D12 Debug Layer):
cargo clippy -p victory-gpu --all-targets -- -D warnings(default and--all-features): cleanindirect::7/7 passed;indirect_mesh_visits_each_translated_group_index3/3 passedVICTORY_D3D12_DEBUG=1(--features diagnostics):indirect_mesh_visits_each_translated_group_index1/1 passedVICTORY_D3D12_DEBUG=1(--features diagnostics,VICTORY_D3D12_WARP=1):indirect::+indirect_mesh_visits_each_translated_group_index8/8 passedcargo xtask policy: 191 files ok(Note for maintainers: while RTX 5090 and WARP pass cleanly here including under the D3D12 Debug Layer, see the AMD RX 6750 XT report above on the new mesh test in case AMD drivers dislike a pixel-shader-less /
outputs: []mesh test pipeline.)LGTM.
Imported from Marvisak/VIctory. Originally posted by wwwwwwww3333333 on 2026-11-26T08:38:59Z.
AMD hardware run of
5385cc6(on main63bcca4). RX 6750 XT (RDNA2), driver 32.0.21045.29003, Windows 11, Rust 1.98.1.cargo test -p victory-gpu --lib -- pipeline::host::tests::indirect_mesh_visits_each_translated_group_index --exact, hardware adapter, three runs:STATUS_STACK_BUFFER_OVERRUN(0xC0000409);The display went black for a moment during the first runs and came back. The same test passes on WARP (three runs out of three). The other four tests of that module pass on the hardware adapter without it.
I have not separated whether this comes from the change or from indirect mesh dispatch on this driver, because I did not run the same test on main. The test is new, so main has nothing to compare with. I'd treat it as "unverified on RDNA2" and not as a regression.
Unit tests only, no game files.
Imported from Marvisak/VIctory. Originally posted by wwwwwwww3333333 on 2026-11-26T09:23:42Z.
A note on the approval above, in case it was written from the WARP/NVIDIA result: the AMD run in my earlier comment is still the open item for
5385cc6. On the RX 6750 XT (driver 32.0.21045.29003)indirect_mesh_visits_each_translated_group_indexon the hardware adapter ended with STATUS_STACK_BUFFER_OVERRUN (0xC0000409) in two of three runs and returned 24 zeros instead of 24 ones in the third, while WARP passed three out of three. I have not found the cause and I am not claiming the linearization is wrong. It is the one result I have that disagrees with the passing runs, so it may be worth another AMD or non-NVIDIA run before merging. Happy to rerun any build you want me to try.Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T09:57:24Z.
@wwwwwwww3333333, thanks for offering to rerun this on the RX 6750 XT. I adapted Andrew’s translated mesh fixture so you can test the same shader, pipeline, UAV and readback on upstream
63bcca43and this PR’s5385cc62. Each command runs one fresh process and prints all 24 counters before releasing the resources. Test commit · Download patchRTX 5080 and Windows WARP agreed in two runs per case on each revision (24 processes total).
(24,1,1)(24,1,1)(3,2,4)From your VIctory checkout in PowerShell, prepare both worktrees.
In the same shell, run this with
$tree = 'base', then with'head'. Hardware usesVICTORY_D3D12_WARP=0. Set it to1for the WARP comparison.Could you share the revision, first failing case, last
MESH_line and exit code, or the three readbacks if they pass? A failure on direct dispatch would reproduce the problem without the indirect clamp. If direct passes, the one-dimensional indirect control distinguishes a general indirect failure from one specific to the three-dimensional record.AI-assisted with Codex. Synthetic inputs only.
Imported from Marvisak/VIctory. Originally posted by wwwwwwww3333333 on 2026-11-26T10:37:24Z.
@steven-seagull27 thanks for the fixture. I ran it on the RX 6750 XT (RDNA2, driver 32.0.21045.29003, Windows 11) with
VICTORY_D3D12_WARP=0;MESH_DEVICEreported the RX 6750 XT in the runs below.Upstream
63bcca43+ test commit 3380643:direct_24x1x1run 1 died with 0xC0000409 right afterMESH_SUBMIT, run 2 read back all 24 counters as 0;indirect_24x1x1the same (0xC0000409, then all zeros);indirect_3x2x4run 1 all zeros.PR head
5385cc6+ the same test commit, after a reboot:direct_24x1x1died with 0xC0000409 right afterMESH_SUBMIT(the script stopped there, so the other two cases were not run on the head).So the direct dispatch already fails on this GPU on both revisions, without the indirect clamp involved. I do not know the cause. After the first failures on the base, a few runs came up on the Microsoft Basic Render Driver after the display driver reset (the display went black a few times), so I am not reporting those.
Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-26T10:40:12Z.
Supporting measurement for the direction: in the prologue's heavy view the card is ~40% of the frame (94-113 ms on an RX 7800 XT), and 350-600 draws a frame are still dropped without a host pipeline. The published Kelvaroq patch series measures 58-94 ms of card time for 4,500-6,400 indirect mesh draws when each record goes through the per-record clamp (~14 us each) against ~4 us when the group count is known up front (0041, launching through an amplification stage). Numbering the groups consecutively is the cheap half of that win and does not need the new stage.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T11:40:38Z.
Thanks for rerunning the controls on the RX 6750 XT. With the same fixture, direct
(24,1,1)dispatch failed on both63bcca43and5385cc6. That control runs without the indirect clamp. The run on5385cc6stopped at the direct case, so the indirect cases on that head remain unverified on this adapter. AMD retestImported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T06:32:00Z.
The
needs workverdict here (2026-11-26 05:44Z) predates the approving review on the current head:fuzeofficlalapproved5385cc6at 09:05Z, after the changes requested on9a851cd. Nothing has changed on the branch since.Asking for a re-triage rather than a code change: the earlier request (a consecutive linearization of bounded indirect mesh groups, and the
Input::MeshGroupaliasing it found) is the one5385cc6answers. CI is green and the PR is clean onmain.Imported from Marvisak/VIctory. Originally posted by CQ187901 on 2026-11-30T04:14:39Z.
Same rule as this PR, and it holds up in practice — posting a note because it was the whole cause of a visible bug in a title we port:
What we saw. A shoreline's near-field terrain layer never drew at all, while the far band was fine. The near layer is drawn from meshlet grids, the far band is a single slice. Everything else checked out (texture waits, early depth, the terrain shaders, water coverage, upload skipping); the G-buffer for the near ground was all zeros and the depth was only the water's, i.e. no fragment was ever written because the groups that would have written them were never dispatched.
Cause. With the per-record clamp
uint3(min(g.x, 65535u), min(g.y, 1u), min(g.z, 1u)), a (x, y, z) grid runs only its first slice, and the translated mesh takes its group index fromSV_GroupID.x, so the othery*z - 1slices have no way to run at all.Fix we landed locally (same shape as here): within the per-record bound, flatten the grid to
x*y*zgroups,[x*y*z, 1, 1]; a grid whose product is past the bound keeps the x-only fallback. Two things worth stating for review:Verification. RTX 3070, same save, same spot, stock switches: before, the near sand was absent (looking through it to the water below); after, it renders. Nothing else changed in the picture, and the FPS cost is the extra groups that were simply never run before.
Branch with the change on top of
main(one entry point there; our fork's batch path got the same rule): https://github.com/CQ187901/VIctory/tree/mesh-groups-wholeView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.