fix(agc): accept ANCILLARY without PS_ITER_SAMPLE for a one-sample depth target without MSAA_ENABLE #9988

Merged
frankea merged 6 commits from upstream-pr/9988 into main 2026-10-24 12:54:07 +00:00
frankea commented 2026-10-23 02:53:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-23T02:53:15Z.


What

A one-sample depth target under a multisampled rasterizer with PA_SC_MODE_CNTL_0.MSAA_ENABLE clear is drawn as a one-sample draw at the pixel center (debt entry "A one-sample target under a multisampled rasterizer without MSAA_ENABLE"). A pixel program that reads the ANCILLARY input threw on this path: a one-sample depth target under a multisampled rasterizer without MSAA_ENABLE is unsupported for points or lines and with alpha-to-coverage, a sample index or coverage input, ....

  • ANCILLARY now throws on this path only with PA_SC_MODE_CNTL_1.PS_ITER_SAMPLE. SAMPLE_COVERAGE still throws, and so does everything else the rule refuses. The message now says "a sample index input under PS_ITER_SAMPLE, a coverage input".
  • The one-sample color rule (one-sample color targets and no depth target) is not changed here. #8121, now in main, changed its PS_ITER_SAMPLE handling; this branch merges it.
  • The debt entry says ANCILLARY throws with a one-sample depth target only under PS_ITER_SAMPLE, and why the rest is accepted.

GPU semantics, with sources:

  • The ancillary word holds the primitive class at bits 0-1, the sample index at bits 8-11 and the render target index at bits 16-28. The sources are in the shader debt entry "Packed pixel ancillary word": Mesa's ac_nir_lower_intrinsics_to_args.c, LLPC, and the RDNA 3 and GCN register guides.
  • In a pixel program the guest does not iterate per sample, the recompiler already reads the sample index as 0, "the iterated sample number of a pixel the hardware does not iterate". That entry marks it as inferred, not measured. Sample 0 at the pixel center is also the sample this path keeps: the one-sample draw tests and writes the depth there. The primitive class and the render target index don't depend on the sample.
  • With PS_ITER_SAMPLE, #7729 draws the program once per pixel on this path, but the console runs one invocation per sample, and each would read its own sample index. That case still throws.

Why: Gran Turismo 7 (PPSA01317) draws three draws of its main pass this way while loading the World Map. They have pixel programs 0x12804bd400, 0x1280441a00 and 0x1280393e00, SPI_PS_INPUT_ENA and SPI_PS_INPUT_ADDR 0x2b01 (PERSP_SAMPLE, POS_X_FLOAT, POS_Y_FLOAT, POS_W_FLOAT, ANCILLARY), PA_SC_MODE_CNTL_1 0, DB_SHADER_CONTROL 0x60 and DB_EQAA 0x00050000. The one-sample depth target is under a 4x PA_SC_AA_CONFIG.

