Skip to content

fix(libSceAgcDriver): decode PS4 tiled scanouts in their own layout on the CPU path - #18

Open
ntamas94 wants to merge 1 commit into
Get-fix:ps4/limbo-gpufrom
ntamas94:fix/ps4-gcn-scanout-decode
Open

ntamas94 wants to merge 1 commit into
Get-fix:ps4/limbo-gpufrom
ntamas94:fix/ps4-gcn-scanout-decode

Conversation

@ntamas94

@ntamas94 ntamas94 commented Oct 21, 2026 •

Copy link
Copy Markdown

What

DecodeDisplayBuffer's 4-byte loop worked out the tiled offset inline and only knew the linear (tilingMode == 1) and PS5 64 KiB layouts. A PS4 Display2D scanout (DisplayTilingGcn) fell into the 64 KiB branch and came out scrambled. The half-float loop and DisplayBufferOffset already go through texelOffset, which handles all three layouts, so the 4-byte loop now calls it too. For the linear and 64 KiB cases texelOffset(buffer, x, y, 4) gives the same offsets as the removed code.

The CPU decode only runs when a flip has no pending image to blit: the first flip, or with APS5_STORE_AT_LABEL=1 / APS5_EAGER_WRITEBACK=1. That is why the default path looks fine and the knobs showed a broken image. The Display2D retile of the render target was correct; only this read was wrong.

Note: texelOffset builds the GCN layout for every texel, so a 1080p CPU decode takes about 116 ms, against 9.4 ms for the old (wrong) 64 KiB formula. The half-float loop pays the same cost today. I left it as it is because this path only runs on the first flip or with the debug knobs.

Tested

Windows 11 (10.0.26200), WinLibs GCC, Release.

  • New GcnDisplay case in linear_display_buffer: it fills a 1920x1024 DisplayTilingGcn buffer through DisplayBufferOffset and checks that every decoded pixel lands at its linear position. It fails before the change and passes after.
  • linear_display_buffer and video_out_hdr_present pass.
  • Gang Beasts (CUSA04865) and Knowledge is Power: Decades (CUSA12435) with APS5_STORE_AT_LABEL=1: before, the frames were scrambled; now the title screen, level0, level11 and the KiP intro and tutorial screens render correctly.

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
  • GPUs tested: NVIDIA GeForce RTX 2080, driver 617.14, Windows 11
  • AI-assisted: yes

🤖 Generated with Claude Code

…n the CPU path

DecodeDisplayBuffer's 4-byte loop computed the tiled offset itself and
only knew the linear and PS5 64 KiB layouts, so a PS4 Display2D scanout
(DisplayTilingGcn) was read with the PS5 formula and came out scrambled.
The half-float loop and DisplayBufferOffset already go through
texelOffset, which handles all three; the 4-byte loop now does too.

The path only runs when a flip has no pending image to blit (the first
flip, or with APS5_STORE_AT_LABEL / APS5_EAGER_WRITEBACK set).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Get-fix

Get-fix commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Thanks @ntamas94. boykopovar#6977 is now a draft integration branch, and its own work is split into boykopovar#9429 to boykopovar#9433 (details). The maintainers asked that the branch not land anything without its own review, so could you open this upstream against main, on top of boykopovar#9431, with Depends on? Once it's open, I'll merge it into ps4/limbo-gpu, list it as a member and run Limbo with it. ps4/limbo-gpu now moves to the split branches, so this pull request may show conflicts here.

AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

@ntamas94

Copy link
Copy Markdown
Author

Opened upstream as boykopovar#9673 against main, on top of boykopovar#9431, with Depends on. It is the same commit; it applied without conflicts.

AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants