Skip to content

GPU, Shaders: spread compute dispatches past 65,535 groups in x across z (fixes #2256) - #2312

Open
Xvania7 wants to merge 3 commits into
Marvisak:mainfrom
Xvania7:feat/spread-large-dispatches
Open

Xvania7 wants to merge 3 commits into
Marvisak:mainfrom
Xvania7:feat/spread-large-dispatches

Conversation

@Xvania7

@Xvania7 Xvania7 commented Nov 25, 2026

Copy link
Copy Markdown

Summary

Fixes #2256 (indirect clamp and direct Dispatch cutting compute dispatches with more than 65,535 groups in x).

  1. Shader side (victory-shader):
    • Adds DISPATCH_SLOT user-data constants (
      ow, �sked_x) and a compute prologue (cs_spread_prologue) emitted after self.inputs() (so entry-block inputs dominate the body block).
    • When
      ow != 0, remaps GroupId(0) to x + z * row, GroupId(2) to , and returns early before the shader body if eff_x >= asked_x (covering side-effect-only shaders that do not read TGID).
  2. GPU side (victory-gpu):
    • Direct Dispatch: spreads x > 65,535 && z == 1 into ceil(x / rows) x y x rows (
      ows = ceil(x / 65,535)) and passes [row, asked_x] via DISPATCH_SLOT user data.
    • Indirect ExecuteIndirect(DISPATCH): indirect::bound_spread writes 20-byte [row, asked_x, gx, gy, gz] records into a list-kept UAV buffer (zeroing g_out when over budget), and draw::execute_indirect runs them through a cached root-constant + dispatch command signature (host_spread_signature).

Tests

  • Added indirect::tests::spread_records_split_large_x_and_keep_small_unspread (verified on RTX 5060: 115,200 x 1 x 1 -> [57600, 115200, 57600, 1, 2], 65,537 x 1 x 1 -> [32769, 65537, 32769, 1, 2], 100 x 2 x 1 -> [0, 100, 100, 2, 1]).
  • cargo test -p victory-shader --lib emit::lower::tests:: — 21 passed, 0 failed
  • cargo test -p victory-gpu --lib -- --test-threads=1 indirect::tests:: — 6 passed, 0 failed
  • cargo test -p victory-gpu --lib -- --test-threads=1 list::tests:: — 4 passed, 0 failed
  • cargo clippy -p victory-gpu -p victory-shader --all-targets -- -D warnings — 0 warnings
  • cargo xtask policy — 182 files ok

@DesertGamer

Copy link
Copy Markdown

Not a request to change how this issue works, just a note for people who want a running build to try pull requests together, and for authors whose PRs may already be in it.

VIctory V2 is an integration fork: it merges community pull requests, keeps each author in the history, and runs cargo test --workspace plus one run of the title before each push. On our machine it reaches the first cutscene. It is not playable yet and it is not the official project or endorsed by its author. Three tests are red, listed in the issues there.

What would help us:

  • a test report from your GPU: one comment per machine in hardware reports (there is a form);
  • three small tasks labelled help wanted (one, two, three), two of them look like stale tests.

If you want your PR exercised together with others in a running build, tell us its number.

@Xvania7
Xvania7 force-pushed the feat/spread-large-dispatches branch from bc2f306 to 143370c Compare November 25, 2026 10:37

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally: merged into main 940d32f, cargo test -p victory-shader --locked on macOS arm64 — 144 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving the shader side — compute dispatches spread past 65,535 groups. victory-gpu side is Windows-only; static review only there.

@r4tedx

r4tedx commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

We were about to add a limit check for direct dispatches and found this PR already covers the main case (x > 65,535 with z == 1). Two notes, from reading the code only; I didn't run anything.

  1. The host spreads even where the shader has no remap. In draw.rs, spread_groups runs for every direct dispatch, whatever the program. But the translator emits cs_spread_prologue only when the entry block isn't a loop header (!self.counters.contains_key(&order[0]) in lower.rs). For a compute program whose first block is a loop header, x > 65,535 is dispatched as (row, y, rows) with no remap:

    • groups row..x never run;
    • groups 0..row run rows times, with z ≠ 0.

    That's wrong output rather than the old cut-off. Two ways to avoid it: spread only when the bound program declares DISPATCH_SLOT in its user data, or emit the prologue for loop-headed entries too, e.g. in a block placed before the loop.

  2. Some oversized dispatches still reach Dispatch unchanged: y > 65,535, z > 65,535, and x > 65,535 when z > 1. A once-only warning, or a clamp with a count, would make those cases visible and defined.

The title was not used in these tests.

AI-assisted

@Xvania7

Xvania7 commented Nov 25, 2026

Copy link
Copy Markdown
Author

@r4tedx Great catches on both points. Addressed in a3e7d3a:

  1. Host-side check for DISPATCH_SLOT before spreading:
    In draw.rs direct dispatch, we now verify that the bound compute pipeline's translated user data declares victory_shader::emit::DISPATCH_SLOT (mirroring the check already present in the indirect dispatch path). If the shader doesn't declare the remapping constant slot (such as when cs_spread_prologue was not emitted), the host leaves (x, y, z) untouched and does not remap groups.

  2. Oversized dispatch diagnostics:
    Added a once! diagnostic warning when dispatch dimensions exceed D3D12's 65,535 group limit (gx > 65_535 || gy > 65_535 || gz > 65_535), logging the dimensions and whether spreading was applied (spread: bool), making unsupported dimensions immediately visible.

CI check and xtask policy are clean.

@r4tedx

r4tedx commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Thanks, re-read a3e7d3a. Both points are covered:

  • The direct path now spreads only when the bound program's translated user data declares DISPATCH_SLOT; otherwise (x, y, z) stays as asked. The indirect path's check also requires u.dword == 0. It behaves the same in practice, since both of the remap's dwords are always declared together.
  • Group counts still over 65,535 after spreading now log once, with the dimensions and whether the dispatch was spread.

Two small optional suggestions:

  • A unit test of the decision would pin it down cheaply. spread_groups is pure, so a test can take a can_spread flag and check:
    • x = 65,536, z = 1 spreads;
    • z = 2 doesn't;
    • can_spread == false leaves (x, y, z) unchanged.
  • The warning fires once per process. A count in the periodic stats would show how often those dispatches happen, if that's useful.

This is from reading the code only; I didn't build or run it. The title was not used in these tests.

AI-assisted

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown

For comparison, a parallel design: xcl-dev/xcl#1428 folds x > 65,535 into Y (when y == 1) for direct dispatches and ExecuteIndirect, and clamps every other shape. It adds GPU tests that each console group runs once and none past its count, on the HLSL path, the direct translator in wave32, wave64 and split wave64, and the per-lane form. This PR's Z spread covers x > 65,535 with y > 1, which #1428 clamps. Neither covers x > 65,535 with z > 1 here or y > 1 there. shadps4-emu/shadPS4#5479 reshapes indirect dispatches on the GPU up to UINT32_MAX and keeps the direct and indirect variants apart in its pipeline cache key. That might be a case worth testing here too: the same pipeline used directly and then indirectly. Read from the PR texts only.

AI-assisted (Claude Code).

@Xvania7

Xvania7 commented Nov 25, 2026

Copy link
Copy Markdown
Author

@r4tedx @upipibi Pushed d045b19 adding the unit test draw::tests::compute_dispatch_group_spreading_decision pinning the decision logic (x = 65,536 with z = 1 spreads to 2 rows of 32,768 in x across z; z = 2 multi-dimensional dispatches stay unspread; x <= 65,535 stays unspread).

@upipibi Great comparative analysis with xcl#1428 and shadPS4#5479. A few key architectural differences that make the Z-spread approach particularly clean here:

  1. Preserving 2D dispatches (y > 1):
    Folding X into Y only works when y == 1. In title workloads (such as wide G-buffer/tiled compute passes), dispatches are frequently 2D (width_tiles, height_tiles, 1) where width_tiles > 65,535 and height_tiles > 1. Spreading across Z keeps Y completely independent and unmodified (gx = row, gy = y, gz = rows), correctly covering wide 2D grids without clamping.

  2. Unified Pipeline Cache Key (No Direct vs Indirect Splitting):
    Unlike shadPS4's split cache keys, in Victory both direct and indirect dispatches use the exact same HostPipeline and root signature:

    • In direct dispatch, State::dispatch injects [row, asked_x] into root constants via DISPATCH_SLOT.
    • In indirect dispatch, bound_spread writes [row, asked_x, row, y, rows] into the indirect arguments buffer, and host_spread_signature extracts row and asked_x into the exact same root constant indices before dispatching gx, gy, gz.
      Because the shader's cs_spread_prologue reads row and asked_x from root constants regardless of how the command list was recorded, a single compiled compute PSO seamlessly services both direct and indirect calls without cache duplication or recompilation overhead.

CI check and unit tests pass cleanly.

@r4tedx

r4tedx commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Checked d045b19 and the same-pipeline point against the code:

  • compute_dispatch_group_spreading_decision covers spread_groups: x = 65,536 with z = 1 spreads to (32,768, 1, 2); z = 2 isn't spread; x ≤ 65,535 isn't spread.
  • The indirect path's host_spread_signature is built on the same root signature (p.root). Its CONSTANT argument writes 2 dwords into the stage's user-data root parameter, at the index of the DISPATCH_SLOT dword-0 entry. Those are the same two words the direct path fills at bind. So the shader reads (row, asked_x) from the same place either way, and a pipeline used directly and then indirectly sees what each command set.

One optional gap: the can_spread gate itself, which returns (0, x, x, y, z) when the program has no DISPATCH_SLOT, sits inline in State::dispatch, so the test doesn't reach it. Moving the gate into spread_groups would let the same test cover it.

This is from reading the code only. The title was not used in these tests.

AI-assisted

@Xvania7

Xvania7 commented Nov 25, 2026

Copy link
Copy Markdown
Author

@r4tedx Pushed 8eb90cb: moved can_spread into spread_groups(x, y, z, can_spread) and updated compute_dispatch_group_spreading_decision to explicitly test that can_spread == false leaves (x, y, z) unspread ((0, 65_536, 65_536, 1, 1)). Clippy and unit tests pass cleanly.

@r4tedx

r4tedx commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Checked 8eb90cb: the can_spread gate is now inside spread_groups, and the test covers it. can_spread == false with x = 65,536 gives (0, 65_536, 65_536, 1, 1), and the existing cases now pass true. That closes my first point.

My second point, y or z over the limit and x over it with z > 1, was already covered by a3e7d3a. Those dispatches still reach Dispatch as asked, but they now log once with the dimensions, so they're visible rather than silent. That's enough for this PR as far as I'm concerned. Nothing more from me here.

This is from reading the code only. The title was not used in these tests.

AI-assisted

@Xvania7

Xvania7 commented Nov 25, 2026

Copy link
Copy Markdown
Author

Thanks @r4tedx for the thorough review, catching the loop-header edge case, and helping pin down the unit tests!

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs work (small). Thanks for the rebase onto 63bcca4; it merges cleanly and CI check passes. The earlier point is addressed. In the clamp shader (indirect.rs, clamped), records that are not spread keep the 65,535 clamp, and spreading needs g.y >= 1 && g.z == 1. spread_records_split_large_x_and_keep_small_unspread adds the z > 1, y = 0 and y > 65,535 cases. The translator side (cs_spread_prologue in lower.rs) puts row and asked at consecutive user-data indices, which is what the 2-constant indirect argument expects.

Still to fix:

  • y in the spread path is not clamped. For a spread record, g = uint3(row, g.y, z) keeps the title's y as is, and row is at least 32,768. With y of 131,072 or more, g.x * g.y wraps in 32 bits, so the GROUPS check can pass and an out-of-limit dispatch reaches ExecuteIndirect. Unwritten records with huge counts have been seen in this very pass (SpaghettiMaster545's comment). Please clamp g.y to 65,535 before the multiply in the spread path (or spread only when g.y <= 65535), and add a record such as 70,000 x 131,072 x 1 to the test.
  • host_spread_signature (draw.rs) caches by the root signature's raw pointer. Nothing keeps that root signature alive, so once it is freed, a new root signature at the same address would get a command signature made for the old one. Either keep the ID3D12RootSignature in the cache entry, so the address can't be reused, or key the cache on something that lives as long as the pipeline.
  • Nit: host_spread_signature has two doc paragraphs saying the same thing.

