Rect lists: the GS carries flat outputs, v0 the provoking vertex #293

Manually merged
github merged 1 commit from gh-pr/293/head into gh-pr/293/base 2026-11-26 04:19:05 +00:00
Owner

@⁠Kalmarv on GitHub · 2026-11-23 22:32 UTC · original
Kalmarv:feat/rect-list-gs-flat → main · +165 −88 · 5 files · 1 commits · merged 2026-11-23 23:20 UTC

The rect list GS (#199) is refused for a VS with an integer output and for a PS that reads an attribute flat, because which vertex of a rect gives a flat value was not established. Those pipelines fall back to the CPU expansion (#195, corner rule in #266), which only handles DrawInstanced with vertex buffers: their indexed draws, and vertices made from the vertex index alone, draw half of each rect. That is the gap named on #189 (closed). This PR takes a rect's flat values from its first vertex and drops the two refusals. Related: #199, #266 (independent of this one; no file in common).

Why the first vertex, from public AMD documents (read for the rule; nothing is copied):

  • PA_SU_SC_MODE_CNTL.PROVOKING_VTX_LAST (bit 19): "Defines which vertex of a primitive is used for attribute components when flat shading is enabled", 0 = First Vtx (D3D), 1 = Last Vtx (OGL). The same text is in the R6xx/R7xx (rev 1.0, January 26, 2009), Southern Islands (November 11, 2011) and Sea Islands (September 19, 2012) 3D register references. It is one bit for every primitive type; none of them makes an exception for DI_PT_RECTLIST.
  • Evergreen / Cayman programming guide (May 24, 2011), 5.2: the pixel shader gets each attribute "as V0, V1-V0, and V2-V0 where V0 is the attribute value at the provoking vertex"; 5.2.1: a flat-shaded term has "the provoking vertex values in V0 and gradients of 0".
  • Mesa sets the bit from state alone, with no rect list case: radeonsi si_state.c L977, radv radv_cmd_buffer.c L13719.

So under D3D's setting a rect's flat value is its first vertex's. The documents say it of primitives in general; it is not measured on a rect.

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs, rect_list_gs: no longer refuses integer outputs (it returns the HLSL, not a Result). Both triangles of a rect now start with v[0]: the two halves along the diagonal through v0, in the winding of v0 v1 v2. main emits (v0, v1, v2) and (a, d, b), so its second triangle starts with another vertex and a flat input would change across the diagonal. The implied fourth vertex is v[0] with its position and float outputs continued from the other three, as before; its integer outputs stay v[0]'s. The pixels covered and the smooth outputs are the same as on main: the rect is one plane on either diagonal.
  • crates/xcl/src/gpu/recomp/pso.rs: rect_list_gs follows; ps_reads_flat and reads_flat existed only for the refusal and are removed.
  • crates/xcl/src/hle/d3d12x/real.rs, rect_list_gs: only a PC pixel shader is refused now.
  • crates/xcl/src/gpu/recomp/runner.rs: draw_gs_indexed, an indexed triangle list draw for the test (draw_on_multi becomes a wrapper of the shared body, which takes optional indices).
  • crates/xcl/src/gpu/recomp/tests.rs: new gpu_rect_list_flat_outputs; rect_list_gs_outputs rewritten for the new rule; rect_list_ps_reads_flat removed with the function it tested (both were #199's refusal tests). +165/−88 in all.

The translation side needs no change: a console PS's integer inputs and its v_interp_mov_f32 attributes are already declared nointerpolation, which D3D12 takes from the triangle's first vertex. The CPU expansion already starts both triangles with v0.

Overlap: #239 changes the same part of runner.rs and conflicts with this branch there (whichever merges second needs a small rebase). #263 (real.rs), #255 (pso.rs), #247, #245, #236, #202, #187, #174, #172, #134 and #128 touch the same files elsewhere and merge clean with this branch.

Tested

  • NVIDIA GeForce RTX 5070 Ti, driver 610.74; Ryzen 9 9950X; Windows 11 (10.0.26200); rustc 1.99.0; debug. Head f03fe38, one commit on main 9ab7d76.
  • cargo test --workspace -- --test-threads=4: 651 passed, 0 failed, 40 ignored (the xcl library: 611 passed, 20 ignored; one test added, one removed). SKIPPED GPU tests: 2, both no wave64 (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware).
  • gpu_rect_list_flat_outputs (new, GPU): a VS with a smooth output, a uint4 output and a float output the PS reads nointerpolation; rects drawn indexed out of a 3 × 2 vertex grid with the corner at v0, at v1 in both directions, at v2, and two rects sharing vertices. Every pixel of a 16 × 16 target is checked: the rect is whole, the smooth output continues into the implied half, and both flat outputs are the first indexed vertex's in both halves. The same draws without the GS leave at least 12 pixels a rect wrong. Passes.
  • It fails on main: with this test and the runner function added to main 9ab7d76 it stops at rect_list_gs's refusal, "TEXCOORD1 is an integer output (flat)".
  • With main's triangle order put back in this branch's GS (integer outputs still allowed): the test fails at corner v0: pixel (2,4) = [-0.68749994, 0.4375, 2.0, 0.25], expected [-0.6875, 0.4375, 1.0, 0.125], the second triangle taking its flat values from v1. So the test holds the triangle order, not only the lifted refusal.
  • gpu_rect_list_corners and gpu_rect_list_fullscreen_order (#199's, unchanged but for the dropped unwrap) pass.
  • rect_list_gs_outputs (no GPU): the generated GS for float, integer and clip-distance outputs compiles with DXC, starts the fourth vertex as v[0] and continues only the float outputs.

Regression run

main: Pending: no title on our machine; asked testers.

PR: Pending: no title on our machine; asked testers.

Not tested

  • The regression run on a real title (scripts/smoke.ps1, main and this head): not done, see above.
  • No console: v0 as a rect's provoking vertex comes from the documents above, which describe primitives in general, not from a measurement of a rect.
  • Culling: whether the hardware culls a rect by its winding. Mesa's rect draws all use cull-none state, so the public sources do not show it. The GS keeps the winding of v0 v1 v2 for both triangles, as on main; a rect list pipeline with back-face culling could drop a rect the console draws.
  • A real console PS with v_interp_mov_f32 or integer inputs behind the GS: the test's shaders are HLSL written for it, with the declaration the translation makes (nointerpolation).
  • v_interp_mov_f32 reading P10 or P20 (another vertex's value) is still not translated, with or without rect lists (emit.rs: v_interp_mov p10/p20).
  • Integer system-value outputs (a render target or viewport index) through the GS: they are copied from v[0] like the others, but no test draws one.
  • A rect list pipeline with a PC pixel shader still gets no GS, as on main.
  • A pipeline that the driver refuses with the GS is still retried without it; that path is unchanged and was not hit.
  • AMD and Intel GPUs.

AI use

  • Claude Code (Claude Fable 5.2): code, tests, sources and this description
**@⁠Kalmarv** on GitHub · 2026-11-23 22:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/293) `Kalmarv:feat/rect-list-gs-flat` → `main` · +165 −88 · 5 files · 1 commits · merged 2026-11-23 23:20 UTC The rect list GS (#199) is refused for a VS with an integer output and for a PS that reads an attribute flat, because which vertex of a rect gives a flat value was not established. Those pipelines fall back to the CPU expansion (#195, corner rule in #266), which only handles `DrawInstanced` with vertex buffers: their indexed draws, and vertices made from the vertex index alone, draw half of each rect. That is the gap named on #189 (closed). This PR takes a rect's flat values from its first vertex and drops the two refusals. Related: #199, #266 (independent of this one; no file in common). Why the first vertex, from public AMD documents (read for the rule; nothing is copied): - `PA_SU_SC_MODE_CNTL.PROVOKING_VTX_LAST` (bit 19): "Defines which vertex of a primitive is used for attribute components when flat shading is enabled", `0 = First Vtx (D3D)`, `1 = Last Vtx (OGL)`. The same text is in the [R6xx/R7xx](https://www.x.org/docs/AMD/old/R6xx_3D_Registers.pdf) (rev 1.0, January 26, 2009), [Southern Islands](https://www.x.org/docs/AMD/old/SI_3D_registers.pdf) (November 11, 2011) and [Sea Islands](https://www.x.org/docs/AMD/old/CIK_3D_registers_v2.pdf) (September 19, 2012) 3D register references. It is one bit for every primitive type; none of them makes an exception for `DI_PT_RECTLIST`. - [Evergreen / Cayman programming guide](https://www.x.org/docs/AMD/old/evergreen_cayman_programming_guide.pdf) (May 24, 2011), 5.2: the pixel shader gets each attribute "as V0, V1-V0, and V2-V0 where V0 is the attribute value at the provoking vertex"; 5.2.1: a flat-shaded term has "the provoking vertex values in V0 and gradients of 0". - Mesa sets the bit from state alone, with no rect list case: radeonsi [`si_state.c` L977](https://gitlab.freedesktop.org/mesa/mesa/-/blob/8792b25de8aa290f601ee5d4d2f5d1cd64694605/src/gallium/drivers/radeonsi/si_state.c#L977), radv [`radv_cmd_buffer.c` L13719](https://gitlab.freedesktop.org/mesa/mesa/-/blob/8792b25de8aa290f601ee5d4d2f5d1cd64694605/src/amd/vulkan/radv_cmd_buffer.c#L13719). So under D3D's setting a rect's flat value is its first vertex's. The documents say it of primitives in general; it is not measured on a rect. **What is in it** - `crates/xcl/src/gpu/recomp/emit.rs`, `rect_list_gs`: no longer refuses integer outputs (it returns the HLSL, not a `Result`). Both triangles of a rect now start with `v[0]`: the two halves along the diagonal through v0, in the winding of v0 v1 v2. `main` emits (v0, v1, v2) and (a, d, b), so its second triangle starts with another vertex and a flat input would change across the diagonal. The implied fourth vertex is `v[0]` with its position and float outputs continued from the other three, as before; its integer outputs stay `v[0]`'s. The pixels covered and the smooth outputs are the same as on `main`: the rect is one plane on either diagonal. - `crates/xcl/src/gpu/recomp/pso.rs`: `rect_list_gs` follows; `ps_reads_flat` and `reads_flat` existed only for the refusal and are removed. - `crates/xcl/src/hle/d3d12x/real.rs`, `rect_list_gs`: only a PC pixel shader is refused now. - `crates/xcl/src/gpu/recomp/runner.rs`: `draw_gs_indexed`, an indexed triangle list draw for the test (`draw_on_multi` becomes a wrapper of the shared body, which takes optional indices). - `crates/xcl/src/gpu/recomp/tests.rs`: new `gpu_rect_list_flat_outputs`; `rect_list_gs_outputs` rewritten for the new rule; `rect_list_ps_reads_flat` removed with the function it tested (both were #199's refusal tests). +165/−88 in all. The translation side needs no change: a console PS's integer inputs and its `v_interp_mov_f32` attributes are already declared `nointerpolation`, which D3D12 takes from the triangle's first vertex. The CPU expansion already starts both triangles with v0. Overlap: #239 changes the same part of `runner.rs` and conflicts with this branch there (whichever merges second needs a small rebase). #263 (`real.rs`), #255 (`pso.rs`), #247, #245, #236, #202, #187, #174, #172, #134 and #128 touch the same files elsewhere and merge clean with this branch. **Tested** - NVIDIA GeForce RTX 5070 Ti, driver 610.74; Ryzen 9 9950X; Windows 11 (10.0.26200); rustc 1.99.0; debug. Head `f03fe38`, one commit on `main` `9ab7d76`. - `cargo test --workspace -- --test-threads=4`: 651 passed, 0 failed, 40 ignored (the `xcl` library: 611 passed, 20 ignored; one test added, one removed). SKIPPED GPU tests: 2, both `no wave64` (`gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`). - `gpu_rect_list_flat_outputs` (new, GPU): a VS with a smooth output, a `uint4` output and a float output the PS reads `nointerpolation`; rects drawn indexed out of a 3 × 2 vertex grid with the corner at v0, at v1 in both directions, at v2, and two rects sharing vertices. Every pixel of a 16 × 16 target is checked: the rect is whole, the smooth output continues into the implied half, and both flat outputs are the first indexed vertex's in both halves. The same draws without the GS leave at least 12 pixels a rect wrong. Passes. - It fails on `main`: with this test and the runner function added to `main` `9ab7d76` it stops at `rect_list_gs`'s refusal, `"TEXCOORD1 is an integer output (flat)"`. - With `main`'s triangle order put back in this branch's GS (integer outputs still allowed): the test fails at `corner v0: pixel (2,4) = [-0.68749994, 0.4375, 2.0, 0.25], expected [-0.6875, 0.4375, 1.0, 0.125]`, the second triangle taking its flat values from v1. So the test holds the triangle order, not only the lifted refusal. - `gpu_rect_list_corners` and `gpu_rect_list_fullscreen_order` (#199's, unchanged but for the dropped `unwrap`) pass. - `rect_list_gs_outputs` (no GPU): the generated GS for float, integer and clip-distance outputs compiles with DXC, starts the fourth vertex as `v[0]` and continues only the float outputs. **Regression run** main: Pending: no title on our machine; asked testers. PR: Pending: no title on our machine; asked testers. **Not tested** - The regression run on a real title (`scripts/smoke.ps1`, `main` and this head): not done, see above. - No console: v0 as a rect's provoking vertex comes from the documents above, which describe primitives in general, not from a measurement of a rect. - Culling: whether the hardware culls a rect by its winding. Mesa's rect draws all use cull-none state, so the public sources do not show it. The GS keeps the winding of v0 v1 v2 for both triangles, as on `main`; a rect list pipeline with back-face culling could drop a rect the console draws. - A real console PS with `v_interp_mov_f32` or integer inputs behind the GS: the test's shaders are HLSL written for it, with the declaration the translation makes (`nointerpolation`). - `v_interp_mov_f32` reading P10 or P20 (another vertex's value) is still not translated, with or without rect lists (`emit.rs`: `v_interp_mov p10/p20`). - Integer system-value outputs (a render target or viewport index) through the GS: they are copied from `v[0]` like the others, but no test draws one. - A rect list pipeline with a PC pixel shader still gets no GS, as on `main`. - A pipeline that the driver refuses with the GS is still retried without it; that path is unchanged and was not hit. - AMD and Intel GPUs. **AI use** - Claude Code (Claude Fable 5.2): code, tests, sources and this description
The rect list GS was refused for a VS with integer outputs and for a PS
that reads flat, because which vertex of a rect gives a flat value was not
established. Those pipelines fell back to the CPU expansion, which only
handles DrawInstanced with vertex buffers: their indexed draws, and
vertices made from the vertex index alone, drew half of each rect.

AMD's register references (R6xx, SI, CIK) define
PA_SU_SC_MODE_CNTL.PROVOKING_VTX_LAST for every primitive: "Defines which
vertex of a primitive is used for attribute components when flat shading
is enabled", 0 = First Vtx (D3D), 1 = Last Vtx (OGL). The Evergreen /
Cayman programming guide (5.2) has a flat attribute as the provoking
vertex's value with gradients of 0. Mesa sets the bit from state alone,
with no exception for rect lists. So under D3D's setting a rect's flat
value is its first vertex's. This is not measured on a rect.

The GS now emits both triangles starting with v[0] (the halves along the
diagonal through v0, in the winding of v0 v1 v2), so every flat input
takes v0's value in both, and the fourth vertex's integer outputs are
v[0]'s. Smooth outputs are as before: the same plane on either diagonal.
pso::ps_reads_flat and reads_flat had no other use and are removed.

runner::draw_gs_indexed draws an indexed triangle list for the test.

Assisted-by: Claude Code (Claude Fable 5.2)
Co-Authored-By: Claude <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:19:02 +00:00
github manually merged commit f03fe38b72 into gh-pr/293/base 2026-11-26 04:19:05 +00:00
Author
Owner

@⁠Kalmarv on GitHub · 2026-11-23 22:32 UTC · original

Regression run wanted. We have no title on our machine. If you can run scripts/smoke.ps1 -Game <your title folder> twice, once built from main (9ab7d76) and once from this PR's head (f03fe38), please paste both xcl-smoke blocks here. I'll copy them into the description with your name and hardware.

🤖 Claude Opus 5.5

**@⁠Kalmarv** on GitHub · 2026-11-23 22:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/293#issuecomment-7115875811) **Regression run wanted.** We have no title on our machine. If you can run `scripts/smoke.ps1 -Game <your title folder>` twice, once built from `main` (`9ab7d76`) and once from this PR's head (`f03fe38`), please paste both `xcl-smoke` blocks here. I'll copy them into the description with your name and hardware. 🤖 Claude Opus 5.5
Author
Owner

@⁠PHeitor1 on GitHub · 2026-11-23 22:47 UTC · original

Tested f03fe38 merged onto main 9ab7d76 on RTX 5060 Ti 8 GB (Blackwell, 32-lane waves), NVIDIA 621.24, Ryzen 5 5600X (Zen 3), Windows 11 Pro 26300 (native), rustc 1.100.0 MSVC, debug, cargo test --workspace --no-fail-fast -- --test-threads=4, no XCL_SAMPLE_*. Baseline main 9ab7d76: 651 passed, 0 failed, 40 ignored.

Pass: 651 passed, 0 failed, 40 ignored. GPU skips: the same 2 as on main (no wave64).

Run and written with Claude Code (Claude Opus 5.5).

**@⁠PHeitor1** on GitHub · 2026-11-23 22:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/293#issuecomment-7116190629) Tested `f03fe38` merged onto `main` `9ab7d76` on RTX 5060 Ti 8 GB (Blackwell, 32-lane waves), NVIDIA 621.24, Ryzen 5 5600X (Zen 3), Windows 11 Pro 26300 (native), rustc 1.100.0 MSVC, debug, `cargo test --workspace --no-fail-fast -- --test-threads=4`, no `XCL_SAMPLE_*`. Baseline `main` `9ab7d76`: 651 passed, 0 failed, 40 ignored. **Pass:** 651 passed, 0 failed, 40 ignored. GPU skips: the same 2 as on `main` (`no wave64`). _Run and written with Claude Code (Claude Opus 5.5)._
Author
Owner

@⁠regiumlepidi on GitHub · 2026-11-23 22:59 UTC · original

Tested f03fe38 (one commit on main 9ab7d76, so the head is the merge result) on NVIDIA RTX 5070 Ti and on an AMD RDNA2 iGPU (native 64-lane waves), with main 9ab7d76 as the baseline on the AMD adapter: pass on both.

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves), driver 617.42 (32.0.16.1742)
  • AMD Radeon(TM) Graphics, the Ryzen 7 9800X3D's iGPU (RDNA2, 64-lane waves), driver 32.0.21030.2001, selected with XCL_ADAPTER=radeon
  • AMD Ryzen 7 9800X3D, 48 GB DDR5-6000, Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 MSVC, DXC from Windows SDK 10.0.26100, debug
  • .\scripts\test.ps1 (cargo test --workspace -- --test-threads=4), no XCL_SAMPLE_* set
Build Adapter Passed Failed Ignored GPU tests skipped
main 9ab7d76 RTX 5070 Ti 651 0 40 2 (no wave64)
main 9ab7d76 RDNA2 iGPU 651 0 40 none
PR f03fe38 RTX 5070 Ti 651 0 40 2 (no wave64)
PR f03fe38 RDNA2 iGPU 651 0 40 none
  • gpu_rect_list_flat_outputs (new) passes on both adapters, as do gpu_rect_list_corners, gpu_rect_list_fullscreen_order, rect_list_gs_outputs and the rect_list_pso_tests.
  • The two skipped tests on NVIDIA are the usual gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware; on the iGPU nothing is skipped, which also shows those runs used the AMD adapter.

Regression run

  • None: I have no unpacked Xbox Series title (the GDK titles on this PC are TargetDeviceFamily="PC" builds).

Not tested

  • scripts/smoke.ps1 on a real title, main or this head.
  • RDNA3 / RDNA4 and Intel; the AMD run is an RDNA2 iGPU, not a discrete card.
  • I did not check the provoking-vertex reasoning against hardware; only the tests above.

AI use: Claude Code with Claude Opus 5.5 ran the builds and tests and wrote this report; the numbers come from those runs.

**@⁠regiumlepidi** on GitHub · 2026-11-23 22:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/293#issuecomment-7116415181) Tested `f03fe38` (one commit on `main` `9ab7d76`, so the head is the merge result) on **NVIDIA RTX 5070 Ti** and on an **AMD RDNA2 iGPU (native 64-lane waves)**, with `main` `9ab7d76` as the baseline on the AMD adapter: **pass on both**. **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves), driver 617.42 (32.0.16.1742) - AMD Radeon(TM) Graphics, the Ryzen 7 9800X3D's iGPU (RDNA2, 64-lane waves), driver 32.0.21030.2001, selected with `XCL_ADAPTER=radeon` - AMD Ryzen 7 9800X3D, 48 GB DDR5-6000, Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 MSVC, DXC from Windows SDK 10.0.26100, debug - `.\scripts\test.ps1` (`cargo test --workspace -- --test-threads=4`), no `XCL_SAMPLE_*` set | Build | Adapter | Passed | Failed | Ignored | GPU tests skipped | |---|---|---|---|---|---| | `main` `9ab7d76` | RTX 5070 Ti | 651 | 0 | 40 | 2 (no wave64) | | `main` `9ab7d76` | RDNA2 iGPU | 651 | 0 | 40 | none | | PR `f03fe38` | RTX 5070 Ti | 651 | 0 | 40 | 2 (no wave64) | | PR `f03fe38` | RDNA2 iGPU | 651 | 0 | 40 | none | - `gpu_rect_list_flat_outputs` (new) passes on both adapters, as do `gpu_rect_list_corners`, `gpu_rect_list_fullscreen_order`, `rect_list_gs_outputs` and the `rect_list_pso_tests`. - The two skipped tests on NVIDIA are the usual `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware`; on the iGPU nothing is skipped, which also shows those runs used the AMD adapter. **Regression run** - None: I have no unpacked Xbox Series title (the GDK titles on this PC are `TargetDeviceFamily="PC"` builds). **Not tested** - `scripts/smoke.ps1` on a real title, main or this head. - RDNA3 / RDNA4 and Intel; the AMD run is an RDNA2 iGPU, not a discrete card. - I did not check the provoking-vertex reasoning against hardware; only the tests above. **AI use:** Claude Code with Claude Opus 5.5 ran the builds and tests and wrote this report; the numbers come from those runs.
This discussion has been locked. Commenting is limited to contributors.
No description provided.