Tested

  • Refreshed onto main 0db47b263 (head ea2b648a0; no conflicts), RTX 4090 (NVIDIA 616.92, Windows 11): the 63 ctest entries of the focused set below pass 63/63, each test run three times, and 63/63 under the validation layer (VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1, ctest -V), with no VUID- line; its only messages are main's three Undefined-Value-ShaderOutputNotConsumed-DynamicRendering warnings from agc_driver_alpha_to_coverage. main 0db47b263 passes the union of the refreshed sets, 115/115, under the same layer settings with no VUID- line.
    Gran Turismo 7 (PPSA01317), on a local stack of main with the open PRs it needs before this stop (#7243, #7256, #7550, #7978, #8564, #9020, #9335, #9068, #9700, #9721, #9743, #9806) and local diagnostics. One of them accepts ANCILLARY on this path whatever PS_ITER_SAMPLE is, and logs the draws it accepts.

  • Without it, 2 of 5 runs stopped on this refusal before GT7 created any tessellation pipeline.

  • With it (run un-3), the three draws above are accepted, all with PS_ITER_SAMPLE clear, so this rule accepts them too. The run went on to the next stop on the other route, the texture sampled with unnormalized coordinates.

Windows 11 (build 26200), NVIDIA GeForce RTX 4090 (driver 616.92), MinGW GCC Release build with BUILD_TESTING=ON, all on one machine.

  • New CPU cases in agc_driver_graphics, with and without a one-sample color target. A one-sample depth draw whose running pixel program reads ANCILLARY without PS_ITER_SAMPLE decodes as a one-sample draw, and the draw precheck accepts it. So does GT7's input set, 0x2b01. SAMPLE_COVERAGE still throws, and ANCILLARY with PS_ITER_SAMPLE still throws (an existing case).
  • Focused set: the 62 ctest entries of 18 targets. These are agc_driver_graphics_tests and the MSAA, CMASK, FMASK and journal tests: alpha_to_coverage, cached_image_multisample_guard, cmask_fast_clear, color565_target, fmask_image_reads, image_msaa_address_on_plane, msaa_enable_single_sample, multisample_fill_host_only, multisample_readback, multisample_retirement, multisampled_pass_order, native_multisample_depth, pipeline_journal, pixel_sample_coverage, sample_mask_multisample, sample_multisample_target, staged_clear_sampled_read.
  • This PR (90d02422e on main 2e0c9251d): 62/62 passed, each test run three times (ctest --repeat until-fail:3).
  • main control: main 2e0c9251d with only this PR's tests/Graphics.cpp. agc_driver_graphics fails on the new case with main's refusal.
  • Validation layer: VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Vulkan SDK 1.4.363.0), ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1 with ctest -V, on main 2e0c9251d (62/62) and on this PR (62/62). Neither log has was not found but was requested by env var VK_INSTANCE_LAYERS, and neither has a VUID- line. Both have the same three Undefined-Value-ShaderOutputNotConsumed-DynamicRendering warnings, from main's agc_driver_alpha_to_coverage.
  • Not run on Linux. tools/check_conventions.py --base origin/main reports no errors; its one warning is the length of the existing debt entry this PR edits.
  • Per @oneandonlydean's review (36b599691), agc_driver_graphics no longer checks that unimplemented one-sample depth states throw: the depthRefused message and its expectFailure calls are gone (SAMPLE_COVERAGE, ANCILLARY under PS_ITER_SAMPLE, a sample-mask export, alpha-to-coverage, points and lines, and four DB_EQAA settings). The positive ANCILLARY and 0x2b01 decode checks, the PS_ITER_SAMPLE and INTERPOLATE_COMP_Z checks and the sample-count mismatch check stay.
  • After merging main 379b1dca3 (fc29c5a33, #9721's conflicting line kept with this PR's) and then main 9c85790c9 (head 5c19aa5e4; #8121 changed the same debt sentence, and both changes are kept), RTX 4090: the 65 ctest entries of the focused set's 18 targets pass 65/65 on both heads, three times each, and 65/65 under the validation layer with no VUID- line; the only messages are main's three Undefined-Value-ShaderOutputNotConsumed-DynamicRendering warnings from agc_driver_alpha_to_coverage. main 9c85790c9 passes the union of the sets tested tonight, 109/109, under the same layer settings with no VUID- line.

Checklist

  • Based on current main; no other open PR implements the same functions. #9721 and #8121, both now in main, changed the same Require (its DB_EQAA mask and message) and the one-sample color rule next to it.
  • 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 (#9721, mine, changed the same line and is in main; this branch keeps both changes)
  • Fixes: none
  • Unblocks: PPSA01317 #4697 (with #9721, the main pass's ancillary draws are drawn; the run then stops on the texture under Tested)
  • GPUs tested: NVIDIA GeForce RTX 4090, driver 616.92, Windows 11 build 26200
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4977097936 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9988). Originally posted by [frankea](https://github.com/frankea) on 2026-10-23T02:53:15Z. --- ### What A one-sample depth target under a multisampled rasterizer with `PA_SC_MODE_CNTL_0.MSAA_ENABLE` clear is drawn as a one-sample draw at the pixel center (debt entry "A one-sample target under a multisampled rasterizer without MSAA_ENABLE"). A pixel program that reads the `ANCILLARY` input threw on this path: `a one-sample depth target under a multisampled rasterizer without MSAA_ENABLE is unsupported for points or lines and with alpha-to-coverage, a sample index or coverage input, ...`. - `ANCILLARY` now throws on this path only with `PA_SC_MODE_CNTL_1.PS_ITER_SAMPLE`. `SAMPLE_COVERAGE` still throws, and so does everything else the rule refuses. The message now says "a sample index input under PS_ITER_SAMPLE, a coverage input". - The one-sample color rule (one-sample color targets and no depth target) is not changed here. #8121, now in `main`, changed its `PS_ITER_SAMPLE` handling; this branch merges it. - The debt entry says `ANCILLARY` throws with a one-sample depth target only under `PS_ITER_SAMPLE`, and why the rest is accepted. GPU semantics, with sources: - The ancillary word holds the primitive class at bits 0-1, the sample index at bits 8-11 and the render target index at bits 16-28. The sources are in the shader debt entry "Packed pixel ancillary word": Mesa's [ac_nir_lower_intrinsics_to_args.c](https://gitlab.freedesktop.org/mesa/mesa/-/blob/bffd91947efc1932da99aca69fc540d6d4201b0c/src/amd/common/nir/ac_nir_lower_intrinsics_to_args.c#L342-L368), LLPC, and the RDNA 3 and GCN register guides. - In a pixel program the guest does not iterate per sample, the recompiler already reads the sample index as 0, "the iterated sample number of a pixel the hardware does not iterate". That entry marks it as inferred, not measured. Sample 0 at the pixel center is also the sample this path keeps: the one-sample draw tests and writes the depth there. The primitive class and the render target index don't depend on the sample. - With `PS_ITER_SAMPLE`, #7729 draws the program once per pixel on this path, but the console runs one invocation per sample, and each would read its own sample index. That case still throws. Why: Gran Turismo 7 (PPSA01317) draws three draws of its main pass this way while loading the World Map. They have pixel programs 0x12804bd400, 0x1280441a00 and 0x1280393e00, `SPI_PS_INPUT_ENA` and `SPI_PS_INPUT_ADDR` 0x2b01 (`PERSP_SAMPLE`, `POS_X_FLOAT`, `POS_Y_FLOAT`, `POS_W_FLOAT`, `ANCILLARY`), `PA_SC_MODE_CNTL_1` 0, `DB_SHADER_CONTROL` 0x60 and `DB_EQAA` 0x00050000. The one-sample depth target is under a 4x `PA_SC_AA_CONFIG`. ### Tested - Refreshed onto `main` 0db47b263 (head ea2b648a0; no conflicts), RTX 4090 (NVIDIA 616.92, Windows 11): the 63 ctest entries of the focused set below pass 63/63, each test run three times, and 63/63 under the validation layer (`VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_REQUIRE_VULKAN=1`, `ctest -V`), with no `VUID-` line; its only messages are `main`'s three `Undefined-Value-ShaderOutputNotConsumed-DynamicRendering` warnings from `agc_driver_alpha_to_coverage`. `main` 0db47b263 passes the union of the refreshed sets, 115/115, under the same layer settings with no `VUID-` line. Gran Turismo 7 (PPSA01317), on a local stack of `main` with the open PRs it needs before this stop (#7243, #7256, #7550, #7978, #8564, #9020, #9335, #9068, #9700, #9721, #9743, #9806) and local diagnostics. One of them accepts `ANCILLARY` on this path whatever `PS_ITER_SAMPLE` is, and logs the draws it accepts. - Without it, 2 of 5 runs stopped on this refusal before GT7 created any tessellation pipeline. - With it (run un-3), the three draws above are accepted, all with `PS_ITER_SAMPLE` clear, so this rule accepts them too. The run went on to the next stop on the other route, the texture sampled with unnormalized coordinates. Windows 11 (build 26200), NVIDIA GeForce RTX 4090 (driver 616.92), MinGW GCC Release build with `BUILD_TESTING=ON`, all on one machine. - New CPU cases in `agc_driver_graphics`, with and without a one-sample color target. A one-sample depth draw whose running pixel program reads `ANCILLARY` without `PS_ITER_SAMPLE` decodes as a one-sample draw, and the draw precheck accepts it. So does GT7's input set, 0x2b01. `SAMPLE_COVERAGE` still throws, and `ANCILLARY` with `PS_ITER_SAMPLE` still throws (an existing case). - Focused set: the 62 ctest entries of 18 targets. These are `agc_driver_graphics_tests` and the MSAA, CMASK, FMASK and journal tests: alpha_to_coverage, cached_image_multisample_guard, cmask_fast_clear, color565_target, fmask_image_reads, image_msaa_address_on_plane, msaa_enable_single_sample, multisample_fill_host_only, multisample_readback, multisample_retirement, multisampled_pass_order, native_multisample_depth, pipeline_journal, pixel_sample_coverage, sample_mask_multisample, sample_multisample_target, staged_clear_sampled_read. - This PR (90d02422e on `main` 2e0c9251d): 62/62 passed, each test run three times (`ctest --repeat until-fail:3`). - `main` control: `main` 2e0c9251d with only this PR's `tests/Graphics.cpp`. `agc_driver_graphics` fails on the new case with `main`'s refusal. - Validation layer: `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (Vulkan SDK 1.4.363.0), `ANYPS5_NO_SHADER_CACHE=1` and `ANYPS5_REQUIRE_VULKAN=1` with `ctest -V`, on `main` 2e0c9251d (62/62) and on this PR (62/62). Neither log has `was not found but was requested by env var VK_INSTANCE_LAYERS`, and neither has a `VUID-` line. Both have the same three `Undefined-Value-ShaderOutputNotConsumed-DynamicRendering` warnings, from `main`'s `agc_driver_alpha_to_coverage`. - Not run on Linux. `tools/check_conventions.py --base origin/main` reports no errors; its one warning is the length of the existing debt entry this PR edits. - Per @oneandonlydean's review (36b599691), `agc_driver_graphics` no longer checks that unimplemented one-sample depth states throw: the `depthRefused` message and its `expectFailure` calls are gone (`SAMPLE_COVERAGE`, `ANCILLARY` under `PS_ITER_SAMPLE`, a sample-mask export, alpha-to-coverage, points and lines, and four `DB_EQAA` settings). The positive `ANCILLARY` and 0x2b01 decode checks, the `PS_ITER_SAMPLE` and `INTERPOLATE_COMP_Z` checks and the sample-count mismatch check stay. - After merging `main` 379b1dca3 (fc29c5a33, #9721's conflicting line kept with this PR's) and then `main` 9c85790c9 (head 5c19aa5e4; #8121 changed the same debt sentence, and both changes are kept), RTX 4090: the 65 ctest entries of the focused set's 18 targets pass 65/65 on both heads, three times each, and 65/65 under the validation layer with no `VUID-` line; the only messages are `main`'s three `Undefined-Value-ShaderOutputNotConsumed-DynamicRendering` warnings from `agc_driver_alpha_to_coverage`. `main` 9c85790c9 passes the union of the sets tested tonight, 109/109, under the same layer settings with no `VUID-` line. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions. #9721 and #8121, both now in `main`, changed the same `Require` (its `DB_EQAA` mask and message) and the one-sample color rule next to it. - [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 (#9721, mine, changed the same line and is in `main`; this branch keeps both changes) - [x] Fixes: none - [x] Unblocks: PPSA01317 #4697 (with #9721, the main pass's ancillary draws are drawn; the run then stops on the texture under Tested) - [x] GPUs tested: NVIDIA GeForce RTX 4090, driver 616.92, Windows 11 build 26200 - [x] AI-assisted: yes (Claude Code)
MarcZX10 commented 2026-10-23 04:12:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T04:12:40Z.

Review: APPROVED


Reviewed exact head 90d02422e2 against current main. The code narrows the exception to the one-sample depth path: ANCILLARY is accepted only when PS_ITER_SAMPLE is clear; sample coverage and per-sample ancillary remain rejected. The tests cover the no-depth/color variants and GT7's reported input mask, while retaining negative controls. The debt note marks the inferred sample-0 behavior as unmeasured on console.

The PR explicitly records the same-line integration order with #9721, which is still open; the touched code is separate in purpose and the PR is mergeable. I reran the convention check against current main, the test-script registration check available at this exact head (171 scripts), and git diff --check; all pass. I could not execute the Vulkan/guest test suite locally because this workspace has no configured AnyPS5 build or GPU test runtime. The author reports 62/62 focused tests repeated three times on Windows with validation enabled, and a negative control that fails on the old behavior. Hosted policy checks pass and product build jobs are skipped.

No blocking issue found in the reviewed diff.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5623796729 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9988#pullrequestreview-5623796729). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T04:12:40Z. **Review:** APPROVED --- Reviewed exact head 90d02422e2d5677145cab66edb9811dc3186c482 against current main. The code narrows the exception to the one-sample depth path: `ANCILLARY` is accepted only when `PS_ITER_SAMPLE` is clear; sample coverage and per-sample ancillary remain rejected. The tests cover the no-depth/color variants and GT7's reported input mask, while retaining negative controls. The debt note marks the inferred sample-0 behavior as unmeasured on console. The PR explicitly records the same-line integration order with #9721, which is still open; the touched code is separate in purpose and the PR is mergeable. I reran the convention check against current main, the test-script registration check available at this exact head (171 scripts), and `git diff --check`; all pass. I could not execute the Vulkan/guest test suite locally because this workspace has no configured AnyPS5 build or GPU test runtime. The author reports 62/62 focused tests repeated three times on Windows with validation enabled, and a negative control that fails on the old behavior. Hosted policy checks pass and product build jobs are skipped. No blocking issue found in the reviewed diff.
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!9988
No description provided.