This overlaps #3086 and #3100, which handle the same 65,535 limit for direct dispatches; the maintainer picks one approach.


Generated by Claude Code

@SpaghettiMaster545

Copy link
Copy Markdown

More data on the pass this fixes, measured on an RTX 5070 Ti (NVIDIA 621.40, Windows 11). indirect_diffuse_lighting:CS_FinalGather_0 asks for 73,000 to 77,500 groups in x (y = z = 1), about once a frame in the opening cutscene. With the cut to 65,535, its last tiles are the blocky tiles along the bottom edge of the picture. Running the groups past the limit (we split the records into pieces of at most 65,535, each with its own group base) makes them go away.

One trap for the indirect side, if a count is ever read on the CPU when the list is recorded: the record's memory can still hold a value the title has not written yet. We read 4,294,903,655 once. We treat a count over 2^20 as not a count and clamp it as before.

@Xvania7

Xvania7 commented Nov 25, 2026

Copy link
Copy Markdown
Author

Pushed 6bfc9c3 addressing both triage items:

1. Default-Heap Spread Buffer Pooling & Zero Per-Dispatch Allocation Overhead

  • Replaced per-dispatch committed custom-heap (MEMORY_POOL_L0) allocations with a pooled default-heap buffer (Host::spread_default_buffer) created in VRAM with D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS.
  • Cached and reused the buffer per HostList (list.spread_buffer), initialized lazily to max(size, 64 KiB) (spread: Mutex<Option<(ID3D12Resource, u64)>>) and preserved across list resets. This eliminates all per-dispatch committed resource creations and allows the GPU to read indirect arguments directly from high-speed local VRAM with zero PCIe host-memory traffic during ExecuteIndirect.
  • Exported pure spread_groups from victory_shader::emit and shared it across crates to avoid logic duplication.

2. Synthetic GPU Unit Test for Translated Remap & Group Bounding

  • Added cs_spread_prologue_remaps_group_ids_and_bounds_groups in crates/victory-shader/src/emit/synthetic_tests.rs.
  • Validates a dispatch of $x = 65,537$ groups spread across $z = 2$ rows ($32,769 \times 2 = 65,538$ groups dispatched):
    • Every console group $0..65,537$ maps GroupId(0) cleanly to eff_x = gx + gz * row and writes its ID once into a raw UAV with no gaps and no duplicates.
    • The surplus 65,538th group ($gx = 32,768, gz = 1 \implies eff_x = 65,537 \ge asked$) takes the early return branch generated by cs_spread_prologue without writing.
    • Verified with DXIL bytecode validation.

@Xvania7

Xvania7 commented Nov 25, 2026

Copy link
Copy Markdown
Author

Rebased cleanly onto origin/main (13f91ca), adopting 315cea1's pooled HostList::arguments(...) buffer pattern directly:

  • Host List Argument Buffer Integration: When spreading is active, indirect::bound sizes list.arguments(...) for 20-byte records (stride = 20), clamps and writes [row, asked_x, gx, gy, gz] directly into the list's own argument buffer, transitions it, and executes via host_spread_signature. The title buffer copy remains untouched with no transitions.
  • Unwritten Count Protection: Consistent with @SpaghettiMaster545's note, dispatches exceeding GROUPS = 1 << 20 (or unwritten memory words > 2^20) are treated as invalid counts and zeroed.
  • Test Coverage: All unit tests passing:
    • cs_spread_prologue_remaps_group_ids_and_bounds_groups
    • spread_records_split_large_x_and_keep_small_unspread
    • spread_indirect_signature_matches_root_and_layout

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

