GPU: expand indirect rectangle-list draws on the GPU #346
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!346
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/346/head"
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?
@BastienRodz on GitHub · 2026-11-24 02:28 UTC · original
BastienRodz:gpu/indirect-rectangles→main· +1590 −27 · 6 files · 7 commits · closed without mergingCloses #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_indirectrefused 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) withRECTANGLES, after the existing argument clamp, two compute passes of ours run beforeExecuteIndirect(new modulecrates/victory-gpu/src/rectangles.rs). Both are HLSL compiled at run time by the system'sD3DCompile(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 (sincec256f83; checked with vkd3d-compiler 2.1, the version GE-Proton11-12 ships).rect_rewrite(one thread per record):start .. start + 3 * rectslies inside every bound per-vertex vertex buffer.rects * 6vertices from a per-list scratch with an atomic counter.rects * 6vertices, the same instances, the allocated start, the same start instance.rect_expand(one group per record, one pass per per-vertex slot):(v0, v1, v2, v0, v2, v3)per rectangle.v3 = v0 + v2 - v1the wayexpand_rectsdoes: same formats (primitive::components), same half-float and UNORM conversions and rounding. Unknown formats and components past the stride keep v0's bytes.ExecuteIndirectthen 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 (since7ff1184). The expanded slots are bound withIASetVertexBuffers. 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.rsand the shader's copy):4090d29): fuzeofficlal's fix for the direct path (comment, theirc256b97), carried here since PR creation is limited to collaborators;1278485).The CPU and GPU paths therefore still agree byte for byte.
List-owned memory (
host.rs):indirect::boundis split so thatclamp_uav(clamp, then a UAV barrier) can be followed by the rewrite pass.bounditself 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:primitive.6 * rectsvertices from 0, the same as a direct rectangle draw today. The vertex-ID remap suggested in #255 is not part of this PR.Tested
Native Windows: the upstream CI's checks (clippy
-D warningswith and without--all-features, thencargo test --workspace --locked) pass on GitHub'swindows-latestat this head: https://github.com/BastienRodz/VIctory/actions/runs/45381063747Latest, on
8ef6bferebased ontomainffe310e(clean):cargo clippy --workspace --all-targets --locked -- -D warnings, with and without--all-featuresas the CI runs it, is clean.victory-gpu: 58 passed under plain Wine (61 withdiagnostics). On vkd3d-proton: 60 passed and 1 failed,a_rejected_blob_gives_an_empty_library, an environment failuremainhas there too. Policy: 155 files ok. The details below are from earlier heads.Mine: Linux x86_64, cross-built with
cargo xwinforx86_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_libraryandbuffer_data_reaches_the_host_texture.Without a host device (plain Wine, so host tests skip): 50 passed. With
--features diagnostics: 52 passed.New 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.hlsl_compiles(both shaders throughD3DCompile),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 withexpand_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_rectsfails, so the comparison catches it.cargo xwin clippy -p victory-gpu --all-targets, with and withoutdiagnostics: one warning, the same one as onmain(a missing safety comment in a test outside this diff).rustfmt --checkis clean onrectangles.rs. The touched files have the same rustfmt diffs as onmain, none new.cargo xtask policy:asset policy: 152 files ok.Tested by others (thanks)
cee702e. With the fix, theExecuteIndirectoutput matched the CPU-expanded reference image (SHA-256).cee702e(comment): the rectangle tests pass with no D3D12 debug-layer errors. An end-to-end fixture (vertex copy, the PR's expansion and barriers, then a realExecuteIndirectdraw starting at vertex 1) matched the expected image on both adapters.cee702e+ #175 (comment): the loading screen now renders (black without this PR). By frame 2048, 11,351 of 11,351 draws and 2,144 of 2,144 dispatches ran. World entry still hangs that NVIDIA GPU, because of wave64 compute pipelines the host refuses (#71); that hang is not from this PR.0aebe86(comment): the whole path, fromState::execute_indirectthroughexpand()to a native draw and readback. The count is written by a compute dispatch on the same list into a separate buffer: count 0 draws nothing, count 1 draws exactly the expected region. No debug-layer errors on either adapter. Ond2a4bae, the same calls are rejected.cee702e(review):victory-gpu50 passed. The review led to0aebe86: the rewrite pass bounds records itself (for #242), and half-float rounding carries. Re-run at0aebe86(comment): 49 passed. The only failure is a timing test inframe.rsthat fails under load, passes alone, and is not touched here. The count-buffer state and the UAV-bound copies are agreed as #334 follow-ups.4090d29(comment):victory-gpu57 passed, 0 failed, includinghalf_midpoints_round_to_evenandgpu_expansion_matches_cpu_expand_rects. With only the shader's old rounding put back, the byte-for-byte test fails on that GPU (0x01where the CPU has0x00).d3dcompiler_47) + vkd3d-proton 3.2.0, atc256f83+ #190 (comment): noE5005, no root signature error, and 0rectangle expander shader unavailabledrops (256/frame before). The only rectangle drop left isindexed rectangles not supported(~0.1/frame). The run later ended in the same texture-read page fault plainmaingives on that card (#714), which is not from this PR. They also ported both passes to the shader crate's DXIL writer (branch, stacked on #190), should no run-time compiler be wanted.c256f83onmain8e79c80in a 13-PR stack (comment): clean merge.victory-gpu64 passed, 0 failed (all 7rectangles::tests::*); withdiagnostics67 passed; full workspace 329 passed, 0 failed.prepareafter the expansion, mostly on dynamic descriptor slot exhaustion (#688).Not run
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 on GitHub · 2026-11-24 02:54 UTC · original
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:
The corrected ExecuteIndirect output produced an RGBA8 image identical by SHA-256 to the CPU-expanded reference.
Validation:
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 on GitHub · 2026-11-24 02:56 UTC · original
Thanks for running it on a real RX 6700 XT, and for the exact-fit case. You're right:
scratch_layouttook 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_alignmentgains two regression cases:Before the fix both return
None.Re-run (cross-built, Wine + vkd3d-proton 3.1 on lavapipe):
cargo xwin test -p victory-gpugives 48 passed and 2 failed, the same two vkd3d-proton environment failures asmain.gpu_expansion_matches_cpu_expand_rectspasses. Clippy: same single warning asmain.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
diagbuild to see whether thetopology 17drop reason goes away.No game data used. AI-assisted (Claude Code).
@fuzeofficlal on GitHub · 2026-11-24 03:03 UTC · original
Native D3D12 results for
cee702eon 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
ExecuteIndirectdraw. 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 earlierbcc32cfrun 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 on GitHub · 2026-11-24 03:09 UTC · original
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:
0 indirectwith 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:
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 on GitHub · 2026-11-24 03:09 UTC · original
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 indirectbefore the world is probably whatmainshows 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
mainwith the same recipe would show whether the dip is there too.What would settle the PR is a world run,
mainagainst this head, same build profile and recipe, comparing:indirect kind 0: pipeline mismatch (compute false, mesh false, topology 17)is gone, and thedropped ... indirectcount per world frame;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 on GitHub · 2026-11-24 03:30 UTC · original
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.bcc32cf, diag build):0x80000003attitle+0x4dcbc9d, ~3.5 min in, twice in a row, each run after the menus/legal/key-art/intro at 30.0 fps.97c78d1, same diag flags, same package):0x80000003attitle+0x4dcbc9das well, 1 min in.The site is a buffer-capacity check:
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 on GitHub · 2026-11-24 03:31 UTC · original
Thanks for the control run. That settles it: the assert at
+0x4dcbc9dhappens without this PR too.Two things for the next comparison:
97c78d1is older than this PR's base. Please comparemainatd2a4baeagainst the headcee702e, which also has the scratch-layout fix.crashes.logentry, the stack, and what the title was doing at the time. Then people with other GPUs can say whether they hit it.AI-assisted (Claude Code).
@justlovett0 on GitHub · 2026-11-24 03:35 UTC · original
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
cee702emerged 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.host root signature refusedDXGI_ERROR_DEVICE_HUNGafter 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 removedThe 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 givingclamp_uavthe buffer parameter so it can askbuffer_state(buffer, BUFFER_WRITE)(#334's tracking), keeping the UAV barrier after the clamp for the rectangle passes, and makingboundaskBUFFER_READinstead of the fixedUAV -> INDIRECT_ARGUMENTtransition. The rectangle path's ownbefore_draw/after_drawbarriers 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 on GitHub · 2026-11-24 03:37 UTC · original
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_uavtakes the buffer and asksbuffer_state(buffer, BUFFER_WRITE), keeping the UAV barrier after the clamp for the rectangle passes;boundasksBUFFER_READinstead of the fixed transition;If #334 merges first, I'll rebase this on it that way.
AI-assisted (Claude Code).
@marquezinii on GitHub · 2026-11-24 04:22 UTC · original
Reviewed
cee702eand ran it on an NVIDIA RTX 5070 (driver 621.24), Windows 11:cargo test -p victory-gpu50 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 forStartVertexLocation), 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 (boundreturnsBounded { 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 * 6ucan wrap, and a pipeline with no per-vertex inputs is then unbounded in count and instances).Half floats.
f32_to_halfin the expand shader combines the rounded mantissa with|(sgn | (ex << 10) | ((man + 0x1000) >> 13)), the same pattern #260 fixes inprimitive.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:
UNORDERED_ACCESSandINDIRECT_ARGUMENT, while the non-rectangle path indraw.rsdoes 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.ByteAddressBufferview would avoid that.StartVertexLocationcomes from an atomic allocation, so its order can change between runs; a vertex shader readingSV_VertexIDalongside inputs would see different IDs than on the direct path. Theshortcut:notes cover only the no-input case.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 matchedexpand_rectsbyte for byte.Not covered: the title (no game data here).
@BastienRodz on GitHub · 2026-11-24 04:25 UTC · original
Thanks for the careful review and the unaligned-stride run. Changes in
0aebe86:rects * 6. A clamp that writes elsewhere can no longer bring back unbounded counts, including for pipelines without per-vertex inputs. What it doesn't reproduce is the clamp's per-list budget, which zeroes records past it. When rebasing onto #242, the rewrite and expand passes should read #242's scratch records, as you say. I'll do that if #242 lands first.gpu_expansion_matches_cpu_expand_rects's inputs don't hit it, and the test still passes.shortcut:note now says that with vertex inputs, the vertex id is the expanded one, from an allocated start whose order between records may change between runs. Making it deterministic needs a prefix sum over the records instead of the atomic. For records that read the vertex id, both paths already differ from the console's ids, so I left that for when a title shader turns out to depend on it.On the questions:
UNORDERED_ACCESS. The rectangle path moves it toINDIRECT_ARGUMENTonly around its ownExecuteIndirectand back, so a list that mixes the paths sees it in the same state between draws. The non-rectangle path reading a separate count buffer while it is still inUNORDERED_ACCESSis older than this PR. #334's state tracking is the place to fix that.UNORDERED_ACCESS(the IA reads them that way too, which is #199/#264). An SRV view would be the mismatch here, since it needsNON_PIXEL_SHADER_RESOURCE. Once #334 tracks buffer states, these reads should ask its tracker; at that point aByteAddressBufferview withBUFFER_READis the better choice. I'll switch when rebasing onto it.HostListand is reused across resets. It goes away when the list object is released, not before. Fair point if a title keeps many lists around: a pool shared between lists would cap it. Noted for later.expand(): true. fuzeofficlal's fixture covered the barrier sequence and a realExecuteIndirectdraw on two GPUs, but nothing in the repository does. A test throughexpand()needs a title shadow and a host pipeline set up by hand. I'll look at adding one.Re-run on
0aebe86(Wine + vkd3d-proton 3.1 on lavapipe):cargo xwin test -p victory-gpugives 48 passed and 2 failed, the same two environment failures asmain. The byte-for-byte GPU test passes. Clippy: unchanged. Policy: 152 files ok.AI-assisted (Claude Code).
@marquezinii on GitHub · 2026-11-24 05:00 UTC · original
Thanks,
0aebe86covers it. Re-ran on the RTX 5070 (621.24):cargo test -p victory-gpu49 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 touchframe.rs). The record bound keepsrects * 6at 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.@claude-GTA6 on GitHub · 2026-11-24 06:01 UTC · original
From a tester working with Claude (AI-assisted); measured on my own machine.
Result on NVIDIA (RTX 5090, 621.24), stacked with #458, #233, #439 and the indirect-argument copy from my comment on #458:
VICTORY_D3D12_DEBUG=1there were no indirect-related API errors, and the world ran about 3 minutes.Two things were needed with #458's buffer-state tracker:
indirect::clamp_uavhas to move the title args buffer throughHostList::transition_bufferinstead of raw barriers. The tracker may have moved that buffer to another state since.prepare, copy the count into list-owned memory, and leavePrepared::before_draw/after_drawout of the count's state. Without the copy, the draw's own shaders move the pool to UAV, andExecuteIndirectreads the count in the wrong state. That was aDXGI_ERROR_INVALID_CALLdevice removal about 20 s into the world.Same branch base as my comment on #458; happy to push the rectangle-side diff if useful.
@BastienRodz on GitHub · 2026-11-24 06:03 UTC · original
Thanks for stacking it and tracking both down.
Count buffer: changed here in
7ff1184, so it no longer depends on what lands first. The rewrite pass already writes records at or past the title's count as empty draws (all zeros), soExecuteIndirectno longer takes a count buffer at all. It runs themaxrecords from the list's own arguments buffer, and the records past the count draw nothing.Prepared::before_draw/after_drawtransition only the list's scratch now. Together with the record bounds from0aebe86, the rectangle path no longer changes the state of any title buffer: the count's host copy is read once by the rewrite pass, like the arguments. This should remove theDXGI_ERROR_INVALID_CALLyou saw with #458, without the extra copy.Clamp: that one belongs to whichever tracker lands (#458 or #334).
clamp_uavshould go through its transition call instead of raw barriers, as you and justlovett0 did. If one of them merges first, I'll rebase this on it that way.Re-run on
7ff1184(Wine + vkd3d-proton 3.1 on lavapipe):victory-gpu48 passed and 2 failed, the same two environment failures asmain.gpu_expansion_matches_cpu_expand_rectspasses; it already checks that a record past the count becomes[0, 0, 0, 0]. Clippy unchanged; policy 152 files ok.AI-assisted (Claude Code).
@vladbondarenko97 on GitHub · 2026-11-24 07:31 UTC · original
A workaround for the
title+0x4dcbc9dassert that otherwise blocks every PR test hereFollowing the control result above (main
97c78d1and head0aebe86both died at+0x4dcbc9d), we RE'd the assert and can now get past it deterministically, which may help other testers reach the world.The assert is a title-side packet stream, not a GPU command buffer. At
+0x4dcbc9d,rcxis a 40-byte slot:desc*,dataBase*, capacity+0x10, cursor+0x18, watermark+0x1c, stream id+0x20. Runtime values at the failing enqueue (r8 = 0x6c0, a 1728-byte packet): capacity0x18000(98304), cursor = watermark =0x17fb0(98224), id0xF0A244EF; the sibling half is at0x114c0. So both halves filled and nothing drained while the descriptor showedready = 1, arg = 0, seq = 0x50. The packets are(id, type, float)records (0.55, 0.2, 1000.0, 2000.0 …), i.e. parameter data, not resource streaming.Workaround: skip only that breakpoint. Comparing
rip & 0xFFF == 0xC9Dis ASLR-proof;Rip += 1lands on0x4DCBC9E(jmp 0x4DCBC8A), which is the enqueue's "return false / packet dropped" path — no other state changes. With this in a diagnostics build, a session-1 run on an RTX 3080 Ti holds 30.0 fps, 46–55 draws/frame, GPU 1.9–7.5 ms, no WARN/ERROR lines, and walks the entire first-run flow (Brightness calibration, Subtitles, Legal Terms with the Confirm press) — all of which used to be unreachable because the title died at this assert within a minute.Not a fix — the right fix is whatever should be draining that stream — but it lets the world-load and picture lanes be tested on
mainand on PR heads without the assert in the way. AI-assisted investigation (Claude Code); all values are from a register/memory dump of our own retail run.@BastienRodz on GitHub · 2026-11-24 08:25 UTC · original
Rebased onto
maincf0bb43(clean) and updated for #418. #418 makesprimitive::f32_to_halfwrite half subnormals, rounded to even, instead of flushing them to zero. The expand shader's copy now does the same (1278485), so the CPU and GPU paths still agree byte for byte.gpu_expansion_matches_cpu_expand_rectsgets a rectangle whose half fourth corner is 2^-16; with the old flush it fails.On
1278485(Wine + vkd3d-proton 3.1 on lavapipe):victory-gpu54 passed and 2 failed, the same two environment failures asmain. Plain Wine: 56 passed. Clippy is clean, with and withoutdiagnostics. Policy: 153 files ok.AI-assisted (Claude Code).
@fuzeofficlal on GitHub · 2026-11-24 04:27 UTC · original · edited 2026-11-24 08:32 UTC
I ran a synthetic check through
expand()viaState::execute_indirecton0aebe86on 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.State::execute_indirectaccepted 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 ond2a4bae, the method rejected both rectangle calls before submission.This covers the rectangle path from
State::execute_indirectthrough 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 as0x3c01instead of0x3c00, and the native draw matched 10/16 reference pixels on both RTX 5090 and WARP. Direct-path commitc256b97applies the retained-bit tie-to-even bias. The same draws match 16/16 on both adapters, with the adjacent odd midpoint still packing to0x3c02.The indirect HLSL helper at
1278485uses 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.@BastienRodz on GitHub · 2026-11-24 08:35 UTC · original
Thanks, good catch, and thanks for measuring it on both adapters. Since PR creation is now limited to collaborators, I've carried your rule here so the two paths stay in step:
4090d29applies it (yourc256b97, credited as co-author) toprimitive::f32_to_halfand to the expand shader's copy. The retained bit decides halfway cases, so1 + 2^-11packs as0x3c00and1 + 3 * 2^-11as0x3c02.Tests:
primitive::tests::half_midpoints_round_to_even: both midpoints, and a value just past one.gpu_expansion_matches_cpu_expand_rects: a rectangle whose half fourth corner is exactly1 + 2^-11. With the old+ 0x1000rounding in the shader only, it fails.On
4090d29(Wine + vkd3d-proton 3.1 on lavapipe):victory-gpu55 passed and 2 failed, the same two environment failures asmain. Plain Wine: 57 passed. Clippy is clean, with and withoutdiagnostics. Policy: 153 files ok.AI-assisted (Claude Code).
@SkillIssueXO on GitHub · 2026-11-24 08:36 UTC · original
Native Windows D3D12 validation of
4090d29on an RTX 5070 Ti (driver 621.24, Windows 11 build 26300.9974, Rust 1.98.1 MSVC). I verified that the default D3D12 device selected the physical RTX 5070 Ti.cargo +1.98.1 test --locked -p victory-gpu -- --test-threads=1completed with 57 passed, 0 failed, 1 ignored, includinghalf_midpoints_round_to_evenandgpu_expansion_matches_cpu_expand_rects.I also verified that the new midpoint fixture catches the old rounding on this GPU. With only the HLSL
f32_to_halfrestored to its parent version, the byte-for-byte test failed with0x01at byte 128 where the CPU reference had0x00. Restoring the PR shader made the focused test pass again.Synthetic inputs only. AI-assisted (Codex).
@Exorion1er on GitHub · 2026-11-24 09:04 UTC · original
Under stock Proton, the expander doesn't compile, so on Linux the rectangle-list draws stay dropped with this PR.
Setup: RX 9070 XT, Fedora 44, Mesa 26.2.7 RADV, GE-Proton11-12's Wine with Proton Experimental's vkd3d-proton 3.2.0, Wine's builtin
d3dcompiler_47.main58fed37+ #190 #454 #493 #579 #704 + this PR (#190removes theWin32_Graphics_Direct3D_Fxcfeature, so I put it back for the test). Diagnostics build, short runs into the first mission.It's the same compiler limitation as the clamp (#170): Wine's
D3DCompilehas noLoadonRWByteAddressBuffer. Your Wine test used Microsoft'sd3dcompiler_47.dllfrom winetricks, which is why it passed there. With Microsoft's DLL loaded (d3dcompiler_47=n,b), the expander builds here too, no E5005, and the topology-17 draws run.Why it matters on this card: before this PR, in one traced world frame (#591), about 190 rectangle-list
ExecuteIndirectdraws each were dropped into three 2560×1440 targets (formats 10, 42 and 44), and only 38 rectangle-list draws ran in the whole frame.So for Wine/Proton users the expander needs either #190's approach (DXIL from the shader crate's writer, no compiler at run time) or a DXC fallback like #178. I haven't measured the picture with the expander running yet: with this PR, #591's trace no longer lists the expanded draws per target, so I can't compare targets one to one.
Counts and log lines only. AI-assisted (Claude Code).
@BastienRodz on GitHub · 2026-11-24 09:15 UTC · original
Thanks, you're right: my Wine runs used Microsoft's
d3dcompiler_47, so they never saw this. Fixed inc256f83, keeping the run-time compile.There were two things, not one. Wine's
D3DCompile(vkd3d-shader) has noLoadonRWByteAddressBuffer, and it also ignores the[RootSignature]attribute. So once the HLSL compiled,CreateRootSignaturefrom the blob would have failed next.RWStructuredBuffer<uint>/StructuredBuffer<uint>. Bindings and arithmetic are unchanged.D3D12SerializeRootSignatureinstead of coming from the shader.Checked against your compiler: I built
vkd3d-compilerfrom thevkd3d-2.1tag, which is the vkd3d-shader GE-Proton11-12 ships (libvkd3d-shader-1.dllreports 2.1).rect_rewrite:25:25: E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'.D3DCompile's (a local-only hook, not committed). On vkd3d-proton 3.1, all 7 rectangle tests pass, includinggpu_expansion_matches_cpu_expand_rectsbyte for byte.With Microsoft's compiler (Wine + vkd3d-proton on lavapipe):
victory-gpu55 passed and 2 failed, the same two environment failures asmain. Plain Wine: 57 passed. Clippy is clean, with and withoutdiagnostics. Policy: 153 files ok.What I couldn't run is your exact stack:
d3dcompiler_47from GE-Proton11-12's Wine, which reaches vkd3d-shader through Wine 11'swined3dand does not load on my Wine 10. If you can rerun stock (d3dcompiler_47builtin) with #190 stacked for the clamp, the drop reasonrectangle expander shader unavailableshould be gone. If it isn't, the WARN line will name the next error.On the per-target comparison: with this PR the expanded draws run as one
ExecuteIndirecteach, like the other indirect draws, so #591's trace would need to count them under their pipeline.AI-assisted (Claude Code).
@Exorion1er on GitHub · 2026-11-24 09:17 UTC · original
Follow-up to my comment above: I ported both expansion passes to the shader crate's writer, so under stock Wine/Proton the expander builds with no
D3DCompile. It's on a branch of my fork, since new PRs are limited to collaborators:https://github.com/Exorion1er/VIctory/commits/gpu/rect-expander-own-writer
root_uav_handleand itspub(crate)root_signature). The first commit merges #190 into this PR's head4090d29, with one resolution inindirect.rs: yourclamp_uav/boundsplit with #190'sARGUMENTS/BUDGET/GROUP. The second commit is the port:emit/rectangles.rs(new), the GPU side'smake()building both root signatures from a description, andFxcdropped.4090d29rule), and the unorm stores saturate.rectanglestests pass 7/7, includinggpu_expansion_matches_cpu_expand_rects. With the fourth corner deliberately broken, that test fails on exactly those bytes, so it really compares.Use any of it as you see fit, credited or not.
AI-assisted (Claude Code).
@BastienRodz on GitHub · 2026-11-24 09:18 UTC · original
Thank you, that's a lot of careful work, and the in-title result is very useful: with the expander running under stock Proton the rectangle-list draws run without faults, and the black picture is a separate problem.
Our two fixes crossed (yours at 09:17, my
c256f83just after), so here is how they fit:c256f83keeps the run-time HLSL, rewritten so vkd3d-shader 2.1 compiles it (word-indexed structured buffers), with the root signatures serialized in code. It doesn't depend on #190, so this PR can land on its own and work under Proton with Wine's builtin compiler, as long as the clamp compiles there too (today that needs #190 or Microsoft'sd3dcompiler_47).D3DCompileat run time at all, your branch is the way to go: I'd rebase this PR onto it, credited, or it can follow as its own change.If you have a moment, a run of
c256f83stacked on #190 with the builtin compiler would show whether the HLSL route holds on your stack too. If it does, either route works, and the choice can follow #190.AI-assisted (Claude Code).
@Exorion1er on GitHub · 2026-11-24 09:23 UTC · original
Our comments crossed: I posted the port a couple of minutes after your fix. I reran what you asked:
c256f83+ #190 (and #454, only for the watchdog switch), GE-Proton11-12's Wine with its builtind3dcompiler_47, Proton Experimental's vkd3d-proton 3.2.0, RX 9070 XT RADV, diagnostics build, short run into the first mission.E5005, no root signature error, and 0rectangle expander shader unavailabledrops (256/frame before). So on stock Proton your fix does what it says.indirect kind 1: indexed rectangles not supportedat about 0.1/frame.GCVM_L2_PROTECTION_FAULT_STATUS:0x0060113B, clientTCP), thendevice removed after a submission of 10 lists. That's the same signature plainmaingives on this card (#714), and this tree has none of the other world fixes I usually stack, so I don't attribute it to the expander. One run, though.So my branch isn't needed for Wine any more. It only matters if you'd rather not have a run-time compiler at all, as #190 did for the clamp. Otherwise, ignore it.
AI-assisted (Claude Code).
@justr4mzi on GitHub · 2026-11-24 10:03 UTC · original
Tested PR #346 (
c256f832) integrated cleanly ontomain(8e79c80) inside a 13-PR combined stack on Windows 11 with an AMD Radeon RX 6700 XT (RDNA2) and Rust 1.98.1 (x86_64-pc-windows-msvc).#688,#609,#652,#472, and#677(plus 7 shader PRs).cargo test -p victory-gpu -- --test-threads=1: 64 passed, 0 failed, 1 ignored (all 7rectangles::tests::*pass on this RDNA2 host, includinghlsl_compiles,rectangle_expander_builds, andgpu_expansion_matches_cpu_expand_rects);--features diagnostics: 67 passed, 0 failed, 1 ignored.cargo test --workspace -- --test-threads=1): 329 passed, 0 failed, 6 ignored;cargo xtask policy:155 files ok.AI-assisted verification and stack testing (reviewed locally).
@iurysf on GitHub · 2026-11-24 11:21 UTC · original
In-game data on NVIDIA. RTX 4070, driver 32.0.16.2101, on top of #493 + #483. Default loop limit, 300 s, 2 runs, idle CPU.
prepareafter the expansion, mostly from dynamic descriptor slot exhaustion (see #688).descriptor/host.rs, 2 indraw.rsand 1 invalu_tests.rs, all context, because the branch predates those PRs. The branch history also carries ~40 files from other work beyond the 6 the PR shows. A rebase onto current main would make it much easier to evaluate.AI-assisted.
@BastienRodz on GitHub · 2026-11-24 11:24 UTC · original
Thanks for the runs. 256 → 12/204 drops with no device removal, and the rest failing in
prepareon dynamic slot exhaustion (#688) rather than in the expander, is useful to know.On the merge: the branch is already on current
main(ffe310e, head8ef6bfe). The PR itself is 7 commits in 6 files (draw.rs,host.rs,indirect.rs,lib.rs,primitive.rs,rectangles.rs), and it touches neitherdescriptor/host.rsnorvalu_tests.rs. Merging the branch into an older base also brings everymaincommit since that base, which is where the ~40 files and those conflicts come from. To add only this PR to your stack:That applies cleanly on a base that has #418 (half subnormals, merged after
d2a4bae), since the half-float commits build on it. On an older base,primitive.rsconflicts. Rebasing your stack onto currentmainavoids both.AI-assisted (Claude Code).
@Yaekai on GitHub · 2026-11-24 16:26 UTC · original
Independent verification on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head
8ef6bfe:cargo test -p victory-gpu --lib: 58 passed, 0 failed (1.33s).cargo clippy -p victory-gpu -- -D warnings: 0 warnings.1.0.2.1,--console series-s, 19-min world run): verified GPU indirect rectangle expansion with zero D3D12 errors or regressions. Ready to merge!@BastienRodz on GitHub · 2026-11-24 16:30 UTC · original
The CPU-path half-float fix (fuzeofficlal's ties-to-even rounding in
primitive.rs) is now its own PR, #1220, so it can land without the expander. Once it merges, I'll rebase this one onto it; the GPU expander's copy of the rounding stays here.@neonbyte1 on GitHub · 2026-11-24 18:12 UTC · original
Results on Linux (Wine 11.22 + vkd3d-proton from GE-Proton11-14), RTX 5090, driver 620.73.04. #346 at
8ef6bfeis ported onto a stack that includes #190's own argument-clamp writer (indirect::bound), soclamp_uavis split out of it as the PR does.Under Wine's HLSL compiler (vkd3d-shader):
rectangles::tests::hlsl_compiles,rectangle_expander_buildsandgpu_expansion_matches_cpu_expand_rectsrun and pass on the 5090. TheStructuredBuffer<uint>reads and the serialized root signatures work there. I changedhlsl_compileslocally so that it fails instead of skipping when a compiler is present. Workspace: 403 passed, 0 failed, 6 ignored.In game (first mission, diagnostics build, medians over frames with more than 1,000 draws):
indirect kind 0: prepare failed (compute false, mesh false)was 256 drops/frame before and is gone.indirect kind 1: indexed rectangles not supported, about 1/frame.The final picture is still black in this stack. The G-buffer shows props but no ground or buildings, which points to the untranslated mesh shaders rather than the full-screen passes.
AI-assisted (Claude); all runs on my machine, no game data shared.
@BastienRodz on GitHub · 2026-11-24 21:42 UTC · original
Closing:
683ad7aonmainnow 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.Pull request closed