Skip to content

feat(libSceHmd2): return the console's display and mirroring buffer sizes - #7690

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
T3cm0:bionic/hmd2-size-queries
Oct 20, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
T3cm0:bionic/hmd2-size-queries

Conversation

@T3cm0

@T3cm0 T3cm0 commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

What

Implements four libSceHmd2 size queries that threw: sceHmd2ReprojectionQueryDisplayBufferSizeAlign, sceHmd2ReprojectionQuerySeeThroughBufferSizeAlign, sceHmd2ReprojectionGetMirroringDisplayBufferSizeAlign and sceHmd2ReprojectionGetMirroringWorkMemorySizeAlign. Each returns a {size, alignment} pair in RAX:RDX (Hmd2::SizeAlign), and the console returns fixed values: 0x6000000 and 0x10000, 0x1106000 and 0x100, 0x5FA0000 and 0x10000, 0x4000 and 0x100. PPSA05666 (Horizon Call of the Mountain) reaches the reprojection set-up right after its PS VR2 tracker set-up, allocates the sizes these queries return and passes the mirroring buffer size (0x5FA0000) to sceHmd2ReprojectionEnableMirroring. sceHmd2ReprojectionQueryBufferSizeAlign is left to #7658, which implements it; the debt file records the value the console returns for it (0x100828 and 0x100), measured the same way. The values were measured on the console; the debt file says what is assumed. Hmd2::SizeAlign has the same layout and member names as the one #7658 adds, so whichever lands second only drops its copy.

Tested

Windows 11 (MinGW GCC 15.2) and Ubuntu 26.04 on WSL2 (GCC 15.2), Release builds: ctest for guest_hmd2 passes on both, and patched_libraries on Windows; the built exports set RAX and RDX as the console's do. The values come from a homebrew payload on a PS5 (firmware 13.60) with no PS VR2 headset that loaded libSceHmd2.sprx without initializing it and called each query with small arguments, always with the same result. The arguments PPSA05666 passes were captured under AnyPS5. Not tested further with a title.

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: feat(libSceVrTracker2): answer as the console's module before initialization #7463
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

T3cm0 and others added 2 commits October 18, 2026 03:50
…ization

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…izes

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Progress report (98db779 → f264452)

📈 System libraries: 66.69% (+0.07%, +4 implemented functions)

✅ 4 implemented
Library Name
libSceHmd2 sceHmd2ReprojectionGetMirroringDisplayBufferSizeAlign
libSceHmd2 sceHmd2ReprojectionGetMirroringWorkMemorySizeAlign
libSceHmd2 sceHmd2ReprojectionQueryDisplayBufferSizeAlign
libSceHmd2 sceHmd2ReprojectionQuerySeeThroughBufferSizeAlign

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 7658 core/libs/prx/libSceHmd2/Hmd2.hpp L51, L63

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 4040 docs/dev/debt/libSceVideoOut.md
PR 6044 core/libs/tests/GuestHmd2.cpp
PR 6977 docs/dev/debt/libSceVideoOut.md

@frankea

frankea commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Datapoint from Gran Turismo 7 (PPSA01317, 01.000.001 base package): the title calls sceHmd2ReprojectionQueryDisplayBufferSizeAlign right after sceHmd2ReprojectionQueryBufferSizeAlign, and this PR's answer is what lets it leave libSceHmd2. On main 324e0e4 + #7658 alone, 3 of 3 runs abort on sceHmd2ReprojectionQueryDisplayBufferSizeAlign not implemented (libSceHmd2.prx+0x1c90 under app.exe+0x952f47, 0x48 bytes after the QueryBufferSizeAlign call site that stopped it on plain main); with this PR added (head e191a13, which brings #7463), 3 of 3 pass all four size queries and stop on sceVrTracker2Initialize not implemented (libSceVrTracker2.prx+0x1650 under app.exe+0x95310a, same function, same module-load thread), 9.5 s (cold shader cache), 4.9 s and 4.9 s after launch, still before the first frame.

Tree Stop Where Wall-clock (3 runs)
main 324e0e4 + #7658 sceHmd2ReprojectionQueryDisplayBufferSizeAlign not implemented libSceHmd2.prx+0x1c90 under app.exe+0x952f47 6.7 s, 4.8 s, 4.8 s
main 324e0e4 + #7658 + this PR sceVrTracker2Initialize not implemented libSceVrTracker2.prx+0x1650 under app.exe+0x95310a 9.5 s, 4.9 s, 4.9 s

Horizon Call of the Mountain (PPSA05666, v01.004.011) on the second tree: 3 of 3 stop on sceVrTracker2Initialize not implemented (108 s cold cache, 10 s, 11 s), the same addresses as with #7463 alone (app.exe+0x4b8d89b, with the libSceHmd2.prx+0x1920 device-information return address and the VR set-up frames app.exe+0x10f8eee / +0x10fadee up the stack). No sceHmd2Reprojection* export is reached before that abort, which matches the PR text: the reprojection set-up comes after the tracker set-up, and on the emulator the tracker set-up throws first. So Horizon cannot confirm the four values yet; GT7 confirms that QueryDisplayBufferSizeAlign is the first of them a title asks for.

Merge notes: against #7658 the only conflict is the duplicate Hmd2::SizeAlign in Hmd2.hpp and the debt bullet, as both PRs predict (I kept #7658's struct block and both sets of declarations; Export.cpp and GuestHmd2.cpp merged by themselves). #7658 itself conflicts with current main in libSceJson2 (#6126); main's files were kept there.

stderr, GT7 run 3 with this PR (abort block)
[libc] unhandled exception 'St13runtime_error' thrown from 00007fff6d06756c
terminate called after throwing an instance of 'std::runtime_error'
  what():  sceVrTracker2Initialize not implemented
FATAL: abort() (SIGABRT) on thread 15624
    #0 0x00007fff6cfa2c98 libc.prx+0x12c98
    #1 0x00007fff6d083b31 libc.prx+0xf3b31
    #2 0x000000000060f750
  stack return address candidates:
    [rsp+0x8] 0x00007fff6cfa2eb5 libc.prx+0x12eb5
    [rsp+0x38] 0x00007fffd0d62139 ucrtbase.dll+0xc2139
    [rsp+0x98] 0x00007fff6d06756c libc.prx+0xd756c
    [rsp+0xb8] 0x00007fffd0d45261 ucrtbase.dll+0xa5261
    [rsp+0xe0] 0x00007fff6d06756c libc.prx+0xd756c
    [rsp+0xe8] 0x00007fff6cffebf6 libc.prx+0x6ebf6
    [rsp+0x138] 0x00007fff6cff9c7b libc.prx+0x69c7b
    [rsp+0x140] 0x00007fff6d06756c libc.prx+0xd756c
    [rsp+0x158] 0x00007fff6d06756c libc.prx+0xd756c
    [rsp+0x168] 0x00007fff6d008203 libc.prx+0x78203
    [rsp+0x180] 0x00007fff6d06756c libc.prx+0xd756c
    [rsp+0x268] 0x00007fff6d008c1e libc.prx+0x78c1e
    [rsp+0x298] 0x00007fff6d06756c libc.prx+0xd756c
    [rsp+0x328] 0x00007fff6a1e1650 libSceVrTracker2.prx+0x1650
    [rsp+0x358] 0x000000014095310a app.exe+0x95310a
    [rsp+0x428] 0x000000014094e714 app.exe+0x94e714
    [rsp+0x488] 0x00007fff6f3ff1bc libkernel.prx+0x4f1bc
    [rsp+0x498] 0x0000000140a86552 app.exe+0xa86552
    [rsp+0x4e8] 0x00007fff6f40c8cc libkernel.prx+0x5c8cc
    [rsp+0x548] 0x0000000140bde714 app.exe+0xbde714
    [rsp+0x578] 0x00007fff70ce6aca libc.prx.guest.prx+0x56aca
    [rsp+0x588] 0x0000000140c54a0f app.exe+0xc54a0f
    [rsp+0x5b8] 0x0000000140c54b87 app.exe+0xc54b87
    [rsp+0x608] 0x0000000140c54623 app.exe+0xc54623
    [rsp+0x668] 0x00007fffa1fc347e libSceSysmodule.prx+0x347e
    [rsp+0x6b8] 0x000000014092b706 app.exe+0x92b706
    [rsp+0x6e8] 0x000000014092bf61 app.exe+0x92bf61
    [rsp+0x728] 0x00000001416d34af app.exe+0x16d34af
    [rsp+0x730] 0x0000000149072da4 app.exe+0x9072da4
    [rsp+0x748] 0x0000000140d12d7f app.exe+0xd12d7f
stderr, Horizon run 2 with this PR (abort block)
[libc] unhandled exception 'St13runtime_error' thrown from 00007fff6f59756c
terminate called after throwing an instance of 'std::runtime_error'
  what():  sceVrTracker2Initialize not implemented
FATAL: abort() (SIGABRT) on thread 17912
    #0 0x00007fff6f4d2c98 libc.prx+0x12c98
    #1 0x00007fff6f5b3b31 libc.prx+0xf3b31
    #2 0x000000000060e8d0
  stack return address candidates:
    [rsp+0x8] 0x00007fff6f4d2eb5 libc.prx+0x12eb5
    [rsp+0x38] 0x00007fffd0d62139 ucrtbase.dll+0xc2139
    [rsp+0x98] 0x00007fff6f59756c libc.prx+0xd756c
    [rsp+0xb8] 0x00007fffd0d45261 ucrtbase.dll+0xa5261
    [rsp+0xe0] 0x00007fff6f59756c libc.prx+0xd756c
    [rsp+0xe8] 0x00007fff6f52ebf6 libc.prx+0x6ebf6
    [rsp+0x138] 0x00007fff6f529c7b libc.prx+0x69c7b
    [rsp+0x140] 0x00007fff6f59756c libc.prx+0xd756c
    [rsp+0x158] 0x00007fff6f59756c libc.prx+0xd756c
    [rsp+0x168] 0x00007fff6f538203 libc.prx+0x78203
    [rsp+0x180] 0x00007fff6f59756c libc.prx+0xd756c
    [rsp+0x268] 0x00007fff6f538c1e libc.prx+0x78c1e
    [rsp+0x298] 0x00007fff6f59756c libc.prx+0xd756c
    [rsp+0x328] 0x00007fff6cef1650 libSceVrTracker2.prx+0x1650
    [rsp+0x348] 0x00007fff70d35d5a libc.prx.guest.prx+0x15d5a
    [rsp+0x358] 0x0000000144b8d89b app.exe+0x4b8d89b
    [rsp+0x3c8] 0x0000000144b8d669 app.exe+0x4b8d669
    [rsp+0x418] 0x0000000144b905f8 app.exe+0x4b905f8
    [rsp+0x428] 0x00007fffb80a46cb libwinpthread-1.dll+0x46cb
    [rsp+0x468] 0x0000000144b904ed app.exe+0x4b904ed
    [rsp+0x478] 0x000000014240dbf9 app.exe+0x240dbf9
    [rsp+0x480] 0x000000014240dbc0 app.exe+0x240dbc0
    [rsp+0x4b8] 0x000000014251dde4 app.exe+0x251dde4
    [rsp+0x528] 0x000000014251df2e app.exe+0x251df2e
    [rsp+0x558] 0x00000001410fb794 app.exe+0x10fb794
    [rsp+0x568] 0x00007fff6cf51920 libSceHmd2.prx+0x1920
    [rsp+0x5a8] 0x00000001410fadee app.exe+0x10fadee
    [rsp+0x628] 0x00000001410f8eee app.exe+0x10f8eee
    [rsp+0x638] 0x00007fffd0fe282f KERNELBASE.dll+0x2282f
    [rsp+0x678] 0x000000014253e09d app.exe+0x253e09d

Tested. Windows 11 (26200), RTX 4090 (NVIDIA 616.92), WinLibs GCC 15.2.0 r7 (UCRT), Release libs target, ccache, one worktree for both trees; GT7's app.exe is the relink from main 31cbb55, Horizon's the 10/14 relink, only libs/ swapped. Desktop session, no input, 600 s cap, APS5_PLAYGO_UNLISTED_CHUNKS=absent for Horizon, box otherwise idle. Not a review of the console measurements.

AI-assisted: yes (Claude Code).

@blawesom

Copy link
Copy Markdown
Contributor

Rebase handoff, with one design decision flagged for review — rebased onto current main (both commits, authorship unchanged).

