test(agc): bound the PM4 system counter by the time since main #28896

Open
Plyxen wants to merge 1 commit from upstream-pr/28896 into main
Plyxen commented 2026-12-04 14:38:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-04T14:38:46Z.


What

testGcnReleaseMemSystemCounter in agc_driver_pm4 checked that the first RELEASE_MEM DATA_SEL 4 value was below 60 s of 800 MHz ticks. The driver counts those ticks from GcnSystemCounterStart, which is set when the library loads. The check runs as the 34th of 63 cases in the default run, so it also needs the 33 cases before it to finish within 60 s of load.

The nightly Sanitizers run takes longer than that: agc_driver_pm4 ran for 97.4 s in run 47261325393 (0b0c56dec5) and failed with "the GCN DATA_SEL 4 counter did not start near zero". The counter was right; the test was slow. The test is not in .github/sanitizer-known-failures.txt.

The test now records when main starts. It checks that the first value is at least the time from main to the packet, and at most that time plus 60 s for start-up before main. That still fails a counter that starts at boot, at the epoch or after main. It no longer depends on how long the earlier cases took.

Tested

On main 484b0368d3, with a temporary local patch (not part of this PR) that sleeps 61 s in main before testGcnReleaseMemSystemCounter, to stand in for the slow earlier cases:

main main + 61 s this PR this PR + 61 s
Windows 11, GCC 15.2, NVIDIA loader pass fails: "did not start near zero" pass pass
Windows 11, GCC 15.2, AMD loader pass fails: "did not start near zero" pass pass
WSL Ubuntu 24.04, GCC 13, ASan + UBSan, lavapipe pass (35 s) fails: "did not start near zero" pass (33 s) pass

The Windows runs used ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and VK_LOADER_DEBUG=layer with layer 1.4.363. agc_driver_pm4 creates no Vulkan instance, so the logs show no layer insert and no VUID-. check_conventions.py passed and pr_overlap.py --branch found no overlapping pull request.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: n/a (test-only change; the test creates no Vulkan device). It ran with the NVIDIA RTX 5080 (621.24) and AMD iGPU (26.11.2) loaders selected on Windows 11, and under Mesa lavapipe in WSL
  • AI-assisted: yes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Updated validation of GCN memory-release counters to account for elapsed runtime and allow for startup delay, rather than requiring the initial counter value to be near zero. This makes the timing check better reflect observed runtime behavior.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5648469337 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28896). Originally posted by [Plyxen](https://github.com/Plyxen) on 2026-12-04T14:38:46Z. --- ### What `testGcnReleaseMemSystemCounter` in `agc_driver_pm4` checked that the first `RELEASE_MEM` `DATA_SEL 4` value was below 60 s of 800 MHz ticks. The driver counts those ticks from `GcnSystemCounterStart`, which is set when the library loads. The check runs as the 34th of 63 cases in the default run, so it also needs the 33 cases before it to finish within 60 s of load. The nightly Sanitizers run takes longer than that: `agc_driver_pm4` ran for 97.4 s in [run 47261325393](https://github.com/boykopovar/AnyPS5/actions/runs/47261325393) (`0b0c56dec5`) and failed with "the GCN DATA_SEL 4 counter did not start near zero". The counter was right; the test was slow. The test is not in `.github/sanitizer-known-failures.txt`. The test now records when `main` starts. It checks that the first value is at least the time from `main` to the packet, and at most that time plus 60 s for start-up before `main`. That still fails a counter that starts at boot, at the epoch or after `main`. It no longer depends on how long the earlier cases took. ### Tested On main 484b0368d3, with a temporary local patch (not part of this PR) that sleeps 61 s in `main` before `testGcnReleaseMemSystemCounter`, to stand in for the slow earlier cases: | | main | main + 61 s | this PR | this PR + 61 s | |---|---|---|---|---| | Windows 11, GCC 15.2, NVIDIA loader | pass | fails: "did not start near zero" | pass | pass | | Windows 11, GCC 15.2, AMD loader | pass | fails: "did not start near zero" | pass | pass | | WSL Ubuntu 24.04, GCC 13, ASan + UBSan, lavapipe | pass (35 s) | fails: "did not start near zero" | pass (33 s) | pass | The Windows runs used `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` and `VK_LOADER_DEBUG=layer` with layer 1.4.363. `agc_driver_pm4` creates no Vulkan instance, so the logs show no layer insert and no `VUID-`. `check_conventions.py` passed and `pr_overlap.py --branch` found no overlapping pull request. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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: none - [x] Unblocks: none - [x] GPUs tested: n/a (test-only change; the test creates no Vulkan device). It ran with the NVIDIA RTX 5080 (621.24) and AMD iGPU (26.11.2) loaders selected on Windows 11, and under Mesa lavapipe in WSL - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Tests** * Updated validation of GCN memory-release counters to account for elapsed runtime and allow for startup delay, rather than requiring the initial counter value to be near zero. This makes the timing check better reflect observed runtime behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
MarcZX10 commented 2026-12-04 15:18:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T15:18:52Z.

Review: APPROVED


Reviewed — looks good

The counter is measured from library load, and the updated assertion accounts for elapsed time since main plus up to 60 seconds of earlier startup delay.

What I ran

Reviewed head 52ef5d6061bf7ebf540e7fe33dfe0402fd5a3fca against the provided main base; no merged preview was run. I used repo_read.py to inspect the changed test, main, and the counter initialization and value calculation. No build or test was run.

python3 repo_read.py search GcnSystemCounterStart
python3 repo_read.py cat core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp 95 114
python3 repo_read.py cat core/libs/prx/libSceAgcDriver/tests/Pm4.cpp 1610 1668
python3 repo_read.py cat core/libs/prx/libSceAgcDriver/tests/Pm4.cpp 3480 3550

Results

Check Result Note
Source review passed Assertion matches counter origin and units
Tests and build not run Author-reported runs were not independently verified

Negative control

Not run; no test or source mutation was performed.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

The reported Windows, WSL, sanitizer, and delayed-case runs were not reproduced. I read the changed test and main entry point in Pm4.cpp, plus the counter implementation in Execution/src/Pm4.cpp; the remainder of the test file was not read. files.json lists one reviewed file and no excluded files.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6191509171 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28896#pullrequestreview-6191509171). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-12-04T15:18:52Z. **Review:** APPROVED --- # Reviewed — looks good The counter is measured from library load, and the updated assertion accounts for elapsed time since `main` plus up to 60 seconds of earlier startup delay. ## What I ran Reviewed head `52ef5d6061bf7ebf540e7fe33dfe0402fd5a3fca` against the provided `main` base; no merged preview was run. I used `repo_read.py` to inspect the changed test, `main`, and the counter initialization and value calculation. No build or test was run. ```text python3 repo_read.py search GcnSystemCounterStart python3 repo_read.py cat core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp 95 114 python3 repo_read.py cat core/libs/prx/libSceAgcDriver/tests/Pm4.cpp 1610 1668 python3 repo_read.py cat core/libs/prx/libSceAgcDriver/tests/Pm4.cpp 3480 3550 ``` ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Assertion matches counter origin and units | | Tests and build | not run | Author-reported runs were not independently verified | ## Negative control Not run; no test or source mutation was performed. ## Findings ### Blocking None. ### Non-blocking None. ## Sources - [Counter origin and 800 MHz conversion](https://github.com/boykopovar/AnyPS5/blob/52ef5d6061bf7ebf540e7fe33dfe0402fd5a3fca/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp#L103-L110) - [Updated timing assertion and `main` timestamp](https://github.com/boykopovar/AnyPS5/blob/52ef5d6061bf7ebf540e7fe33dfe0402fd5a3fca/core/libs/prx/libSceAgcDriver/tests/Pm4.cpp#L1639-L1658) ## Not verified The reported Windows, WSL, sanitizer, and delayed-case runs were not reproduced. I read the changed test and `main` entry point in `Pm4.cpp`, plus the counter implementation in `Execution/src/Pm4.cpp`; the remainder of the test file was not read. `files.json` lists one reviewed file and no excluded files. ## To get this to a good state Nothing is required.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/28896:upstream-pr/28896'
git switch 'upstream-pr/28896'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/28896'
git switch 'upstream-pr/28896'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/28896'
git switch 'upstream-pr/28896'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/28896'
git switch 'main'
git merge --squash 'upstream-pr/28896'
git switch 'main'
git merge --ff-only 'upstream-pr/28896'
git switch 'main'
git merge 'upstream-pr/28896'
git push origin 'main'
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!28896
No description provided.