Skip to content

feat(agc): run the pixel program per sample for PS_ITER_SAMPLE - #5673

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
ps54all:feat/agc-ps-iter-sample
Oct 14, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
ps54all:feat/agc-ps-iter-sample

Conversation

@ps54all

@ps54all ps54all commented Oct 14, 2026

Copy link
Copy Markdown

What

PA_SC_MODE_CNTL_1 bit 16 (PS_ITER_SAMPLE) was refused together with the other scan-control bits ("sample iteration, primitive discard or out-of-order rasterization"). Metal Gear Solid 4 programs 0x293 = 0x06030000, so every draw failed on it.

  • On a multisampled draw the bit decodes to State::perSampleShading, which sets sampleShadingEnable with minSampleShading = 1.0 in the pipeline's multisample state. The draw throws when the device lacks sampleRateShading.
  • On a single-sample draw the bit has no effect and is dropped.
  • The flag is part of the pipeline library keys (fragment shader and fragment output), the full pipeline key and the draw register key comparison, so draws that differ only in it do not share a pipeline.
  • The remaining refusal for the other bits (multi-shader-engine primitive discard, out-of-order rasterization) is unchanged; its message no longer says "sample iteration".
  • The bit position comes from the PS5_Mesa GFX10.3 register file (PS_ITER_SAMPLE bits 16-16, next to MULTI_SHADER_ENGINE_PRIM_DISCARD_ENABLE at 17). The debt entry in docs/dev/debt/libSceAgcDriver.md records that per-sample execution on the console is taken from the register name and Vulkan's definition, not measured.

Tested

Windows 11, RTX 3080 (driver 610.74), WinLibs GCC 15.2.0 r7, Release.

  • agc_driver_graphics: the old assertion that 0x06030000 is refused becomes: a single-sample target accepts it and decodes without sample shading; a 2x target with 0x293 = 0x10000 is accepted by the precheck and decodes with perSampleShading; without the bit it does not. With the mask change reverted the test fails ("per-sample iteration of a single-sample target was rejected"); with it the test passes.
  • All 499 agc ctest tests pass (rebased on main f74ec63; one skipped before the rebase, agc_driver_stencil_ref_export, missing device feature). python tools/check_conventions.py --base origin/main and tools/check_test_registration.py pass.
  • Not covered: there is no Vulkan readback test that a multisampled draw runs its pixel program once per sample; the pipeline path is only exercised through the decode tests and the existing pipeline tests.
  • Metal Gear Solid 4 (PPSA18194): with an equivalent local change (mask only) the game gets past this refusal and reaches gameplay. I did not log whether any draw using the bit was multisampled.

Checklist

  • Based on current main; no other open PR implements the same functions (searched PR titles/bodies and the tree for PS_ITER_SAMPLE, PA_SC_MODE_CNTL_1, sampleShading on 2026-10-14)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: PPSA18194
  • GPUs tested: NVIDIA RTX 3080 only
  • AI-assisted: yes (Claude Code); the runs are on my machine.

🤖 Generated with Claude Code

@tibzejoker

Copy link
Copy Markdown
Contributor

Runs for this PR at head f2c548638. Windows 11, MinGW-w64 GCC 15.2.0 Release, two GPUs in one machine: Intel UHD Graphics 770 (driver 32.0.101.6129, picked with ANYPS5_GPU=Intel) and RTX 4090 (NVIDIA 616.92).

  • The tests built from this PR's changed test files (agc_compute_descriptor_layout_flags, agc_descriptor_pool_reset_failure, agc_driver_address_space_teardown, agc_driver_covered_centroid_state, agc_driver_graphics, agc_sparse_buffer_holes) pass on both GPUs.
  • ctest -R "agc_driver|agc_masked|agc_shader" -j4: no failures on either GPU. Intel: 396 tests, 28 skipped. NVIDIA: 396 tests, 1 skipped (agc_driver_stencil_ref_export). The skips are the same as on main with each GPU. On the UHD 770 they are features it doesn't support: f64, 64-bit and float atomics, mesh shaders, fp16 interpolation and dot, shader clock.

No difference between the two GPUs.

AI-assisted (Claude Code).

@simonbronk

Copy link
Copy Markdown
Contributor

AMD and NVIDIA runs for this PR at head f2c548638. Windows 11 Pro 26200, WinLibs GCC 15.2.0 (MinGW-w64), Release, one machine with two GPUs, each picked with ANYPS5_GPU:

  • NVIDIA GeForce RTX 5070, driver 617.42 (32.0.16.1742)
  • AMD Radeon(TM) Graphics, Ryzen integrated, gfx1036 (1002:13c0, RDNA 2), driver 32.0.21036.18

ctest -R "agc|shader|video_out" -j 8 (515 tests, including the ones this PR adds or changes):

No title run. AI-assisted: yes (Claude Code ran the builds and tests).

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
@adriadam10 adriadam10 self-assigned this Oct 14, 2026
PA_SC_MODE_CNTL_1 bit 16 (PS_ITER_SAMPLE) was rejected with the other scan
control bits. On a multisampled draw it now enables Vulkan sample shading with
a minimum rate of 1.0, and the draw throws when the device lacks
sampleRateShading. On a single-sample draw the bit has no effect and is
dropped. The flag is part of the pipeline, pipeline library and draw register
keys.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@adriadam10

Copy link
Copy Markdown
Collaborator

Rebased onto main (adjacency conflict in State.hpp with ditheredAlphaToCoverage, no logic change). Checked: perSampleShading is in both pipeline library keys, the full pipeline key and sameDecode; the throw without sampleRateShading; the decode tests (they no longer compile without the change); build + agc ctest green (agc_driver_tessellation segfaults the same on main without this PR); the debt entry states that per-sample execution is not measured. Merging once CI is green.

@adriadam10
adriadam10 force-pushed the feat/agc-ps-iter-sample branch from f2c5486 to af7ca4a Compare October 14, 2026 13:15
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
@ps54all

ps54all commented Oct 14, 2026 •

Copy link
Copy Markdown
Author

Thanks @adriadam10 for the rebase onto main. It matches the one I made locally: the only conflict was State.hpp, where #4451's ditheredAlphaToCoverage landed next to perSampleShading, both kept. The same patch on main 344afad05 passes all 518 agc tests here (Windows 11, RTX 3080, 610.74). And thanks @tibzejoker and @simonbronk for the Intel, NVIDIA and AMD runs.

AI-assisted (Claude Code).

@adriadam10

Copy link
Copy Markdown
Collaborator

Re-checked the author's rebase on current main: same patch as the previous head, only context lines differ. perSampleShading is in both pipeline library keys, the full pipeline key and sameDecode; it throws without sampleRateShading. Build + agc ctest green here (agc_driver_tessellation segfaults the same on main); without the change agc_driver_graphics no longer compiles. Per-sample execution on the console is not measured, as the debt entry states. Merging once CI is green.

@adriadam10
adriadam10 merged commit f3a826b 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* docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants