Skip to content

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

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
simonbronk:feat/sample-location-grid
Oct 14, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
simonbronk:feat/sample-location-grid

Conversation

@simonbronk

Copy link
Copy Markdown
Contributor

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 5a6ad0e:
  • 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 Onimusha: Way of the Sword (PPSA27836) #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 Resident Evil Village (PPSA01556) #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 Onimusha: Way of the Sword (PPSA27836) #5769, PPSA01556 Resident Evil Village (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

…h a 2x2 grid

PA_SC_AA_SAMPLE_LOCS_PIXEL_* patterns that differ between the four pixels
of the guest's 2x2 grid threw. Pass them through VK_EXT_sample_locations
as a 2x2 sample location grid on devices whose maxSampleLocationGridSize
for the sample count allows it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adriadam10 adriadam10 self-assigned this Oct 14, 2026
@adriadam10

Copy link
Copy Markdown
Collaborator

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.

@github-actions github-actions Bot added docs agc libSceAgc* labels Oct 14, 2026
@adriadam10
adriadam10 merged commit 979ad7b into boykopovar:main Oct 14, 2026
9 checks passed
adriadam10 added a commit to adriadam10/AnyPS5 that referenced this pull request Oct 14, 2026
…a pipeline

boykopovar#5861 added both to the pipeline state and its store key; the recipe dropped them, so a
replayed pipeline keyed another configuration.

Co-Authored-By: Claude <noreply@anthropic.com>
@EagleBearerYS

Copy link
Copy Markdown
Contributor

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

JJenkx pushed a commit to JJenkx/AnyPS5 that referenced this pull request Oct 14, 2026
…a pipeline

boykopovar#5861 added both to the pipeline state and its store key; the recipe dropped them, so a
replayed pipeline keyed another configuration.

Co-Authored-By: Claude <noreply@anthropic.com>
JJenkx pushed a commit to JJenkx/AnyPS5 that referenced this pull request Oct 15, 2026
…a pipeline

boykopovar#5861 added both to the pipeline state and its store key; the recipe dropped them, so a
replayed pipeline keyed another configuration.

Co-Authored-By: Claude <noreply@anthropic.com>
JJenkx pushed a commit to JJenkx/AnyPS5 that referenced this pull request Oct 15, 2026
…a pipeline

boykopovar#5861 added both to the pipeline state and its store key; the recipe dropped them, so a
replayed pipeline keyed another configuration.

Co-Authored-By: Claude <noreply@anthropic.com>
adriadam10 added a commit to adriadam10/AnyPS5 that referenced this pull request Oct 15, 2026
…a pipeline

boykopovar#5861 added both to the pipeline state and its store key; the recipe dropped them, so a
replayed pipeline keyed another configuration.

Co-Authored-By: Claude <noreply@anthropic.com>
adriadam10 added a commit to adriadam10/AnyPS5 that referenced this pull request Oct 16, 2026
…a pipeline

boykopovar#5861 added both to the pipeline state and its store key; the recipe dropped them, so a
replayed pipeline keyed another configuration.

Co-Authored-By: Claude <noreply@anthropic.com>
adriadam10 added a commit to adriadam10/AnyPS5 that referenced this pull request Oct 16, 2026
…a pipeline

boykopovar#5861 added both to the pipeline state and its store key; the recipe dropped them, so a
replayed pipeline keyed another configuration.

Co-Authored-By: Claude <noreply@anthropic.com>
adriadam10 added a commit to adriadam10/AnyPS5 that referenced this pull request Oct 16, 2026
…a pipeline

boykopovar#5861 added both to the pipeline state and its store key; the recipe dropped them, so a
replayed pipeline keyed another configuration.

Co-Authored-By: Claude <noreply@anthropic.com>
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.

3 participants