feat(agc): pass custom sample locations through VK_EXT_sample_locations #2183

Closed
Raghav314 wants to merge 9 commits from upstream-pr/2183 into main
Raghav314 commented 2026-10-09 10:59:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Raghav314 on 2026-10-09T10:59:42Z.


What

Follow-up to #419, as discussed there. decodeSamples refused any PA_SC_AA_SAMPLE_LOCS pattern other than the standard one for the sample count, so a title that rasterizes with its own pattern threw "nonstandard sample locations are unsupported".

The registers give each sample's position as a signed 4-bit offset in 1/16 pixel from the pixel center. VK_EXT_sample_locations takes positions in [0, 1) of the pixel, so a register offset x is 0.5 + x / 16. The console's standard 4x pattern maps exactly onto Vulkan's standard 4x positions this way, which checks both the scale and the direction of y.

  • A pattern that is the same for all four pixels of the quad becomes the pipeline's sample locations (a 1x1 grid). It is part of the pipeline key. Patterns that differ between the pixels still throw.
  • The device needs the extension with variableSampleLocations, 4 sub-pixel bits and a coordinate range covering 0 to 15/16, for the draw's sample count. Otherwise a draw with custom locations throws. Requiring variable locations means pipelines with different patterns can share a render pass.
  • A multisampled depth image is created with SAMPLE_LOCATIONS_COMPATIBLE_DEPTH when the device supports that for its format and sample count (vkGetPhysicalDeviceImageFormatProperties with the flag and the image's usage). A draw with custom locations whose depth target the device cannot make compatible throws. The depth image stays in GENERAL after creation, so no layout transition needs the locations.
  • A CB resolve does not depend on where the samples are, so it now accepts any quad-uniform pattern instead of only the standard one.
  • TechnicalDebt gets an entry.

PPSA36082

Hades II rasterizes its 4x targets with an ordered grid: the PA_SC_AA_SAMPLE_LOCS words are 0x444cc4cc for all four pixels, that is (±4, ±4)/16. On main f1451396 with the fixes it needs to get that far plus #419, it threw the error above while rendering (it showed up as a failed presentation). With this change, #2121 and #2132, the game renders those passes correctly in gameplay. On the RTX 4090 every depth format it supports is compatible at 1x to 8x, and the game ran into gameplay with this change with no refusals or skipped draws in the log.

Tested

Linux (CachyOS), x86-64, GCC, 7800X3D / RTX 4090.

  • agc_driver_graphics (new checks):
    • The game's 4x ordered grid decodes; 2x positions in another order decode; a pattern that differs between the quad's pixels is refused; the standard 4x pattern is not treated as custom.
    • An 8x pattern decodes from both register words of each pixel.
    • The console's standard 4x offsets convert to Vulkan's standard 4x positions; the extreme offsets convert to 0 and 15/16.
    • Depth compatibility on a stub device: no extension, a supported format and count, an unsupported count, a refused format, and a single-sample target. The query uses the flag and the usage the depth image is created with.
  • Mutations, each failing a check: y flipped, 1/8 pixel instead of 1/16, one register word per pixel, the format not queried, the format's sample counts ignored, the extension's sample counts ignored, single-sample allowed.
  • Not covered by a device test: the pipeline actually rasterizing at the custom positions. That part was checked in game.
  • The linux job of current build.yml run locally (SPIRV tools on, test registration check, build, libs, ctest), both on this head (468/468) and on it merged with main d70b8998 (517/518). #419 conflicts with main on one line of Texture.hpp since #1059 (both add a declaration there); for that merge I kept both. agc_driver_dcc_keys_first_write fails on main without this change too.

Checklist

  • Based on #419's head; 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 in TechnicalDebt
  • 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: #419 (its commits are included here until it merges)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4799500525 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2183). Originally posted by [Raghav314](https://github.com/Raghav314) on 2026-10-09T10:59:42Z. --- ### What Follow-up to #419, as discussed there. `decodeSamples` refused any `PA_SC_AA_SAMPLE_LOCS` pattern other than the standard one for the sample count, so a title that rasterizes with its own pattern threw "nonstandard sample locations are unsupported". The registers give each sample's position as a signed 4-bit offset in 1/16 pixel from the pixel center. VK_EXT_sample_locations takes positions in [0, 1) of the pixel, so a register offset `x` is `0.5 + x / 16`. The console's standard 4x pattern maps exactly onto Vulkan's standard 4x positions this way, which checks both the scale and the direction of y. - A pattern that is the same for all four pixels of the quad becomes the pipeline's sample locations (a 1x1 grid). It is part of the pipeline key. Patterns that differ between the pixels still throw. - The device needs the extension with `variableSampleLocations`, 4 sub-pixel bits and a coordinate range covering 0 to 15/16, for the draw's sample count. Otherwise a draw with custom locations throws. Requiring variable locations means pipelines with different patterns can share a render pass. - A multisampled depth image is created with `SAMPLE_LOCATIONS_COMPATIBLE_DEPTH` when the device supports that for its format and sample count (`vkGetPhysicalDeviceImageFormatProperties` with the flag and the image's usage). A draw with custom locations whose depth target the device cannot make compatible throws. The depth image stays in `GENERAL` after creation, so no layout transition needs the locations. - A CB resolve does not depend on where the samples are, so it now accepts any quad-uniform pattern instead of only the standard one. - TechnicalDebt gets an entry. ### PPSA36082 Hades II rasterizes its 4x targets with an ordered grid: the `PA_SC_AA_SAMPLE_LOCS` words are `0x444cc4cc` for all four pixels, that is (±4, ±4)/16. On main f1451396 with the fixes it needs to get that far plus #419, it threw the error above while rendering (it showed up as a failed presentation). With this change, #2121 and #2132, the game renders those passes correctly in gameplay. On the RTX 4090 every depth format it supports is compatible at 1x to 8x, and the game ran into gameplay with this change with no refusals or skipped draws in the log. ### Tested Linux (CachyOS), x86-64, GCC, 7800X3D / RTX 4090. - `agc_driver_graphics` (new checks): - The game's 4x ordered grid decodes; 2x positions in another order decode; a pattern that differs between the quad's pixels is refused; the standard 4x pattern is not treated as custom. - An 8x pattern decodes from both register words of each pixel. - The console's standard 4x offsets convert to Vulkan's standard 4x positions; the extreme offsets convert to 0 and 15/16. - Depth compatibility on a stub device: no extension, a supported format and count, an unsupported count, a refused format, and a single-sample target. The query uses the flag and the usage the depth image is created with. - Mutations, each failing a check: y flipped, 1/8 pixel instead of 1/16, one register word per pixel, the format not queried, the format's sample counts ignored, the extension's sample counts ignored, single-sample allowed. - Not covered by a device test: the pipeline actually rasterizing at the custom positions. That part was checked in game. - The linux job of current `build.yml` run locally (SPIRV tools on, test registration check, build, libs, ctest), both on this head (468/468) and on it merged with main d70b8998 (517/518). #419 conflicts with main on one line of `Texture.hpp` since #1059 (both add a declaration there); for that merge I kept both. `agc_driver_dcc_keys_first_write` fails on main without this change too. ### Checklist - [x] Based on #419's head; 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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: #419 (its commits are included here until it merges) - [x] AI-assisted: yes
Raghav314 commented 2026-10-09 11:07:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Raghav314 on 2026-10-09T11:07:49Z.


Closing in favour of #2169, which implements the same thing and was opened first. I've left my Hades II results and a depth-format note there.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6079661570 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2183#issuecomment-6079661570). Originally posted by [Raghav314](https://github.com/Raghav314) on 2026-10-09T11:07:49Z. --- Closing in favour of #2169, which implements the same thing and was opened first. I've left my Hades II results and a depth-format note there.

Pull request closed

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!2183
No description provided.