Skip to content

test(agc): allocate the sparse heap import output in whole blocks - #23869

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
cocoa55:fix/sparse-heap-import-aligned-alloc
Nov 27, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
cocoa55:fix/sparse-heap-import-aligned-alloc

Conversation

@cocoa55

@cocoa55 cocoa55 commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

What

OutputBlock calls std::aligned_alloc(Block, bytes) with a 64 KiB alignment. The in-place store tests create a 256-byte source block, and aligned_alloc needs a size that is a multiple of the alignment. ASan rejects it (invalid-aligned-alloc-alignment, SparseHeapImport.cpp:60), so agc_driver_sparse_heap_import and agc_driver_sparse_heap_import_mirror stop before running. The allocation now rounds up to a whole block. The registered guest range keeps its requested size.

Tested

CachyOS, GCC 16, the sanitizer job's flags (ANYPS5_ENABLE_ASAN=ON, -fsanitize=undefined). Both tests failed on main 23786c4e4f and passed 5 of 5 runs each with this change, with and without ASan. CI's sanitizer job doesn't run this test, because ANYPS5_AGC_EXECUTION_TESTS limits it to three AGC tests.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file — n/a
  • 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 — n/a
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce GTX 1660, driver 615.78.08, Linux
  • AI-assisted: yes

🤖 Generated with Claude Code

aligned_alloc needs a size that is a multiple of its alignment. The source
block of the in-place store tests is 256 bytes with a 64 KiB alignment, so
ASan rejects the allocation and agc_driver_sparse_heap_import and its mirror
variant stop before running.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the agc libSceAgc* label Nov 19, 2026
@Colewiz7

Copy link
Copy Markdown
Contributor

Head de7a2ae662 merged onto main 23786c4e4f as c2298995d3, no conflict. Linux 7.3.4, GCC 16.2.1 Release, Mesa 26.2.6 RADV, RX 7900 XT (gfx1100) and 7800X3D iGPU (gfx1036).

No new failures and no new validation messages on either GPU.

RX 7900 XT iGPU
tests run (6299 on the 7900 XT, the 2028 GPU ones on the iGPU), new failures vs main none none
-R '^agc' (1960 tests) with the layer, new failures vs main none none
VUID- / SYNC-HAZARD lines 0 / 0 0 / 0

Layer runs used VK_LAYER_KHRONOS_validation 1.4.363.1 with VK_LOADER_DEBUG=layer and ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1; the loader inserted the layer in every run, and the set of distinct validation messages matches main.

AI-assisted: yes

@domx4q

domx4q commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Ran the two sparse heap import tests on NVIDIA's proprietary Linux driver with the Khronos validation layer; the description's GTX 1660 run names no validation-layer run.

Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release (no ASan), NVIDIA GeForce RTX 4090 (vendor 0x10de, device 0x2684, Ada), proprietary driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head de7a2ae662 merged onto main 34369467e4 with --no-ff, clean merge. Main baseline is a Release build of 34369467e4 on the same machine.

WAYLAND_DISPLAY=wayland-1 XDG_RUNTIME_DIR=/run/user/1000 DISPLAY=:0 ANYPS5_REQUIRE_DISPLAY=1 \
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
ctest --test-dir build -R '^agc_driver_sparse_heap_import' -V
main 34369467e4 this PR
Result 2/2 passed 2/2 passed
Insert instance layer "VK_LAYER_KHRONOS_validation" 2 2
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- none none

Both tests select the RTX 4090 and print sparse heap import tests passed. This is a non-ASan build, where glibc's aligned_alloc accepts the 256-byte size, so main passes too; the run only shows that the rounded-up output block does not change the Vulkan path. The ASan failure the PR fixes is not reproduced here.

No new VUID- errors; both focused tests pass on Ada.

AI-assisted: yes (Claude Code)

@kiwe147

kiwe147 commented Nov 21, 2026

Copy link
Copy Markdown

Tested head de7a2ae662, applied with git apply on main fd4aeed483 together with the other 29 PRs of one batch (#17478, #21223, #24030, #24201, #14202, #18889, #19531, #21641, #21773, #22468, #22471, #23239, #23255, #23484, #23992, #24311, #18425, #21195, #21255, #22989, #23507, #23886, #14582, #17878, #19666, #19899, #20138, #21656, #21746). All applied without conflicts and the whole tree built.

Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. GPUs: NVIDIA GeForce RTX 3080 (driver 621.24) and the AMD Radeon iGPU of the CPU (gfx1036, driver 32.0.21036.18). No validation layer. iGPU run: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_GPU="AMD Radeon", agc_/video tests only.

tests RTX 3080 iGPU
agc_driver_sparse_heap_import, agc_driver_sparse_heap_import_mirror, agc_host_import_sparse and 3 more (6 tests, matched by name to the test file this PR changes) 5 pass, 1 Skipped 5 pass, 1 Skipped

Not run here: agc_host_import_sparse reports Skipped on this Windows setup, so I could not confirm the new case. This run shows no regression elsewhere.

Whole batch: the full ctest -j 12 (6522 tests) on the RTX 3080 has 4 failing tests; the 4 that also fail on main fd4aeed483 are agc_driver_stencil_plane_memory, agc_driver_msaa_dcc_unwatch, agc_storage_write_back_host_retile, and pr_overlap_names, which needs a newer Python than my 3.10. Intermittent in this run (pass when rerun alone, or known flaky): agc_driver_store_over_untracked. The 2125 agc_/video tests on the iGPU have 2 failing: agc_driver_stencil_plane_memory, agc_driver_store_over_untracked (agc_driver_stencil_plane_memory also fails on main).

This is one combined tree, not a run of this PR alone.

AI-assisted: yes (Claude Code)

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

The allocation now rounds its size up to a multiple of the required alignment while registering the guest range at its requested size.

What I ran

Reviewed head de7a2ae662d122d20e2a5c42e1adf853465fc0f1. I read the prepared description, commits, manifest, diff, and the changed source file (lines 1–110). I did not run commands or tests.

Results

Check Result Note
Diff and source review passed One changed allocation expression
Tests not run No local test execution

Findings

Blocking

None.

Non-blocking

None.

Not verified

The manifest lists one changed file and marks it included; that file was read. The prepared files.json and alternate review/files/ path were unavailable through the reader, so I could not inspect excluded-file metadata. Reported test results in the PR description were not independently verified. No tests were run.

To get this to a good state

Nothing is required.

@Gonic0

Gonic0 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

macOS data point for de7a2ae662, and a second failure it uncovers there.

Apple M5 Pro, macOS 27.3, Apple clang, x86_64 Release under Rosetta 2. MoltenVK from Vulkan SDK 1.4.363.0 with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and VK_LOADER_DEBUG=layer. Tree: main 0538bc2ebf + #17425 + #11049 (needed to build on macOS, #24117), this pull request applied on top.

  • Without it, agc_driver_sparse_heap_import stops at sparse heap import: cannot allocate the output block: macOS's aligned_alloc returns null when the size is not a multiple of the alignment, so the 256-byte source block fails there even without ASan.
  • With it, the allocation succeeds, and the test then fails further on, in 2 of 2 runs: sparse heap import: a store into the grown part: heap word 0 is 0x0, expected 0x8000. The layer was inserted and logged no VUID- message.

So on macOS this pull request fixes what it says, and the remaining failure is a separate macOS issue in the in-place sparse heap import (#19553), not in this change. I'm looking into that one.

AI-assisted: yes (Claude Code)

@oneandonlydean
oneandonlydean merged commit b7d960b into boykopovar:main Nov 27, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants