Skip to content

perf(agc): reuse image tables that hold a 2D array entry and its flat 2D partner - #26184

Closed
theGodspeed1999 wants to merge 1 commit into
boykopovar:mainfrom
theGodspeed1999:fix/image-table-array-partner-reuse
Closed

theGodspeed1999 wants to merge 1 commit into
boykopovar:mainfrom
theGodspeed1999:fix/image-table-array-partner-reuse

Conversation

@theGodspeed1999

Copy link
Copy Markdown
Contributor

What

An image table that holds a one-layer 2D array entry and a flat 2D entry over the same surface was never remembered, so every draw that used it resolved all its entries again. In the Wolverine (PPSA03671) slow scene this was the main cost (see #25529).

The remembered table now keeps those partner entries, and a reused table binds them the way a fresh lookup does: the array entry shares the flat entry's texture, or is looked up on its own if the flat entry did not share it. The revalidation walk handles partner entries too. ReusedTableCount stays at 4.

How it fits with #6340: that PR lets clean entries be reused when another entry in the table cannot be; this one lets the partner entries be reused. They touch the same function but solve different cases, and either can land first (I commented there: #6340 (comment)).

It does not make the scene playable. The slow part stays at about 0.2 frames per second. What is left is that the sampled-texture cache (2 GiB) is full, so tables lose their textures, and that every queue ordering point (about 29 per second) clears the list of remembered tables. The bigger cause stays on #25529.

Tested

Windows 10 (19045), RTX 3060 Ti 8 GB (driver 617.42), Ryzen 7 5700X, Marvel's Wolverine (PPSA03671), scripted pad press (APS5_PAD_SCRIPT_LIVE), APS5_SKIP_REFUSED_DISPATCHES=1 APS5_SKIP_REFUSED_DRAWS=1 in all runs because shaders 0x11d049aa00 (#6191, #7395) and 0x11d0125d00 (#5879, #7689) are refused. The runs were made on main eb856f9 plus this change; the branch is now rebased on 709342e209.

  • Execution tests agc_driver_image_table_reuse, agc_driver_image_table_array_views, agc_driver_image_table_variants: all three passed on the same change before the rebase (on main eb856f9). After the rebase onto 709342e209 I only compiled them and did not run them again. The new case in ImageTableArrayViews.cpp fails without the change (0 reused, 3 resolved) and passes with it. It also checks that an image store with a pending write makes the table resolve again.
  • python3 tools/check_conventions.py --base origin/main --head HEAD: passed.

Slow phase (first 30 blocks of 10 s after it starts), one run of main against six runs of this change (14 minutes each):

run tables reused presents per 10 s binding ms per 10 s
main 0.5% 1.5 7440
change 1 55% 2.1 6031
change 2 0.5% 0.9 6707
change 3 32% 2.1 7391
change 4 57% 3.0 5838
change 5 28% 2.1 7560
change 6 38% 1.9 7293

Reuse went up in 5 of 6 runs. In run 2 it stayed at 0.5% and the frame rate was lower than on main. Runs of the same build differ a lot (#26053), so one run is not enough to judge a speed change here. Mean over the six: about 2.0 presents per 10 s (+33%), binding time about -9%. That is a small boost.

Same-frame pair: the Screen Reader prompt from main and from this change is pixel-identical (mean difference 0.000, 0% of pixels changed). The two images are attached in a comment below.

Related issues found in the same runs: #26043 (broken small letters on the prompt, the same with and without this change), #26044 (input), #26045 (frame capture log line), #26053 (runs differ).

Checklist

… 2D partner

A table whose one-layer 2D array entry shares the texture of a flat 2D entry was never remembered, so every draw resolved it again. The remembered table now keeps such partner entries and binds them as a fresh resolve would. The execution test covers reuse and an image store with a pending write.
@theGodspeed1999

Copy link
Copy Markdown
Contributor Author
screen_reader_prompt_after screen_reader_prompt_before Here is the same-frame pair that was asked for on #25529. It is the Screen Reader prompt in Marvel's Wolverine (PPSA03671), at the same point in the game. The first picture is from main and the second is from this change.

I compared them pixel by pixel and found no difference at all: 0.000 on average, and 0% of the pixels changed. So this change does not alter what is drawn. The small letters on this prompt look broken in both pictures. That is a separate problem (#26043), and this change neither causes it nor fixes it.

Both runs skipped two shaders that the game can't use yet (APS5_SKIP_REFUSED_DISPATCHES=1 and APS5_SKIP_REFUSED_DRAWS=1, see #6191 and #5879).

AI-assisted.

@github-actions github-actions Bot added the open PR limit Closed over the open PR limit: 1 without merged PRs, 20 with at least 1, none from 20 label Nov 23, 2026
@github-actions

Copy link
Copy Markdown

Thank you for your contribution! Authors with no pull requests merged into main can have 1 open pull request at a time, authors with at least 1 merged can have 20, and from 20 merged there is no limit. This PR has been automatically closed and labeled "open PR limit" because that limit was reached. This is not a judgment of the quality of your changes: reopen it once one of your open pull requests is merged or closed.

@theGodspeed1999

Copy link
Copy Markdown
Contributor Author

Replaces #26184 (closed by the open PR limit). The new PR is #27527. AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open PR limit Closed over the open PR limit: 1 without merged PRs, 20 with at least 1, none from 20

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant