GPU: keep v0 as the leading vertex in CPU-expanded rectangles #2992

Open
steven-seagull27 wants to merge 7 commits from upstream-pr/2994 into main
steven-seagull27 commented 2026-11-26 02:47:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T02:47:05Z.


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.

Hardware & API reference for v0 as leading vertex

  • AMD's Southern Islands 3D Register Guide defines DI_PT_RECTLIST (p. 31) and PA_SU_SC_MODE_CNTL.PROVOKING_VTX_LAST (p. 68, 0 = first vertex for D3D).
  • AMD PAL (gfx9UniversalCmdBuffer.cpp#L6460-L6464) defines RectList as three rectangle vertices and programs the first/last provoking-vertex register mode.
  • Direct3D 11.3 §8.14 specifies the first non-adjacent vertex as the leading vertex for constant/flat attributes.

Under first-vertex mode, both generated triangles must start at v0 across all three right-angle corners ([0, 1, 3, 0, 3, 2], [0, 1, 2, 0, 2, 3], [0, 1, 2, 0, 3, 1]).

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. Once #2729 lands, this PR will be rebased onto main as that clean two-commit stack with no merge commits.

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.

CPU implementation Incorrect four-channel pixels / 24 on RTX 5080 Built-in WARP
Original #2994 head 0b144bc 14 / 24 14 / 24
#2729 alone 857f394 12 / 24 12 / 24
Current combined head 0 / 24 0 / 24

With the right angle at v0, the first pixel on 0b144bc read 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-gpu Clippy and the asset-policy check passed.

AI-assisted. Synthetic fixtures only.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5503068576 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2994). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-26T02:47:05Z. --- 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](https://github.com/Marvisak/VIctory/pull/2970#issuecomment-7180953508). The diagonal and vertex ordering follow their geometry-shader work. ### Hardware & API reference for `v0` as leading vertex - AMD's [Southern Islands 3D Register Guide](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/programmer-references/SI_3D_registers.pdf) defines `DI_PT_RECTLIST` (p. 31) and `PA_SU_SC_MODE_CNTL.PROVOKING_VTX_LAST` (p. 68, `0` = first vertex for D3D). - [AMD PAL](https://github.com/GPUOpen-Drivers/pal/blob/c5e800072a32f68b6ccc4422936d96167c6e0728/inc/core/palCmdBuffer.h#L91-L148) (`gfx9UniversalCmdBuffer.cpp#L6460-L6464`) defines `RectList` as three rectangle vertices and programs the first/last provoking-vertex register mode. - [Direct3D 11.3 §8.14](https://microsoft.github.io/DirectX-Specs/d3d/archive/D3D11_3_FunctionalSpec.htm#LeadingVertex) specifies the first non-adjacent vertex as the leading vertex for constant/flat attributes. Under first-vertex mode, both generated triangles must start at `v0` across all three right-angle corners (`[0, 1, 3, 0, 3, 2]`, `[0, 1, 2, 0, 2, 3]`, `[0, 1, 2, 0, 3, 1]`). **This is stacked on [#2729](https://github.com/Marvisak/VIctory/pull/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](https://github.com/steven-seagull27/VIctory/compare/857f394ebe5a7f8d1b4100979cd801eb4ac4deb8...64598c44626fb6968728c0d1f27bfc224ff99c2d) contains the v0 ordering and its regression. Once #2729 lands, this PR will be rebased onto `main` as that clean two-commit stack with no merge commits. 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](https://github.com/steven-seagull27/VIctory/commit/c3149187c8fb877693bb41465af9bc17f17c0387) 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. | CPU implementation | Incorrect four-channel pixels / 24 on RTX 5080 | Built-in WARP | |---|---:|---:| | Original #2994 head `0b144bc` | 14 / 24 | 14 / 24 | | #2729 alone `857f394` | 12 / 24 | 12 / 24 | | Current combined head | **0 / 24** | **0 / 24** | With the right angle at v0, the first pixel on `0b144bc` read 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-gpu` Clippy and the asset-policy check passed. AI-assisted. Synthetic fixtures only.
kotekompotek commented 2026-11-26 02:58:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T02:58:01Z.

Review: APPROVED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6067950572 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2994#pullrequestreview-6067950572). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T02:58:01Z. **Review:** APPROVED --- 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.
steven-seagull27 commented 2026-11-26 03:05:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T02:54:19Z.


The CI failure is reproducible on unmodified main 63bcca43. Both workspace Clippy jobs and all rectangle tests passed on the runner. Its sole failure was frame::tests::waits_end_on_ticks_and_count_frames at frame.rs:231: after a 2 ms tick, the zero-timeout poll returned S_OK (0) when the test expected TIMEOUT (1).

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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7181221624 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2994#issuecomment-7181221624). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-26T02:54:19Z. --- The [CI failure](https://github.com/Marvisak/VIctory/actions/runs/45744708856/job/139657843162) is reproducible on unmodified main `63bcca43`. Both workspace Clippy jobs and all rectangle tests passed on the runner. Its sole failure was `frame::tests::waits_end_on_ticks_and_count_frames` at `frame.rs:231`: after a 2 ms tick, the zero-timeout poll returned `S_OK` (0) when the test expected `TIMEOUT` (1). 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](https://github.com/Marvisak/VIctory/pull/2861) and [#2877](https://github.com/Marvisak/VIctory/pull/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.
fuzeofficlal commented 2026-11-26 03:07:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T03:07:56Z.

Review: CHANGES_REQUESTED


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::rectangles in draw.rs:1610 calls expand_rects independently 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 FLOAT3 positions (0,0), (0,1), (1,0) (right = 0 → [0,1,3,0,3,2]) and Stream 1 holding RGBA8_UNORM colors (no float2+ element, so right falls back to 1 → [0,1,2,0,2,3]), Triangle 0 pairs synthesized position v3 with v2's color and Triangle 1 pairs v2's position with synthesized v3's color (whereas on main, both streams emitted [0,1,2] for Triangle 0).
    • Suggest determining right once per rectangle from the position stream (or passing the chosen right-angle corners into expand_rects across all slots) and adding a split-stream regression test.
    • For a single interleaved stream, all three corner permutations preserve winding and keep v0 leading.
<!-- greyfinch-sync:Marvisak/VIctory:review:6068018404 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2994#pullrequestreview-6068018404). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T03:07:56Z. **Review:** CHANGES_REQUESTED --- 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::rectangles` in `draw.rs:1610` calls `expand_rects` independently 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 `FLOAT3` positions `(0,0), (0,1), (1,0)` (`right = 0` → `[0,1,3,0,3,2]`) and Stream 1 holding `RGBA8_UNORM` colors (no float2+ element, so `right` falls back to `1` → `[0,1,2,0,2,3]`), Triangle 0 pairs synthesized position `v3` with `v2`'s color and Triangle 1 pairs `v2`'s position with synthesized `v3`'s color (whereas on `main`, both streams emitted `[0,1,2]` for Triangle 0). - Suggest determining `right` once per rectangle from the position stream (or passing the chosen right-angle corners into `expand_rects` across all slots) and adding a split-stream regression test. - For a single interleaved stream, all three corner permutations preserve winding and keep `v0` leading.
steven-seagull27 commented 2026-11-26 04:06:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T03:20:14Z.


@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 c314918, the new regression binds separate POSITION and RGBA8_UNORM streams through the regular guest draw vtable. It reads smooth RG and flat RG simultaneously at all four pixels for three vertex rotations and both windings. Both adapters gave the same result: 14/24 incorrect pixels on the old 0b144bc, 12/24 on #2729 alone, and 0/24 on the updated PR. The original float-first, UNORM and constant-stride checks also passed on both. The PR description now links the small overlay on top of #2729.

Could you take another look at this head?

<!-- greyfinch-sync:Marvisak/VIctory:comment:7181623020 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2994#issuecomment-7181623020). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-26T03:20:14Z. --- @fuzeofficlal Your split-stream example reproduces on the old head. I fast-forwarded this PR to include @andrewpozdnakov7-jpg's original [#2729](https://github.com/Marvisak/VIctory/pull/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 [`c314918`](https://github.com/steven-seagull27/VIctory/commit/c3149187c8fb877693bb41465af9bc17f17c0387), the new regression binds separate POSITION and RGBA8_UNORM streams through the regular guest draw vtable. It reads smooth RG and flat RG simultaneously at all four pixels for three vertex rotations and both windings. Both adapters gave the same result: 14/24 incorrect pixels on the old `0b144bc`, 12/24 on #2729 alone, and **0/24** on the updated PR. The original float-first, UNORM and constant-stride checks also passed on both. The PR description now links the small overlay on top of #2729. Could you take another look at this head?
futurepro62 commented 2026-11-26 05:04:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T04:07:59Z.


Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head c314918 (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 869 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: cpu_rectangle_uses_the_position_corner_order_for_split_vertex_streams, split_rectangle_keeps_the_leading_color_on_both_triangles, both_triangles_keep_v0_for_every_right_angle_and_winding.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7182323042 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2994#issuecomment-7182323042). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T04:07:59Z. --- Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head `c314918` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **869 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `cpu_rectangle_uses_the_position_corner_order_for_split_vertex_streams`, `split_rectangle_keeps_the_leading_color_on_both_triangles`, `both_triangles_keep_v0_for_every_right_angle_and_winding`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Marvisak commented 2026-11-26 06:03:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T05:37:28Z.


Automated triage for the maintainers.

Needs work. The rectangle changes themselves look right to me. In expand_rects_with_corners (victory-gpu/src/primitive.rs) the three index orders ([0,1,3,0,3,2], [0,1,2,0,2,3], [0,1,2,0,3,1]) each split the quad along the diagonal opposite the right angle, keep the input winding, and start both triangles at v0. draw.rs now picks one corner order per rectangle from the POSITION stream and applies it to every stream, so split position/color buffers stay consistent. CI passed after a re-run, and a full NVIDIA test run is reported in the thread.

What stops it as is:

  • It carries #2729's four commits (another contributor's work, including a merge of main) plus a merge commit of its own. Please let #2729 be reviewed and land first, then rebase this PR to just 0b144bc and the regression commit, with no merge commits.
  • Evidence for v0. The PR's claim is that a rectangle's flat inputs come from v0 across both halves. The reference given is #2970's geometry-shader path, which is VIctory's own code. Please cite where that rule comes from (public AMD documentation, or a console capture / the title's own rendering showing it), as for other emulation-behaviour changes.

CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7183655733 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2994#issuecomment-7183655733). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T05:37:28Z. --- <!-- victory-triage v1 head=c3149187c8fb877693bb41465af9bc17f17c0387 verdict=needs-work at=2026-11-26T05:37:18Z --> Automated triage for the maintainers. **Needs work.** The rectangle changes themselves look right to me. In `expand_rects_with_corners` (`victory-gpu/src/primitive.rs`) the three index orders (`[0,1,3,0,3,2]`, `[0,1,2,0,2,3]`, `[0,1,2,0,3,1]`) each split the quad along the diagonal opposite the right angle, keep the input winding, and start both triangles at v0. `draw.rs` now picks one corner order per rectangle from the POSITION stream and applies it to every stream, so split position/color buffers stay consistent. CI passed after a re-run, and a full NVIDIA test run is reported in the thread. What stops it as is: - **It carries #2729's four commits** (another contributor's work, including a merge of main) plus a merge commit of its own. Please let #2729 be reviewed and land first, then rebase this PR to just `0b144bc` and the regression commit, with no merge commits. - **Evidence for v0.** The PR's claim is that a rectangle's flat inputs come from v0 across both halves. The reference given is #2970's geometry-shader path, which is VIctory's own code. Please cite where that rule comes from (public AMD documentation, or a console capture / the title's own rendering showing it), as for other emulation-behaviour changes. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
andrewpozdnakov7-jpg commented 2026-11-28 08:15:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T08:15:31Z.


I checked the public AMD sources for the v0 question in the review.

  • AMD's Southern Islands register guide lists DI_PT_RECTLIST on p. 31. The PA_SU_SC_MODE_CNTL.PROVOKING_VTX_LAST description on p. 68 gives the first vertex for the D3D setting. The AMD PAL header describes RectList as three rectangle vertices and defines the first/last choice for flat vertex-shader outputs. Its graphics command implementation writes that choice to the register.
  • Direct3D 11.3 §8.14 identifies the first non-adjacent vertex as the source of constant attributes. The inference for the fallback is that both generated triangles must lead with the input rectangle's v0 when first-vertex mode is selected. The public sources describe that mode. I did not inspect a console register capture.

I also reran the split-stream fixture at c314918, with counting enabled so it read all 24 pixels even on the control. The control replaces only primitive.rs with #2729's version on the same code and test base. App-local WARP 1.0.22 and Agility 1.620.2 returned 12/24 mismatches on the control and 0/24 on #2994, both with the D3D12 debug switch off and on. The mismatches were all in the flat channels. All five tests matching rectangle passed on #2994. The #2729 merge dependency remains.

Please retain the original Git authors if reusing the fixtures. If incorporating this follow-up into another commit, please keep:

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7236466196 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2994#issuecomment-7236466196). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T08:15:31Z. --- I checked the public AMD sources for the v0 question in [the review](https://github.com/Marvisak/VIctory/pull/2994#issuecomment-7183655733). - AMD's [Southern Islands register guide](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/programmer-references/SI_3D_registers.pdf) lists `DI_PT_RECTLIST` on p. 31. The `PA_SU_SC_MODE_CNTL.PROVOKING_VTX_LAST` description on p. 68 gives the first vertex for the D3D setting. The [AMD PAL header](https://github.com/GPUOpen-Drivers/pal/blob/c5e800072a32f68b6ccc4422936d96167c6e0728/inc/core/palCmdBuffer.h#L91-L148) describes `RectList` as three rectangle vertices and defines the first/last choice for flat vertex-shader outputs. Its [graphics command implementation](https://github.com/GPUOpen-Drivers/pal/blob/c5e800072a32f68b6ccc4422936d96167c6e0728/src/core/hw/gfxip/gfx9/gfx9UniversalCmdBuffer.cpp#L6460-L6464) writes that choice to the register. - [Direct3D 11.3 §8.14](https://microsoft.github.io/DirectX-Specs/d3d/archive/D3D11_3_FunctionalSpec.htm#LeadingVertex) identifies the first non-adjacent vertex as the source of constant attributes. The inference for the fallback is that both generated triangles must lead with the input rectangle's v0 when first-vertex mode is selected. The public sources describe that mode. I did not inspect a console register capture. I also reran the split-stream fixture at `c314918`, with counting enabled so it read all 24 pixels even on the control. The control replaces only `primitive.rs` with #2729's version on the same code and test base. App-local WARP 1.0.22 and Agility 1.620.2 returned **12/24 mismatches** on the control and **0/24** on #2994, both with the D3D12 debug switch off and on. The mismatches were all in the flat channels. All five tests matching `rectangle` passed on #2994. The #2729 merge dependency remains. Please retain the original Git authors if reusing the fixtures. If incorporating this follow-up into another commit, please keep: Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted with OpenAI Codex.
steven-seagull27 commented 2026-11-28 20:17:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-28T20:17:04Z.


Thanks for the review and thanks @andrewpozdnakov7-jpg for pulling the public hardware and API references together.

For the v0 provoking-vertex rule in the CPU fallback:

  • AMD's Southern Islands 3D Register Guide defines DI_PT_RECTLIST (p. 31) and PA_SU_SC_MODE_CNTL.PROVOKING_VTX_LAST (p. 68, 0 = first vertex for D3D).
  • AMD PAL (gfx9UniversalCmdBuffer.cpp#L6460-L6464) defines RectList as three rectangle vertices and writes that first/last provoking-vertex mode to the register.
  • Direct3D 11.3 §8.14 specifies the first non-adjacent vertex as the leading vertex for constant/flat attributes.

Splitting the rectangle into [0, 1, 3, 0, 3, 2] / [0, 1, 2, 0, 2, 3] / [0, 1, 2, 0, 3, 1] keeps v0 as the leading vertex of both generated triangles across all three right-angle corners and both windings under first-vertex mode.

I will update the PR description with these public references and rebase onto main as a clean two-commit stack (0b144bc + the split-stream regression, no merge commits) once #2729 lands.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7245172465 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2994#issuecomment-7245172465). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-28T20:17:04Z. --- Thanks for the review and thanks @andrewpozdnakov7-jpg for pulling the public hardware and API references together. For the `v0` provoking-vertex rule in the CPU fallback: - AMD's [Southern Islands 3D Register Guide](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/programmer-references/SI_3D_registers.pdf) defines `DI_PT_RECTLIST` (p. 31) and `PA_SU_SC_MODE_CNTL.PROVOKING_VTX_LAST` (p. 68, `0` = first vertex for D3D). - [AMD PAL](https://github.com/GPUOpen-Drivers/pal/blob/c5e800072a32f68b6ccc4422936d96167c6e0728/inc/core/palCmdBuffer.h#L91-L148) (`gfx9UniversalCmdBuffer.cpp#L6460-L6464`) defines `RectList` as three rectangle vertices and writes that first/last provoking-vertex mode to the register. - [Direct3D 11.3 §8.14](https://microsoft.github.io/DirectX-Specs/d3d/archive/D3D11_3_FunctionalSpec.htm#LeadingVertex) specifies the first non-adjacent vertex as the leading vertex for constant/flat attributes. Splitting the rectangle into `[0, 1, 3, 0, 3, 2]` / `[0, 1, 2, 0, 2, 3]` / `[0, 1, 2, 0, 3, 1]` keeps `v0` as the leading vertex of both generated triangles across all three right-angle corners and both windings under first-vertex mode. I will update the PR description with these public references and rebase onto `main` as a clean two-commit stack (`0b144bc` + the split-stream regression, no merge commits) once #2729 lands.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2994:upstream-pr/2994'
git switch 'upstream-pr/2994'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/2994'
git switch 'upstream-pr/2994'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2994'
git switch 'upstream-pr/2994'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2994'
git switch 'main'
git merge --squash 'upstream-pr/2994'
git switch 'main'
git merge --ff-only 'upstream-pr/2994'
git switch 'main'
git merge 'upstream-pr/2994'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!2992
No description provided.