fix(shader): place hull input components by their offset in the control-point slot #4723

Merged
gjonn merged 1 commit from upstream-pr/4723 into main 2026-10-14 06:04:51 +00:00
gjonn commented 2026-10-12 19:46:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gjonn on 2026-10-12T19:46:39Z.


What

A hull program that reads another input control point at a constant LDS offset (the fast path in TessellationPointer for inv * stride + constant) took the vec4 component from the whole constant (constant % 16 / 4) instead of from the offset inside the slot the constant lands in. The attribute already used constant % stride, and so does the general path. With a local stride that is not a multiple of 16 the two disagree: with a 24-byte stride, a read of control point inv + 1 at offset 24 + 4 = 28 picked component 3 instead of 1, so the hull got the wrong data. The component is now constant % stride % 16 / 4.

PPSA01317 needs this. Its tessellated hull programs read the next input control point with a 24-byte local stride, and on main they read the wrong components.

The new execution test hull program reading the next of 4 input control points of 24 bytes draws triangle patches with 4 input and 3 output control points. A local program writes 24-byte slots, and output control point i copies input i + 1 with ds_read_b128 ... offset:24.

#4082 changes another part of TessellationPointer (the factor index), not this line.

Tested

Windows 11, MinGW Release build, ctest -R "^agc_driver_tessellation$" on an NVIDIA GPU.

On main with only the test added:

AGC graphics: hull program reading the next of 4 input control points of 24 bytes, unculled: the level-1 patch was not drawn as one flat triangle, centre (16, 24, 40, 255)
0% tests passed, 1 tests failed out of 1

With the fix:

Tessellation tests passed
1/1 Test #461: agc_driver_tessellation ..........   Passed    0.52 sec

agc_tessellation_factor_ring passes as well.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4834236628 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4723). Originally posted by [gjonn](https://github.com/gjonn) on 2026-10-12T19:46:39Z. --- ### What A hull program that reads another input control point at a constant LDS offset (the fast path in `TessellationPointer` for `inv * stride + constant`) took the vec4 component from the whole constant (`constant % 16 / 4`) instead of from the offset inside the slot the constant lands in. The attribute already used `constant % stride`, and so does the general path. With a local stride that is not a multiple of 16 the two disagree: with a 24-byte stride, a read of control point `inv + 1` at offset 24 + 4 = 28 picked component 3 instead of 1, so the hull got the wrong data. The component is now `constant % stride % 16 / 4`. PPSA01317 needs this. Its tessellated hull programs read the next input control point with a 24-byte local stride, and on `main` they read the wrong components. The new execution test `hull program reading the next of 4 input control points of 24 bytes` draws triangle patches with 4 input and 3 output control points. A local program writes 24-byte slots, and output control point `i` copies input `i + 1` with `ds_read_b128 ... offset:24`. #4082 changes another part of `TessellationPointer` (the factor index), not this line. ### Tested Windows 11, MinGW Release build, `ctest -R "^agc_driver_tessellation$"` on an NVIDIA GPU. On `main` with only the test added: ``` AGC graphics: hull program reading the next of 4 input control points of 24 bytes, unculled: the level-1 patch was not drawn as one flat triangle, centre (16, 24, 40, 255) 0% tests passed, 1 tests failed out of 1 ``` With the fix: ``` Tessellation tests passed 1/1 Test #461: agc_driver_tessellation .......... Passed 0.52 sec ``` `agc_tessellation_factor_ring` passes as well. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
blawesom commented 2026-10-13 06:58:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-13T06:58:56Z.


Rebase handoff — rebased onto current main, authorship unchanged.

The conflicts needed a real semantic merge with today's #4727: main's inPatch(...) wrapper on the vertex computation is kept, with this PR's fixed component expression (constant % stride % 16u / 4u instead of constant % 16u / 4u) inside it. Both test lines (main's HullDynamicIndex, this PR's HullNextInput) are kept.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV):

  • builds; tools/check_conventions.py --base origin/main passes
  • full suite: 1013/1014 — the only failure is the agc_driver_tessellation segfault that current main itself has (reported on #4727)

One data point for #4727: this PR's fix does not resolve that segfault — with this branch applied (including #4727's inPatch change plus this PR's component fix), agc_driver_tessellation still crashes identically. So the regression is in #4727's computed-index path itself, not the constant-offset component indexing this PR repairs.

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/4723
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is ea2bbefb2.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6140127879 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4723#issuecomment-6140127879). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-13T06:58:56Z. --- **Rebase handoff** — rebased onto current `main`, authorship unchanged. The conflicts needed a real semantic merge with today's #4727: main's `inPatch(...)` wrapper on the vertex computation is kept, with this PR's fixed component expression (`constant % stride % 16u / 4u` instead of `constant % 16u / 4u`) inside it. Both test lines (main's `HullDynamicIndex`, this PR's `HullNextInput`) are kept. Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV): - builds; `tools/check_conventions.py --base origin/main` passes - **full suite: 1013/1014** — the only failure is the `agc_driver_tessellation` segfault that current `main` itself has (reported on #4727) **One data point for #4727:** this PR's fix does **not** resolve that segfault — with this branch applied (including #4727's `inPatch` change plus this PR's component fix), `agc_driver_tessellation` still crashes identically. So the regression is in #4727's computed-index path itself, not the constant-offset component indexing this PR repairs. **To pick it up:** ``` git fetch https://github.com/blawesom/AnyPS5 rebase/4723 git checkout <your branch> git merge --ff-only FETCH_HEAD ``` Head is `ea2bbefb2`.
adriadam10 commented 2026-10-13 15:34:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T15:34:45Z.


Rebased onto current main (the test had to be moved onto the new PatchDraw helper from the quad/clamp work; the fix itself is unchanged, inside #4727's inPatch(...)).

  • constant % stride % 16u / 4u is consistent with the attribute index (constant % stride / 16u) and with the general path.
  • The new case fails with the fix reverted ("hull program reading the next of 4 input control points of 24 bytes ... not drawn as one flat triangle") and passes with it, on CI's lavapipe. On RADV agc_driver_tessellation still segfaults on main itself, independent of this PR.

Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6149201531 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4723#issuecomment-6149201531). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T15:34:45Z. --- Rebased onto current `main` (the test had to be moved onto the new `PatchDraw` helper from the quad/clamp work; the fix itself is unchanged, inside #4727's `inPatch(...)`). - `constant % stride % 16u / 4u` is consistent with the attribute index (`constant % stride / 16u`) and with the general path. - The new case fails with the fix reverted ("hull program reading the next of 4 input control points of 24 bytes ... not drawn as one flat triangle") and passes with it, on CI's lavapipe. On RADV `agc_driver_tessellation` still segfaults on `main` itself, independent of this PR. Merging once the full Build 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!4723
No description provided.