Skip to content

fix(agc): a 0xffffffff register offset names no register - #16054

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
stuart-russell:fix/agc-register-offset-sentinel
Nov 25, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
stuart-russell:fix/agc-register-offset-sentinel

Conversation

@stuart-russell

@stuart-russell stuart-russell commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What

A SET_*_REG/SET_*_REG_INDIRECT packet whose register offset is 0xffffffff names no register; the hardware accepts the packet and the remaining entries still take effect. The driver threw (indirect register sentinel semantics are not implemented), which aborted the whole submission.

registerOffset now returns an empty optional for 0xffffffff, and the four call sites (validation range check, the direct SET_*_REG write loop, the indirect pair loop and the indirect trace) skip that entry instead of writing it. APS5_PM4_RING dumps of such packets still list the other offsets.

IndirectRegistersValid still classifies a list holding the sentinel as invalid, so the re-read-at-execution path and the released reports that depend on it are unchanged; the sentinel entry is skipped when either copy is written, so both copies behave the same.

The packets that carry a byte offset are SET_CONTEXT_REG (0x69), SET_SH_REG (0x76), SET_UCONFIG_REG (0x79) and their indirect forms. SET_UCONFIG_REG_INDEX (0x7a) selects a bank and index rather than a byte offset and still rejects 0xffffffff.

Part of the split of #10420; independent of #10779 and #16053.

References

The context register space ends below 0x4000, so 0xffffffff cannot name a register; the packet is accepted, not rejected. docs/dev/debt/libSceAgcDriver.md records the SET_*_REG_INDIRECT read timing for the entries that are genuinely invalid (bits 16-27 set). Measurement: the title trace that motivated the series contains SET_CONTEXT_REG packets carrying this offset, and before the change the submission threw.

Tested

agc_driver_pm4 (18 tests) and agc_driver_graphics pass, and tools/check_conventions.py --base origin/main passes, on d23df92b38. The register tests now execute such a packet and check that the neighbouring entries land while the sentinel entry writes nothing, instead of expecting a failure.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R 'agc_driver_(pm4|graphics)' -V passes with no VUID- lines and without the "was not found but was requested by env var VK_INSTANCE_LAYERS" message. This machine has no Vulkan device, so that run covers the decode path only.

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
  • 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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: the branch's Linux test machine has no Vulkan device
  • AI-assisted: yes

@oneandonlydean oneandonlydean self-assigned this Nov 5, 2026
@JJenkx