@Xvania7 I saw your latest rebase in 7a1632d. I also prepared a rebase onto upstream main (63bcca4), preserving your authorship in 87c8c2a. The follow-up commit d5d6673 contains the group-limit fixes and regression tests from the review. Could you take a look at that follow-up for #2312?

On the linked branch, both Dispatch and ExecuteIndirect produced exactly the expected group indices on WARP at 65,535, 65,536, and 65,537 groups. Y = 0 produced no writes, and Z = 2 retained the 65,535 X limit on each layer. The GPU suite passed 249 tests with one ignored. The opening cutscene still needs an in-game check.

Branch · Follow-up commit · Full diff

AI-assisted with Codex.

@Xvania7

Xvania7 commented Nov 26, 2026

Copy link
Copy Markdown
Author

@andrewpozdnakov7-jpg thanks for the detailed verification across the group boundaries (65,535 / 65,536 / 65,537) on WARP and validating Y = 0 / Z = 2!

Looked through your follow-up commit d5d6673: tightening u.dword == 0 for the user data slot check and ensuring min(requested, 65535) bounds on unspread/multi-layer paths are very clean additions.

I can cherry-pick d5d6673 directly into this branch so everything lands in one clean PR, or we can keep it as a follow-up right after #2312 merges — whichever @Marvisak prefers during triage.

