Queued occlusion counter dumps give alternating visibility in PPSA15657 (objects pop every other frame) #5215

Closed
opened 2026-10-13 14:49:41 +00:00 by johnmaia · 1 comment
johnmaia commented 2026-10-13 14:49:41 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-13T14:49:41Z.


Summary

With the queued occlusion counter dumps from 7638c1184 ("keep occlusion counter dumps inside the open render pass"), Epic Mickey: Rebrushed (PPSA15657, UE 4.27) gets visibility results that flip from frame to frame. Level geometry is drawn every other frame, so objects visibly pop in and out. APS5_LABEL_RUNS_INLINE=1 (which makes QueuesSampleDumps() false) removes it at no cost.

Setup

  • Linux, RX 7600, RADV Mesa 25.2.8.
  • main 3faa9cb40 + #5097 + #4551 + #5030; the last three fix unrelated rendering in this title.

Evidence

1. The game itself stops issuing draws on alternate frames. A per-draw log (vertex/pixel shader, index count, index buffer), compared over 40 consecutive presents, shows many depth-prepass/base-pass pairs present only every other frame (.1.1.1.1…, 211 such draws). They're the same meshes and index buffers each time, and draws per frame alternate between about 640 and 710. On screen, a stair wall is drawn in frames 6 and 8 but missing in 7 and 9.

2. The alternation tracks occlusion queries. Same tree, same level:

Run Alternating world draws Visible popping In-level FPS
default (queued dumps) yes (211 draw patterns) yes 4.73
r.AllowOcclusionQueries=0 (engine.ini) no no —
APS5_LABEL_RUNS_INLINE=1 no no 5.08
APS5_SYNC_FLIP=1 no no 5.02

3. Query volume and results. Reading back each dumped counter one present later (16 DB words, end - begin per query):

  • Default: the title issues about 180 queries on odd frames and about 80 on even frames, and 50–70% of them read 0.
  • Inline: it settles to about 12 queries per frame.
  • So in queued mode UE keeps re-testing objects whose visibility keeps flipping.

Ruled out

  • Missed sampled draws: NoteSampledDraw in segment mode was instrumented per frame. Every sampled draw is on open->commands with counting on (e.g. 527 calls, 317 segments begun, 0 on another command buffer, 0 not counting).
  • The idle label fallback: WriteLabelOnGpu returns 1 only when Recorder::Idle(), and a queued dump keeps a batch open.
  • Store/dump order within a run: QueuedWriteGroups starts a new group when a plain store overlaps an earlier dump.

What I think is left

Recorded at once, the dumps are still asynchronous GPU work and the results are right. Queued, each dump's value is computed at closeStoreRun from dumpSegments (the pendingSamples index at queue time) and the shared sampleCounter. So my guess is that the per-dump segment accounting goes wrong when a batch holds many begin/end dumps with segments in between, or across batches. I haven't pinned down which yet.

The title reuses query slots on a frame cycle and checks the ready bits itself, so a dump that lands with a stale or shifted total looks like a valid "0 samples" result.

Workaround

APS5_LABEL_RUNS_INLINE=1. On this title it's also slightly faster (5.08 vs 4.73 FPS in the same level).

I can run builds or diagnostics on this title if that helps.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5832471303 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/5215). Originally posted by [johnmaia](https://github.com/johnmaia) on 2026-10-13T14:49:41Z. --- ### Summary With the queued occlusion counter dumps from 7638c1184 ("keep occlusion counter dumps inside the open render pass"), Epic Mickey: Rebrushed (PPSA15657, UE 4.27) gets visibility results that flip from frame to frame. Level geometry is drawn every other frame, so objects visibly pop in and out. `APS5_LABEL_RUNS_INLINE=1` (which makes `QueuesSampleDumps()` false) removes it at no cost. ### Setup - Linux, RX 7600, RADV Mesa 25.2.8. - main 3faa9cb40 + #5097 + #4551 + #5030; the last three fix unrelated rendering in this title. ### Evidence **1. The game itself stops issuing draws on alternate frames.** A per-draw log (vertex/pixel shader, index count, index buffer), compared over 40 consecutive presents, shows many depth-prepass/base-pass pairs present only every other frame (`.1.1.1.1…`, 211 such draws). They're the same meshes and index buffers each time, and draws per frame alternate between about 640 and 710. On screen, a stair wall is drawn in frames 6 and 8 but missing in 7 and 9. **2. The alternation tracks occlusion queries.** Same tree, same level: | Run | Alternating world draws | Visible popping | In-level FPS | |---|---|---|---| | default (queued dumps) | yes (211 draw patterns) | yes | 4.73 | | `r.AllowOcclusionQueries=0` (engine.ini) | no | no | — | | `APS5_LABEL_RUNS_INLINE=1` | no | no | 5.08 | | `APS5_SYNC_FLIP=1` | no | no | 5.02 | **3. Query volume and results.** Reading back each dumped counter one present later (16 DB words, `end - begin` per query): - Default: the title issues about 180 queries on odd frames and about 80 on even frames, and 50–70% of them read 0. - Inline: it settles to about 12 queries per frame. - So in queued mode UE keeps re-testing objects whose visibility keeps flipping. ### Ruled out - **Missed sampled draws:** `NoteSampledDraw` in segment mode was instrumented per frame. Every sampled draw is on `open->commands` with counting on (e.g. 527 calls, 317 segments begun, 0 on another command buffer, 0 not counting). - **The idle label fallback:** `WriteLabelOnGpu` returns 1 only when `Recorder::Idle()`, and a queued dump keeps a batch open. - **Store/dump order within a run:** `QueuedWriteGroups` starts a new group when a plain store overlaps an earlier dump. ### What I think is left Recorded at once, the dumps are still asynchronous GPU work and the results are right. Queued, each dump's value is computed at `closeStoreRun` from `dumpSegments` (the `pendingSamples` index at queue time) and the shared `sampleCounter`. So my guess is that the per-dump segment accounting goes wrong when a batch holds many begin/end dumps with segments in between, or across batches. I haven't pinned down which yet. The title reuses query slots on a frame cycle and checks the ready bits itself, so a dump that lands with a stale or shifted total looks like a valid "0 samples" result. ### Workaround `APS5_LABEL_RUNS_INLINE=1`. On this title it's also slightly faster (5.08 vs 4.73 FPS in the same level). I can run builds or diagnostics on this title if that helps. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
johnmaia commented 2026-10-13 15:18:52 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-13T15:18:52Z.


Root cause found; fix in #5232.

Recorder::QueuedWriteGroups records a group's plain stores before its dumps, and a store started a new group only when it overlapped an earlier dump. So the label the title writes after its occlusion queries (different memory) joined the dumps' group and landed before them. The title polled the label and read the counters before the dumps were written. Splitting the group at any store after a dump removes the alternating draws and the popping in PPSA15657. The QueuedWriteGroups tests now also run in ctest (agc_queued_write_groups); the updated one fails without the change.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6148886354 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/5215#issuecomment-6148886354). Originally posted by [johnmaia](https://github.com/johnmaia) on 2026-10-13T15:18:52Z. --- Root cause found; fix in #5232. `Recorder::QueuedWriteGroups` records a group's plain stores before its dumps, and a store started a new group only when it overlapped an earlier dump. So the label the title writes after its occlusion queries (different memory) joined the dumps' group and landed **before** them. The title polled the label and read the counters before the dumps were written. Splitting the group at any store after a dump removes the alternating draws and the popping in PPSA15657. The `QueuedWriteGroups` tests now also run in ctest (`agc_queued_write_groups`); the updated one fails without the change. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
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#5215
No description provided.