fix(agc): accept fractional-even tessellation partitioning #5402

Merged
codingreapermaps merged 1 commit from upstream-pr/5402 into main 2026-10-14 20:57:21 +00:00
codingreapermaps commented 2026-10-13 18:50:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by codingreapermaps on 2026-10-13T18:50:29Z.


What

Tessellation with VGT_TF_PARAM.PARTITIONING 3 (fractional-even) threw only triangle and quad domains with integer or fractional-odd partitioning and triangle output are supported by the reference path. #5234 left this mode for its own PR; this is that PR.

  • Partitioning 3 compiles to Vulkan's SpacingFractionalEven, which radeonsi programs as PART_FRAC_EVEN. The draw state, the shader input info, the SPIR-V emitter and the pipeline's module check all accept it.
  • Its factors are bounded at 64, as for integer partitioning; only fractional-odd keeps 63.
  • The lower end of the range is not clamped in the hull program: Vulkan raises every factor of a fractional-even patch that is not culled to at least 2, which is also the D3D11 range for this mode ([2, 64]). A VGT_HOS_MAX_TESS_LEVEL below 2 therefore still tessellates at 2; the console's order of that clamp and the minimum is not measured and is recorded in docs/dev/debt/shader.md.
  • Power-of-two partitioning (1) still throws.

Tested

Windows 11, MinGW-w64 GCC 15.2.0, NVIDIA GeForce MX450 (driver 581.83) and lavapipe (Mesa 26.2.4, mesa-dist-win).

  • agc_driver_graphics_tests: VGT_TF_PARAM 0x4004d decodes as partitioning 3 and is no longer refused; 0x40045 (power of two) still is.
  • agc_driver_tessellation_tests: new RequireFractionalEvenPartitioning checks that the domain module has fractional-even spacing and that the hull bounds factors at 64. Its domain program lowers each domain point by 3·min(u, v, w), so edge points stay in place and only an interior point reaches below the patch. With integer spacing the level-1 patch covers nothing below its base and the level-5 patch does. With fractional-even spacing the level-1 patch does too (raised to level 2), the level-0 patch is culled and the level-5 patch has interior points. All tessellation tests pass on NVIDIA and lavapipe.
  • PPSA12361 (Transport Fever 2: Console Edition): without the change it stops with the error above while loading a map; with it the map loads (its ambient audio plays) and the title reaches its first frame of the map, where it stops on an unrelated multisampled storage image write.
  • The tests ran on this branch, on main at 43349d433. The title ran on a local branch with this change and unrelated local changes (#4820 among them).

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: PPSA12361 (no Game bring-up discussion yet)
  • GPUs tested: NVIDIA GeForce MX450, driver 581.83, Windows 11; lavapipe (Mesa 26.2.4), Windows 11
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4847934711 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5402). Originally posted by [codingreapermaps](https://github.com/codingreapermaps) on 2026-10-13T18:50:29Z. --- ### What Tessellation with `VGT_TF_PARAM.PARTITIONING` 3 (fractional-even) threw `only triangle and quad domains with integer or fractional-odd partitioning and triangle output are supported by the reference path`. #5234 left this mode for its own PR; this is that PR. - Partitioning 3 compiles to Vulkan's `SpacingFractionalEven`, which [radeonsi programs as `PART_FRAC_EVEN`](https://gitlab.freedesktop.org/mesa/mesa/-/blob/mesa-24.0.0/src/gallium/drivers/radeonsi/si_state_shaders.cpp#L536-537). The draw state, the shader input info, the SPIR-V emitter and the pipeline's module check all accept it. - Its factors are bounded at 64, as for integer partitioning; only fractional-odd keeps 63. - The lower end of the range is not clamped in the hull program: Vulkan raises every factor of a fractional-even patch that is not culled to at least 2, which is also the D3D11 range for this mode ([2, 64]). A `VGT_HOS_MAX_TESS_LEVEL` below 2 therefore still tessellates at 2; the console's order of that clamp and the minimum is not measured and is recorded in `docs/dev/debt/shader.md`. - Power-of-two partitioning (1) still throws. ### Tested Windows 11, MinGW-w64 GCC 15.2.0, NVIDIA GeForce MX450 (driver 581.83) and lavapipe (Mesa 26.2.4, mesa-dist-win). - `agc_driver_graphics_tests`: `VGT_TF_PARAM` 0x4004d decodes as partitioning 3 and is no longer refused; 0x40045 (power of two) still is. - `agc_driver_tessellation_tests`: new `RequireFractionalEvenPartitioning` checks that the domain module has fractional-even spacing and that the hull bounds factors at 64. Its domain program lowers each domain point by `3·min(u, v, w)`, so edge points stay in place and only an interior point reaches below the patch. With integer spacing the level-1 patch covers nothing below its base and the level-5 patch does. With fractional-even spacing the level-1 patch does too (raised to level 2), the level-0 patch is culled and the level-5 patch has interior points. All tessellation tests pass on NVIDIA and lavapipe. - PPSA12361 (Transport Fever 2: Console Edition): without the change it stops with the error above while loading a map; with it the map loads (its ambient audio plays) and the title reaches its first frame of the map, where it stops on an unrelated multisampled storage image write. - The tests ran on this branch, on `main` at `43349d433`. The title ran on a local branch with this change and unrelated local changes (#4820 among them). ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: PPSA12361 (no Game bring-up discussion yet) - [x] GPUs tested: NVIDIA GeForce MX450, driver 581.83, Windows 11; lavapipe (Mesa 26.2.4), Windows 11 - [x] AI-assisted: yes
coltken95 commented 2026-10-13 19:17:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-13T19:17:13Z.


Tested on Linux x86-64 (Release build, lavapipe / llvmpipe LLVM 20.1.2), with 6e527338b merged into main 18c438b10:

  • With the PR: agc_driver_graphics passes (it fails on main), but agc_driver_tessellation fails at the new fractional-even case:
    AGC graphics: fractional-even partitioning: the level-1 patch was not raised to level 2 with a domain point at its centre, (255, 0, 0, 255)
  • On main the same test stops earlier, as expected, with only triangle and quad domains with fractional-odd partitioning and triangle output are supported by the reference path.

I can't tell from here whether this is specific to lavapipe's tessellator; the PR was tested on an NVIDIA MX450 under Windows.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6153272420 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5402#issuecomment-6153272420). Originally posted by [coltken95](https://github.com/coltken95) on 2026-10-13T19:17:13Z. --- Tested on Linux x86-64 (Release build, lavapipe / llvmpipe LLVM 20.1.2), with 6e527338b merged into main 18c438b10: - With the PR: `agc_driver_graphics` passes (it fails on main), but `agc_driver_tessellation` fails at the new fractional-even case: `AGC graphics: fractional-even partitioning: the level-1 patch was not raised to level 2 with a domain point at its centre, (255, 0, 0, 255)` - On main the same test stops earlier, as expected, with `only triangle and quad domains with fractional-odd partitioning and triangle output are supported by the reference path`. I can't tell from here whether this is specific to lavapipe's tessellator; the PR was tested on an NVIDIA MX450 under Windows. AI-assisted: yes (Claude Code)
oneandonlydean commented 2026-10-14 03:05:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T03:05:43Z.


coltken95's lavapipe run fails the new case: the level-1 patch was not raised to level 2 with a domain point at its centre. CI runs these tests on lavapipe, so please find out whether the test or the clamp is wrong there.

The branch also carries a copy of #5234's commit; once #5234 is in, please rebase so only yours is left.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159960471 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5402#issuecomment-6159960471). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T03:05:43Z. --- coltken95's lavapipe run fails the new case: `the level-1 patch was not raised to level 2 with a domain point at its centre`. CI runs these tests on lavapipe, so please find out whether the test or the clamp is wrong there. The branch also carries a copy of #5234's commit; once #5234 is in, please rebase so only yours is left.
codingreapermaps commented 2026-10-14 09:55:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by codingreapermaps on 2026-10-14T09:55:54Z.


The test was wrong, not the clamp. The test pixel shader reads the colour with v_interp_mov_f32 from P0, so every tessellated triangle is flat-shaded with its provoking vertex. The check at the centre therefore depended on which vertex the tessellator emits first, and that order is implementation-dependent. NVIDIA puts the centre point first in each of the six triangles around it, so the centre read 255. lavapipe puts an edge point first, so it read 0. Integer spacing with every factor at 2, which this PR does not touch, gives the same split: 255 on NVIDIA, 0 on lavapipe.

The new test does not depend on the vertex order. Its domain program lowers each point by 3·min(u, v, w), so edge points stay in place and only an interior point reaches below the patch's base. With integer spacing, the level-1 patch covers nothing below its base. With fractional-even spacing, it does (raised to level 2). The level-5 patch covers that area in both modes. It passes on NVIDIA and on lavapipe (Mesa 26.2.4), which raises the level-1 factors to 2 like the D3D11 tessellator it is built on (TriProcessTessFactors).

Rebased on main now that #5234 is in; only this PR's commit is left.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6165709027 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5402#issuecomment-6165709027). Originally posted by [codingreapermaps](https://github.com/codingreapermaps) on 2026-10-14T09:55:54Z. --- The test was wrong, not the clamp. The test pixel shader reads the colour with `v_interp_mov_f32` from P0, so every tessellated triangle is flat-shaded with its provoking vertex. The check at the centre therefore depended on which vertex the tessellator emits first, and that order is implementation-dependent. NVIDIA puts the centre point first in each of the six triangles around it, so the centre read 255. lavapipe puts an edge point first, so it read 0. Integer spacing with every factor at 2, which this PR does not touch, gives the same split: 255 on NVIDIA, 0 on lavapipe. The new test does not depend on the vertex order. Its domain program lowers each point by `3·min(u, v, w)`, so edge points stay in place and only an interior point reaches below the patch's base. With integer spacing, the level-1 patch covers nothing below its base. With fractional-even spacing, it does (raised to level 2). The level-5 patch covers that area in both modes. It passes on NVIDIA and on lavapipe (Mesa 26.2.4), which raises the level-1 factors to 2 like the D3D11 tessellator it is built on ([`TriProcessTessFactors`](https://gitlab.freedesktop.org/mesa/mesa/-/blob/mesa-24.0.0/src/gallium/auxiliary/tessellator/tessellator.cpp#L1085-L1131)). Rebased on `main` now that #5234 is in; only this PR's commit is left.
adriadam10 commented 2026-10-14 19:27:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T19:27:45Z.


Checked on a rebase onto current main (only docs/dev/debt/shader.md conflicted; I kept main's relative patch index line and this PR's lines): scoped build + ctest green; agc_driver_graphics and agc_driver_tessellation also pass on CI's lavapipe (Mesa 25.2.8). With the code changes reverted both tests fail, so they pin the change. The fractional-even test no longer depends on the tessellator's vertex order. Pushing the rebase; merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6176557912 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5402#issuecomment-6176557912). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T19:27:45Z. --- Checked on a rebase onto current main (only `docs/dev/debt/shader.md` conflicted; I kept main's relative patch index line and this PR's lines): scoped build + ctest green; `agc_driver_graphics` and `agc_driver_tessellation` also pass on CI's lavapipe (Mesa 25.2.8). With the code changes reverted both tests fail, so they pin the change. The fractional-even test no longer depends on the tessellator's vertex order. Pushing the rebase; merging once CI is green.
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
boykopovar/AnyPS5!5402
No description provided.