fix(agc): preserve draw pipeline order for committer flushes and HLE clears #18809

Merged
vovasicidk merged 2 commits from upstream-pr/18809 into main 2026-11-21 16:47:29 +00:00
vovasicidk commented 2026-11-12 11:06:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by vovasicidk on 2026-11-12T11:06:36Z.


What

  • Restrict DrawPipeline::HeldReads on DrawPipeline::Queue0()'s committer thread to pipeline.items.front() (committerPipeline thread-local scope in DrawPipeline::run()), so future queued draws (items[1..N-1], up to 31 ahead with APS5_PIPELINED_DRAWS=32) do not block StorageTexture::FlushPending for the currently executing item while keeping full queue checks for external callers and the active item's own reads.
  • Drain DrawPipeline::Queue0() before Graphics::TakeMultisampledSingleClear mutates single-clear state or reads guest descriptors, and move the fallback Graphics::MatchMemoryValueFill -> Graphics::NoteMemoryValueFill path after fillBuffer (which already notes depth metadata at commit time) and DrawPipeline::Queue0().Drain.
  • Add agc_driver_pipelined_flush_read_order (tests/execution/PipelinedFlushReadOrder.cpp + tests/cmake/agc_driver_pipelined_flush_read_order_tests.cmake) testing committer vs external HeldReads, Vulkan StorageTexture::FlushPending past future queued reads under APS5_PIPELINED_DRAWS=32, and MatchMultisampledSingleClear draining DrawPipeline::Queue0().

Tested

  • OS / Build: Windows 10 (10.0.19045.0), MinGW-w64 UCRT64 GCC 16.2.0, Release, Vulkan validation layer 1.4.363.0-1.
  • Vulkan validation comparison (ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer via ctest --test-dir build -R <pattern> -V):
    • Baseline (main): 21/21 focused agc_driver_* tests passed in 42.54 s (Insert instance layer "VK_LAYER_KHRONOS_validation" x24, 0 was not found, 0 VUID-/SYNC-HAZARD- errors).
    • Candidate (fix/agc-pipelined-draw-order 8a62a39f62d): 24/24 focused agc_driver_* tests passed in 40.81 s (Insert instance layer "VK_LAYER_KHRONOS_validation" x30, 0 was not found, 0 VUID-/SYNC-HAZARD- errors, 0 skipped), including agc_driver_pipelined_flush_read_order, agc_driver_pipelined_flush_read_order_draw_pipeline, and agc_driver_pipelined_flush_read_order_plan_verify.
  • python tools/check_conventions.py and python tools/check_test_registration.py both exited 0 (2563 test executable(s)).
  • Note: FAR: Changing Tides (PPSA03766) itself was not run here; behavior was verified at the driver/Vulkan level.

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: Fixes #18022
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 3060 Ti (driver 595.79, Windows 10)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5276220738 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18809). Originally posted by [vovasicidk](https://github.com/vovasicidk) on 2026-11-12T11:06:36Z. --- ### What - Restrict `DrawPipeline::HeldReads` on `DrawPipeline::Queue0()`'s committer thread to `pipeline.items.front()` (`committerPipeline` thread-local scope in `DrawPipeline::run()`), so future queued draws (`items[1..N-1]`, up to 31 ahead with `APS5_PIPELINED_DRAWS=32`) do not block `StorageTexture::FlushPending` for the currently executing item while keeping full queue checks for external callers and the active item's own reads. - Drain `DrawPipeline::Queue0()` before `Graphics::TakeMultisampledSingleClear` mutates single-clear state or reads guest descriptors, and move the fallback `Graphics::MatchMemoryValueFill` -> `Graphics::NoteMemoryValueFill` path after `fillBuffer` (which already notes depth metadata at commit time) and `DrawPipeline::Queue0().Drain`. - Add `agc_driver_pipelined_flush_read_order` (`tests/execution/PipelinedFlushReadOrder.cpp` + `tests/cmake/agc_driver_pipelined_flush_read_order_tests.cmake`) testing committer vs external `HeldReads`, Vulkan `StorageTexture::FlushPending` past future queued reads under `APS5_PIPELINED_DRAWS=32`, and `MatchMultisampledSingleClear` draining `DrawPipeline::Queue0()`. ### Tested - OS / Build: Windows 10 (10.0.19045.0), MinGW-w64 UCRT64 GCC 16.2.0, Release, Vulkan validation layer `1.4.363.0-1`. - Vulkan validation comparison (`ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer` via `ctest --test-dir build -R <pattern> -V`): - Baseline (`main`): 21/21 focused `agc_driver_*` tests passed in 42.54 s (`Insert instance layer "VK_LAYER_KHRONOS_validation"` x24, 0 `was not found`, 0 `VUID-`/`SYNC-HAZARD-` errors). - Candidate (`fix/agc-pipelined-draw-order` `8a62a39f62d`): 24/24 focused `agc_driver_*` tests passed in 40.81 s (`Insert instance layer "VK_LAYER_KHRONOS_validation"` x30, 0 `was not found`, 0 `VUID-`/`SYNC-HAZARD-` errors, 0 skipped), including `agc_driver_pipelined_flush_read_order`, `agc_driver_pipelined_flush_read_order_draw_pipeline`, and `agc_driver_pipelined_flush_read_order_plan_verify`. - `python tools/check_conventions.py` and `python tools/check_test_registration.py` both exited 0 (`2563 test executable(s)`). - Note: `FAR: Changing Tides (PPSA03766)` itself was not run here; behavior was verified at the driver/Vulkan level. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: Fixes #18022 - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 3060 Ti (driver 595.79, Windows 10) - [x] AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!18809
No description provided.