GPU: keep rectangle corners consistent across vertex streams #2727
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2729"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T19:01:57Z.
The CPU fallback for rectangle draws chose a right-angle vertex in each vertex buffer. A separate RGBA8 color stream could use its fallback vertex even when the position stream chose a different one. Its attributes then went to the wrong vertices of the second triangle.
Choose the corners once from the explicit POSITION input when available, with the existing float-position heuristic as fallback. Use the same corners to expand every per-vertex stream.
The same WARP regression submits a rectangle through VIctory's draw vtable with positions and colors in separate buffers and a nonzero start vertex. On
13f91cathe bottom-right texel reads [0.75, 0, 0, 1]. Onf701a1dit reads [0.75, 0.75, 0, 1]. The top-left control reads [0.25, 0.25, 0, 1] in both. Six paired runs reproduced the result across both D3D12 debug settings.The second case puts a float color in slot 0 and POSITION in slot 1. On
f701a1dthe bottom-right texel is clear. On5f92980it reads [0.75, 1.5, 0, 1]. The original RGBA8 case still passes. Six paired WARP runs reproduce the second result across both debug settings.The third case binds a four-byte RGBA8 buffer with stride zero, so the input assembler reads one color for every vertex. On
5f92980both sampled texels are clear. Onbd0226eboth read [1, 0, 0, 1]. The expanded draw keeps the input assembler view for this constant stream. The two earlier layouts still pass.The serial GPU suite passed 199 tests with one ignored in each setting. Strict GPU Clippy with both feature configurations and asset policy passed. AI-assisted using Codex. Synthetic vertex data.
Coordination claim
Please keep the Git author when reapplying the commit. If you fold the change or test into another commit, please add:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T19:04:13Z.
Review: CHANGES_REQUESTED
A lower-numbered float attribute stream can choose the corner for the position stream. For example, put
TEXCOORDin slot 0 with[(0,1), (0,0), (1,0)]andPOSITIONin slot 1 with the three positions from your test. The UVs pick vertex 1, while the positions pick vertex 0. Applying the UV choice changes the generated fourth position from(1,-1)to(1,3).Could the draw prefer an identified position input when choosing the shared corner? Swapping the slots in the existing fixture and using float UVs that choose a different corner would cover this regression.
AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T19:04:59Z.
Correct fix for a real per-stream divergence: expand_rects previously picked the right-angle corner independently per stream, so an RGBA8 color stream could choose a different corner than the position stream and scramble the second triangle's attributes. Choosing corners once via find_map over streams (first stream whose elements yield a usable float position) and sharing them across all expands is the right shape; corners.as_deref().unwrap_or_default() keeps a sane fallback when no stream yields one. Collapsing the per-slot defer_host calls into one closure is also tidier. The regression test (separate position/color buffers, nonzero start vertex, texel asserts) reproduces the exact failure.
Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T19:51:08Z.
Review: APPROVED
No description provided.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T19:10:51Z.
I reran the rectangle with float colors in slot 0 and POSITION in slot 1. On
f701a1dthe fallback chose its angle from color and left the bottom-right texel clear. 5f92980 prioritizes the named position and reads [0.75, 1.5, 0, 1]. The original separate RGBA8 case still passes. Six paired WARP runs, the serial GPU suite (199 passed, one ignored) in both debug settings, strict Clippy and asset policy passed.I also ran DrDarkDK's exact TEXCOORD example with [(0,1), (0,0), (1,0)] in slot 0. The bottom-right texel is clear on
f701a1dand reads [0.75, -0.5, 0, 1] on5f92980. CI passed on the updated head.Please keep the Git author on cherry-pick or rebase. If the solution or tests are folded into another commit, please add:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T19:36:20Z.
Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and review of
bd0226e6(on13f91ca):Verification (
rustc 1.98.1MSVC)cargo xtask policy: 184 files ok.cargo clippy --locked -p victory-gpu --all-targets -- -D warningsand--features diagnostics: 0 warnings.cargo test --locked -p victory-gpu --lib -- primitive(9 passed) andrect(12 passed, includingcpu_rectangle_uses_the_position_corner_order_for_split_vertex_streams).VICTORY_D3D12_WARP=1):cargo test --locked -p victory-gpu --features diagnostics-> 199 passed, 0 failed, 1 ignored.Review & Merge-Ordering Notes
cornersonce from thePOSITION(index 0) stream — with fallback to the firstF32/F16attribute stream andv1default — keeps split vertex streams consistent, and thestride == 0constant-stream handling (v.address != 0 && v.size != 0 && shadow::find(...)) skips CPU expansion cleanly.victory-shader/src/emit/rect.rs, which improvesright_anglethat this PR calls); conflicts incrates/victory-gpu/src/draw.rs::State::rectangleswith #2727 (f712e159, which adds checked arithmetic forfirst + count/SizeInBytesoverflow) — both are semantically complementary and straightforward to rebase together.Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T19:24:12Z.
The expanded draw also needs to keep a valid zero-stride vertex stream. I added a four-byte RGBA8 buffer containing opaque red. Both sampled texels are clear on
5f92980. bd0226e reuses the bound vertex view and both read [1, 0, 0, 1] on WARP. The two earlier layouts pass. Six paired runs, the serial GPU suite (199 passed, one ignored) in both debug settings, strict Clippy and asset policy passed.Please retain the Git author on cherry-pick or rebase. If you fold the change or test into another commit, please add:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
The GitHub check failed on the frame-pacing test, whose source is identical to main at
13f91ca. I reproduced its S_OK versus TIMEOUT assertion with a simulated late poll and updated the existing fixture PR, #2265, in 303be14. A maintainer rerun of the check onbd0226ewould help verify the current rectangle head independently.Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T22:51:32Z.
I resolved the test-module conflict and merged current main
842b0cbin 857f394.The same WARP draw on
219878ayields bottom-right[0.75, 0, 0, 1]for the split UNORM streams. The updated branch yields[0.75, 0.75, 0, 1]and passes the float-first and constant-stride controls. Both serial GPU suites on the final revision passed 247 tests with one ignored, including the upstream depth-bounds tests and the frame-timing test that failed in the previous CI run. Both strict GPU Clippy modes and asset policy passed.Please retain the Git author when moving the fix or tests. If squashing them into another commit, please add this trailer.
Co-authored-by: andrewpozdnakov7-jpg [email protected]
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:16:50Z.
Automated triage for the maintainers.
The CPU rectangle expansion in
State::rectangles(crates/victory-gpu/src/draw.rs) picked the right-angle corner separately for each vertex stream, so a separate colour stream could end up paired with the wrong vertices. This PR picks the corners once, viaprimitive::rectangle_corners, from thePOSITIONinput when the layout names one and with the old float heuristic otherwise, and expands every stream with them. A stride-0 stream now keeps its bound view instead of failing the draw.I checked the new
positionflag inpipeline/host.rs, that source ranges are still checked before the deferred copy, and the three-layout WARP test. The branch is merged with currentmain, and CIcheckpasses. #2727 edits the same function and will need a rebase after this one. This is a recommendation for a maintainer to look, not an approval.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T02:47:34Z.
@andrewpozdnakov7-jpg I tested your
857f394alongside the CPU provoking-vertex follow-up requested on #2970. I've left your position-slot selection and constant-stride handling in this PR. My standalone follow-up #2994 only changes the triangle order and is marked to merge after #2729.The two changes together matched the reference GS on all 24 draws on both an RTX 5080 and built-in WARP. I also ran your three-layout draw-vtable regression on each adapter; its sampled colors all passed. For integration there's one commit directly on your current head which keeps your expander signature and original commit history. No action needed on your branch.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T01:54:30Z.
I combined
857f394ebe5a7f8d1b4100979cd801eb4ac4deb8with #3646 in ec47248, preserving both PR heads. The only addition beyond the clean merge is a CPU regression for a separateR10G10B10A2_UNORMcolor stream.The test uses two rectangles whose positions select right-angle indices 0 and 2. On this PR head alone, the expanded fourth vertices still contain copied packed colors. In the integration, the two fourth colors are
(1023, 270, 0, 3)and(1000, 0, 100, 1), and the other ten colors retain their expected order. All 11 primitive tests passed from the isolated exact source, along with asset policy. This validates the CPU expansion on generated vertex data.Please preserve the Git author if cherry-picking or rebasing, or include this trailer if folding the test into another commit.
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.