Repository navigation
Conversation
…OW=1) Each indirect execution had a clamp of its own: a wait for all earlier work, a compute dispatch, another wait, then the draw, about 5,100 times a world frame. With the switch, an indirect draw opens a window: one clamp pass recorded where the single clamp would be, reading a table the CPU fills while recording. The indirect draws after it that store to no buffer add their records to that table and read them clamped from the window's part of the argument buffer, with no pass and no barrier of their own. The pass clamps in draw order and charges the list's budget in that order, as the single clamps did. A window ends at any draw, dispatch or unordered-access clear other than a joining indirect draw, at an indirect dispatch, at an indirect draw whose shaders may store, at work a host library records and at the list's end; a draw opens a new one when the table, the bytes or the records are full or its arguments lie in a host copy the pass has no view of. Off by default; the clamp shader is the host's own, so the translator's source hash and the shader cache stay as they are. Counters per frame in the copy statistics line (diagnostics).
|
Tested the library-recording boundary on RTX 5080 and Windows WARP. I recorded two valid draw-argument records, replaced both records with a native GPU
As a negative control I removed only the This exercises the actual public library callback and GPU copy. The harness called the clamp entry points directly and read their output buffers. It establishes ordering at that boundary, without drawing a frame or estimating frame time. Alternative PR |
Dukestar69
left a comment
There was a problem hiding this comment.
Verified on RTX 5090 & WARP against origin/main (63bcca4):
cargo test -p victory-gpu --lib indirect:: -- --test-threads=1: 11/11 passed on RTX 5090 and WARP (includinga_store_ends_the_window,a_window_after_a_spent_budget_runs_empty,a_window_clamps_max_records_whatever_the_count,windows_clamp_as_single_clamps_do, andwindows_leave_the_argument_buffer_common).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Clean opt-in VICTORY_CLAMP_WINDOW batching for consecutive indirect draw clamps.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
|
Ported this window to a Linux/Wine line (RTX 3080 Ti, vkd3d-proton Before ( With your window ( Two things a porter may hit on a tree that has an older step window as well:
I did not take |
|
The settled-cell numbers, and they go the other way here — worth knowing before #2472's decision: Same build, same switch set, only
So it does exactly what it promises for the counts — the 1,190 mesh draws that no step can serve all join, only the compute dispatches remain — and it loses 66 ms on the card. The reason is visible in the shader: the window's pass is one group that loops over every record of the run ( What would win on this stack, if you take it further: the same table, but the records' bounds computed per group (one group per tile of 64, like the single clamp does) and the budget charged with the interlocked walk the single clamp uses, so the pass stops being serial. Your table is the part that is right; the pass's shape is what costs. (The port is in my tree behind |
|
@Slay326 I checked The integration App-local Agility 1.620.2/WARP 1.0.22: 13 indirect tests passed. Full GPU diagnostics with If both changes are taken, the integration is ready for the mesh-clamp side. Please retain the Git author on cherry-pick or rebase, or add |
|
I took the parallel shape you'd want next, and it is worse than the serial pass here — the numbers, so nobody spends the day on it:
The parallel version: one group per tile of 64 records, each tile's bounds worked out by its own lanes exactly as the single clamp does them, and the budget charged through the interlocked walk on the budget word (load, walk the tile, compare-exchange, retry). The walk is the price. 64 groups retry one word and each retry walks its tile again; the exact order a single clamp had — one call at a time, each seeing the budget the one before left — is not recoverable by contending groups. So on this stack the ~1,790 tiny passes are cheaper than charging the budget in order, in both shapes, and the switch stays off. What that leaves, if the count is what you want to fix: the order only matters for the budget. A window whose records are charged in table order on one group but with the tile's bounds precomputed (a first pass, one group per tile, writing each record's cost into the table) would take the serial walk down to 64 additions per tile — that is the shape I'd try next, but I'm not building a third variant before something else pays here. |
…y are (pull request Marvisak#927), SDWA sign extension of 16-bit results (upstream VIctory Marvisak#3124); two switches off by default (clamp windows, occlusion queries) and offline tools - Marvisak#927 (tippythetaidum): a buffer_load_format whose every use takes a half as f16, and d16 typed loads and stores at a table's fixed places, move 16-bit integers bit-exactly through unsigned twin views (HostShader::half_views). The face network reads its indices this way: mouths open and move (confirmed in a test run on an RTX 4070). Thank you, tippythetaidum. - upstream Marvisak#3124: SDWA dst_unused 1 (sext) with WORD_0 copies bit 15 upward; the reserved dst_unused 3 is refused. - VICTORY_CLAMP_WINDOW=1|alt (after upstream Marvisak#3197): indirect draws clamped a window at a time. Measured on this layer: 1.0 draw a pass (nothing joins): stays off. - VICTORY_OCCLUSION=1|alt (after upstream Marvisak#3138): the title's occlusion queries answered by the card; a counter of queries by kind (the title begins thousands). Not yet measured: off. - translate: VICTORY_NATIVE_HEADS lists each container program's first bytes; an ignored test decodes a raw GFX10 code file; the native pipeline dump writes root signatures. (Device methods 0x1c8 / 0x218 turned out to be a precompiled-pipeline cache the title falls back from.) The shader translator changed: delete both shader caches before the first run.
|
Thanks for testing and for the detailed reports, I'm on it.
AI-assisted. |
Regression test for the case reported on Marvisak#3197 together with Marvisak#2996 (5385cc6).
The window's pass carried its own copy of the mesh bounds; a change to the single clamp's rule (Marvisak#2996, 5385cc6) left the window on the old one and dropped mesh groups (reported on Marvisak#3197). Both shaders now take the rule from one HLSL function.
|
Pushed the fix (bdc4167, plus the test dff6c00): the single clamp and the window now share one Checked on an RTX 3070 (indirect tests):
AI-assisted. |
The window's mesh rule divergence fixed in bdc4167 was found and integrated first by Andrew (d16ae7d) on Marvisak#3197. Co-authored-by: Andrew <296776509+andrewpozdnakov7-jpg@users.noreply.github.com>
|
CPU cost per call of Method. KainanP/VIctory@perf/list-call-bench now has
The same on main + #1978 + #2821 + #3258 + #3274 + #3275 (the draw path with the texture-lock contention mostly gone,
Tests,
The failures are the same as on main on each adapter (the NVIDIA heap pair; on Intel that pair plus AI use: Claude Code (Claude Opus 5.5) extended the benchmark, ran the measurements and drafted this comment. |
|
The latest |
|
In-game numbers for this PR on an RTX 3080 Ti (Ryzen 7 5700X, PCIe 3.0, driver 621.40), plus one change on top that roughly doubles its gain. MeasuredSame scene in each run (the opening interior, about 5000 draws a frame, about 4200 of them indirect). The figures are medians of the steady reports, after loading. The clamp window comes from this PR's approach.
In timing runs ( Storing draws can close a window instead of ending itIn B, 63 windows a frame held 2268 draws, and 1916 indirect draws were still clamped alone because their pipeline
In practice: when the draw's pipeline may store, call
Checking the windowsTo make sure the windows are correct, I adapted fxceless's window check (fxceless's fork, commit These measurements and changes were made with AI assistance (Claude Code). |
|
Tested in game on an RTX 5090 (driver 620.73.04), Linux, GE-Proton11-14 Wine with its vkd3d-proton, GTA VI's opening prison yard, merged onto #2472 (same stack as my note there). Under Wine
Measured with AI-assisted (Claude); measured on my machine, no game data shared. |
|
Timed follow-up (same setup,
So the draws themselves got about three times cheaper, not only the clamps: with a barrier, a one-group dispatch and a rebind between every two indirect draws, the draw stream itself paid far more than the clamps' own 7 µs each. The 1,133 clamps left are the 920 indirect dispatches (never batched) plus window openers. AI-assisted (Claude); measured on my machine, no game data shared. |
|
Thanks for testing under Wine and for the fix.
What I can check on our side: the ported shaders and root signatures on native D3D12 (RTX 3070 and 4070), all AI-assisted. |
|
An AMD data point for choosing between this PR and #2472, as asked above. Setup: RX 7900 XTX (driver 32.0.32029.2010), Ryzen 9 7900X3D, Windows 11. Diagnostics builds of each PR merged onto
Given 0 errors here, it may be worth having it on by default. |
…ime (VICTORY_CLAMP_WINDOW=1) Conflicts with Marvisak#2312 (dispatches spread past 65,535 groups), both kept: - indirect::bound keeps Marvisak#2312's `spread` argument and 20-byte output records, and first ends an open window as Marvisak#3197 has it (and counts a single clamp). - State::execute_indirect: Marvisak#3197's window for indirect draws, Marvisak#2312's spread signature for dispatches; a dispatch never joins a window, and the clamp of one execution takes `is_spread` as before. The capture read-back keeps Marvisak#2312's record layout at the window's offset.
… in windows) with Marvisak#2312 kept
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Native Windows RTX 5070 12 GB, driver 621.40, Series X opening car sequence. Tested
Each run contributed 96 common Present intervals; captures and their following intervals were excluded. In the shared 25–61 s window after the world marker the medians were 579 → 579 ms and 586 → 591 ms. The window path was active: its counters imply about 801 and 813 clamp dispatches avoided per frame in the two enabled runs (grouped draws minus windows, median of complete report windows). All six launches reached the endpoint and all Presents returned S_OK. All 12 |
|
@Slay326 as you suggested, the read-mark rule is now its own PR: #3531 (draft, stacked on this one and #2472 plus the Wine fix; the change to review is its last commit). Measured share on our stack: windows without the rule 246.8 ms frame / 124.2 ms GPU, with it 209.1 / 78.0, clamp passes 2,847 → 1,138 per frame. It composes with Machad3x's storing-draw idea (details in #3531). AI-assisted (Claude); measured on my machine, no game data shared. |
…y are (pull request Marvisak#927), SDWA sign extension of 16-bit results (upstream VIctory Marvisak#3124); two switches off by default (clamp windows, occlusion queries) and offline tools - Marvisak#927 (tippythetaidum): a buffer_load_format whose every use takes a half as f16, and d16 typed loads and stores at a table's fixed places, move 16-bit integers bit-exactly through unsigned twin views (HostShader::half_views). The face network reads its indices this way: mouths open and move (confirmed in a test run on an RTX 4070). Thank you, tippythetaidum. - upstream Marvisak#3124: SDWA dst_unused 1 (sext) with WORD_0 copies bit 15 upward; the reserved dst_unused 3 is refused. - VICTORY_CLAMP_WINDOW=1|alt (after upstream Marvisak#3197): indirect draws clamped a window at a time. Measured on this layer: 1.0 draw a pass (nothing joins): stays off. - VICTORY_OCCLUSION=1|alt (after upstream Marvisak#3138): the title's occlusion queries answered by the card; a counter of queries by kind (the title begins thousands). Not yet measured: off. - translate: VICTORY_NATIVE_HEADS lists each container program's first bytes; an ignored test decodes a raw GFX10 code file; the native pipeline dump writes root signatures. (Device methods 0x1c8 / 0x218 turned out to be a precompiled-pipeline cache the title falls back from.) The shader translator changed: delete both shader caches before the first run. Rewritten from fxceless/victory-fork 58de9bf: diagnostics/ (run logs) dropped.
|
@Slay326 follow-up to this PR as #3676 (draft, stacked on this head AI-assisted (Claude); measured on my machine, no game data shared. |
Relation to #2472
This overlaps with #2472 by ESAT586, which takes the same approach: it batches the per-draw argument clamps of runs of indirect draws into fewer passes. Either this PR or #2472 should be merged, not both. Both batch the same clamps but reach different draws: #2472 the start of each list up to its first writing command, this PR anywhere in the list (each window ends at the next other draw). If #2472 is merged, I will close this and only bring the remaining windows back as a follow-up on top of it if in-game numbers show it matters.
I am opening it because we measured this version in game, so the numbers below may help with the decision. The differences I can see:
VICTORY_CLAMP_WINDOW=1; with the variable unset it is the same path asmain.Problem
Each indirect execution gets its own argument clamp (
indirect::bound). That is a UAV barrier, a one-group compute dispatch, another barrier and a transition, then the draw with the graphics pipeline bound again. In the world that comes to about 5,100 clamp passes a frame. The card switches from drawing to compute and back for every record, and no draw overlaps the next. Measured with GPU timestamps, the clamps alone took about 29 ms a frame.Change
Only
crates/victory-gpuchanges. WithVICTORY_CLAMP_WINDOW=1:indirect.rs: an indirect draw (not a dispatch) whose pipeline stores to no buffer opens a window. The window costs one UAV barrier and one clamp dispatch, placed where the single clamp would be. The clamp shader reads a table in the list's upload memory. The CPU fills that table while it records the following draws, and the GPU reads it only when the list runs. Each following draw that can join appends its record and reads its arguments from its part of the window's buffer. It needs no pass, barrier, transition or pipeline rebind of its own. The budget is charged in draw order, with the same bounds as the single clamp.A window ends at:
external.rs)host.rs)A new window starts when one is full (64 draws, 64 KiB, 4,096 records) or when the arguments come from a fifth source buffer.
draw.rs:execute_indirectuses the window when it can, and the single clamp as before when it cannot.may_storedecides.copystat.rs(diagnostics only): a "clamps per frame" line, printed only with the variable set. It counts single passes, windows, draws per window, and the draws clamped alone because they may store.The switch is off by default. With the variable unset, the only added work is one cached flag check per draw and one at each list close and reset. The clamp shader is compiled by the host, so the translator's source hash and shader caches stay as they are.
Tested
Windows 11 Pro 26200, RTX 3070 8 GB (driver 610.88), title 1.0.2.1, release +
diagnostics, BVH on,VICTORY_BACK_THREADS=4. 480 s runs in A-B-A order, same shader cache.mainalone cannot be measured on this card: it runs at 0.1 fps because the view heap overflows without #1779. The numbers therefore come from our test stack, an older main plus open NVIDIA PRs (among them #1762, #1779 and #2242/#2280/#2409). This commit, with the variable set, was the only change between A and B:VICTORY_CLAMP_WINDOW=1Unit tests, all with synthetic data (garbage records, no game data):
windows_clamp_as_single_clamps_do: a window gives the single clamp's results word for word. Cases: garbage records, the budget running out mid-window, more than 64 draws, two sources, and a 100-record draw across two tiles.a_window_after_a_spent_budget_runs_emptya_store_ends_the_window: includes the counter-check that a window left open would read the old value.a_window_clamps_max_records_whatever_the_countwindows_leave_the_argument_buffer_common: in any list order.Checks on this branch (
origin/main63bcca4 + this commit), RTX 3070:cargo test -p victory-gpu --release -- --test-threads=1: 249 passed / 2 failed withdiagnostics, 234 passed / 2 failed without. The two failures are the known heap-size pair on NVIDIA (dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views), which fail onmaintoo.cargo clippy -p victory-gpu -p victory-hle --all-targets -- -D warnings: clean with and withoutdiagnostics.cargo xtask policy: ok.Not addressed
draw.rs,host.rsandexternal.rsend windows is covered only by the game runs.AI-assisted.