feat(agc): count which key component differs on resource-content cache misses #5408

Merged
AlxcBTW merged 3 commits from upstream-pr/5408 into main 2026-10-14 12:08:16 +00:00
AlxcBTW commented 2026-10-13 19:05:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-13T19:05:19Z.


What

APS5_TRACE_RESOURCE_KEY_MISSES=1 reports why a resource-content cache lookup missed, not just that it missed. On each miss, the new key is compared word by word with the last key of the same shader set. Each differing word is attributed to the component it belongs to:

  • the descriptor layout;
  • buffer V# words 0–3;
  • image and sampler descriptors;
  • shader data;
  • the draw target and index tail;
  • other.

Every 10 s it prints one line per draw/dispatch:

[keymiss] resource-content dispatch (10 s): misses N; differing: layout …, V# word0 …, V# word1 …, V# word2 …, V# word3 …, image …, sampler …, shader-data …, other …, draw target/index …; no-candidate …; identical …; not comparable …

It also prints up to 256 per-miss lines, at most 4 per shader set, naming the components that changed.

This complements #5364, which traces draw-key misses. This PR covers the resource-content key, which is the one that decides whether a draw or dispatch re-records its descriptor contents. For #5345 the question is which part of that key changes from frame to frame: a buffer base address (word 0), a size or stride (word 2), or the layout itself. That decides whether masking a component in the key is worth trying. Off by default; no behaviour change without the variable.

Tested

  • New unit test tests/KeyMiss.cpp:
    • labels a dispatch key and a draw key component by component;
    • checks that a change in each component is attributed to that component;
    • checks that a key of a different length counts as not comparable.
  • Fork CI green on Linux and Windows.
  • Not run in a title on this branch yet.

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
  • Unblocks: none (diagnostic for #5345)
  • GPUs tested: n/a (trace only, off by default; CI unit test)
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4848115693 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5408). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-13T19:05:19Z. --- ### What `APS5_TRACE_RESOURCE_KEY_MISSES=1` reports **why** a resource-content cache lookup missed, not just that it missed. On each miss, the new key is compared word by word with the last key of the same shader set. Each differing word is attributed to the component it belongs to: - the descriptor layout; - buffer V# words 0–3; - image and sampler descriptors; - shader data; - the draw target and index tail; - other. Every 10 s it prints one line per draw/dispatch: ``` [keymiss] resource-content dispatch (10 s): misses N; differing: layout …, V# word0 …, V# word1 …, V# word2 …, V# word3 …, image …, sampler …, shader-data …, other …, draw target/index …; no-candidate …; identical …; not comparable … ``` It also prints up to 256 per-miss lines, at most 4 per shader set, naming the components that changed. This complements #5364, which traces *draw-key* misses. This PR covers the resource-content key, which is the one that decides whether a draw or dispatch re-records its descriptor contents. For #5345 the question is which part of that key changes from frame to frame: a buffer base address (word 0), a size or stride (word 2), or the layout itself. That decides whether masking a component in the key is worth trying. Off by default; no behaviour change without the variable. ### Tested - New unit test `tests/KeyMiss.cpp`: - labels a dispatch key and a draw key component by component; - checks that a change in each component is attributed to that component; - checks that a key of a different length counts as not comparable. - Fork CI green on Linux and Windows. - Not run in a title on this branch yet. ### Checklist - [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] Unblocks: none (diagnostic for #5345) - [x] GPUs tested: n/a (trace only, off by default; CI unit test) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
adriadam10 commented 2026-10-14 11:47:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T11:47:37Z.


Checked on Linux (GCC/Ninja, PR merged onto main): agc_driver_key_miss passes and does not build without the change. The component labelling matches the ContentKey layout for dispatch and draw keys, and with the variable unset nothing changes. The two other failures in the libSceAgcDriver ctest scope (agc_recorder_kept_bytes, agc_driver_tessellation) also fail on clean main. Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6167622387 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5408#issuecomment-6167622387). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T11:47:37Z. --- Checked on Linux (GCC/Ninja, PR merged onto main): `agc_driver_key_miss` passes and does not build without the change. The component labelling matches the `ContentKey` layout for dispatch and draw keys, and with the variable unset nothing changes. The two other failures in the libSceAgcDriver ctest scope (`agc_recorder_kept_bytes`, `agc_driver_tessellation`) also fail on clean main. Merging once the full Build is green.
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!5408
No description provided.