GPU: keep rectangle corners consistent across vertex streams #2729
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!2729
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 19:01 UTC · original
andrewpozdnakov7-jpg:fix/rectangle-stream-corner→main· +441 −38 · 3 files · 4 commits · openThe 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]
@kotekompotek on GitHub · 2026-11-25 19:04 UTC · original
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.
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 19:10 UTC · original · edited 2026-11-25 19:14 UTC
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]
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 19:24 UTC · original · edited 2026-11-25 19:37 UTC
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.@fuzeofficlal on GitHub · 2026-11-25 19:36 UTC · original
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.@andrewpozdnakov7-jpg on GitHub · 2026-11-25 22:51 UTC · original
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]
@Marvisak on GitHub · 2026-11-25 23:16 UTC · original
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
@steven-seagull27 on GitHub · 2026-11-26 02:47 UTC · original
@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.
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.