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

Merged
ps54all merged 1 commit from upstream-pr/5673 into main 2026-10-14 13:48:58 +00:00
ps54all commented 2026-10-14 05:52:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-14T05:52:50Z.


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 f74ec639c; 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

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4853593866 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5673). Originally posted by [ps54all](https://github.com/ps54all) on 2026-10-14T05:52:50Z. --- ### 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 f74ec639c; 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 - [x] 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) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: PPSA18194 - [x] GPUs tested: NVIDIA RTX 3080 only - [x] AI-assisted: yes (Claude Code); the runs are on my machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tibzejoker commented 2026-10-14 08:29:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-14T08:29:58Z.


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).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6164222945 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5673#issuecomment-6164222945). Originally posted by [tibzejoker](https://github.com/tibzejoker) on 2026-10-14T08:29:58Z. --- 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 commented 2026-10-14 08:59:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-14T08:59:35Z.


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):

  • RTX 5070: all 515 pass.
  • AMD gfx1036: all pass except agc_driver_lds_mixed_width_atomics, agc_driver_pixel_interlock and agc_driver_layered_volume_vertex_no_gpl. These three fail the same way on current main (872f52320) on this GPU and pass there on the RTX 5070; they are the three of #5271, so not caused by this PR.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6164728461 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5673#issuecomment-6164728461). Originally posted by [simonbronk](https://github.com/simonbronk) on 2026-10-14T08:59:35Z. --- 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): - RTX 5070: all 515 pass. - AMD gfx1036: all pass except `agc_driver_lds_mixed_width_atomics`, `agc_driver_pixel_interlock` and `agc_driver_layered_volume_vertex_no_gpl`. These three fail the same way on current `main` (`872f52320`) on this GPU and pass there on the RTX 5070; they are the three of #5271, so not caused by this PR. No title run. AI-assisted: yes (Claude Code ran the builds and tests).
adriadam10 commented 2026-10-14 13:15:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T13:15:41Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6169236137 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5673#issuecomment-6169236137). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T13:15:41Z. --- 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.
ps54all commented 2026-10-14 13:35:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-14T13:35:53Z.


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).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6169627518 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5673#issuecomment-6169627518). Originally posted by [ps54all](https://github.com/ps54all) on 2026-10-14T13:35:53Z. --- 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 commented 2026-10-14 13:48:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T13:48:46Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6169896395 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5673#issuecomment-6169896395). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T13:48:46Z. --- 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.
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!5673
No description provided.