Skip to content

fix(agc): recapture and skip refused draws on the draw finisher - #15455

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
Nesyth:fix/agc-draw-finisher-gaps
Nov 12, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
Nesyth:fix/agc-draw-finisher-gaps

Conversation

@Nesyth

@Nesyth Nesyth commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

What

A draw finished on the draw finisher (APS5_DRAW_PIPELINE, #6946) handled two cases differently from the same draw finished on queue 0's worker. The capture check before the hand-off to the committer (capturedMemoryChanged) ran only on the worker, since its redo replays the draw from the worker's queue state. So a draw whose captured memory changed before that point was recorded with the old capture. With APS5_SKIP_REFUSED_DRAWS=1, a draw refused on the finisher stopped the driver instead of being skipped. The finisher now runs the check too, and on a change it captures the draw's stages again from the tail it already holds. A refused draw is reported and skipped as on the worker.

Tested

Windows 11 Pro 26300, Radeon RX 7900 XTX (AMD Software 26.10.1), Ryzen 7 7800X3D, Release, MinGW-w64 GCC 15.2.

agc_driver_draw_recapture_on_change_finisher and agc_driver_draw_unsupported_buffer_type_skip_refused_finisher run the two existing tests with the finisher on. Removing the finisher's check, the restart before the second pass or the refused-draw catch makes the matching test fail.

  • The ^agc_ suite, 1290 tests, has the same two failures as main (agc_driver_direct_write_completion, agc_driver_sample_order_grid_reference). This holds with the finisher off and with APS5_DRAW_PIPELINE=1 set for every test.
  • The focused draw tests with the validation layer: 175 on main and 177 on this branch (the two finisher variants) pass. Both report the same 6 lines of VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 and no missing layer.

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: AMD Radeon RX 7900 XTX, AMD Software 26.10.1 (32.0.32015.7029), Windows 11 Pro 26300
  • AI-assisted: yes

@github-actions github-actions Bot added build agc libSceAgc* labels Nov 3, 2026
@Nesyth
Nesyth marked this pull request as ready for review November 3, 2026 17:45
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Hi Nesyth,

Three points on 6e2c50b26e, from two independent reviews. The first one blocks; the other two are questions.

  1. Draw offsets are applied twice on a finisher retry. For a direct draw, finishDraw calls FoldDrawOffsets before the capture-change check, and that adds the vertex-offset SGPR to firstVertex. restartFinishedDraw resets the capture and stage state but keeps the already folded drawParameters, so the recursive finishDraw adds the same offset again. For example, a packet firstVertex of 5 with a shader offset of 7 becomes 12 on the first pass and 19 on the retry, where it should stay 12. A large offset can also trip a false overflow. The worker path doesn't hit this because it goes back through ResolveDraw. Could you rebuild the retry from the original resolved parameters, and add a finisher regression that combines the descriptor-change case with a shader using a nonzero vertex-offset SGPR? It should check the rendered result against an unchanged control and require exactly one recapture. The current zero-to-valid descriptor test exercises recapture, but not that offsets are applied once.

  2. Program bytes on the retry. restartFinishedDraw starts the second pass from AppendProgramMemory(tail.memory, programs), so it reuses the first pass's program snapshots and their captured bytes, and capturedMemoryChanged returns false while RecaptureScope is active. If the memory that changed is a program's own header or code region, the second pass would be built from the old bytes with nothing to flag it. The worker's redo calls draw again from the packet. Does that rebuild programs from guest memory? If so, could the finisher test also cover a change to such a region, or could you say why that region can't differ between the two passes?

  3. Skip count. In the finisher's new catch (const RefusedDraw&), the worker path calls countSkip(Graphics::DrawSkip::Thrown) before ReportRefusedDraw, and the finisher path doesn't. Should a refused draw on the finisher be counted as skipped the same way?

#15456 sits directly on this branch, so it picks up whatever changes here.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head 6e2c50b merged onto main 4f41f4c · tested 2026-11-03 18:32 UTC · 27 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,761 passed · 6 failed (0 new, 3 also fail on main, 3 unstable on main) · 48 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,815 of 3,811 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 (932 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.1 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 4 of the last 10 main runs
agc_driver_submit_progress: failed in 5 of the last 10 main runs
agc_submit_progress: failed in 6 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 (4 IDs in 517 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (517 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 509 more
VUID-vkCmdCopyImage-srcImage-01548 (9 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, agc_driver_stencil_null_feedback, and 1 more
VUID-vkCmdCopyImage-srcImage-01551 (9 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, agc_driver_stencil_null_feedback, and 1 more
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (1 test): agc_driver_srgb8_color_target
Skipped (48)
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_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_stencil_ref_export: skipped, the device lacks VK_EXT_shader_stencil_export
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 co
Reproduce
git fetch origin 6e2c50b26e121e53b5ffaa7ae72f69cbb551dcad 4f41f4c375f5abb487dbd184fbc150f31994d762
git checkout 4f41f4c375f5abb487dbd184fbc150f31994d762 && git merge --no-ff 6e2c50b26e121e53b5ffaa7ae72f69cbb551dcad
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.

@Nesyth

Nesyth commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

@oneandonlydean Thanks. The first two are fixed in 07ca4e1; the third needs no change.

Offsets on a finisher retry. The tail now keeps the parameters from Pm4::ResolveDraw, and restartFinishedDraw restores them, so the retry folds the vertex offset once from the original values. The new case in DrawRecaptureOnChange.cpp registers a vertex program whose header carries the vertex buffer and attribute tables, so its s16 fetch add is folded into firstVertex (s16 = 3, GE_INDX_OFFSET = 5). The program stores the vertex index it saw. A control draw with the V# unchanged writes slots 8 to 10, which proves one fold. The same draw with its V# moved by the capture-check hook must be checked on the finisher, be prepared again exactly once and write the same slots. Without the restore it writes slots 11 to 13 and fails.

Program bytes on the retry. The worker's redo decodes again from the packet. A registered program keeps the registry's snapshot there, and an unregistered one is read again by ReadRawShader, which drops its cached copy once the bytes differ. The finisher retry now does the same: when a program's code or header no longer matches guest memory, it takes the snapshot again through ProgramSnapshot into the tail's own program copy, and notes a raw snapshot as the decode does. A registered program therefore stays as the worker would draw it. A second new case draws an unregistered copy of the vertex program and patches one instruction in the check seam, so only the new code puts the triangle on screen. On the finisher it fails without the re-take (the old code ran, one retry) and passes with it. It also passes inline and in the default mode.

Skip count. The worker's countSkip is a local of the packet loop that feeds Graphics::CountDrawSkip only under APS5_PROFILE_DRAW, and a profiled run never hands a draw to the finisher (the hand-off requires !profile). The finisher's catch therefore has nothing to count, so I left it as it is.

I'll bring #15456 onto this branch once you're happy with it.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head 07ca4e1 merged onto main 1e65852 · tested 2026-11-03 20:57 UTC · 19 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,768 passed · 5 failed (0 new, 3 also fail on main, 2 unstable on main) · 48 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,821 of 3,818 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 (937 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.1 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 4 of the last 10 main runs
agc_driver_submit_progress: failed in 5 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 (4 IDs in 519 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (519 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 511 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_srgb8_color_target
Skipped (48)
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_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_stencil_ref_export: skipped, the device lacks VK_EXT_shader_stencil_export
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 co
Reproduce
git fetch origin 07ca4e169ba65eb5d1b6b00426b1bc8e3320ae3a 1e658521a0a599872612bb91949311e2956b5283
git checkout 1e658521a0a599872612bb91949311e2956b5283 && git merge --no-ff 07ca4e169ba65eb5d1b6b00426b1bc8e3320ae3a
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.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ AMD GPU test: passed

PR head 07ca4e1 merged onto main 1e65852 · tested 2026-11-03 21:25 UTC · 18 min

GPU AMD Radeon RX 6300 (RADV NAVI24), driver Mesa 25.2.8-0ubuntu0.24.04.4, Vulkan 1.4.318
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-42-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,752 passed · 10 failed (0 new, 9 also fail on main, 1 unstable on main) · 59 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,821 of 3,818 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 (937 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.4 s, ⚠️ public_headers 60.7 s, ⚠️ agc_driver_image_sample_unnormalized 52.2 s, ⚠️ agc_driver_lazy_resolved_abi 44.4 s, ⚠️ agc_shader_sampler_limits 36.5 s
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 7 of the last 9 main runs
Failing on main too (9, not counted against this PR)
agc_driver_image_table
agc_driver_native_depth_bda_clear
agc_driver_native_multisample_depth
agc_driver_store_over_untracked
agc_driver_submit_progress
agc_submit_progress
agc_submit_progress_no_timeline
guest_mmap_executable
guest_socket_options_multicast
Validation IDs already present on main (4 IDs in 519 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (519 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 511 more
VUID-vkCmdCopyImage-srcImage-01548 (4 tests): agc_driver_depth_clear_hle, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-vkCmdCopyImage-srcImage-01551 (4 tests): agc_driver_depth_clear_hle, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (1 test): agc_driver_srgb8_color_target
Skipped (59)
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_copied_writer_label_order: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_float16_unused_nan_payloads: skipped, the device has no native f16 conversions with RTE rounding and kept f16 denormals
agc_driver_image_table_vouched_lookups: skipped, the device reports 4 of 4 host-imported pages written after a GPU read, so a watched imported table cannot be vouched for
agc_driver_linear_target_direct_write_completion: skipped, the device does not keep host imports write-watched, so no completion stamp over the target is tracked
agc_driver_ngg_vertex_wave_reduction: skipped, s3 describes a 32-lane wave only on 32-lane subgroups, and the device has 64 lanes
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_unit_shadow: skipped, the device does not import watched host memory for unit shadows
agc_driver_unit_shadow_budget: skipped, the device does not import watched host memory for unit shadows
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_idle_publish_wait: skipped, the device reports 4 of 4 host-imported pages written after a GPU read, so a forced watch of the import reads its submissions as CPU stores
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_shadowed_key_stores: skipped, the device imports no watched host memory under a unit shadow
agc_small_tiled_shadow_label: skipped, host imports are unavailable: the test block is not imported and watched
agc_storage_clear_hand_over: skipped, the device imports no watched host memory for the clear-key hand-over
agc_storage_pending_key_refresh: skipped, refreshes over a pending key store are not testable here
agc_unit_shadow: skipped, the device does not import watched host memory for unit shadows
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 dr
Reproduce
git fetch origin 07ca4e169ba65eb5d1b6b00426b1bc8e3320ae3a 1e658521a0a599872612bb91949311e2956b5283
git checkout 1e658521a0a599872612bb91949311e2956b5283 && git merge --no-ff 07ca4e169ba65eb5d1b6b00426b1bc8e3320ae3a
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 12 --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 16 --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 AMD 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 9335 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp L1340

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 5609 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 5925 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 6804 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_draw_unsupported_buffer_type_tests.cmake
PR 9387 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_draw_recapture_on_change_tests.cmake
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_draw_unsupported_buffer_type_tests.cmake
PR 10193 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_draw_unsupported_buffer_type_tests.cmake
PR 10359 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 10678 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 11435 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 11436 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 13928 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_draw_unsupported_buffer_type_tests.cmake
PR 13929 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_draw_unsupported_buffer_type_tests.cmake
PR 16753 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 17024 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 17786 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 18078 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 18515 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp

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

Copy link
Copy Markdown
Contributor

Thanks for this. The finisher restart resets everything finishDraw writes before its capture check, and RecaptureScope keeps the retry from checking again. I ran the PR's tests with the full pipeline env (APS5_DRAW_PIPELINE=1 APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1) on lavapipe with VVL 1.4.363.1 and sync validation, and they pass. I found two things, each with a test and a fix.

1. A restarted relocated hit caches the donor's unpatched decode under its own key (Execution/src/Driver/Draw/Draw.cpp)

When the worker's lookup hits through a relocation alias (userPatches non-empty and drawHit), draw() keeps the donor's decode unpatched. Lines 687-690 patch it only when !drawHit. userPatches is a local in draw() at line 403, so restartFinishedDraw (1388) cannot see it.

The restart sets drawHit = false at 1434, and finishDraw's cacheDrawStages then inserts tail.decode under the draw's own drawKey. That entry's decode carries the donor's user words, while its variants were captured through the draw's own words.

A later draw relocated from that entry gets the wrong shift. relocateDrawEntry (DrawRelocate.cpp:285-291) computes its moves from the donor decode's user words, so it shifts the captured runs by the wrong distance and misses. A wrong hit is also possible if the memory at the wrongly shifted runs happens to match.

Repro, in tests/execution/DrawCacheRelocation.cpp at the end of MovedForwardedWordReachesStageDataHit:

  1. A relocated stage data hit (through &OffsetTable[2]) changes its forwarded data from the capture check hook, so it is restarted on the finisher.
  2. The donor tables are moved to other data, and the same draw is drawn again.
  3. A draw through a second table at the same alignment must then be a relocated hit.

Results on lavapipe:

  • At 44e8088, under APS5_DRAW_PIPELINE=1 (_draw_pipeline and _plan_verify), the third draw misses (0 hits, 1 insert). Inline, it is a relocated stage data hit.
  • With the fix below, both variants pass, and so do the other four relocation variants.
  • Pixels are right in both cases, because a miss recompiles. The cost is the lost relocation hits, plus a possible false hit.

Suggested fix: carry the patches in the tail, and apply them on a restart when the worker hit.

@@ struct DrawTail {
     Pm4::DrawParameters resolvedParameters{};
+    std::vector<DrawUserPatch> userPatches;
@@ DrawVerdict Driver::draw(
-    std::vector<DrawUserPatch> userPatches;
+    auto& userPatches = tail.userPatches;
@@ void Driver::restartFinishedDraw(DrawTail& tail) {
+    if (tail.drawHit && !tail.userPatches.empty()) {
+        auto patched = std::make_shared<DrawDecode>(*tail.decode);
+        for (const auto& patch : tail.userPatches) patched->programs[patch.program].userData[patch.index] = patch.value;
+        tail.decode = std::move(patched);
+    }
     const auto& programs = *tail.programs;

I chose carrying userPatches over copying every user word from writablePrograms into the decode. writablePrograms also holds per-draw edits for mesh and indirect draws (the mesh index buffer words, the indirect arguments), and those must not reach a cached decode. The patch set is exactly what draw() applies on a miss at 687-690.

2. _inline fails when APS5_DRAW_PIPELINE is set in the environment (tests/execution/DrawRecaptureOnChange.cpp:440)

FetchOffsetIsFoldedOnceOnRecapture requires the check to run on the finisher whenever DrawFinisher::Enabled(), which is APS5_DRAW_PIPELINE alone (DrawPipeline.cpp:61). Draws are handed off only when they are pipelined too: DrawPipeline::Depth() != 0 (PacketExecution.cpp:183). _inline sets APS5_PIPELINED_DRAWS=0, so with APS5_DRAW_PIPELINE=1 in the outer environment it fails: "the fetching draw was checked on the queue worker, not the draw finisher".

-    if (AgcDriver::DriverDetail::DrawFinisher::Enabled()) Expect(FetchCheckedOnFinisher.load(), ...
+    if (AgcDriver::DriverDetail::DrawFinisher::Enabled() && AgcDriver::DriverDetail::DrawPipeline::Depth() != 0) Expect(FetchCheckedOnFinisher.load(), ...

With it, the forced-inline run passes, and _finisher still requires the finisher.

Commits to take. Three commits, directly on your head 44e8088, so they fast-forward:

  • e4be080 test: the skip-refused run under the full pipeline env, and the relocation repro (it fails until the next commit);
  • a128816 fix: patch a relocated hit's decode when the finisher restarts it;
  • d2c5354 test: require the finisher recapture only when draws are pipelined.
git fetch https://github.com/chitters2004/AnyPS5 draft/review-15455
git merge --ff-only FETCH_HEAD

Or cherry-pick only what you want, for example git cherry-pick a12881674e d2c535482f after the fetch. Squash them however suits the PR.

🤖 Generated with Claude Code

@chitters2004

Copy link
Copy Markdown
Contributor

One more small thing. resolvedParameters (a full Pm4::DrawParameters, 136 bytes) is added to every DrawTail, and every draw allocates one with make_shared in draw(), whether or not it reaches the finisher. On our per-draw allocation census (warmed recipe auto draws, lavapipe) that is +171 bytes per draw: 8221 bytes against 8050 at the base. The allocation count is unchanged.

The copy exists only so that the restart can undo fold(), which writes the folded first vertex into tail.drawParameters. If finishDraw works on a local copy instead, the tail keeps the parameters as resolved, and the restart needs neither the field nor the restore:

@@ struct DrawTail {
-    Pm4::DrawParameters resolvedParameters{};
@@ DrawVerdict Driver::draw(
         drawParameters = Pm4::ResolveDraw(packet, queue);
-        tail.resolvedParameters = drawParameters;
@@ DrawVerdict Driver::finishDraw(DrawTail& tail, PerformanceTimer& timing) {
-    auto& drawParameters = tail.drawParameters;
+    auto drawParameters = tail.drawParameters;
@@ void Driver::restartFinishedDraw(DrawTail& tail) {
-    tail.drawParameters = tail.resolvedParameters;

Results:

  • With it, the census measures 8040 bytes per draw.
  • Your FetchOffsetIsFoldedOnceOnRecapture still passes on _inline and _finisher.
  • Putting back the reference without the saved copy makes _finisher fail with "the retry folded s16 into the first vertex again", so the test already guards this.

It's the fourth commit on the same fork branch, 88402da "perf(agc): finish a draw from a copy of its resolved parameters", on top of the three from my earlier comment, so it still fast-forwards from your head 44e8088:

git fetch https://github.com/chitters2004/AnyPS5 draft/review-15455
git merge --ff-only FETCH_HEAD

On its own, without the earlier commits, it doesn't cherry-pick cleanly (it sits next to the relocation fix in restartFinishedDraw), so if you'd rather take only this change, the diff above is the whole of it.

🤖 Generated with Claude Code

chitters2004 pushed a commit to chitters2004/AnyPS5 that referenced this pull request Nov 12, 2026
…eline env

Registers agc_driver_draw_unsupported_buffer_type_skip_refused_draw_pipeline,
the skip-refused run under APS5_DRAW_PIPELINE=1, APS5_PIPELINED_DRAWS=32 and
APS5_PIPELINE_DISPATCH=1. Adds a case to the draw cache relocation test: a
relocated stage data hit whose data changes before its capture check is
restarted, the donor's tables then point at other data, and the same draw
again must still read through its own user word, not the donor's decode.

CI-Tests: agc_driver_draw_cache_relocation|agc_driver_draw_unsupported_buffer_type|agc_driver_draw_recapture_on_change
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011mLh2ezxgHr94nrZ32MRLz
@oneandonlydean
oneandonlydean merged commit 17e9ff3 into boykopovar:main Nov 12, 2026
13 checks passed
oneandonlydean pushed a commit that referenced this pull request Nov 16, 2026
Registers agc_driver_draw_unsupported_buffer_type_skip_refused_draw_pipeline,
the skip-refused run under APS5_DRAW_PIPELINE=1, APS5_PIPELINED_DRAWS=32 and
APS5_PIPELINE_DISPATCH=1. Adds a case to the draw cache relocation test: a
relocated stage data hit whose data changes before its capture check is
restarted, the donor's tables then point at other data, and the same draw
again must still read through its own user word, not the donor's decode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Nesyth
Nesyth deleted the fix/agc-draw-finisher-gaps branch November 17, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants