Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
gjonn:fix/hull-input-slot-component
Oct 14, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
gjonn:fix/hull-input-slot-component

Conversation

@gjonn

@gjonn gjonn commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

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

@blawesom

Copy link
Copy Markdown
Contributor

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):

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.

…ol-point slot

A hull reading input control point i + k at a constant LDS offset took the
vec4 component from the whole constant (constant % 16 / 4) instead of from
its offset inside that control point's slot. With a local stride that is not
a multiple of 16, a read of the next control point (offset 24 + 4 with a
24-byte stride) landed on component 3 instead of 1. Take the component from
constant % stride, as the attribute and the general path already do.
@adriadam10

Copy link
Copy Markdown
Collaborator

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.

@adriadam10
adriadam10 force-pushed the fix/hull-input-slot-component branch from 21758e6 to 1c8d898 Compare October 13, 2026 15:34
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
RINNECODER added a commit to RINNECODER/AnyPS5 that referenced this pull request Oct 14, 2026
* fix(agc): accept integer tessellation partitioning

Ported from upstream PR boykopovar#5234, adapted to our triangle/fractional-odd
only tessellation path: VGT_TF_PARAM.PARTITIONING 0 decodes, emits equal
spacing and bounds factors at 64. Metal still refuses guest tessellation
draws in MetalRenderState.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj

* fix(agc): accept fractional-even tessellation partitioning

Ported from upstream PR boykopovar#5402 (its integer-partitioning base commit is
the previous commit), adapted to our triangle-only tessellation path:
VGT_TF_PARAM.PARTITIONING 3 decodes, emits fractional-even spacing and
bounds factors at 64. Metal still refuses guest tessellation draws.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj

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

Ported from upstream PR boykopovar#4723 (shader hunk; its Vulkan execution test is
not ported).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj

* fix(shader): lower hulls with one input or one output control point (partial)

Ported from upstream PR boykopovar#5457, commits 1, 4 and 5 of 5 (hull exec masks
restored through phis, input stride from the patch term, one output
control point per patch). Vulkan execution-test hunks are not ported.

Skipped from boykopovar#5457, with reasons:
- relative patch index rebuilt as data: needs GE_CNTL.PRIM_GRP_SIZE and
  BREAK_WAVE_AT_EOI in TessellationConfiguration, VGT_LS_HS_CONFIG
  patchesPerGroup and the request key/serializer additions. None of
  these exist on main, which only lowers triangle fractional-odd hulls.
- recording BDA faults in hull programs: drops a refusal whose safety
  rests on upstream hull work we lack; the refusal stays.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj

* fix(shader): honour SPI_BARYC_CNTL.FRONT_FACE_ALL_BITS for the front-face input

Ported from upstream PR boykopovar#5314. Tracks SPI_BARYC_CNTL in the draw key and
shader request key, and bumps the request serialization to version 24
(shared with the following slice-offset port, which adds no second bump).

Not ported: the ShaderMemory serializer-version assertions of the PR,
which build on upstream test scaffolding absent from main.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj

* fix(shader): propagate color view slice to pixel ancillary input

Ported from upstream PR boykopovar#5500, adapted to main: the draw decode sets the
color view slice as layerBase (the layer-export decode this PR also
touches does not exist on main, so its diagnostic and layers hunks are
skipped). layerBase is added to the pixel info, request key, shader info,
disk cache and pipeline specialization constants. The request
serialization stays at version 24, bumped once by the front-face commit.
The shader disk cache format is bumped to 36.

Not ported: unrelated hunks the upstream commit carried in Recompiler.cpp
(dot-product capability option) and its ShaderMemory serializer tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj

* test(shader): cover tessellation partitioning, hull slot placement, layerBase and serializer v24

Fix the stale serialization version expectation in the shader memory test,
add pixel ancillary rows with a non-zero layerBase, extract PixelLayerBase
for a derivation test, and point the FrontFace note at TechnicalDebt.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: XairRrR <dev910382@gmail.com>
@oneandonlydean
oneandonlydean merged commit 46d3c13 into boykopovar:main Oct 14, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants