feat(agc): rasterize sample locations that vary between pixels through a 2x2 grid #5861

Merged
simonbronk merged 1 commit from upstream-pr/5861 into main 2026-10-14 14:44:30 +00:00
simonbronk commented 2026-10-14 14:02:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-14T14:02:10Z.


What

Onimusha: Way of the Sword (PPSA27836) and Resident Evil Village (PPSA01556, #5169) render with two-sample checkerboard rendering. Their PA_SC_AA_SAMPLE_LOCS_PIXEL_* registers differ between the pixels of the guest's 2x2 grid:

PA_SC_AA_CONFIG 0x00108001 (2 samples)
X0Y0 0x00000c04  X1Y0 0x00000c04  X0Y1 0x0000040c  X1Y1 0x0000040c

That is samples at (+4, 0)/16 and (-4, 0)/16 on even rows, swapped on odd rows. decodeSampleLocations threw "nonstandard sample locations varying between pixels are unsupported".

VK_EXT_sample_locations takes such a pattern as a sample location grid. VkSampleLocationsInfoEXT indexes it as (x + y * width) * samplesPerPixel + i, which is the guest's register order (X0Y0, X1Y0, X0Y1, X1Y1). The draw state rule refuses a nonzero window offset, so the host framebuffer origin is the guest's and the grid lines up.

  • State keeps the locations of all four pixels (sampleLocations grows to 32 bytes, pixel * 8 + sample) and sets sampleLocationGrid when they differ. SampleLocationGrid gives 2x2 or 1x1, and SampleLocations fills the grid in Vulkan's order.
  • The pipeline creation and the render pass begin info pass the grid. The grid flag and its locations are part of the library, pipeline and draw keys.
  • The device records the sample counts whose VkMultisamplePropertiesEXT::maxSampleLocationGridSize is a multiple of 2x2 (sampleLocationGridSampleCounts). A pattern varying between pixels on any other sample count throws, naming the grid.
  • The limits in docs/dev/debt/libSceAgcDriver.md are updated.

The per-sample-count query matters: VkPhysicalDeviceSampleLocationsPropertiesEXT::maxSampleLocationGridSize on the RTX 5070 is 1x1, but vkGetPhysicalDeviceMultisamplePropertiesEXT gives 2x4 for 2 samples, 2x2 for 4 and 1x2 for 8. The AMD iGPU gives 2x2 for each. So both GPUs here take the checkerboard pattern.

Tested

  • Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, main 5a6ad0ed3:
    • full ctest -j 8 on the RTX 5070: 1183 of 1184 pass; check_main_sync fails on a Windows code page and is unrelated;
    • ctest -R "agc|shader|video_out" on the AMD iGPU: 551 of 554 pass; agc_driver_lds_mixed_width_atomics, agc_driver_pixel_interlock and agc_driver_layered_volume_vertex_no_gpl fail as listed in #5271 for this GPU.
  • agc_driver_graphics: the old refusal case (a standard 2x pattern with the samples swapped in one pixel) now decodes as a grid. The games' pattern decodes as a 2x2 grid with the locations in Vulkan's order. ValidateSampleLocations refuses it without grid support for 2 samples and accepts it with it. A uniform 4x pattern stays 1x1.
  • agc_pipeline_library (on the GPU): a grid pattern builds its own fragment shader and fragment output libraries, and the uniform pattern is reused afterwards. It passes on both GPUs.
  • PPSA27836 on Windows (RTX 5070), on a local branch with the fixes in #5769: the draw that threw now passes. The title then stops at the next part of the checkerboard rendering: "a color target's sample count differs from the rasterizer's" (two-sample rasterization into a one-sample target, the second approximation in #5169). That is not part of this change.
  • python tools/check_conventions.py --base upstream/main: passes.

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 — not applicable
  • 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 — not applicable
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: PPSA27836 #5769, PPSA01556 #5169 (one of its two checkerboard approximations)
  • GPUs tested: NVIDIA GeForce RTX 5070, driver 617.42 (32.0.16.1742); AMD Radeon(TM) Graphics, Ryzen iGPU gfx1036, driver 32.0.21036.18; both Windows 11 Pro 26200
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4859087187 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5861). Originally posted by [simonbronk](https://github.com/simonbronk) on 2026-10-14T14:02:10Z. --- ### What Onimusha: Way of the Sword (PPSA27836) and Resident Evil Village (PPSA01556, #5169) render with two-sample checkerboard rendering. Their `PA_SC_AA_SAMPLE_LOCS_PIXEL_*` registers differ between the pixels of the guest's 2x2 grid: ``` PA_SC_AA_CONFIG 0x00108001 (2 samples) X0Y0 0x00000c04 X1Y0 0x00000c04 X0Y1 0x0000040c X1Y1 0x0000040c ``` That is samples at (+4, 0)/16 and (-4, 0)/16 on even rows, swapped on odd rows. `decodeSampleLocations` threw "nonstandard sample locations varying between pixels are unsupported". VK_EXT_sample_locations takes such a pattern as a sample location grid. [`VkSampleLocationsInfoEXT`](https://docs.vulkan.org/refpages/latest/refpages/source/VkSampleLocationsInfoEXT.html) indexes it as `(x + y * width) * samplesPerPixel + i`, which is the guest's register order (X0Y0, X1Y0, X0Y1, X1Y1). The draw state rule refuses a nonzero window offset, so the host framebuffer origin is the guest's and the grid lines up. - `State` keeps the locations of all four pixels (`sampleLocations` grows to 32 bytes, pixel * 8 + sample) and sets `sampleLocationGrid` when they differ. `SampleLocationGrid` gives 2x2 or 1x1, and `SampleLocations` fills the grid in Vulkan's order. - The pipeline creation and the render pass begin info pass the grid. The grid flag and its locations are part of the library, pipeline and draw keys. - The device records the sample counts whose `VkMultisamplePropertiesEXT::maxSampleLocationGridSize` is a multiple of 2x2 (`sampleLocationGridSampleCounts`). A pattern varying between pixels on any other sample count throws, naming the grid. - The limits in `docs/dev/debt/libSceAgcDriver.md` are updated. The per-sample-count query matters: `VkPhysicalDeviceSampleLocationsPropertiesEXT::maxSampleLocationGridSize` on the RTX 5070 is 1x1, but `vkGetPhysicalDeviceMultisamplePropertiesEXT` gives 2x4 for 2 samples, 2x2 for 4 and 1x2 for 8. The AMD iGPU gives 2x2 for each. So both GPUs here take the checkerboard pattern. ### Tested - Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, `main` 5a6ad0ed3: - full `ctest -j 8` on the RTX 5070: 1183 of 1184 pass; `check_main_sync` fails on a Windows code page and is unrelated; - `ctest -R "agc|shader|video_out"` on the AMD iGPU: 551 of 554 pass; `agc_driver_lds_mixed_width_atomics`, `agc_driver_pixel_interlock` and `agc_driver_layered_volume_vertex_no_gpl` fail as listed in #5271 for this GPU. - `agc_driver_graphics`: the old refusal case (a standard 2x pattern with the samples swapped in one pixel) now decodes as a grid. The games' pattern decodes as a 2x2 grid with the locations in Vulkan's order. `ValidateSampleLocations` refuses it without grid support for 2 samples and accepts it with it. A uniform 4x pattern stays 1x1. - `agc_pipeline_library` (on the GPU): a grid pattern builds its own fragment shader and fragment output libraries, and the uniform pattern is reused afterwards. It passes on both GPUs. - PPSA27836 on Windows (RTX 5070), on a local branch with the fixes in #5769: the draw that threw now passes. The title then stops at the next part of the checkerboard rendering: "a color target's sample count differs from the rasterizer's" (two-sample rasterization into a one-sample target, the second approximation in #5169). That is not part of this change. - `python tools/check_conventions.py --base upstream/main`: passes. ### Checklist - [x] Based on current `main`; 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file — not applicable - [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 — not applicable - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: PPSA27836 #5769, PPSA01556 #5169 (one of its two checkerboard approximations) - [x] GPUs tested: NVIDIA GeForce RTX 5070, driver 617.42 (32.0.16.1742); AMD Radeon(TM) Graphics, Ryzen iGPU gfx1036, driver 32.0.21036.18; both Windows 11 Pro 26200 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
adriadam10 commented 2026-10-14 14:22:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T14:22:22Z.


Checked the decode against the register order and the Vulkan grid indexing ((x + y * width) * samplesPerPixel + i), the 2x2 divisibility of maxSampleLocationGridSize per sample count, the key changes (library, pipeline, draw) and the debt entry. agc_driver_graphics, the recorder and prepared graphics tests pass locally, and the new graphics test does not build without the change. Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6170592138 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5861#issuecomment-6170592138). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T14:22:22Z. --- Checked the decode against the register order and the Vulkan grid indexing (`(x + y * width) * samplesPerPixel + i`), the 2x2 divisibility of `maxSampleLocationGridSize` per sample count, the key changes (library, pipeline, draw) and the debt entry. `agc_driver_graphics`, the recorder and prepared graphics tests pass locally, and the new graphics test does not build without the change. Merging once the full Build is green.
EagleBearerYS commented 2026-10-14 18:56:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T18:56:15Z.


For the record, on an RTX 3070 Laptop GPU this check stops Resident Evil Village (PPSA01556, 01.210.000) during its title screen:

AGC graphics: sample locations varying between pixels require a 2x2 sample location grid for the draw's sample count

Windows 11 (10.0.26300), driver 617.42, main e34c47921. The draw uses 2 samples, and for that count this GPU doesn't report a sample location grid that's a multiple of 2x2. Before this PR, our older stack from 2026-10-13 stopped at the same point with "nonstandard sample locations varying between pixels are unsupported".

Village needs local changes to reach the title on this 16 GB PC: #5851, #5703, #5815's two commits, and local commits that prepare shaders at their first draw and fix title-stage stops. The run also carried an unrelated overlay branch. Locally we approximate by using pixel (0,0)'s locations for every pixel, a workaround that isn't for merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6175947353 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5861#issuecomment-6175947353). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-14T18:56:15Z. --- For the record, on an RTX 3070 Laptop GPU this check stops Resident Evil Village (PPSA01556, 01.210.000) during its title screen: ``` AGC graphics: sample locations varying between pixels require a 2x2 sample location grid for the draw's sample count ``` Windows 11 (10.0.26300), driver 617.42, `main` e34c47921. The draw uses 2 samples, and for that count this GPU doesn't report a sample location grid that's a multiple of 2x2. Before this PR, our older stack from 2026-10-13 stopped at the same point with "nonstandard sample locations varying between pixels are unsupported". Village needs local changes to reach the title on this 16 GB PC: #5851, #5703, #5815's two commits, and local commits that prepare shaders at their first draw and fix title-stage stops. The run also carried an unrelated overlay branch. Locally we approximate by using pixel (0,0)'s locations for every pixel, a workaround that isn't for merging.
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!5861
No description provided.