feat(agc): centroid pixel inputs and NoPerspective by I/J pair #136

Merged
oneandonlydean merged 1 commit from upstream-pr/136 into main 2026-10-01 07:49:02 +00:00
oneandonlydean commented 2026-09-29 00:33:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-09-29T00:33:26Z.


What

  • Centroid inputs. DecodePixelStageInfo rejected SPI_PS_INPUT_ENA/ADDR with PERSP_CENTROID (bit 2) or LINEAR_CENTROID (bit 6). PPSA21564 binds 0x326 (perspective center and centroid, linear center, POS_X/Y). Both bits are now accepted.
  • VGPR layout. The PS input VGPR layout now follows the hardware rule. SPI_PS_INPUT_ADDR places every input it names in SPI order (2 VGPRs per I/J pair, 3 for the pull model, 1 otherwise), loaded or not, and ENA & ADDR selects the loaded ones.
    • ShaderPixelStageInfo carries inputAddr (replacing perspectiveCenterVgpr) plus perspectiveCentroid and linearCentroid.
    • The prologue places each loaded input at PixelInputVgpr(inputAddr, input).
    • This also fixes a bug on main: the system inputs were always written from v0 because psSystemInputBase was never set, so POS_X overwrote the center I whenever barycentrics were enabled.
  • Centroid values. The pipeline rasterizes single-sampled, where the centroid is the pixel center. With fragment barycentrics the centroid pairs therefore carry the center barycentrics: BaryCoordKHR for perspective, BaryCoordNoPerspKHR for the linear center and centroid pairs.
  • NoPerspective per parameter. Main decorated every interpolated parameter NoPerspective whenever LINEAR_CENTER was loaded (the single psNoPerspective flag). Now:
    • v_interp_p2 records, per parameter, whether its J operand is the J of a loaded linear pair or a perspective pair (IrProgramMetadata::pixelLinearInputs / pixelPerspectiveInputs).
    • A parameter is NoPerspective when it is read through a linear pair.
    • A parameter read through neither kind of pair (for example, the J was copied to another VGPR) keeps main's rule.
    • A parameter read through both kinds throws.
    • Only pixel stages consult this.
  • RequestSerializer moves to version 5 (main is at 4 since #133 added MeshConfiguration::esgsItemSize). The new pixel fields are gated on >= 5, and requests before version 5 read back with their loaded inputs as the layout. The recompile cache key and the driver's draw key compare and hash the new fields.
  • The "unsupported SPI_PS_INPUT_ENA/ADDR" error now prints ENA and ADDR. The other bits (the pull model, line stipple, sample coverage, fixed-point position) still throw.

The TechnicalDebt entry about skipped barycentrics is unchanged. This PR does not change how fragmentShaderBarycentricEnabled reaches the recompiler.

No overlap with #101 or #83: both touch TranslationContext.hpp next to the image op declarations, and this PR adds SetPixelInput and a member elsewhere in the class.

Tested

  • Linux (CachyOS, GCC). agc_shader_memory gains verifyPixelInputs:
    • the PixelInputVgpr layouts (0x326, and ADDR-only inputs reserving VGPRs),
    • a two-parameter pixel shader whose parameters are interpolated through the perspective and the linear center pairs gets NoPerspective only on the linear one; this fails with the recording reverted,
    • reading one parameter through both kinds of pair throws,
    • inputAddr and the centroid flags survive serialization and change the cache key and the context hash.
  • agc_driver_graphics_tests PixelInputLayoutTests:
    • decoding 0x326, 0x1146 and ADDR-only layouts; the still-unsupported bits throw,
    • the serialization round trip,
    • which builtin each VGPR holds in the recompiled entry (centroid pairs, POS_X after three pairs, ADDR-only pairs left unloaded),
    • NoPerspective by pair.
      On main, 0x326 is rejected.
  • Exercised in PPSA21564 on our integration branch.
  • Rebased on current main. ctest: 79/79 pass; agc_driver_graphics_tests and agc_shader_memory_tests pass.

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
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4670964738 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/136). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-09-29T00:33:26Z. --- ### What - **Centroid inputs.** `DecodePixelStageInfo` rejected `SPI_PS_INPUT_ENA/ADDR` with PERSP_CENTROID (bit 2) or LINEAR_CENTROID (bit 6). PPSA21564 binds 0x326 (perspective center and centroid, linear center, POS_X/Y). Both bits are now accepted. - **VGPR layout.** The PS input VGPR layout now follows the hardware rule. `SPI_PS_INPUT_ADDR` places every input it names in SPI order (2 VGPRs per I/J pair, 3 for the pull model, 1 otherwise), loaded or not, and ENA & ADDR selects the loaded ones. - `ShaderPixelStageInfo` carries `inputAddr` (replacing `perspectiveCenterVgpr`) plus `perspectiveCentroid` and `linearCentroid`. - The prologue places each loaded input at `PixelInputVgpr(inputAddr, input)`. - This also fixes a bug on main: the system inputs were always written from v0 because `psSystemInputBase` was never set, so POS_X overwrote the center I whenever barycentrics were enabled. - **Centroid values.** The pipeline rasterizes single-sampled, where the centroid is the pixel center. With fragment barycentrics the centroid pairs therefore carry the center barycentrics: `BaryCoordKHR` for perspective, `BaryCoordNoPerspKHR` for the linear center and centroid pairs. - **NoPerspective per parameter.** Main decorated every interpolated parameter NoPerspective whenever LINEAR_CENTER was loaded (the single `psNoPerspective` flag). Now: - `v_interp_p2` records, per parameter, whether its J operand is the J of a loaded linear pair or a perspective pair (`IrProgramMetadata::pixelLinearInputs` / `pixelPerspectiveInputs`). - A parameter is NoPerspective when it is read through a linear pair. - A parameter read through neither kind of pair (for example, the J was copied to another VGPR) keeps main's rule. - A parameter read through both kinds throws. - Only pixel stages consult this. - `RequestSerializer` moves to version 5 (main is at 4 since #133 added `MeshConfiguration::esgsItemSize`). The new pixel fields are gated on `>= 5`, and requests before version 5 read back with their loaded inputs as the layout. The recompile cache key and the driver's draw key compare and hash the new fields. - The "unsupported SPI_PS_INPUT_ENA/ADDR" error now prints ENA and ADDR. The other bits (the pull model, line stipple, sample coverage, fixed-point position) still throw. The TechnicalDebt entry about skipped barycentrics is unchanged. This PR does not change how `fragmentShaderBarycentricEnabled` reaches the recompiler. No overlap with #101 or #83: both touch `TranslationContext.hpp` next to the image op declarations, and this PR adds `SetPixelInput` and a member elsewhere in the class. ### Tested - Linux (CachyOS, GCC). `agc_shader_memory` gains `verifyPixelInputs`: - the `PixelInputVgpr` layouts (0x326, and ADDR-only inputs reserving VGPRs), - a two-parameter pixel shader whose parameters are interpolated through the perspective and the linear center pairs gets NoPerspective only on the linear one; this fails with the recording reverted, - reading one parameter through both kinds of pair throws, - `inputAddr` and the centroid flags survive serialization and change the cache key and the context hash. - `agc_driver_graphics_tests` `PixelInputLayoutTests`: - decoding 0x326, 0x1146 and ADDR-only layouts; the still-unsupported bits throw, - the serialization round trip, - which builtin each VGPR holds in the recompiled entry (centroid pairs, POS_X after three pairs, ADDR-only pairs left unloaded), - NoPerspective by pair. On main, 0x326 is rejected. - Exercised in PPSA21564 on our integration branch. - Rebased on current `main`. `ctest`: 79/79 pass; `agc_driver_graphics_tests` and `agc_shader_memory_tests` pass. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
oneandonlydean commented 2026-09-30 21:01:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-09-30T21:01:08Z.


On the overlap note: the shared part with #167 is the pixel system input base. On main psSystemInputBase is never set, so the system inputs are written from v0 over the interpolants; #167 fixes that by counting the VGPRs that SPI_PS_INPUT_ADDR names and passing the sum as the base. This PR fixes the same bug as part of the full layout (every input SPI_PS_INPUT_ADDR names is placed at its own VGPRs in SPI order, and ENA & ADDR selects the loaded ones), so it covers that piece of #167. The rest of each PR is independent.

If #167 merges first, I'll rebase this PR onto it straight away. #137 is stacked on this one and only shows the overlap through this commit.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5919650169 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/136#issuecomment-5919650169). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-09-30T21:01:08Z. --- On the overlap note: the shared part with #167 is the pixel system input base. On main `psSystemInputBase` is never set, so the system inputs are written from v0 over the interpolants; #167 fixes that by counting the VGPRs that `SPI_PS_INPUT_ADDR` names and passing the sum as the base. This PR fixes the same bug as part of the full layout (every input `SPI_PS_INPUT_ADDR` names is placed at its own VGPRs in SPI order, and `ENA & ADDR` selects the loaded ones), so it covers that piece of #167. The rest of each PR is independent. If #167 merges first, I'll rebase this PR onto it straight away. #137 is stacked on this one and only shows the overlap through this commit.
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!136
No description provided.