Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
stuart-russell:fix/agc-pixel-input-count
Nov 15, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
stuart-russell:fix/agc-pixel-input-count

Conversation

@stuart-russell

Copy link
Copy Markdown
Contributor

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

@JJenkx

JJenkx commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Windows check of head c449b913df, merged onto main 31b4aa91e8 (bd50769895, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • guest_font_graphics passes in 3 of 3 runs, none skipped.

AI-assisted: yes.

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1395 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4040 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5925 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cpp
PR 6235 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawDecode.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6280 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6481 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6804 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6808 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7256 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7642 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 8246 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9335 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9356 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9387 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9508 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9712 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9895 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10049 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10193 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10249 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderInputState.cpp
PR 11825 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 13928 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 13929 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 14032 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 14944 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 15548 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 15570 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 16753 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 17611 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 19100 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 19119 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 20315 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp

@github-actions github-actions Bot added the agc libSceAgc* label Nov 9, 2026
@Doorriiaann

Copy link
Copy Markdown
Contributor

A GPU run, since Tested says the branch's machine has no Vulkan device: RTX 3070 (8 GB), driver 610.57.04, Debian 13, kernel 6.12.115, GCC 13.3.0 Release, validation layer 1.4.335, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, the whole suite (ctest -j6), since every draw goes through the changed decode.

merge-base 697b66b1e4 this PR c449b913df
tests 4773: 4729 passed, 43 skipped, 1 failed 4773: 4729 passed, 43 skipped, 1 failed
VUID- lines / layer not found 0 / 0 0 / 0

The one failure is agc_driver_present_upscale (SEGFAULT) on both sides, which fails on main here already. The skip lists are identical. agc_driver_graphics, which now includes ShaderDeclaredPixelInputTests, passes. So neither the new per-primitive throw nor the 32-input limit fires anywhere in the existing GPU tests on NVIDIA, and every draw test that passed before still passes.

AI-assisted: yes

@stuart-russell

Copy link
Copy Markdown
Contributor Author

On the overlap bot's note: #16025 edits the depthCopySource line in decodeDraw (adding StencilCopyPixelProgramAddress), while this PR inserts the fragment-header lookup immediately after it. That is textual adjacency, not a semantic clash — whichever lands first, the other is a one-line rebase. Depends on: none stands.

@gabichuuuuu

Copy link
Copy Markdown
Contributor

Windows check of head c449b913df, merged onto main 28237a8567 (clean merge, built together with other open PRs that touch different files).

Setup: Windows 11 x64, WinLibs GCC 15.2.0 (r7), Ninja, Release, BUILD_TESTING=ON, Python 3.15.

  • Tests built from this PR's test files: agc_address_copy_cap, agc_address_copy_cap_mirror, agc_address_copy_cap_remembered, agc_address_space_unwatched_mirror_import, agc_command_batch_fence_failure, agc_compute_descriptor_layout_flags, agc_copy_input_failure_lifetime, agc_copy_input_kept_bytes, agc_depth_copy_kept_bytes, agc_descriptor_cache, agc_descriptor_pool_reset_failure, agc_driver_address_space_teardown, agc_driver_alpha_to_coverage_state, agc_driver_covered_centroid_state, agc_driver_depth_bounds_state, agc_driver_fault_only_template_records, agc_driver_fault_only_template_records_kept, agc_driver_fault_only_template_records_loop_guard, agc_driver_fault_only_template_records_loop_guard_kept, agc_driver_graphics, agc_driver_linear_volume_nonresident, agc_driver_msaa_dcc_state, agc_driver_sample_location_grid_fallback, agc_driver_sample_order_planning, agc_driver_undithered_alpha_to_coverage_state, agc_driver_unobserved_provoking_vertex, agc_driver_unused_viewport_depth, agc_graphics_profile_draw, agc_heap_mirror_reference_size, agc_heap_mirror_run_unwatch, agc_heap_mirror_run_unwatch_no_space_cache, agc_heap_mirror_unwatch, agc_heap_mirror_unwatch_no_space_cache, agc_pipeline_journal, agc_pipeline_journal_extended_paths, agc_pipeline_journal_long_paths, agc_pipeline_library_clear_waits_for_build, agc_pipeline_store_fixed_bound, agc_pipeline_store_growth, agc_pipeline_store_lazy_buffer_pool, agc_pipeline_store_replay_growth, agc_pipeline_store_touch, agc_sparse_buffer_holes, agc_sparse_heap_mirror_budget, agc_sparse_heap_mirror_unwatch, agc_sparse_heap_mirror_unwatch_no_space_cache.
  • All of them pass in 3 of 3 runs.
  • Negative control: with this PR's code reverted to main, the tests do not build (core/libs/prx/libSceAgcDriver/tests/Graphics.cpp:1799:47: error: too many arguments to function 'ShaderRecompiler::ShaderPixelStageInfo AgcDriver::Graphics::DecodePixelStageInfo(const AgcDriver::Regis), which is expected when the tests use interfaces the PR adds or changes.

AI-assisted: yes.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 14, 2026
SPI_PS_IN_CONTROL.INPUT_NUM is the queued interpolant count; a fragment shader that declares more inputs read interpolators the decode never set up. Use the larger of the queued count and the header's num_input_semantics, default an unwritten SPI_PS_INPUT_CNTL to its interpolant index, and throw on per-primitive inputs instead of mis-decoding them.
@stuart-russell
stuart-russell force-pushed the fix/agc-pixel-input-count branch from 6388612 to 95285f4 Compare November 14, 2026 22:20
@stuart-russell

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (ee25ae607b) so the branch is linear again. The only conflict was in decodeDraw: main has since added StencilCopyPixelProgramAddress to the depthCopySource line, which is kept, followed by this PR's fragment-header lookup and the two-argument-plus-header DecodePixelStageInfo call.

Verified on the rebased head: agc_driver_pm4, agc_driver_graphics and agc_gcn_color_target pass (35 tests), conventions clean.

@NathanFahey23

Copy link
Copy Markdown
Contributor

Windows NVIDIA check of head 95285f4c87, merged onto main b885c40a67 (b5dd9cae39, clean merge), on the head rebased since the last Windows check.

Setup: Windows 11 Home 10.0.26300, i9-13900K, WinLibs GCC 15.2.0, Release, RTX 4080 (10de:2704, driver 32.0.16.2101), ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, Khronos validation layer loaded. GPU set: ctest -R '^(agc_\|shader\|video_out\|guest_video)' --parallel 4, one run per side.

main b885c40a67 merge b5dd9cae39
GPU set 1843 pass, 20 skipped, 0 failed 1843 pass, 20 skipped, 0 failed
VUID- lines 0 0
tests this PR changes (agc_driver_graphics) 1 Passed
homebrew, 30 s each (tools/title_run.py, cold shader cache) Jelly5 rendering 118.2, VLC rendering 119.5, DriftCheck rendering 59.9, PS5SX2 rendering 59.8, DOOM rendering 36.4 Jelly5 rendering 118.2, VLC rendering 119.5, DriftCheck rendering 59.9, PS5SX2 rendering 59.8, DOOM rendering 36.4

The one test not run on both sides is agc_driver_upload_cache_read_only_flush: its executable does not build on Windows on this main (setenv, fixed by #19899). The homebrew titles are Jelly5, VLC, DriftCheck, PS5SX2 and DOOM; fps is one run each, for whether they still render, not a performance comparison.

Not checked: AMD, Linux, macOS, any commercial title.

AI-assisted: yes

@oneandonlydean
oneandonlydean merged commit 39d9bb9 into boykopovar:main Nov 15, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants