Repository navigation
GPU: keep v0 as the leading vertex in CPU-expanded rectangles - #2994
steven-seagull27 wants to merge 7 commits into
Conversation
Use the same provoking-vertex split as fuzeofficlal's rectangle geometry shader in Marvisak#2970.
# Conflicts: # crates/victory-gpu/src/primitive.rs
|
The CI failure is reproducible on unmodified main I built that exact base and ran just the unchanged frame test. It passed 50/50 in isolation. Under synthetic scheduling contention (eight test processes and two CPU workers sharing one logical processor), 37/40 hit the identical line and 0-vs-1 assertion. The other three missed timing expectations at lines 230 or 235. This is the same failure already tracked in #2861 and #2877. Could a maintainer re-run the failed job? GitHub requires repository-admin access for my rerun request. I kept this PR confined to the rectangle expander. |
kotekompotek
left a comment
There was a problem hiding this comment.
LGTM — CPU-side sibling of #2970's fix, same invariant: v0 leads both triangles so flat attributes agree.
Verified the geometry for all three right-angle positions (concrete cross-products): right=0 → (v0,v1,v3)+(v0,v3,v2) diagonal v0–v3; right=2 → (v0,v1,v2)+(v0,v3,v1) diagonal v0–v1; right=1 → (v0,v1,v2)+(v0,v2,v3) diagonal v0–v2 — each pair covers the quad with identical winding. The emit order writes the computed fourth vertex at its slot first, then copy_within duplicates it into the other v3 slot for right=0 — correct.
fourth = copy(v0) + element fixups is right: interpolated components get computed corner values, flat components come from the leading vertex which is v0 in both triangles — so taking v0's raw bytes is semantically identical to taking va's.
The new test is discriminating: all three right-angle positions × both windings assert the exact emitted order including the synthesized corner.
fuzeofficlal
left a comment
There was a problem hiding this comment.
Code review on 0b144bc0 (static source inspection; no runtime GPU execution):
- High — Split vertex streams can disagree on triangle corner order (
crates/victory-gpu/src/primitive.rs:38-69,crates/victory-gpu/src/draw.rs:1610-1635):State::rectanglesindraw.rs:1610callsexpand_rectsindependently per bound vertex-buffer slot.- Because this PR makes Triangle 0's output vertex order depend on which corner is chosen as
right(0 => [0,1,3,0,3,2],2 => [0,1,2,0,3,1],_ => [0,1,2,0,2,3]), two separate vertex streams for the same draw can pick different orders. - For example, with Stream 0 holding
FLOAT3positions(0,0), (0,1), (1,0)(right = 0→[0,1,3,0,3,2]) and Stream 1 holdingRGBA8_UNORMcolors (no float2+ element, sorightfalls back to1→[0,1,2,0,2,3]), Triangle 0 pairs synthesized positionv3withv2's color and Triangle 1 pairsv2's position with synthesizedv3's color (whereas onmain, both streams emitted[0,1,2]for Triangle 0). - Suggest determining
rightonce per rectangle from the position stream (or passing the chosen right-angle corners intoexpand_rectsacross all slots) and adding a split-stream regression test. - For a single interleaved stream, all three corner permutations preserve winding and keep
v0leading.
|
@fuzeofficlal Your split-stream example reproduces on the old head. I fast-forwarded this PR to include @andrewpozdnakov7-jpg's original #2729 commit. The draw now computes the right-angle corner from POSITION once and passes the same order to the color stream. The v0-leading change applies to that shared order. At Could you take another look at this head? |
|
Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
|
Automated triage for the maintainers. Needs work. The rectangle changes themselves look right to me. In What stops it as is:
CI: passing. Generated by Claude Code |
The CPU rectangle-list fallback can give the second triangle a different leading vertex when the input rectangle's right angle is at v0 or v2. A flat pixel input then changes halfway across the rectangle. This is the CPU follow-up requested by @fuzeofficlal on #2970. The diagonal and vertex ordering follow their geometry-shader work.
This is stacked on #2729. Please merge that PR first. The current head includes @andrewpozdnakov7-jpg's original
857f394, which computes each rectangle's corner order once using its position stream and shares it across the draw. It also handles inputs before a named POSITION and stride-zero streams. The small two-commit overlay directly on #2729 contains the v0 ordering and its regression.Both output triangles start at v0 and keep the input winding. The synthesized vertex retains v0's bytes for unknown/integer formats and interpolates recognized components. The CPU primitive test checks all six emitted vertices for all three right-angle orderings and both windings.
Split positions and colors
The review regression binds a float POSITION buffer and a separate RGBA8_UNORM color buffer through the guest command-list vtable. One pixel shader returns interpolated RG and flat RG together. The test draws all three vertex rotations under both windings, checks all four pixels of each 2×2 rectangle, and verifies that the CPU fallback ran. Each adapter produced the same counts.
0b144bc857f394With the right angle at v0, the first pixel on
0b144bcread smooth RG(0.25, 0.0)against(0.25, 0.25). With #2729 alone, the smooth value at the next pixel was correct, but flat RG read(1, 0)against v0's(0, 0). The shared position order and the v0-leading indices address those two errors together.Other verification
The earlier 32×32 readback compared CPU-expanded triangle-list draws to #2970's geometry-shader reference. With both fixes, all 24 draws matched on each adapter (24,576 texels per adapter), across interleaved and split streams, both windings, and flat and interpolated pixel inputs. On the final head, the new draw regression, the existing three-layout test including stride zero, and the primitive v0 regression passed with RTX 5080 (driver 621.40) and built-in Microsoft WARP selected separately. Strict all-feature
victory-gpuClippy and the asset-policy check passed.AI-assisted with Codex. Synthetic fixtures only.