Repository navigation
Rect lists: the GS carries flat outputs, v0 the provoking vertex - #293
Conversation
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 <noreply@anthropic.com>
|
Regression run wanted. We have no title on our machine. If you can run 🤖 Claude Opus 5.5 |
|
Tested Pass: 651 passed, 0 failed, 40 ignored. GPU skips: the same 2 as on Run and written with Claude Code (Claude Opus 5.5). |
|
Tested Tested
Regression run
Not tested
AI use: Claude Code with Claude Opus 5.5 ran the builds and tests and wrote this report; the numbers come from those runs. |
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
DrawInstancedwith 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 forDI_PT_RECTLIST.si_state.cL977, radvradv_cmd_buffer.cL13719.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 aResult). Both triangles of a rect now start withv[0]: the two halves along the diagonal through v0, in the winding of v0 v1 v2.mainemits (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 isv[0]with its position and float outputs continued from the other three, as before; its integer outputs stayv[0]'s. The pixels covered and the smooth outputs are the same as onmain: the rect is one plane on either diagonal.crates/xcl/src/gpu/recomp/pso.rs:rect_list_gsfollows;ps_reads_flatandreads_flatexisted 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_multibecomes a wrapper of the shared body, which takes optional indices).crates/xcl/src/gpu/recomp/tests.rs: newgpu_rect_list_flat_outputs;rect_list_gs_outputsrewritten for the new rule;rect_list_ps_reads_flatremoved with the function it tested (both were D3D12.X: rect lists drawn whole through a generated geometry shader #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_f32attributes are already declarednointerpolation, 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.rsand 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
f03fe38, one commit onmain9ab7d76.cargo test --workspace -- --test-threads=4: 651 passed, 0 failed, 40 ignored (thexcllibrary: 611 passed, 20 ignored; one test added, one removed). SKIPPED GPU tests: 2, bothno 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, auint4output and a float output the PS readsnointerpolation; 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.main: with this test and the runner function added tomain9ab7d76it stops atrect_list_gs's refusal,"TEXCOORD1 is an integer output (flat)".main's triangle order put back in this branch's GS (integer outputs still allowed): the test fails atcorner 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_cornersandgpu_rect_list_fullscreen_order(D3D12.X: rect lists drawn whole through a generated geometry shader #199's, unchanged but for the droppedunwrap) pass.rect_list_gs_outputs(no GPU): the generated GS for float, integer and clip-distance outputs compiles with DXC, starts the fourth vertex asv[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
scripts/smoke.ps1,mainand this head): not done, see above.main; a rect list pipeline with back-face culling could drop a rect the console draws.v_interp_mov_f32or integer inputs behind the GS: the test's shaders are HLSL written for it, with the declaration the translation makes (nointerpolation).v_interp_mov_f32reading P10 or P20 (another vertex's value) is still not translated, with or without rect lists (emit.rs:v_interp_mov p10/p20).v[0]like the others, but no test draws one.main.AI use