fix(agc): take the pixel input count from the shader header #17911

Merged
stuart-russell merged 1 commit from upstream-pr/17911 into main 2026-11-15 20:16:28 +00:00
stuart-russell commented 2026-11-09 22:01:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by stuart-russell on 2026-11-09T22:01:53Z.


What

SPI_PS_IN_CONTROL.INPUT_NUM (bits 0 to 5) is the queued interpolant count; a fragment shader can declare more inputs than the state sets up, and the draw then decoded fewer interpolators than the shader reads.

  • DecodePixelStageInfo takes the fragment shader header and uses the larger of the queued count and num_input_semantics, throwing when that count exceeds 32.
  • SPI_PS_IN_CONTROL.VALID_NUM (bits 9 to 13) declares per-primitive inputs, which this path cannot emulate; it throws instead of mis-decoding.
  • Interpolator control registers between the queued count and the declared count are noted as reads and default to their interpolant index when the state never wrote them.
  • decodeDraw passes the fragment program's header.

Split from #10420; independent of the other pieces.

References

SPI_PS_IN_CONTROL fields as above; an unwritten SPI_PS_INPUT_CNTL_i holds ANCILLARY | FLAT_SHADE | OFFSET all clear with DEFAULT_VAL equal to i.

Tested

agc_driver_pm4, agc_driver_graphics, agc_gcn_color_target and the other agc_driver_* suites the pattern selects (32 tests) pass, and tools/check_conventions.py --base origin/main passes, on 697b66b1e4. New ShaderDeclaredPixelInputTests covers the queued-only decode, a header declaring five inputs, the defaulted control register for an unwritten one, the per-primitive throw and the 32-input limit.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R 'agc_driver_graph' -V passes with no VUID- lines. This machine has no Vulkan device, so that run covers the decode path only.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: the branch's Linux test machine has no Vulkan device
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5231915270 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17911). Originally posted by [stuart-russell](https://github.com/stuart-russell) on 2026-11-09T22:01:53Z. --- ### What `SPI_PS_IN_CONTROL.INPUT_NUM` (bits 0 to 5) is the *queued* interpolant count; a fragment shader can declare more inputs than the state sets up, and the draw then decoded fewer interpolators than the shader reads. - `DecodePixelStageInfo` takes the fragment shader header and uses the larger of the queued count and `num_input_semantics`, throwing when that count exceeds 32. - `SPI_PS_IN_CONTROL.VALID_NUM` (bits 9 to 13) declares per-primitive inputs, which this path cannot emulate; it throws instead of mis-decoding. - Interpolator control registers between the queued count and the declared count are noted as reads and default to their interpolant index when the state never wrote them. - `decodeDraw` passes the fragment program's header. Split from #10420; independent of the other pieces. ### References `SPI_PS_IN_CONTROL` fields as above; an unwritten `SPI_PS_INPUT_CNTL_i` holds `ANCILLARY | FLAT_SHADE | OFFSET` all clear with `DEFAULT_VAL` equal to `i`. ### Tested `agc_driver_pm4`, `agc_driver_graphics`, `agc_gcn_color_target` and the other `agc_driver_*` suites the pattern selects (32 tests) pass, and `tools/check_conventions.py --base origin/main` passes, on `697b66b1e4`. New `ShaderDeclaredPixelInputTests` covers the queued-only decode, a header declaring five inputs, the defaulted control register for an unwritten one, the per-primitive throw and the 32-input limit. `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R 'agc_driver_graph' -V` passes with no `VUID-` lines. This machine has no Vulkan device, so that run covers the decode path only. ### 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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: the branch's Linux test machine has no Vulkan device - [x] AI-assisted: yes
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!17911
No description provided.