Skip to content

GPU: expand indirect rectangle-list draws on the GPU - #346

Closed
BastienRodz wants to merge 7 commits into
Marvisak:mainfrom
BastienRodz:gpu/indirect-rectangles
Closed

BastienRodz wants to merge 7 commits into
Marvisak:mainfrom
BastienRodz:gpu/indirect-rectangles

Conversation

@BastienRodz

@BastienRodz BastienRodz commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #255 for non-indexed draws.

What

Indirect draws with the console's rectangle-list topology (17) now run on the host instead of being dropped. State::execute_indirect refused them because rectangles are expanded on the CPU (primitive::expand_rects), and an indirect draw's vertex count is only known on the GPU. #255 counts about 250 of these drops per world frame, and the title draws its full-screen passes as rectangles.

How

For kind 0 (DRAW) with RECTANGLES, after the existing argument clamp, two compute passes of ours run before ExecuteIndirect (new module crates/victory-gpu/src/rectangles.rs). Both are HLSL compiled at run time by the system's D3DCompile (cs_5_1): Microsoft's, or Wine's vkd3d-shader under Wine/Proton. For the latter they read buffers as 32-bit words ((RW)StructuredBuffer<uint>), and their root signatures are serialized in code (since c256f83; checked with vkd3d-compiler 2.1, the version GE-Proton11-12 ships).

  1. rect_rewrite (one thread per record):
    • Respects the title's count buffer.
    • Checks that start .. start + 3 * rects lies inside every bound per-vertex vertex buffer.
    • Allocates rects * 6 vertices from a per-list scratch with an atomic counter.
    • Writes a rewritten copy of the record into a list-owned arguments buffer: rects * 6 vertices, the same instances, the allocated start, the same start instance.
    • The title's arguments are not changed beyond what the clamp already does.
  2. rect_expand (one group per record, one pass per per-vertex slot):
    • Writes (v0, v1, v2, v0, v2, v3) per rectangle.
    • Computes v3 = v0 + v2 - v1 the way expand_rects does: same formats (primitive::components), same half-float and UNORM conversions and rounding. Unknown formats and components past the stride keep v0's bytes.
  3. ExecuteIndirect then reads only list-owned buffers: the rewritten arguments, in which records at or past the title's count are empty draws, so no count buffer is passed (since 7ff1184). The expanded slots are bound with IASetVertexBuffers. Transitions around the draw put the scratch back in unordered access, so the next indirect rectangle draw of the list reuses it.

Half floats, on both paths (primitive.rs and the shader's copy):

The CPU and GPU paths therefore still agree byte for byte.

List-owned memory (host.rs):

  • one 8 MiB default-heap vertex scratch per list, made on first use;
  • a rewritten-arguments buffer that grows when a draw has more records;
  • chunks of atomic counters, zeroed at submission the way the clamp's budget is.

indirect::bound is split so that clamp_uav (clamp, then a UAV barrier) can be followed by the rewrite pass. bound itself behaves as before.

Fallbacks: if a pass is unavailable or the arguments are unaligned, the draw is dropped as before, each case with its own diagnostics why(...) reason. Records that do not fit the scratch, or that reach past their buffers, draw nothing.

The rectangle path changes the state of no title buffer: the arguments and the count are only read, by the rewrite pass.

Limitations, written as shortcut: notes in the module:

Tested

Native Windows: the upstream CI's checks (clippy -D warnings with and without --all-features, then cargo test --workspace --locked) pass on GitHub's windows-latest at this head: https://github.com/BastienRodz/VIctory/actions/runs/45381063747

Latest, on 8ef6bfe rebased onto main ffe310e (clean): cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features as the CI runs it, is clean. victory-gpu: 58 passed under plain Wine (61 with diagnostics). On vkd3d-proton: 60 passed and 1 failed, a_rejected_blob_gives_an_empty_library, an environment failure main has there too. Policy: 155 files ok. The details below are from earlier heads.

Mine: Linux x86_64, cross-built with cargo xwin for x86_64-pc-windows-msvc, tests run under Wine 11 with Xvfb.

  • GPU tests: vkd3d-proton 3.1 on Mesa lavapipe (software Vulkan; VKD3D_FEATURE_LEVEL=12_0), as the host D3D12 device.

  • HLSL: compiled by Microsoft's d3dcompiler_47.dll, installed with winetricks.

  • cargo xwin test -p victory-gpu: 48 passed, 2 failed, 1 ignored. main (d2a4bae) in the same setup: 41 passed, the same 2 failed. The two failures are the known vkd3d-proton environment failures, a_rejected_blob_gives_an_empty_library and buffer_data_reaches_the_host_texture.

  • Without a host device (plain Wine, so host tests skip): 50 passed. With --features diagnostics: 52 passed.

  • New tests:

    • Unit tests: slot_elements_filters_and_clips_to_stride, scratch_layout_handles_multi_slot_and_alignment, max_source_vertices_takes_minimum_across_slots, dispatch_grid_respects_d3d12_limit.
    • Compile checks: hlsl_compiles (both shaders through D3DCompile), rectangle_expander_builds (the host accepts both pipelines).
    • gpu_expansion_matches_cpu_expand_rects: runs both passes on synthetic vertices and compares the GPU output byte for byte with expand_rects. The vertices cover F32x2, F16x2, UNORM16x2, UNORM8x4, an unknown format and an element past the stride. The records cover two rectangles, a rectangle with instances and a start instance, an out-of-bounds record, a zero-instance record and a record past the count.
  • Mutation check: with the shader's fourth corner changed to a + f + b, gpu_expansion_matches_cpu_expand_rects fails, so the comparison catches it.

  • cargo xwin clippy -p victory-gpu --all-targets, with and without diagnostics: one warning, the same one as on main (a missing safety comment in a test outside this diff).

  • rustfmt --check is clean on rectangles.rs. The touched files have the same rustfmt diffs as on main, none new.

  • cargo xtask policy: asset policy: 152 files ok.

Tested by others (thanks)

Not run

  • The world picture with this PR, on a setup that does not hang there.

No game data used: every test input is synthetic.

AI-assisted: implemented with Gemini 4 Neon, then reviewed, corrected (docs, count-buffer state) and tested with Claude Code. Every command above was really run.

🤖 Generated with Claude Code

@DarX-Oren

Copy link
Copy Markdown

Native RDNA2 validation and scratch alignment fix

Tested this PR on physical AMD RX 6700 XT hardware using native Windows D3D12.

I found an issue in scratch_layout(): reserving worst-case alignment slack can reject a valid layout when the vertex slots already fit within the available capacity.

I implemented a local correction that calculates the actual alignment padding while preserving the production 8 MiB scratch limit.

The same synthetic rendering fixture was tested before and after the correction:

Test Original #346 Local fix
Normal rectangle: incorrect pixels 0/1024 0/1024
Exact 120-byte fit: incorrect pixels 1024/1024 0/1024

The corrected ExecuteIndirect output produced an RGBA8 image identical by SHA-256 to the CPU-expanded reference.

Validation:

  • RX 6700 XT (1002:73df)
  • Driver: 32.0.21045.29003
  • 10 rectangle tests passed
  • 272 workspace tests passed
  • 276 tests passed with diagnostics
  • Zero failures, four ignored per configuration
  • Clippy and asset policy passed

Four additional comparisons were internally skipped because the console compiler was unavailable. The D3D12 debug layer was also unavailable.

Indexed rectangles and SV_VertexID remapping remain outside the scope of this correction.

The fix and regression test are available in my local commit b34ae5c. I can share the patch if you would like to incorporate it into this PR.

No commercial game data was used.

AI use: OpenAI Codex assisted with implementation, testing and analysis on physical hardware.

BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 24, 2026
…st case

scratch_layout took 16 bytes of alignment slack per extra slot off the
capacity before counting vertices, so a layout that fits exactly (two
slots of 8 and 12 bytes in 120, no padding needed) was refused, and in
8 MiB a few rectangles of room were lost. It now starts from the
unpadded vertex count and steps down a rectangle at a time until the
padded regions fit. Reported by DarX-Oren on Marvisak#346.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BastienRodz

Copy link
Copy Markdown
Contributor Author

Thanks for running it on a real RX 6700 XT, and for the exact-fit case. You're right: scratch_layout took the worst-case slack (16 bytes per extra slot) off the capacity before counting vertices, so a layout that fits exactly was refused. With the 8 MiB scratch the cost in practice was a few rectangles of room, but it was wrong.

Fixed in cee702e. It now starts from the unpadded vertex count and steps down one rectangle at a time until the padded regions fit. I wrote it myself rather than taking your patch, to keep the history in one piece. scratch_layout_handles_multi_slot_and_alignment gains two regression cases:

  • two slots of 8 and 12 bytes in 120 bytes: 6 vertices, second slot at 48;
  • two slots of 4 bytes: 55 bytes too few, 56 enough, second slot at 32.

Before the fix both return None.

Re-run (cross-built, Wine + vkd3d-proton 3.1 on lavapipe): cargo xwin test -p victory-gpu gives 48 passed and 2 failed, the same two vkd3d-proton environment failures as main. gpu_expansion_matches_cpu_expand_rects passes. Clippy: same single warning as main. cargo xtask policy: 152 files ok.

If you can, a rerun of your pixel fixture on this head would be welcome, and so would a world run on a diag build to see whether the topology 17 drop reason goes away.

No game data used. AI-assisted (Claude Code).

@fuzeofficlal

Copy link
Copy Markdown
Contributor

Native D3D12 results for cee702e on Windows 11. All 8 rectangle tests passed on both an RTX 5090 and a Radeon iGPU (1002:13c0), with no errors from the D3D12 debug layer. That includes the updated scratch-layout tests.

The additional fixture copies synthetic vertices into a vertex buffer on the same command list, then records the PR's expansion and barriers followed by an actual ExecuteIndirect draw. The indirect record starts at vertex 1, after an unrelated sentinel. All 64 pixels matched the expected 8×8 image on both adapters. On the RTX 5090, omitting the vertex copy in the earlier bcc32cf run left the target at the clear color and failed the first pixel assertion.

The fixture uses a small test graphics pipeline and synthetic inputs throughout. Game rendering, the caller's pipeline routing, and count-buffer behavior are outside its coverage.

@vladbondarenko97

Copy link
Copy Markdown

First test of this PR against the retail title (the PR is synthetic-only today), on the GPU where the dropped rect draws matter most.

Setup: RTX 3080 Ti 12 GB, driver 610.60 (32.0.16.1060), Windows 11 Pro 26300, i7-12700KF, complete 1.0.2.1 package (all 111 files SHA-256-verified), built at the PR head with --profile diag --features diagnostics, XCL-style isolation off, network disabled.

Result — the counter says the fix is live:

victory_gpu::host: 30.0 fps, 33.3 ms/frame (2.0 ms on the GPU), 39 draws/frame,
  dropped 0 without a host pipeline (0 being made) and 0 indirect

0 indirect with rect-list content on screen: the indirect rect draws are reaching the host path instead of being dropped. Menus, the legal screens (Copyright / Photosensitivity), the full-colour key art and the intro video all render; frame captures (diagnostics) are clean PNGs at 30 fps.

Two observations that may be useful:

  1. During one transition the rate dropped to 9.4 fps / 106.4 ms per frame with the GPU at only 2.3 ms — i.e. the cost was not in the expand passes; it recovered to 30.0 fps on the next sample. If anyone else sees a periodic dip, it is worth checking whether the rewrite/expand readback or the scratch allocation is on that path.
  2. One run that started 2 s after I killed a previous instance failed every frame with no swap chain — Not enough memory resources are available to process this command (14,861 failures, zero swap chains) — that was environmental (the prior process's GPU memory had not been reclaimed yet), not this PR; with a 25 s settle it initialised normally. Worth knowing before attributing a swap-chain failure to the change.

I did not reach the world in these runs (menu input is scripted here), so I cannot yet say what the expand passes do to world content — happy to run it again with whatever key/timing recipe you want, or to try a patch build that logs per-draw counts.

AI-assisted (Claude Code CLI via a model proxy; logs and offsets only, no game data).

@BastienRodz

Copy link
Copy Markdown
Contributor Author

Thanks for running it against the title. A caveat on the counter: per #255 the rectangle drops are in world frames, and the menus and intro may issue no indirect rectangle draws at all. So 0 indirect before the world is probably what main shows too. It doesn't confirm the new path yet.

On the 9.4 fps dip: this path has no readback. Everything it adds runs on the GPU. The CPU side only zeroes a 4 KiB counter chunk at submission and copies the element table (a few bytes) into upload memory, once per indirect rectangle draw. With the GPU at 2.3 ms the time went elsewhere on the CPU, and the expand passes can only have run if indirect rectangle draws were issued, which brings us back to the point above. Running main with the same recipe would show whether the dip is there too.

What would settle the PR is a world run, main against this head, same build profile and recipe, comparing:

  • the drop summary: whether indirect kind 0: pipeline mismatch (compute false, mesh false, topology 17) is gone, and the dropped ... indirect count per world frame;
  • ms/frame in the world;
  • whether the picture behind the opening cutscene's title card changes (VICTORY_CAPTURE).

For scripted input, VICTORY_KEYS=<seconds>:<key>,... presses keys at those seconds whether the window has focus or not (README, Debugging). Space the presses out so they get past the start screen and profile, then give loading about 50 s.

AI-assisted (Claude Code).

@vladbondarenko97

Copy link
Copy Markdown

Quick control result so nobody attributes this to the change: on the same machine/package main (97c78d1) hits the same assert as the PR head, so this is not from the rect work.

  • PR head (bcc32cf, diag build): 0x80000003 at title+0x4dcbc9d, ~3.5 min in, twice in a row, each run after the menus/legal/key-art/intro at 30.0 fps.
  • main (97c78d1, same diag flags, same package): 0x80000003 at title+0x4dcbc9d as well, 1 min in.

The site is a buffer-capacity check:

mov ebx, [rcx+0x10]   ; capacity
mov eax, [rcx+0x18]   ; size
sub ebx, eax
cmp ebx, r8d          ; capacity - size vs requested
jb  +0x4dcbc9d        ; int3

So it is a request for more than a buffer's remaining capacity — streaming/upload sizing, not rect drawing. I don't have a world run to compare yet because this gate stops the title on our box before the world loads (both builds). If that assert is on your side too, the main-vs-head comparison you asked for needs it out of the way first; if it is not, tell me what differs in your environment and I will re-run.

For completeness, the machine: RTX 3080 Ti 12 GB, driver 610.60, Windows 11 Pro 26300, i7-12700KF, complete 1.0.2.1 package (111/111 SHA-256 verified).

AI-assisted (Claude Code CLI via a model proxy; logs and offsets only, no game data).

@BastienRodz

Copy link
Copy Markdown
Contributor Author

Thanks for the control run. That settles it: the assert at +0x4dcbc9d happens without this PR too.

Two things for the next comparison:

AI-assisted (Claude Code).

@justlovett0

Copy link
Copy Markdown

Game confirmation on the original #348 machine (as requested on #282): the rectangle draws run and the loading screen renders – but world entry still hangs the GPU, for a separate reason (wave64 compute refusals, #71).

Setup: Windows 10 21H2 19044.7846, RTX 3080 10 GB (driver 32.0.15.9649), Ryzen 9 7900X, 32 GB RAM. This PR's head cee702e merged locally with #175 (Agility SDK 1.620.2 – required on this Win10 box; without it the title crashes at init, #348/#84). Release build, same dump (v1.0.2.1, b99f876b74d4a77f), no input; the title auto-plays to the opening cutscene.

#175 only #175 + this PR
loading screen picture black renders (confirmed by hand)
draws run by frame 2048 16,383 (menus only) 11,351 of 11,351, dispatches 2,144 of 2,144 (menus + loading + world entry)
host root signature refused 0 0
outcome menus fine DXGI_ERROR_DEVICE_HUNG after a submission of 32 lists at the first world frames (~75 s in); "VICE CITY, TWO YEARS AGO" card shows, ~1 fps, then the device is removed

The hang is not this PR's: 100 compute pipelines are refused on this NVIDIA card (WaveSize(64) on a 32-lane host, the #71 hypothesis); their culling/indirect output is never produced. With #233 stacked on top, refusals drop to 1 – see the comment there.

One integration note for when this and #334 both land: they conflict in indirect.rs. I resolved it by giving clamp_uav the buffer parameter so it can ask buffer_state(buffer, BUFFER_WRITE) (#334's tracking), keeping the UAV barrier after the clamp for the rectangle passes, and making bound ask BUFFER_READ instead of the fixed UAV -> INDIRECT_ARGUMENT transition. The rectangle path's own before_draw/after_draw barriers on the list-owned scratch are untouched.

Logs kept locally (pr346-run.log, 4,854 lines) – happy to provide excerpts.

AI use: Qwen Code (underlying model name not disclosed by the tool) built the merged stack, ran the title, extracted the counts and drafted this comment at the user's request; the user confirmed the visible loading screen.

@BastienRodz

Copy link
Copy Markdown
Contributor Author

Thank you, that's the confirmation this PR needed: the loading screen renders, and every draw and dispatch up to world entry runs. I've added it to the description. Agreed that the hang after the title card is the wave64 refusals (#71), not this change.

On #334: thanks for working out the merge. Whichever of the two lands second should take your resolution:

  • clamp_uav takes the buffer and asks buffer_state(buffer, BUFFER_WRITE), keeping the UAV barrier after the clamp for the rectangle passes;
  • bound asks BUFFER_READ instead of the fixed transition;
  • the rectangle path's barriers on its list-owned scratch stay as they are.

If #334 merges first, I'll rebase this on it that way.

AI-assisted (Claude Code).

@marquezinii

Copy link
Copy Markdown
Contributor

Reviewed cee702e and ran it on an NVIDIA RTX 5070 (driver 621.24), Windows 11: cargo test -p victory-gpu 50 passed, 0 failed, 1 ignored; all rectangle tests pass. I found no defect in the corner math, bounds, allocator or barriers. One ordering problem and a few questions:

Rebasing onto #242. The rewrite and expand passes read the title's own argument records after clamp_uav (the rewrite pass, and the expand shader again for StartVertexLocation), so they rely on today's clamp writing the clamped values back in place. #242 changes the clamp to read the source in place and write clamped records into a separate scratch buffer (bound returns Bounded { scratch }, no in-place variant). Since #242 is meant to land first, after the rebase both passes need to read #242's scratch records; reading the title's copy would bring back unclamped counts (rects * 6u can wrap, and a pipeline with no per-vertex inputs is then unbounded in count and instances).

Half floats. f32_to_half in the expand shader combines the rounded mantissa with | (sgn | (ex << 10) | ((man + 0x1000) >> 13)), the same pattern #260 fixes in primitive.rs (a rounding carry is lost when the exponent is odd, e.g. 1.99995 gives 1.0). CPU and GPU agree today, so not a regression, but the shader will need the same change when #260 lands or the two paths diverge.

Questions:

  • The rectangle path moves the title's count buffer between UNORDERED_ACCESS and INDIRECT_ARGUMENT, while the non-rectangle path in draw.rs does not transition it. If one list uses a separate count buffer on both paths, one of them sees it in the wrong state. Worth a check with the debug layer once a count-buffer title draw shows up.
  • The title's vertex-buffer copies are bound writable in the expand pass although they are only read. If an earlier draw in the same list read one as a vertex buffer, it was promoted to a read state, and a read state cannot be promoted to unordered access. A ByteAddressBuffer view would avoid that.
  • StartVertexLocation comes from an atomic allocation, so its order can change between runs; a vertex shader reading SV_VertexID alongside inputs would see different IDs than on the direct path. The shortcut: notes cover only the no-input case.
  • The 8 MiB per-list vertex scratch is never released.

The GPU test drives both shaders with hand-written constants and does not go through expand(), so the barrier sequence, slot layout, counter reset and argument-buffer growth have no test. I tried a temporary case through the shaders with an 11-byte stride, data starting 3 bytes in, unaligned f32/half/unorm16 attributes and two records: the GPU output matched expand_rects byte for byte.

Not covered: the title (no game data here).

BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 24, 2026
The rewrite pass read the title's records after the clamp and relied on
the clamp having written its bounds back in place. It now applies the
same bounds itself (2^24 vertices, 2^26 vertex instances), so a clamp
that writes elsewhere (Marvisak#242) cannot bring back unbounded counts.

f32_to_half in the expand shader or-ed the rounded mantissa into the
exponent, losing a rounding carry when the exponent is odd (1.99995
became 1.0); it now adds it, as Marvisak#260 does for primitive.rs.

The module notes also say that, with vertex inputs, the vertex id is
the expanded one, from an allocated start whose order between records
may change from run to run.

Reported by marquezinii on Marvisak#346.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BastienRodz

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review and the unaligned-stride run. Changes in 0aebe86:

On the questions:

Re-run on 0aebe86 (Wine + vkd3d-proton 3.1 on lavapipe): cargo xwin test -p victory-gpu gives 48 passed and 2 failed, the same two environment failures as main. The byte-for-byte GPU test passes. Clippy: unchanged. Policy: 152 files ok.

AI-assisted (Claude Code).

@fuzeofficlal

fuzeofficlal commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

I ran a synthetic check through expand() via State::execute_indirect on 0aebe86 on Windows 11 (build 26200), using an RTX 5090 and WARP. A one-thread compute dispatch writes the count at byte offset 16 of a separate buffer on the same command list. The CPU starts with the opposite value, and the indirect record starts at vertex 1.

GPU-written count Result on both adapters
0 All 64 pixels stayed at the clear color
1 The expected 4×4 region drew, and all other pixels stayed clear

State::execute_indirect accepted both calls. Count copyback matched the GPU value with the adjacent words intact. The D3D12 debug callback reported zero errors during recording and submission on both adapters. With the same fixture on d2a4bae, the method rejected both rectangle calls before submission.

This covers the rectangle path from State::execute_indirect through native draw and readback with a test PSO and synthetic inputs. The mixed rectangle/non-rectangle count-buffer case discussed above is outside this run.

I also verified the direct rectangle path's normal FP16 midpoint rounding with a separate synthetic input. At dd54de2, the direct expansion packed an even midpoint as 0x3c01 instead of 0x3c00, and the native draw matched 10/16 reference pixels on both RTX 5090 and WARP. Direct-path commit c256b97 applies the retained-bit tie-to-even bias. The same draws match 16/16 on both adapters, with the adjacent odd midpoint still packing to 0x3c02.

The indirect HLSL helper at 1278485 uses the analogous fixed bias for normal values. Applying the same retained-bit rule there would align the direct and indirect paths. This comparison of the HLSL helper is from source inspection.

@marquezinii

Copy link
Copy Markdown
Contributor

Thanks, 0aebe86 covers it. Re-ran on the RTX 5070 (621.24): cargo test -p victory-gpu 49 passed, 1 ignored, all rectangle tests included (the one other failure, frame::tests::waits_end_on_ticks_and_count_frames, is a timing test that fails under load and passes 3 of 3 alone; this PR does not touch frame.rs). The record bound keeps rects * 6 at most 2^25, and the half rounding now matches #260's. The answers on the count-buffer state and the UAV-bound copies make sense to me as #334 follow-ups.

suirentakamura referenced this pull request in suirentakamura/victory-suiren Nov 24, 2026
Conflicts: indirect.rs (our clamp is built by our own emitter: kept its
register constants in #346's clamp_uav/bound split), host.rs (our staging
arena and #346's rectangle scratch, both kept; #346's default_buffer was
already ours).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
suirentakamura referenced this pull request in suirentakamura/victory-suiren Nov 24, 2026
…y stage

Conflicts: draw.rs (indirect rectangles: pipelines with our geometry stage
run with the title's records; the others take #346's GPU expansion),
pipeline/host.rs (our blend tests and #1020's stage, both kept).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
This was referenced Nov 24, 2026
@BastienRodz

Copy link
Copy Markdown
Contributor Author

Closing: 683ad7a on main now draws rectangle lists, indirect ones included, through a generated geometry shader, which covers what this PR did with a compute expander. Thanks to everyone who tested it on real hardware and in the title (DarX-Oren, fuzeofficlal, justlovett0, marquezinii, SkillIssueXO, Exorion1er, justr4mzi, iurysf, Yaekai, neonbyte1). The half-float ties-to-even fix carried here is still open on its own as #1220.

KainanP added a commit to KainanP/VIctory that referenced this pull request Nov 24, 2026
…) onto Marvisak#334 + integ/next

Taken instead of Marvisak#282 (same draws, Marvisak#255; only one can land): Marvisak#346 expands on
the GPU after the clamp, so vertex data the GPU wrote earlier in the
submission is seen, and its record grouping starts at each record's first
vertex. It has the stronger title evidence: the loading screen renders
(justlovett0, RTX 3080), the `prepare failed`/topology-17 drops go from 256
per frame to 0 with no device removal (neonbyte1, RTX 5090/Wine; Exorion1er,
RX 9070 XT/Proton; iurysf, RTX 4070), and every defect reported on it was
fixed by a later commit (scratch layout cee702e, record bounds 0aebe86,
count buffer 7ff1184, Wine compiler c256f83). Marvisak#282 expands on the CPU (does
not see GPU-written vertices, copies bound buffers whole, three times per
draw after 4d3d003) and its last head was only checked in short runs.

Conflicts:
1. crates/victory-gpu/src/indirect.rs, module doc: the stack's (Wine-safe
   clamp in structured buffers, root signature made beside it) kept, with
   Marvisak#346's sentence on the rectangle expansion added.
2. indirect.rs, `bound`: Marvisak#346 splits it into `clamp_uav` (clamp + UAV
   barrier) and `bound` (then a fixed UAV -> INDIRECT_ARGUMENT transition);
   Marvisak#334 (merged just before) replaced the fixed transitions with its buffer
   states (`bound` asks for BUFFER_WRITE, `execute` for BUFFER_READ). Kept
   Marvisak#346's split with Marvisak#334's tracking, the resolution justlovett0 and the
   author agreed on (Marvisak#346 comments 7121242441, 7121274527): `clamp_uav` takes
   the buffer, starts a command and asks for BUFFER_WRITE; `bound` is
   `clamp_uav` (the read state comes from `execute`), no fixed transition.
3. crates/victory-gpu/src/host.rs: the stack's `PooledUpload` and Marvisak#346's
   `RectScratch` added at the same place; both kept.

Non-textual fixes:
- rectangles.rs calls `clamp_uav(list, &args.buffer, ..)` (new parameter).
- rectangles.rs: the rewrite and expand passes bind the count's and the
  vertex buffers' host copies as root UAVs. With Marvisak#334 those copies' states
  are tracked, so they now ask for BUFFER_WRITE in the clamp's command
  (otherwise a copy a draw had moved to GENERIC_READ would be bound as a
  UAV in a read state). The draw's own `prepare` then asks for the read
  state as before. The list-owned scratch keeps Marvisak#346's own barriers.
- primitive.rs: Marvisak#346's half-float rounding commit (8c7ac43) is already here
  through Marvisak#1220 (in Marvisak#1418), so `half_midpoints_round_to_even` is not added
  twice: the PR adds 8 tests, 7 are new here.
KainanP added a commit to KainanP/VIctory that referenced this pull request Nov 24, 2026
…y unchanged pages current) onto Marvisak#346 + Marvisak#334 + integ/next

Taken instead of Marvisak#693 (shadow buffers in DEFAULT VRAM with staging
readback): both rewrite how shaders' writes reach title memory, on
incompatible models (Marvisak#1024 stores from the CPU-mapped host copy; Marvisak#693 has
no CPU mapping and merges from readback snapshots), so only one can land.
Marvisak#693 has unfixed in-title regressions on its last head's predecessor and no
title run since: about 2x slower frames and 5-7x GPU time on an RX 6700 XT
(Marvisak#693 (comment)), GPU
page faults inside freed `shadow readback/upload staging` on RX 6950 XT and
RX 6700 XT (Marvisak#693 (comment)),
and a changes-requested review (mercuryVM). Its last commit (1c94839) fixes
the review's failure paths but not the performance loss, and was not run in
the title. Marvisak#1024 has no negative report; its tests pass on RTX 4090/Wine,
RTX 5070 Ti, RX 7700 XT, RTX 5090/Wine, and a title run with it (and Marvisak#472,
Marvisak#322) had shorter frames and less copy-back time (AgneyaK).

Conflicts, crates/victory-gpu/src/shadow.rs:
1. `Shadow::copy_back`: the stack (Marvisak#124, TG0000) skips pages already found
   unchanged against this submission's snapshot (`UnchangedPages`) and
   allocates the title buffer lazily, by PAGE; Marvisak#1024 writes back only the
   runs of bytes the GPU changed (`write_runs`) and marks a synced page
   current only if title memory still equals the copy after the final
   write-watch query. Independent: both kept. The loop keeps the stack's
   `unchanged.differs` guard and lazy buffer, with Marvisak#1024's run collection
   and `write_runs` inside; the final check takes the (by then allocated)
   lazy buffer for its page re-reads.
2. Tests: the stack's `mod tests` and Marvisak#1024's `mod copy_back_tests` at the
   same place. The shared text holds the closing `);`, `}` and `}`, so the
   stack's module is closed in the hunk and Marvisak#1024's module follows as its
   own `#[cfg(test)]` item (not nested).

No other non-textual fix needed (cargo check --all-targets --all-features).
KainanP added a commit to KainanP/VIctory that referenced this pull request Nov 24, 2026
…us) onto Marvisak#1024 + Marvisak#346 + Marvisak#334 + integ/next

One conflict, crates/victory-gpu/src/host.rs tests: the stack adds
`adapter_filter_parses_index_and_name` and the capability tests, Marvisak#211 adds
`present_compositor_builds_both_pipeline_states`, at the same place. The
shared text holds the `#[test]` before and the closing brace after, so the
stack's last test is closed in the hunk and Marvisak#211's follows as its own test
(not nested). `Host::present` (single plane fast path, compositor for 2+)
and `queue::present` merged without conflict; the stack does not change
either. No non-textual fix needed (cargo check --all-targets --all-features).

No negative report on Marvisak#211: the Series S menus render on RTX 2070 SUPER,
RTX 4070 SUPER, RTX 3060 Laptop, RTX 4080, RX 7600 and WARP, and the device
removals seen later in the world also happen in Series X mode without it.
KainanP added a commit to KainanP/VIctory that referenced this pull request Nov 24, 2026
…6B16A16_FLOAT) onto Marvisak#211 + Marvisak#1024 + Marvisak#346 + Marvisak#334 + integ/next

Conflicts, both in tests:
1. crates/victory-gpu/src/descriptor/host.rs: the stack's tests
   (`raw_views_start_on_16_bytes` and the raw/structured view tests after
   it, from Marvisak#1426/Marvisak#704) and Marvisak#492's four `rgb9e5_srv_*` tests at the same
   place; git interleaved them over shared lines (a resource description's
   `SampleDesc`, a closing brace), so the two hunks are not separable
   texts. Resolved by keeping the stack's tests exactly as they were and
   adding Marvisak#492's four tests whole, as Marvisak#492 has them, before
   `dynamic_slots_are_held_until_released` (where Marvisak#492 put them). The
   resulting diff of the file against the previous head equals Marvisak#492's own
   (+235/-5 against main).
2. crates/victory-gpu/src/resource.rs: the stack's
   `get_desc_reports_the_allocated_mip_chain` and Marvisak#492's
   `r9g9b9e5_target_format_substitutes_rgba16f` /
   `r9g9b9e5_render_target_and_uav_textures_create_on_host` at the end of
   the module. The shared text holds the `#[test]` before and the closing
   braces after: the stack's test is closed in the hunk and Marvisak#492's follow
   as separate tests (not nested).

The non-test changes (`target_format`, `fits` taking a resource
description, `fits_texture_srv`, RTV and pipeline formats) merged without
conflict. `fits` has no other caller in the stack. Uploads from title
memory still skip render-target/UAV textures (`texture::title_written`),
so no 4-byte RGB9E5 rows are detiled into a substituted 8-byte texture.
Known open point from the review, not fixed by Marvisak#492: a copy between a
substituted target and a sampled-only RGB9E5 texture would mismatch
formats on the host; no report shows the title doing that.
No non-textual fix needed (cargo check --all-targets --all-features).
KainanP added a commit to KainanP/VIctory that referenced this pull request Nov 24, 2026
…sak#98, Marvisak#334 to Marvisak#492, validation)

The line rebuilt on the bundles' current heads (Marvisak#1402 119b763, Marvisak#1492 5bbc098
without Marvisak#98, Marvisak#1504 1d41891, Marvisak#1511 ca601f0) with every merge replayed, and the
merges after this file's first version (Marvisak#334, Marvisak#346, Marvisak#1024, Marvisak#211, Marvisak#492): merge
order, the runner's numbers on 967d3ae (RTX 571, WARP 570 + the known Marvisak#1084
failure, all features 580; Marvisak#98's one test leaves), what is not included (Marvisak#98,
Marvisak#282 for Marvisak#346, Marvisak#693 for Marvisak#1024, Marvisak#306's latest commit), and the open pull
requests whose head is contained here (109, from the 18:24 collection).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PastiiJay pushed a commit to PastiiJay/klbf-lab-beta that referenced this pull request Nov 25, 2026
…st case

scratch_layout took 16 bytes of alignment slack per extra slot off the
capacity before counting vertices, so a layout that fits exactly (two
slots of 8 and 12 bytes in 120, no padding needed) was refused, and in
8 MiB a few rectangles of room were lost. It now starts from the
unpadded vertex count and steps down a rectangle at a time until the
padded regions fit. Reported by DarX-Oren on Marvisak#346.
PastiiJay pushed a commit to PastiiJay/klbf-lab-beta that referenced this pull request Nov 25, 2026
The rewrite pass read the title's records after the clamp and relied on
the clamp having written its bounds back in place. It now applies the
same bounds itself (2^24 vertices, 2^26 vertex instances), so a clamp
that writes elsewhere (Marvisak#242) cannot bring back unbounded counts.

f32_to_half in the expand shader or-ed the rounded mantissa into the
exponent, losing a rounding carry when the exponent is odd (1.99995
became 1.0); it now adds it, as Marvisak#260 does for primitive.rs.

The module notes also say that, with vertex inputs, the vertex id is
the expanded one, from an allocated start whose order between records
may change from run to run.

Reported by marquezinii on Marvisak#346.
Xeltax added a commit to Xeltax/VIcky that referenced this pull request Nov 25, 2026
… of title memory by address

Ideas from a review by Claude Fable, after fork PR Marvisak#346. All off unless set.

- Touch marks (shader, always on): the fault note's store of an access
  through a copy now goes to that copy's dword at MEMORY_TOUCHED instead of
  the sink, so it costs no store of its own. The faults buffer grows to
  MEMORY_NOTES dwords (notes, marks, touches). The card test checks it.
- VICTORY_MEMORY_REFRESH=touched: a list's first dispatch refreshes only the
  copies touched lately, the named, the new and those about to be declared
  written, and every copy at least once in 8 frames (shortcut: an untouched
  copy may read bytes up to 8 frames old at its next first touch).
- VICTORY_MEMORY_NAMED_WRITES=0: a copy named only by a dispatch (a root view
  or a constant that looks like an address) and never marked by a store
  stops being declared written after 3 frames.
- VICTORY_REFRESH_STAMP=1: a refresh of a range the journal answered alone
  is skipped under the same asking (no write can be noted there meanwhile).
- Diagnostics: one line a frame of refreshes, skipped refreshes and copies
  declared written by reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A4bpLmErkufJL3LGgfR561
Steenax6 added a commit to Steenax6/VIctory-NVID that referenced this pull request Nov 26, 2026
…ritten

A shader that reads title memory by address declared every numbered copy
written whenever its code could store anywhere. The programs that walk
the ray-tracing structures only load by address and store their results
through their views: they declared up to 1,023 copies (4.3 GB in the
source's runs) for a compare after each submission, and a walker in the
same list as a quarantined builder stage carried what the builder wrote
back to the title.

Translated::stores_by_address says whether a program has a scalar-memory,
flat or global store or atomic (or code that is not all known); only then
are the numbered copies declared. Its views' ranges are declared as
before. VICTORY_WRITE_SKIP=0 still declares everything.

Sources: fxceless/victory-fork PR Marvisak#294 part 2 (ALFREDOHDEZ, RTX 4070: the
quarantine stopped leaking, a 400 s builder run) and PR Marvisak#916,
AllStars101-sudo/victory-lap aca8308ab3, ka1qux/BRVIctory-ka1qux 4c9dff93d
(writes_guest_memory). The shader-side dirty marks of PR Marvisak#346 are not
taken (they change translated shaders).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

World: ~250 indirect rectangle-list draws per frame are dropped (topology 17), and the world stays black behind the cutscene