JJenkx commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Windows check of head b8aa165dd1, merged onto main 4180951e90 (551b55ddb1, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release, with ANYPS5_REQUIRE_VULKAN=1 and Vulkan validation layers enabled. The hosted Windows check does not run these tests on pull requests.

  • agc_driver_pm4_failure, agc_driver_pm4_failure_inline, agc_driver_pm4_rewind_trace pass in 3 of 3 runs, none skipped (no Vulkan instance created).

AI-assisted: yes.

@github-actions github-actions Bot added the agc libSceAgc* label Nov 5, 2026
@adam25136

adam25136 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Windows run of the full selection, including its GPU tests: head b8aa165dd1 merged into main d23df92b38 (git merge --no-ff, clean merge). The description's machine has no Vulkan device, and JJenkx's Windows check above ran three tests that create no Vulkan instance.

GPU NVIDIA GeForce RTX 5080 (10de:2c02), driver 621.14 (32.0.16.2114), Vulkan 1.4.357
Host Windows 10 Pro 22H2 (19045), i9-12900KF, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON
Selection 2,338 tests, chosen by tools/select_tests.py select for the 2 changed files
Run select_tests.py ctest build --parallel 4 --timeout 120 with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1; main d23df92b38 ran its full suite (4,198 tests) the same way on this machine
Result 2,324 passed, 12 skipped, 2 failed, 0 new
Validation The 1,289 agc_* tests of the selection that ran, again with VK_LAYER_KHRONOS_validation 1.4.367 (the Khronos nightly built from 3baa2b8), ctest -V --parallel 4, implicit layers disabled; main ran its 1,364 the same way. This change logs the same 151 messages in the same 23 tests as main, and no ID that main doesn't have for the same test

No title was run.

Edited: these tests create no Vulkan device, so "pass on the GPU" was wrong for them, and the GPU tests are only a regression check here.

AI-assisted: yes. Claude Code ran the builds and tests and drafted this comment; a separate review agent checked it. The numbers are from the runs on this machine.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head b8aa165 merged onto main 080dbd0 · tested 2026-11-05 18:03 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,880 passed · 5 failed (0 new, 3 also fail on main, 2 unstable on main) · 52 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,937 of 4,077 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 (970 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.4 s
Unstable on main (2, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 2 of the last 10 main runs
agc_submit_progress: failed in 1 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
Passed on retry (1, failed in the parallel run, passed when re-run with a 360 s timeout; not counted against this PR)
agc_driver_submit_progress: Failed in the parallel run; also passed only on retry in 10 other runs in the last 7 days
Validation IDs already present on main (9 IDs in 588 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (588 tests): agc_compute_pipeline_replay, agc_driver, agc_driver_address_draw_space_reuse, agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, and 580 more
VUID-VkShaderModuleCreateInfo-pCode-08737 (14 tests): agc_driver_dpp16_operands, agc_driver_dpp8_pk_fmac, agc_driver_dx10_clamp, agc_driver_f16_fma_denormal_modes, agc_driver_f16_fma_invalid_nan, agc_driver_float16_fma_rounding, agc_driver_float16_modifiers, agc_driver_float16_native, and 6 more
VUID-VkShaderModuleCreateInfo-pCode-08739 (14 tests): agc_driver_dpp16_operands, agc_driver_dpp8_pk_fmac, agc_driver_dx10_clamp, agc_driver_f16_fma_denormal_modes, agc_driver_f16_fma_invalid_nan, agc_driver_float16_fma_rounding, agc_driver_float16_modifiers, agc_driver_float16_native, and 6 more
VUID-VkShaderModuleCreateInfo-pCode-08741 (14 tests): agc_driver_dpp16_operands, agc_driver_dpp8_pk_fmac, agc_driver_dx10_clamp, agc_driver_f16_fma_denormal_modes, agc_driver_f16_fma_invalid_nan, agc_driver_float16_fma_rounding, agc_driver_float16_modifiers, agc_driver_float16_native, and 6 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-VkPipelineShaderStageCreateInfo-module-parameter (1 test): agc_driver_float16_unused_nan_payloads
VUID-VkPipelineShaderStageCreateInfo-pSpecializationInfo-06849 (1 test): agc_driver_float16_unused_nan_payloads
Skipped (52)
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_gcn_display_present: skipped, no display: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
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_driver_vertex_elected_atomic_max: skipped, the device runs vertex programs in subgroups, so they keep their cross-lane reductions
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
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_device_capability: 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_host_resolution_disabled: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_four_k: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_height_only: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_limit: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_malformed: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_host_resolution_width_only: 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 
Reproduce
git fetch origin b8aa165dd13584b9bbdd2adbd1bba56b9b4b2e1c 080dbd08c6f83be5a1768af7d3342d701bf34d21
git checkout 080dbd08c6f83be5a1768af7d3342d701bf34d21 && git merge --no-ff b8aa165dd13584b9bbdd2adbd1bba56b9b4b2e1c
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.

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 18914 core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp L534-540

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 6186 core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
PR 12944 core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
PR 15136 core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
PR 21059 core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
PR 22434 core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
PR 22546 core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
PR 22647 core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
PR 23188 core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
core/libs/prx/libSceAgcDriver/tests/Pm4.cpp

@Jirka135

Copy link
Copy Markdown
Contributor

Reviewed a 0xffffffff register offset names no register — no blocking findings

The change is correct for the four call sites it touches, but IndirectRegistersValid still calls the sentinel invalid, so the real indirect path, the dispatch-ahead scan and the debt entry still classify it as invalid.

What I ran

Head reviewed: b8aa165dd13584b9bbdd2adbd1bba56b9b4b2e1c (base main). I read the description, the thread, the single commit, the diff, and at head: registerOffset, Validate, Execute, ExecuteIndirectRegisters, IndirectRegistersValid (all Execution/src/Pm4.cpp), every caller of the last two (Driver/Packets/PacketExecution.cpp, Driver/Dispatch/DispatchAhead.cpp), the tests, and docs/dev/debt/libSceAgcDriver.md / docs/dev/ENVIRONMENT.md.

No build or test was run here; this review is from reading the code only. The test results in the description are the author's; the Windows runs (JJenkx, adam25136) and the NVIDIA CI run (TechLevelZero) in the thread are theirs. I reproduced none of them.

Results

Check Result Note
registerOffset callers (Pm4.cpp:494, 1018, 1022, 1029, 1191) handle nullopt passed All five skip or ignore it; none dereferences unchecked (the fifth, :1018, is the (void) pre-check loop, which is why the description counts four)
Offset arithmetic overflow passed Non-sentinel offsets are <= 0xffff; Validate bounds size - 2 <= 0x10000 - offset (:495, no underflow), so *offset + (i - 2) (:1192) stays <= 0xffff and cannot wrap uint32
Only 0xffffffff becomes "no register" passed 0x7fffffff etc. mask to > 0xffff and still throw (:95-99)
New tests fail without the fix passed (by reasoning) Old registerOffset threw for both new inputs
Real indirect path exercised by tests not covered See Non-blocking 1

Findings

Blocking

None.

Non-blocking

  1. IndirectRegistersValid was not updated and still rejects 0xffffffff (Pm4.cpp:1007; the test at tests/Pm4.cpp:1190 asserts it). Its callers therefore still treat the sentinel as invalid. In PacketExecution.cpp:570-589 a list holding it takes the else branch: landPendingWaits, recordQueuedLabelsBeforeRead, a re-read of the list, and a one-time stderr report naming it as an invalid entry. In DispatchAhead.cpp:234 the scan breaks at such a packet, ending the look-ahead. Both end up executing correctly (the else branch calls ExecuteIndirectRegisters, which now skips the entry), but at a synchronisation cost and with a misleading message. Is the sentinel meant to stay "invalid" for these two callers? If not, drop it from IndirectRegistersValid.
  2. The debt entry docs/dev/debt/libSceAgcDriver.md:247 still says a copy holding the sentinel throws unless APS5_SKIP_INVALID_INDIRECT_REGISTERS=1; after this PR it is skipped regardless of the variable, so that entry is stale. docs/dev/ENVIRONMENT.md:442 is still right for other invalid entries but no longer needs to cover the sentinel.
  3. SET_UCONFIG_REG_INDEX (0x7a) with 0xffffffff is still rejected by Validate (Pm4.cpp:493: packet[1] must be one of the two allowed special values) before registerOffset runs. The description says SET_*_REG; the new direct test uses 0x69 only (tests/Pm4.cpp, the 0xffffffffu, 52, 53 packet).
  4. The indirect test (tests/Pm4.cpp:141-143) goes through execute() to Execute and does not run PacketExecution, so non-blocking 1 is untested. The all-sentinel list and an empty-after-skip list are also not covered.

Not verified

  • Hardware behaviour of the sentinel on a console (the description's title trace is not available to me).
  • Any run on a GPU or AMD driver.
  • Whether 0xffffffff in an 0x7a packet occurs in practice.

To get this to a good state

Nothing is required. Worth deciding: the IndirectRegistersValid question (1) and refreshing the debt and ENVIRONMENT text (2).

AI-assisted: yes (code read with Claude Code; no build or test run).

@stuart-russell
stuart-russell force-pushed the fix/agc-register-offset-sentinel branch from b8aa165 to d9ecc0d Compare November 12, 2026 21:33
@stuart-russell

Copy link
Copy Markdown
Contributor Author

Thanks — all four points were useful, and 1 and 2 were real gaps rather than style.

1. IndirectRegistersValid now treats the sentinel as a valid entry: it continues on 0xffffffff and only rejects offsets with bits 16-27 set. A list holding the sentinel therefore takes the normal path in PacketExecution instead of the re-read-at-execution branch with the "invalid entry" report, and DispatchAhead no longer breaks its scan on it. ExecuteIndirectRegisters still skips the entry, so behaviour at the worker is unchanged; the cost Jirka described is gone. The existing assertion at tests/Pm4.cpp:1196 is inverted to match.

2. Debt row refreshed: SET_*_REG_INDIRECT no longer lists the sentinel among the "not a register offset" entries; it now says an entry of 0xffffffff names no register and is skipped wherever the list is read, separately from the bits-16-27 case that still triggers the re-read and still needs APS5_SKIP_INVALID_INDIRECT_REGISTERS. docs/dev/ENVIRONMENT.md did not name the sentinel, so it is unchanged and still correct for the other entries.

3. Scope corrected in the description: the packets that carry a byte offset are SET_CONTEXT_REG (0x69), SET_SH_REG (0x76), SET_UCONFIG_REG (0x79) and their indirect forms. SET_UCONFIG_REG_INDEX (0x7a) selects a bank and index rather than a byte offset, Validate rejects 0xffffffff there before registerOffset runs, and that behaviour is unchanged.

4. Not covered, deliberately: I tried adding a sentinel-first list and an all-sentinel list to testRegisters, but through execute() the list is read with ReadIndirectRegisters and the write did not land where the case expected; rather than encode a test I do not understand, I left it out. A test that exercises PacketExecution's fast path would need the submission harness (testPartlyUpdatedRegisterListSkipsOnlyItsInvalidEntries shape), and that is the honest way to cover point 1's behaviour change. Say if you want it in this PR or as a follow-up.

agc_driver_pm4, agc_driver_graphics and agc_gcn_color_target pass on the force-pushed head d9ecc0de7d, conventions clean.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 14, 2026
@stuart-russell
stuart-russell force-pushed the fix/agc-register-offset-sentinel branch from 5268741 to 5ff533d Compare November 14, 2026 22:12
@stuart-russell

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (ee25ae607b) so the branch is linear again, which resolves the conflict main had with it. The merge you pushed kept both debt entries; that is preserved: the SET_*_REG_INDIRECT entry carries this PR's wording (sentinel skipped, bits 16-27 still the invalid case) and the shader float-mode entry is main's text unchanged.

Verified on the rebased head: agc_driver_pm4, agc_driver_graphics and agc_gcn_color_target pass (35 tests), conventions clean.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 14, 2026
@domx4q

domx4q commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

NVIDIA Linux run with the Khronos validation layer of the PM4 register-offset sentinel change, on the tests from the Tested section.

Setup: Arch Linux, kernel 7.3.4, GCC 16.2.1, Release. 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 5ff533d581 merged onto main e4caa07950 (clean merge); main is a separate Release build of e4caa07950 on the same machine.

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_(pm4|graphics)' -V
main e4caa07950 this PR
Result 34/34 passed 34/34 passed
Insert instance layer "VK_LAYER_KHRONOS_validation" 6 (in 3 tests) 6 (in 3 tests)
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- 0 0

Every device test selected the RTX 4090 (Selected GPU name=NVIDIA GeForce RTX 4090 / loader Using "NVIDIA GeForce RTX 4090"), none fell back to llvmpipe.

The other tests in the set are host-only and create no Vulkan instance.

No new VUID- errors; all 34 focused tests pass on Ada, same as main.

AI-assisted: yes (Claude Code)

@stuart-russell
stuart-russell force-pushed the fix/agc-register-offset-sentinel branch 2 times, most recently from e42d541 to 1688b10 Compare November 16, 2026 22:07
@stuart-russell

Copy link
Copy Markdown
Contributor Author

Thanks @domx4q — 34/34 on both sides, the layer inserted in 3 tests on each, and zero VUID- on Ada is exactly the confirmation this needed after the Windows and AMD runs.

Two housekeeping changes on the new head 1688b10918:

  • The debt change now goes through the fragment workflow rather than editing docs/dev/debt/libSceAgcDriver.md directly: docs/dev/debt/changes/fix-agc-register-offset-sentinel.md carries a ## change [SET_*_REG_INDIRECT] entry, and the debt file itself is untouched. python3 tools/debt_fold.py --check and the conventions check pass.
  • The branch is still linear on ee25ae607b and merges cleanly with main f8d3890240; only Pm4.cpp, its tests and the fragment are in the diff.

@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 — no blocking findings

Head 1688b109186059ffdc464d2404e61009f5291af6 shows no verified defect in the sentinel handling, but the author's test run cites another commit, so no formal approval is given. Nothing blocks this; the points below are optional.

What I ran

  • Head reviewed: 1688b109186059ffdc464d2404e61009f5291af6, base main.
  • Read the description, commit list, manifest and diff from the review folder.
  • Read the head of the callers in core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp (lines 578–608) and the other IndirectRegistersValid call sites by search.
  • No build and no tests were run.

Results

Check Result Note
Diff read (3 files) passed Full diff read
Full text of changed files not run Only the changed hunks and search hits were read
Unit tests (agc_driver_pm4, agc_driver_graphics) not run Author reports a run on d23df92b38, not on this head
check_conventions.py not run Author reports a pass on d23df92b38

Findings

Blocking

None.

Non-blocking

  • docs/dev/debt/changes/fix-agc-register-offset-sentinel.md:1: the checklist says no .md notes were added and that the change is generic, not specific to one title. The new file names a title ID and a game (PPSA23566, UFC 6). If this file is the expected technical-debt record format, the checklist should say so; otherwise the title reference could be dropped.
  • core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp:71 (the direct 0x69/0x76/0x79 path): a direct packet whose offset is 0xffffffff now writes nothing, including its value dwords. The description's "the remaining entries still take effect" reads as referring to indirect list entries. The code and the new test agree on the whole-packet skip; the description could say so to avoid doubt.

Not verified

  • The author's tests and convention check ran on d23df92b38, not on head 1688b109186059ffdc464d2404e61009f5291af6. They were not re-run here.
  • The hardware claims in the debt note (how the console's graphics PFP reads a register list written after submission, and the PPSA23566 behaviour) were not checked. They depend on hardware and traces that were not available here.
  • Submission.cpp was checked only at its call to IndirectRegistersValid (line 434), not in full.
  • The full text of Pm4.cpp and tests/Pm4.cpp was not read; the review covers the changed hunks and the call sites found by search.
  • registerOffset for 0x7a (SET_UCONFIG_REG_INDEX) is still rejected by the bank check before registerOffset is reached; this was read from the diff context, not from an executed test.

To get this to a good state

Nothing is required.

Optional, before merge:

  • Confirm the title reference and the "no notes added" checklist item in the debt note.
  • Re-run agc_driver_pm4 and agc_driver_graphics on the current head 1688b109186059ffdc464d2404e61009f5291af6 and record the output in the PR, since the cited run is on another commit.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@stuart-russell on current main this head fails agc_driver_prepared_shaders, _indirect, _uncached and _debug, the same way on a rerun: "prepared invocation rebuilt an unchanged materialized result". The other 19 PRs in that batch pass these tests, and base plus this PR alone fails them, so the change in Pm4.cpp seems to make an unchanged prepared invocation get rebuilt (the test takes 17 s instead of 1 s). Could you check how the 0xffffffff offset change interacts with the prepared invocation cache? I have held the PR out of the merge trains until these four tests pass with it.

A SET_*_REG packet or indirect register list with a 0xffffffff offset is accepted by the hardware and the rest of the packet still takes effect. The driver threw and lost the submission. registerOffset now reports the sentinel through an optional, and the validation range check, the direct write loop, the indirect pair loop and the indirect trace skip that entry.
@stuart-russell
stuart-russell force-pushed the fix/agc-register-offset-sentinel branch from 1688b10 to 14aba68 Compare November 19, 2026 14:19
@stuart-russell

Copy link
Copy Markdown
Contributor Author

You were right, and the cause was mine: IndirectRegistersValid was the culprit, not the sentinel decode itself.

In 1688b10918 (following a code review) I changed IndirectRegistersValid to treat 0xffffffff as a valid entry. That function also decides whether a submitted SET_*_REG_INDIRECT list takes the "re-read it where the packet executes" path, and that path is what agc_driver_prepared_shaders* exercises — an indirect register list the worker reads again was reported as fully scanned is exactly the assertion that flipped. The 17 s runtime was the same re-read work moving out of the path the tests expect.

Fix in 14aba68c24: IndirectRegistersValid is back to treating the sentinel as invalid, so the re-read heuristic, its reports and the dispatch look-ahead are untouched. The sentinel still names no register where it matters: registerOffset returns an empty optional and both the direct write loop and the indirect write loop skip that entry, including the copy read again at the packet. The debt fragment says that now instead of the earlier claim.

Verified locally on this head (14aba68c24, main at 6db6a3e927): agc_driver_prepared_shaders, _indirect, _uncached, _debug and the agc_driver_pm4*, agc_driver_graphics and agc_gcn_color_target suites — 62 tests, all pass; conventions clean.

Thanks for holding it out of the merge trains rather than merging it; that would have been a nasty one to bisect later.

@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

Nothing blocks this change; the inspected implementation and regression coverage support merging.

What I ran

  • Reviewed head 14aba68c24b9a2f40af7cc06eaab0341eb6a8782 against base main using the prepared diff and repo_read.py.
  • No tests or builds were run.

Results

Check Result Note
Changed code review passed All changed files and added lines reviewed
Tests and build not run No commands run

Findings

Blocking

None.

Non-blocking

None.

Not verified

  • Runtime behavior, tests, build, and hardware behavior were not verified.
  • Read: core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp, core/libs/prx/libSceAgcDriver/tests/Pm4.cpp, and docs/dev/debt/changes/fix-agc-register-offset-sentinel.md; all are listed as reviewed in the manifest. No changed files were excluded.

To get this to a good state

Nothing is required.

@kiwe147

kiwe147 commented Nov 21, 2026

Copy link
Copy Markdown

Tested head 14aba68c24, applied with git apply on main fd4aeed483 together with the other 25 PRs of one batch (#24107, #24132, #24238, #15143, #22088, #22685, #23739, #24032, #20001, #20344, #24170, #24396, #16856, #17298, #20497, #23347, #24426, #24554, #24598, #21376, #21556, #22047, #22082, #14124, #18476). 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_pm4, agc_driver_pm4_failure, agc_driver_pm4_replay and 3 more (6 tests, matched by name to the test file this PR changes) all pass all pass

Whole batch: the full ctest -j 12 (6524 tests) on the RTX 3080 has 8 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. Traced to other PRs of the batch, each by reverting it and testing again: #21556 (guest_json_allocator), #16856 (guest_kernel_sys_module_internal), #15143 (guest_math_exact); none is in this PR's area. Failing tests I could not trace to a single PR (reverting the likely candidates did not clear them): public_headers. The 2127 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)

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.

9 participants