Skip to content

fix(agc): bind a V# of exactly the range limit within the limit - #7717

Merged
oneandonlydean merged 4 commits into
boykopovar:mainfrom
xXPBSXx:fix-agc-view-range-adjustment
Nov 2, 2026
Merged

oneandonlydean merged 4 commits into
boykopovar:mainfrom
xXPBSXx:fix-agc-view-range-adjustment

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What

Teardown (PPSA15246) stops with guest buffer view exceeds descriptor range limit from compute shader 0x1409cd300. A local print before the check in GuestBufferMemory::Descriptor shows why (lines 29-34 of the 71 lines of that run's stderr; main 5d9dcc42d plus the print; lines 32 and 34 are the SIGABRT output of the same abort):

[diag-td] address 2571b565c bytes ffffffff adjustment 12 range 10000000b limit ffffffff region 202000000-384000000 end 384000000 direct 0 mirror 0 cut 0
[gpu] driver failure: compute shader 0x1409cd300: AGC graphics: guest buffer view exceeds descriptor range limit

The V# size is exactly maxStorageBufferRange (0xffffffff), so the clamp that #5778 added in ShaderResources::addGuestBuffer (size past the limit) does not apply. The address is 12 bytes past a 16-byte offset-alignment boundary, so Descriptor binds from the alignment below and adds that 12 to the range (ViewBytes): 0x10000000b, one DWORD-rounded step over the limit, and it throws. The registered region behind the address is larger than the limit.

The debt entry for #5778 gets one sentence on this case. Descriptor now limits the range to maxStorageBufferRange rounded down to a DWORD when the V# itself fits the limit. A V# larger than the limit still reaches the existing check. What the console does for an access past the bound range is not known, as for #5778.

New viewAtRangeLimitTests binds a V# of exactly the limit 12 bytes into a registered block, with a second V# at the block start so that the view's region begins before it and the offset alignment is 16. It fails on main with guest buffer view exceeds descriptor range limit and passes with the change.

Tested

Windows 10 (19045), MinGW-w64, Release; the run below is from the earlier head e74c6abb4 on upstream/main 43797ca8a. The current head 4c615cbac4 has the same source and test hunks (compared by patch id) plus two debt-only commits; it merges cleanly with main 8b426927d7 and tools/check_conventions.py --base upstream/main passes on it. The test run was not repeated on it. ctest -R '^agc_driver_graphics$': passed (11.5 s). Without the one-line change, the same test fails with AGC graphics: guest buffer view exceeds descriptor range limit (0.66 s, run before the rebase onto 43797ca8a; the test file did not change with it). tools/check_conventions.py --base upstream/main: all checks passed. The test module runs against the mock Vulkan device; no GPU was used for the PASS. The title reproduction above ran on an NVIDIA GeForce RTX 4080 SUPER (Windows 10); Teardown (PPSA15246) with this change (e74c6abb4 on 43797ca8a, fresh libs, no input from me, played by hand from the menu into the first area): the run's stderr (160 lines) no longer contains exceeds descriptor range limit (0 matches, counted with Python). The run then stops at line 139 with driver failure: AGC driver: unsupported PM4 packet type: header 0x00000000 at DWORD 15 of 6369 (SIGABRT, lines 139-142); that is a separate stop and not part of this change. Measured by others on earlier heads: karimibrahim07 on Windows 11 (NVIDIA GeForce RTX 3060, driver 610.88) at head e74c6abb4: agc_driver_graphics passes 3 of 3 with the change and fails with GuestBufferMemory.cpp of main; savvaniss on Windows 11 (Intel UHD 770 and AMD Radeon RX 9070 XT) at head 76012a2bf: all 21 tests pass with the change, agc_driver_graphics fails without it on both. Linux/lavapipe not tested.

Checklist

AI-assisted (Claude Code).

🤖 Generated with Claude Code

@github-actions github-actions Bot added unblocks title Names a title ID on the Unblocks line docs agc libSceAgc* labels Oct 19, 2026
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1395 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4040 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5021 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 5925 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6186 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6194 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6223 docs/dev/debt/libSceAgcDriver.md
PR 6235 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6273 docs/dev/debt/libSceAgcDriver.md
PR 6280 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6300 docs/dev/debt/libSceAgcDriver.md
PR 6412 docs/dev/debt/libSceAgcDriver.md
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6548 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6808 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6918 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6970 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6977 docs/dev/debt/libSceAgcDriver.md
PR 7048 docs/dev/debt/libSceAgcDriver.md
PR 7256 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7410 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7449 docs/dev/debt/libSceAgcDriver.md
PR 7457 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7514 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7604 docs/dev/debt/libSceAgcDriver.md
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7978 docs/dev/debt/libSceAgcDriver.md
PR 8592 docs/dev/debt/libSceAgcDriver.md
PR 8707 docs/dev/debt/libSceAgcDriver.md
PR 9012 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 9020 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9335 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9356 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9387 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9432 docs/dev/debt/libSceAgcDriver.md
PR 9489 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9592 docs/dev/debt/libSceAgcDriver.md
PR 9712 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9852 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 9915 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9950 docs/dev/debt/libSceAgcDriver.md
PR 10025 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 10233 docs/dev/debt/libSceAgcDriver.md
PR 10256 docs/dev/debt/libSceAgcDriver.md
PR 10359 docs/dev/debt/libSceAgcDriver.md
PR 10442 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 11551 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 12120 docs/dev/debt/libSceAgcDriver.md
PR 12157 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 13148 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 14212 docs/dev/debt/libSceAgcDriver.md

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 19, 2026

@karimibrahim07 karimibrahim07 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.

Windows run of head e74c6abb4, merged onto main ccbd40240 together with #7669, #7670, #7709 and #7680 (each merge clean, built once). Windows 11 Pro (26300), Ryzen 5 3600, NVIDIA GeForce RTX 3060 (driver 610.88), WinLibs GCC 15.2.0 r7, Ninja Release.

  • agc_driver_graphics with viewAtRangeLimitTests passes, --repeat until-fail:3.
  • Negative control: with main's GuestBufferMemory.cpp it fails with AGC graphics: guest buffer view exceeds descriptor range limit, as in your description.

Code: ViewBytes(bytes, adjustment) adds the offset adjustment to the view, so a V# of exactly maxStorageBufferRange at an address off minStorageBufferOffsetAlignment always ended up past the limit and threw. Capping it at the limit rounded down to a DWORD fixes that. The cap only applies when bytes <= maxStorageBufferRange, so a V# over the limit still goes through the existing allocation-end and placeholder handling.

One wording point for the debt line: the cap applies to any V# whose size plus its adjustment passes the limit, not only one of exactly the limit. A V# a few bytes under the limit at an unaligned address also loses its last bytes. Something like "a V# within its offset adjustment of the limit" would describe what the code does. The test covers the exact-limit case, which is the Teardown one.

Not checked: a title. I don't have Teardown.

AI-assisted: yes. I ran the build, the test and the negative control above.

@xXPBSXx

xXPBSXx commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the Windows run and the negative control. You are right that the cap applies to any V# whose size plus its offset adjustment passes the limit, not only to one of exactly the limit. The debt line now says "a V# within its offset adjustment of the limit (for example exactly the limit)" (76012a2, documentation only; the code and the test are unchanged from 72abbb5, on which agc_driver_graphics passed on Windows 10, RTX 4080 SUPER).

AI-assisted: yes.

@savvaniss

Copy link
Copy Markdown
Contributor

Intel and AMD Windows data: with this PR's test changes, agc_driver_graphics fails on main and passes with the PR, on an Intel UHD 770 and an AMD RX 9070 XT.

Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built, ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, with VkCache emptied first. This head 76012a2bf merged into main 6b8228b2b. "Without" means only this PR's diff to tests/Graphics.cpp, applied to main 6b8228b2b.

Tests, ×3 UHD 770 RX 9070 XT
This head: the 21 tests built from tests/Graphics.cpp 21 of 21 pass 21 of 21 pass
Without agc_driver_graphics fails: guest buffer view exceeds descriptor range limit; the other 20 pass same

AI-assisted: yes (Claude Code)

xXPBSXx and others added 3 commits October 19, 2026 12:27
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ustment of the limit

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@xXPBSXx
xXPBSXx force-pushed the fix-agc-view-range-adjustment branch from 76012a2 to 4c615cb Compare October 19, 2026 10:35
@adriadam10 adriadam10 self-assigned this Oct 19, 2026
@xXPBSXx

xXPBSXx commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Title data point for this PR (data only).

Title: PPSA15246, 300 s per run through the runner, Windows 10 Pro 10.0.19045, WinLibs GCC 15.2.0, Release, relinker and all libs built from one tree. Baseline: upstream/main 50efb5c405. With the PR: the same main with 4c615cbac4 merged (a local merge, not pushed). The Selected GPU line of each .out names the card.

NVIDIA GeForce RTX 4080 SUPER (ANYPS5_GPU=4080, vendor=0x10de):

  • Baseline, run_120957.err lines 134-139: compute shader 0x1409cd300: AGC graphics: guest buffer view exceeds descriptor range limit, then SIGABRT.
  • With the PR, run_124109.err: that refusal does not occur. The run stops later, at AGC driver: unsupported PM4 packet type: header 0x00000000 at DWORD 15 of 6369 (lines 146 and 162), which this PR does not touch.

AMD Radeon RX 6400 (ANYPS5_GPU="RX 6400", vendor=0x1002, 4 GiB card, device-local heap 3227 MiB in the log):

  • Baseline, run_121237.err line 140, and with the PR, run_124555.err line 140: the same stop in the same shader, compute shader 0x1409cd300: AGC graphics: vkAllocateMemory buffer: allocation=5435817984 ... Vulkan result -13. On this card the PR changes nothing for this title.

One run per card and state. I did not look at the picture, and I did not run the PR's test on this machine for this comment.

Not run: other GPUs, other titles, the console.

AI-assisted (Claude Code).

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed unblocks title Names a title ID on the Unblocks line labels Oct 25, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 26, 2026
@xXPBSXx

xXPBSXx commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Merged main into the branch with a normal merge (no force push; the reviewed head 4c615cbac4 is an ancestor of the new head 7cdedf0256). The fix line in GuestBufferMemory.cpp is unchanged. The one conflict was in docs/dev/debt/libSceAgcDriver.md, where main added a neighboring entry; both entries are kept. tools/check_conventions.py --base upstream/main passes, and git diff --stat upstream/main...HEAD is the same three files as before. agc_driver_graphics passes on the merged head (Windows 10 Pro 10.0.19045; the test runs on the CPU and does not select a GPU).

AI-assisted (Claude Code).

@TechLevelZero

TechLevelZero commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head 7cdedf0 merged onto main e6f5730 · tested 2026-11-01 16:38 UTC · 21 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,429 passed · 6 failed (0 new, 3 also fail on main, 3 unstable on main) · 45 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 2,480 of 3,148 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (931 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.1 s, ⚠️ agc_driver_graphics_maps_fallback 31.9 s, ⚠️ agc_driver_graphics 30.6 s
Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 1 of the last 10 main runs
agc_submit_progress: failed in 6 of the last 10 main runs
agc_submit_progress_no_timeline: failed in 8 of the last 10 main runs
Failing on main too (3, not counted against this PR)
agc_driver_image_table
guest_mmap_executable
guest_socket_options_multicast
Validation IDs already present on main (5 IDs in 484 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (484 tests): agc_driver, agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, agc_driver_bda_anchor_reads, agc_driver_bda_span_reads, and 476 more
VUID-vkCmdCopyImage-srcImage-01548 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-vkCmdCopyImage-srcImage-01551 (7 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (1 test): agc_driver_prepared_exports
VUID-VkShaderModuleCreateInfo-pCode-08737 (1 test): agc_driver_image_sample_derivatives
Skipped (45)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_sample_order_grid_reference: skipped, the device does not keep depth drawn at custom sample locations at those locations, even after a transition that names them: the composite of uniform renders holds the guest's depth in 0 of 3005 sloped samples, so no path can be compared with it bit for bit
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip_in_order: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_dcc: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_deferred: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_main: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_fps_limit: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_o
Reproduce
git fetch origin 7cdedf02560213f335794e23c2aebeb74ddcee83 e6f57307fa7f47165d7fc1bee945abdb2f6816e7
git checkout e6f57307fa7f47165d7fc1bee945abdb2f6816e7 && git merge --no-ff 7cdedf02560213f335794e23c2aebeb74ddcee83
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@oneandonlydean oneandonlydean self-assigned this Nov 2, 2026
@oneandonlydean
oneandonlydean merged commit 8ea18de into boykopovar:main Nov 2, 2026
10 checks passed
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.

6 participants