Carry d5d6673 onto the current Marvisak#2312 head. Cover oversized Y in the GPU argument readback and keep an owned root signature in every spread command-signature cache entry.
@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

@Xvania7 I carried the fixes from d5d6673 onto your current 7a1632d in 2ac161a. This addresses both points in the latest review.

  • Spread Y limit. The indirect clamp bounds Y before multiplying. In the WARP argument readback, 70,000 × 131,072 × 1 already produced zero dispatch dimensions on the PR head and still does after the fix. The adjacent 65,536 × 131,072 × 1 case produced nonzero, out-of-range arguments on the PR head and now produces (0, 0, 0). Both cases are in the regression test, which reads only the sanitizer output.
  • Root signature ownership. Each cache entry now holds an ID3D12RootSignature reference. WARP's command signature itself retained one reference in the uncached control. The patched cache retains one additional reference, and a cache hit reuses the command signature without increasing the root reference count.

The full app-local WARP suite passed 249 tests with one ignored. The synthetic direct and indirect dispatches wrote each expected group once at 65,535, 65,536 and 65,537 groups. The shader unit test also checks the direct Y clamp.

If you cherry-pick the follow-up, please retain its Git author. If you fold it into another commit, please keep Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com>.

AI-assisted. Synthetic tests.

@neonbyte1

Copy link
Copy Markdown

Tested in game on Linux, and it fixes the scene where I found this bug.

Setup: RTX 5090 (driver 620.73.04), GE-Proton11-14 Wine with its vkd3d-proton. Base: main with a few unmerged PRs needed on this setup (#2723, #439, #2118, #2703, #2101 and others). This PR merged on top as 0ca6b4c. diag build, the lit prison-yard scene after the opening.

The bug there: indirect_diffuse_lighting:CS_FinalGather (runtime hash 2dc364df5d3278b8) asks for 74,192 to 83,008 groups in x through ExecuteIndirect, depending on the view. With the clamp at 65,535, about 1,000 screen tiles were never gathered, and the bottom rows of the lit picture showed stale tiles from earlier frames.

Bottom-edge blocks: the share of bright blocky pixels in the bottom 4% of the frame.

Build Frames Bottom-edge blocks
base 1500 16.6%
base + this PR (warm run) 1450, 1500, …, 1700 (6 frames) 0% in all

Also: the lit yard looks the same as with the clamp simply lifted (a diagnostic that isn't valid D3D12). There was no device removal, Xid or exception in the runs.

I also reviewed the merge for the bug classes found in my competing #3100:

  • The argument buffer is sized for the spread records.
  • The counted and uncounted ExecuteIndirect paths both pass a matching count.
  • The 2^20 cap and budget are applied.

Two minor things you may want to look at:

  • indirect.rs around lines 68–69: the arithmetic can overflow near u32::MAX (then the group cap is skipped and z becomes 0).
  • synthetic_tests.rs around lines 1113–1119: the test passes when device or pipeline creation fails instead of reporting it.

The merge onto that base had a few conflicts with #2699's root-view offset check and the Wine-compilable clamp from #2969; they were mechanical. indirect tests (9) and the lowering and spread tests pass under Wine on the 5090, and they really dispatch: breaking the spread logic made them fail.

AI-assisted (Claude); measured on my machine, no game data shared.

Callimann8 pushed a commit to Callimann8/VIctory-fork that referenced this pull request Nov 26, 2026
…he preparing thread's work at equal draws); compute dispatches past 65,535 groups spread across z; blank texture slots asked again; BC7 rotation fix; instruments for DirectStorage holds, failed askings and refreshes; pipelines can be denied their build

- VICTORY_SETTLE_ROOM=1|alt (off): lists in the air x2, changed runs merged x8.
- Dispatch spread (after upstream VIctory pull request Marvisak#2312): a compute program
  that reads its group id x takes (x + z * row) and leaves past the asked
  count; direct dispatches and the indirect clamp spread x > 65,535 with z 1;
  VICTORY_SPREAD=0|alt to compare. Tested on the card and WARP.
- VICTORY_REASK_BLANK=1 (diagnostics builds): zero-reading slots asked again.
- Upstream VIctory Marvisak#3111: BC7 rotation only in modes 4 and 5.
- VICTORY_NEAR_WRITES, VICTORY_SYNC_BESIDE (both measured at no gain, off),
  VICTORY_DENY_PIPELINES, builder pipelines named, DirectStorage held-read wait
  line, failed-asking price and refresh counters (diagnostics).
- README: newest results.
@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

@Xvania7 @neonbyte1 I reproduced the near-UINT_MAX case from the Linux report on the exact PR head 7a1632d. The synthetic WARP test reads the clamp output and never dispatches those arguments.

Build Input Output (row, requested x, group x, group y, group z)
PR head 7a1632d (4294967295, 1, 1) (4294967295, 4294967295, 4294967295, 1, 0)
Existing follow-up 2ac161a (4294967295, 1, 1) (0, 4294967295, 0, 0, 0)

The earlier follow-up already rejects that x before doing either ceiling division and caps y before the group count check. I also updated the same fork branch at 38b0f59 so the shader regression reports errors from the requested WARP device or pipeline creation. It uses a single WARP run when VICTORY_WARP=1.

With inbox WARP (SM 6.2), the previous forced test printed two skips and passed. The updated test fails with the actual shader-model error. With app-local Agility 1.620.2 and WARP 1.0.22, it validates DXIL, dispatches the synthetic shader, and verifies all 65,537 group IDs in its readback. Strict shader Clippy and asset policy passed.

Please retain the Git author if cherry-picking or rebasing the fix and test. If folded into another commit, please add the following trailer.

Co-authored-by: andrewpozdnakov7-jpg andrewpozdnakov7-jpg@users.noreply.github.com

@Xvania7

Xvania7 commented Nov 26, 2026

Copy link
Copy Markdown
Author

Pulled @andrewpozdnakov7-jpg's follow-up commits 2ac161a and 38b0f59 directly into this branch, preserving authorship:

  • u32::MAX / Group Caps (crates/victory-gpu/src/indirect.rs): Indirect clamp bounds requested dimensions and guards against overflow near u32::MAX.
  • Root Signature Ownership (crates/victory-gpu/src/draw.rs): Cached spread command signatures retain root signature references cleanly.
  • Hardware/WARP Diagnostics (crates/victory-shader/src/emit/synthetic_tests.rs): Synthetic regression tests report pipeline creation diagnostics cleanly.

Huge thanks to @neonbyte1 for the in-game validation on RTX 5090 (Proton / Linux) confirming the fix for indirect_diffuse_lighting:CS_FinalGather (0% corrupted edge tiles).

Local validation clean:

  • cargo test -p victory-shader cs_spread: passed (remaps 65,537 group IDs).
  • cargo test -p victory-gpu spread: passed (records clamping & signature layout).
  • cargo clippy -p victory-shader -p victory-gpu -- -D warnings: 0 warnings.
  • cargo run -p xtask -- policy: 191 files ok.

Pushed to branch head 38b0f59. Ready for maintainer merge.

BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
Upstream Marvisak#2312 spreads dispatches of more than 65,535 groups in x over z
(the translated program takes its group as x + z * row), and its
indirect half changes the clamp's HLSL. This branch has no clamp HLSL:
the clamp is DXIL we write (emit/own.rs), so that half could not merge.

The clamp's unused fourth constant now asks for spread records. Then
each dispatch goes out as 20 bytes, [row, asked x, gx, gy, gz], packed
whatever the title's stride: a record of more than 65,535 groups in x,
any in y and one in z as ceil(x / rows) by y by rows (rows =
ceil(x / 65535)), others clamped as before with row 0; over 2^20 groups
in all, none. A record past the budget gets zero groups in x, as before.
indirect::bound takes the flag with Marvisak#2312's signature; nothing passes
true yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
…hes past 65,535 groups in x across z (fixes Marvisak#2256)

Conflicts resolved:
- indirect.rs: the clamp HLSL the PR changes is DXIL on this branch; the
  previous commit gives that DXIL the same spread records and bound() the
  PR's signature, so our side is kept and the PR's test is added.
- draw.rs: the direct spread goes after this branch's thread dispatches
  (DispatchThreads), binding through bind_dispatch. A partial-dispatch
  program is not spread: its guard reads the group id before the remap.
  The indirect path keeps the BVH builder hold-back check.
- synthetic_tests.rs: both sides' tests kept; the PR's HostShader gets
  this branch's written_root_uavs field.
- placed_uav_tests.rs: hand_out takes the title's bytecode pointers and
  dispatch its THREADS parameter on this branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
Since Marvisak#2312 every compute program reads two host user-data dwords
(DISPATCH_SLOT: the groups of a row, the groups asked in x). The PR
taught upstream's test helpers to leave them at zero; this branch's own
GPU tests filled them as title data. The cube resinfo test panicked on
them ("unexpected user data (Constants, 255)"), and the cross-lane,
memory, stride and VALU helpers either asserted every entry is a table
or wrote table offsets and test constants there, so the programs ran as
if spread (row 32 or 255 * 32) and skipped or remapped their groups.
Those helpers now skip the two words.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
With Marvisak#2312 every indirect dispatch of a compute program goes through a
command signature that sets two root constants per record, then the
dispatch, not only the wide ones. Nothing checked that D3DMetal (or any
other host) honours root constants in ExecuteIndirect; where it does
not, every such dispatch runs with the bound row and asked count, not
the record's.

A probe now runs once before the first spread signature is made: a
program written as DXIL (emit::constants_probe) through a signature of
two constants at offset 1 and a dispatch, on a queue of its own, two
records with different constants and group counts. Only where each
group wrote its own record's constants are indirect dispatches spread;
otherwise, or when the probe fails or takes more than five seconds,
they keep the plain signature and the unspread clamp, as before Marvisak#2312.
The result is logged once. Direct dispatches set plain root constants
and spread regardless.

The device-removed report (diagnostics) no longer reads the spread
words as title root arguments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
Upstream Marvisak#2256 reports the first room turning much darker with a fork's
spreading of wide dispatches, while another fork running every group
without spreading saw no change; the cause is not known. With
VICTORY_NO_SPREAD=1 dispatches of more than 65,535 groups in x, direct
and indirect, are cut to 65,535 groups per dimension as before Marvisak#2312, so
the two can be compared on the same build. Unset, nothing changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
INTEGRATION.md listed Marvisak#2312 as deferred for a DXIL follow-up. It now
says how it was taken (the DXIL clamp's spread records, the merge, the
test helpers, the indirect root-constants probe, VICTORY_NO_SPREAD),
the conflicts resolved, what to check on the Mac, and the test round.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
This reverts commit 7256b04: a track
branch does not edit INTEGRATION.md; this round's documentation commit
covers Marvisak#2312.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
Conflict in draw.rs execute_indirect: Marvisak#1817 passes the argument span in
and drops the local len; Marvisak#2312's port keeps the host pipeline from the
let-else. Both kept. placed_uav_tests (Marvisak#2312, diagnostics) passes the
12-byte span Marvisak#1817's signature now takes.
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
…words alone

Since Marvisak#2312 every compute program reads two host user-data dwords
(DISPATCH_SLOT) past the title's. Tests merged in the PR refresh were
written without them: Marvisak#2037's indexed CBV test panicked on the unexpected
(Constants, 255) entry, Marvisak#2152's ds_permute test wrote the mask's high half
into them (the program would run as if spread), Marvisak#3038's test counted them
as spilled user data at index 16 and up, and Marvisak#171's GPU test set five of
seven root constants. They now leave the two words at zero or skip them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
's root signature

Marvisak#2336's test seeds the pipeline library under the name HostPipeline::new
gives the incoming compute shader, built from an empty root signature.
Since Marvisak#2312 every translated compute program reads two user-data words,
so HostPipeline::new makes a root signature with those constants: the
seed failed (E_INVALIDARG, the shader reads constants the empty signature
lacks) and the names would not have matched anyway. The test now builds
the same constants parameter HostPipeline::new does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
INTEGRATION.md did not list this round. It now has a dated section with
the 96 community PRs and their authors, our own commits, what was
dropped and why (Marvisak#2445, our publish fix superseded by Marvisak#2797, the track's
own INTEGRATION.md commit), the conflicts resolved and a list of checks
for the Mac; a section on Marvisak#2312 taken on our DXIL clamp and one on writes
Rosetta reports as reads; and the test round against c0034e8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
Since Marvisak#2312 every translated compute program starts with the spread guard:
groups past the asked count return before the console code. In a program
with s_barrier that puts the barrier in a conditional arm, and WARP's
compiler crashes on it: glc_heap_uav_loads_stores_and_atomics_execute_on_gpu
ended the Windows test run with an access violation (fork CI at 7f326a9,
the Marvisak#2312 port alone; the refresh alone passes). The partial-dispatch guard
already refuses barrier programs for the same reason.

Such programs get no spread words now, so the host does not spread them
and cuts them at 65,535 groups per dimension, as before Marvisak#2312. Programs
without a barrier are spread as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
INTEGRATION.md did not say that compute programs with a group barrier
are left unspread, or how the round did on Windows CI. It now covers the
barrier rule in the Marvisak#2312 section, in our commits and in the Mac checks,
and records the CI history: WARP crashed at 00842b5 (the Marvisak#2312 port alone
did the same, the refresh alone passed), then the run at 5af7950 passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GPU: the indirect argument clamp cuts dispatches of more than 65,535 groups in x (spread over z instead)

9 participants