The decision: main's b378541e7 ("report the PS VR2 runtime as unavailable again") landed after your merge-base and reverted sceHmd2Initialize to UnsupportedFeature — your branch was built on the initialization-succeeds model. I kept main's architecture (Initialize fails, TestWithoutHeadset stays) and layered your feature on it: the four size queries return the console-measured values ungated, and VrTracker2 applied verbatim. If your intent is to re-land the succeeds-model (#7323 behavior), the Initialize restoration plus your full TestInitialized suite is the part to redo — I did not guess that direction.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds; the Hmd2 tests pass (2/2); conventions pass; full suite green apart from the four known main regressions (#5444 Mesa, #7584 BDA, #7766, #7784), none from this PR.

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/7690
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is 38ce5ba3d.

@frankea

frankea commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Console values for this PR's Hmd2 answers, measured inside Gran Turismo 7 (PPSA01317, 01.690.000) on a retail PS5 (firmware 13.40) with a PS VR2 headset connected and on, by calling the exports from the running game process (ptrace from an elfldr payload):

  • The four size queries match this PR exactly: QueryDisplayBufferSizeAlign 0x6000000 / 0x10000, QuerySeeThroughBufferSizeAlign 0x1106000 / 0x100, GetMirroringDisplayBufferSizeAlign 0x5FA0000 / 0x10000, GetMirroringWorkMemorySizeAlign 0x4000 / 0x100. MLB The Show 25 (no headset, Hmd2 not initialized) gets the same four pairs.
  • sceHmd2GetFieldOfViewWithoutHandle returns 0 with 1.84177089, 0.947190642, 1.32898104, 1.32898104, bit-identical to DefaultFieldOfView.
  • sceHmd2GetDeviceInformation with the headset present returns 0 and 28 bytes: status 0, userId 0, panel 4000 × 2040, latency90Hz 5555, latency120Hz 4160, hmuMount 0, lensSeparationDistance 66 (0x42), reserved 0, virtualImageDistance 2.0f. Apart from status (0 here, 2 = NotDetected in this PR) and lensSeparationDistance (66 here, 0 in this PR), every field matches. I did not measure the no-headset answer inside an initialized title, so this does not say the PR's NotDetected values are wrong, only what a title sees with a headset.
  • GT7 polls sceHmd2GetDeviceInformation every frame from its main loop (seen by recording the title's own calls).

AI-assisted: yes (Claude Code)

@blawesom

Copy link
Copy Markdown
Contributor

Rebase handoff — rebased onto current main (585075cb7, both commits, authorship unchanged).

The resolution, same direction as my earlier flag on this PR: main's b378541e7 deliberately restored the Initialize-fails model (sceHmd2Initialize → UNSUPPORTED_FEATURE), so your first commit's succeeds-model debt text is superseded — I kept main's entry and applied your VrTracker2 before-init answers and the measured size queries on top of it. One consequence I fixed in the docs: main's entry still said the display and see-through size queries "stay unimplemented and throw pending console measurements of their sizes and alignments" — stale once your top commit lands, so that clause now covers only sceHmd2ReprojectionQueryBufferSizeAlign (the one you left unimplemented, its measurement documented in your new entry). Your new entry for the five measurements is untouched.

Worth noting for reviewers: @frankea's console measurements from inside GT7 this morning (PS VR2 connected) match your four implemented values exactly — independent corroboration on top of your payload measurements.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds; guest_hmd2 and guest_vr_tracker2 pass; full suite green apart from the four known main regressions (#5444 Mesa, #7584 BDA, #7766, #7784), none from this PR; conventions pass with two [debt-length] findings (one is main's pre-existing Hmd2 entry, shortened by the clause fix; one is this PR's new VrTracker2 entry — warnings only).

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/7690
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is 7a5d02a79.

# Conflicts:
#	docs/dev/debt/libSceHmd2.md
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 20, 2026
@oneandonlydean
oneandonlydean merged commit 3fd1cc3 into boykopovar:main Oct 20, 2026
10 checks passed
primesoul-web added a commit to primesoul-web/AnyPS5 that referenced this pull request Oct 20, 2026
oneandonlydean pushed a commit that referenced this pull request Oct 20, 2026
The overlap audit against origin/main and the open pull requests found 39 of
the 193 declared exports that must not be declared here:

- 14 that origin/main already exports. The nid_patcher computes the NID of a
  symbol from its name, and a name ending in _nid_postfix exports the NID of
  the base name, so scePadOpen, sceNetInit and the rest are already there.
- 23 that an open pull request provides: #6832, #6847, #6852, #7846, #7881,
  #7889, #7890, #6977 and #7690.
- 2 whose technical-debt file an open pull request creates: #7463 and #8094.

The scope is now 30 libraries and 154 exports.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants