Skip to content

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

Merged
boykopovar merged 1 commit into
boykopovar:mainfrom
oneandonlydean:feat/pixel-input-vgpr-layout
Oct 1, 2026
Merged

boykopovar merged 1 commit into
boykopovar:mainfrom
oneandonlydean:feat/pixel-input-vgpr-layout

Conversation

@oneandonlydean

@oneandonlydean oneandonlydean commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

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 feat(shader): translate NGG geometry programs to mesh shaders #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

@github-actions github-actions Bot added shader core/shader agc libSceAgc* needs rebase Conflicts with main, rebase needed labels Sep 29, 2026
@oneandonlydean
oneandonlydean force-pushed the feat/pixel-input-vgpr-layout branch from d5eded2 to 858cdea Compare September 29, 2026 21:59
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Sep 29, 2026
@oneandonlydean
oneandonlydean force-pushed the feat/pixel-input-vgpr-layout branch from 858cdea to b49a1e9 Compare September 30, 2026 11:00
@oneandonlydean
oneandonlydean force-pushed the feat/pixel-input-vgpr-layout branch from b49a1e9 to 710f784 Compare September 30, 2026 11:12
oneandonlydean added a commit to oneandonlydean/AnyPS5 that referenced this pull request Sep 30, 2026
…, boykopovar#129) into astrobot

Conflicts resolved:
- Shader disk cache (boykopovar#129 as merged upstream): upstream's version, plus
  astrobot's imageDepthCompare and waveLayout fields (format 3).
- Shader fusion: upstream's fd4700b replaces astrobot's boykopovar#124 version.
- -KRzWekV120: upstream's export replaces astrobot's; its test now calls
  sceAgcUnknown__MKRzWekV120.
- Misaligned buffer views: upstream's push-constant adjustment (3dec6ce)
  replaces astrobot's view aliases; GuestBufferMemory is the rebased boykopovar#121
  version (write watch on shared direct memory).
- DirectMemory: rebased boykopovar#121 (re-register after the shared-backing remap,
  aliased pages leave the watch) plus boykopovar#164's per-piece unmap.
- Depth: astrobot's DepthTarget model is kept for attachments; upstream's
  DepthSurface module is dropped (it would duplicate it). Upstream's
  mip-chain colour targets, CB_COLOR_VIEW MIP_LEVEL at bits 26-29 and
  export formats are taken into DecodeColorBuffer.
- GPU-selected V#s: upstream's gpuDescriptor replaces astrobot's opt-in
  runtimeDescriptor; image_bvh_intersect_ray is upstream's.
- Occlusion counter dumps: upstream's Vulkan occlusion queries replace
  astrobot's always-visible PIXEL_PIPE_STAT dump.
- AudioOut2 DualSense ports: rebased boykopovar#180 on upstream's 16-bit ports.
- Pixel stage decode: rebased boykopovar#136; mesh push constants: rebased boykopovar#133.
- Label waits (boykopovar#178): noteHeldAtSubmit moved into reserveOutputs.
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Sep 30, 2026
SPI_PS_INPUT_ENA/ADDR with PERSP_CENTROID (bit 2) or LINEAR_CENTROID
(bit 6) was rejected; PPSA21564 binds 0x326 (perspective center and
centroid, linear center, POS_X/Y).

The PS input VGPR layout now follows the hardware rule: SPI_PS_INPUT_ADDR
places every input it names in SPI order (two VGPRs per I/J pair, three
for the pull model, one otherwise), loaded or not, and ENA & ADDR selects
the loaded ones. ShaderPixelStageInfo carries inputAddr (replacing
perspectiveCenterVgpr) plus perspectiveCentroid and linearCentroid; the
recompiler places each loaded input with PixelInputVgpr. This also fixes
the system inputs, which were always written from v0 (psSystemInputBase
was never set), so POS_X overwrote the center I in any draw with
barycentrics enabled.

Draws are rasterized single-sampled, where the centroid is the pixel
center: with fragment barycentrics the centroid pairs carry the center
barycentrics (BaryCoordKHR for perspective; the linear center and
centroid pairs now get BaryCoordNoPerspKHR).

NoPerspective was decided for every parameter by one flag (LINEAR_CENTER
loaded). v_interp_p2 now records whether it reads the J of a linear or a
perspective pair, and a parameter is NoPerspective when it is read
through a linear pair; parameters read through neither keep the old
rule. A parameter read through both kinds of pair throws. Only pixel
stages consult this.

The request serializer moves to version 5 (older requests read back with
their loaded inputs as the layout); the cache key and the driver's draw
key compare and hash the new fields. The unsupported-input error names
ENA and ADDR.
@oneandonlydean
oneandonlydean force-pushed the feat/pixel-input-vgpr-layout branch from 710f784 to cb66ec2 Compare September 30, 2026 19:48
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Sep 30, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator Author

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.

pidsmandaks-ux added a commit to pidsmandaks-ux/AnyPS5 that referenced this pull request Oct 1, 2026
Import generic pixel-input compatibility fixes from upstream PRs boykopovar#136 and boykopovar#137.
@boykopovar
boykopovar merged commit bc3528b into boykopovar:main Oct 1, 2026
3 checks passed
oneandonlydean added a commit to oneandonlydean/AnyPS5 that referenced this pull request Oct 1, 2026
…opovar#208 test layout, our merged PRs) into astrobot

Conflicts resolved:
- Driver.cpp: upstream split it into Execution/src/Driver/*; astrobot's
  driver changes are ported into the split files (flip throttle
  APS5_MAX_QUEUED_FLIPS, dispatch tolerance, NoteProgram, metadata-pass
  switch and DB HTILE blits, depth state in the draw register key, HTILE
  fill clears, wait outcome counters, opt-in deferred EOP interrupts).
  boykopovar#192's KnownDrawRejection is taken.
- Our merged PRs take upstream's reviewed versions: boykopovar#124 shader fusion,
  boykopovar#128 videoout open param, boykopovar#132 CB metadata passes, boykopovar#138 EOP events,
  boykopovar#176 GE_INDX_OFFSET, boykopovar#136/boykopovar#137 pixel inputs and NoPerspective by I/J
  pair, boykopovar#133 mesh tests. boykopovar#142's interpolation validation is upstream's.
- Depth: astrobot's DepthTarget model stays; upstream's DepthSurface
  module is dropped again, boykopovar#188's 16-bit depth-bit reads are kept on top.
- Videodec2: upstream's ffmpeg-core version (boykopovar#42 rework); 3rdparty/FFmpeg
  stays for libSceAvPlayer only.
- Tests follow boykopovar#208's layout (add_test_executable, build/tests); the
  AvPlayer, GDS and wave tests are defined the same way.
- Shader disk cache format 5 and request serialization version 7 cover
  both sides' fields.
- Duplicates the auto-merge produced (state decoders, RequestInputInfo,
  structurizer helpers, image offsets, opcode enum, tests) are removed.
@oneandonlydean
oneandonlydean deleted the feat/pixel-input-vgpr-layout branch October 1, 2026 21:26
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.

2 participants