feat(libSceGnmDriver): build PS4 command buffers and submit them #9432
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9432"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Get-fix on 2026-10-21T21:51:04Z.
What
Part 4 of the PS4 Limbo stack, split out of #6977 (the whole stack is listed in #6978). Only the last four commits are this PR; the ones below them are #9430 and #9431.
A real
libSceGnmDriverfor PS4 titles on the AGC executor:sceGnmshader setters (sceGnmSetPsShader,SetVsShader,SetCsShaderand the ES/GS/HS/LS ones), the default hardware state, markers,sceGnmInsertWaitFlipDoneand the EOP event calls, with the packets, register offsets and reserved sizes of shadPS4'sgnmdriver.cpp(listed as unverified indocs/dev/debt/libSceGnmDriver.md).sceGnmSubmitCommandBuffers,sceGnmSubmitAndFlipCommandBuffersandsceGnmSubmitDoneinto the AGC executor:GNM_ERROR_SUBMISSION_FAILED_INVALID_ARGUMENT: a null draw buffer, a byte count that is not a multiple of 4, or a constant byte count without a constant buffer.GcnGuestShaders()through the AGC driver, so a PS4 title's shaders take the GCN decoder.sceVideoOutSubmitChangeBufferAttribute2, and accepts the PS4 10-bit display format.sceVideoOutCursorSetHotSpotis declared as not implemented (Limbo imports it;mainhas the other four cursor calls since #6135).sceGnmAreSubmitsAllowed,sceGnmIsUserPaEnabled,sceGnmDriverCaptureInProgressandsceRazorIsLoadedanswer for a host without development tools and are listed under Silent stubs, as shadPS4 answers for retail firmware.sceGnmLogicalCuMaskToPhysicalCuMaskandsceGnmLogicalCuIndexToPhysicalCuIndexthrow: the console's logical-to-physical compute unit mapping is not documented.Tested
Windows 11, WinLibs GCC 15.2, NVIDIA GeForce RTX 5060 Ti (driver 610.88), on
main7e2ba73e4with #9430 and #9431:guest_gnm_driver(new) checks:WRITE_DATA, with the label checked after the GPU is idle.With filler handling switched off, it fails with
GnmDriver: unsupported PM4 packet type in the draw command buffer.video_out_flip_ps4registers a tiled PS4 buffer, refuses tiling mode 2, and changes a PS4 set to tiled and back.The full suite of 1,893 tests: 1,886 pass and 4 skip, the same 4 that skip on
main(three for device features this GPU lacks, andguest_video_out_wqhd_detection_no_vulkan). The 3 that fail also fail onmain7e2ba73e4on this machine:agc_driver_sample_orderand its--grid-referenceand--recipe-depth-locationscases.Limbo (CUSA01664), converted and run with the whole stack on 22 Oct, GPU otherwise idle: a 60 s scripted run from start into gameplay, with no errors and no not-implemented calls. The frames dumped about every 9 s show the save's checkpoint (the gallows and the crate) rendered correctly, with the boy moving the crate between dumps.
sceGnmLogicalCuMaskToPhysicalCuMaskis imported but not called.Validation layer:
ctest -R "^(agc|video_out|shader|recompiler|gcn)" -VwithANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Vulkan SDK 1.4.363), onmain7e2ba73e4and on this PR with #9430 and #9431, same machine and GPU. Both builds use-DANYPS5_VIDEO_OUT_TEST_DRIVER=windows, so the 14 VideoOut flip tests get a real display.main: 913 tests; 907 pass, 3 skip and 3 fail (agc_driver_sample_orderand its two cases).agc_gcn_decodeandagc_driver_gcn_detile, which pass. All 14 flip tests pass on both.VUID-errors in the same 8 existing PS5 tests, with the same IDs and counts test for test (agc_driver_prepared_exports, the threeagc_driver_sample_ordercases and four others). This PR adds none.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-22T04:27:56Z.
@Get-fix I've read #9432's own commit (on top of #9431). The PS5 flip and present path is unchanged: every new branch is behind
group.ps4. One thing blocks it:core/libs/prx/libSceVideoOut/tests/Flip.cpp:159-163(not touched here) still registers a PS4 buffer withtiling_mode = 0and expects the exception "tiled display buffers are not implemented". This PR removes that throw (Buffer.cppnow throws only fortiling_mode > 1), sovideo_out_flip_ps4will fail on every lane. Could you update that test so it expects a tiled PS4 buffer to register, and keep a refused case fortiling_mode > 1?One more question, not a blocker:
libSceGnmDriver/Export.cppadds about 570 lines of command-buffer writers with no test of their own, so for now Limbo is their only coverage. If a small submit smoke test is easy (build a short command buffer and check the packets it writes), I'd like one. If not, say so and I'll weigh the Limbo evidence instead.Once the test is fixed, I'll run the full workflow on the new head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:47:36Z.
Review: CHANGES_REQUESTED
The reported Limbo run and paired Vulkan validation are useful evidence, and the PR correctly records several unverified areas as technical debt. I found a generic command-buffer case that the new parser rejects, plus validation/evidence gaps that should be addressed before merge:
PacketAtrejects every packet whose type is not 3. AMD's Southern Islands programming guide defines type-2 as a one-dword filler packet used to consume unused trailing allocation space, and also permits it in command streams (see PM4 §2.1.3 and §2.1.6, pp. 12–13). A valid PS4 DCB or CCB containing this standard padding will throw before submission. Please accept and preserve/skip type-2 filler packets, and add a command-buffer regression covering one in both the draw and constant streams.CheckSubmissionvalidates array pointers and byte limits, but not each DCB/CCB element or dword alignment. A nonzero DCB length withdcbs[i] == nullptrreachesPacketAtand dereferences null; a byte length not divisible by four is silently truncated by/ 4. Please reject these malformed entries before parsing and cover them with tests. Also make a nonzero CCB length with a null CCB pointer an explicit invalid-argument result rather than silently treating it as an absent CCB.sceGnmLogicalCuMaskToPhysicalCuMaskignores its GPU argument and returns the logical mask unchanged, but this behavior has no evidence or technical-debt entry. Under the repository rule that a function must implement its behavior or throw, please provide evidence/tests for this mapping or leave it as a throwing unimplemented path with the relevant debt recorded.The PR comparison is 534 commits behind current
main; the described test baseline iscecb540a6. Please rebase onto currentmainand rerun the affected AGC/shader/VideoOut focused tests with the repository-required validation-layer environment on bothmainand the change, then refresh conventions, intake, and overlap checks. The current reported paired runs are thorough for that older baseline, but do not validate the current base.Hosted conventions, eligibility, intake, labels, and report checks pass. Product Linux/Windows and relinker jobs are skipped. I did not run these tests locally because no matching PR checkout/build is available; the existing full
/tmpbuild belongs to a different change.Imported from boykopovar/AnyPS5. Originally posted by Get-fix on 2026-10-22T11:06:53Z.
@oneandonlydean @MarcZX10 thanks for the reviews. Rebased onto
main7e2ba73e4with three new commits on top of the original one:video_out_flip_ps4(f2928f44d): the test now registers a PS4 buffer with tiling mode 0 and checks it is described as a GCN display buffer with its pitch padded to 128 pixels, and it keeps a refused case for tiling mode 2 (VIDEO_OUT_ERROR_INVALID_TILING_MODE). The rerun also showed that the test's earlier step, which changes a PS4 set to tiling mode 0 throughsceVideoOutSubmitChangeBufferAttribute2, failed with this PR: the changed set kept a PS4 pitch of 0.sceVideoOutSubmitChangeBufferAttribute2now computes the same padded pitch as the registration, and the test changes the set to tiled, checks it, and changes it back to linear.Type-2 filler packets (
057384487): a type-2 dword in the draw or constant command buffer is dropped instead of throwing, per the SI guide sections you linked. @ntamas94 did the same in #9676 first, so they are credited as co-author.Malformed submissions (same commit): a null
dcbs[i], a draw or constant byte count that is not a multiple of 4, and a nonzero constant byte count with a null constant buffer pointer or array now returnGNM_ERROR_SUBMISSION_FAILED_INVALID_ARGUMENTbefore any packet is read. A zero constant byte count without a constant buffer array is accepted as no constant buffer.Smoke test (same commit): the new
guest_gnm_driverchecks:WRITE_DATA, with the label checked afterAgcDriverWaitIdle;With filler handling switched off, it fails with
GnmDriver: unsupported PM4 packet type in the draw command buffer.sceGnmLogicalCuMaskToPhysicalCuMask(e2ad553d7): it now throws likesceGnmLogicalCuIndexToPhysicalCuIndex, and both are listed indocs/dev/debt/libSceGnmDriver.md. The console maps logical to physical compute units by the units disabled on its GPU, and I have no evidence of that mapping; shadPS4's identity answer isn't evidence either. Limbo imports the function but did not call it in a 60 s run from start to gameplay.The tests, the paired validation-layer runs and the Limbo run on the new base are in the description.
AI-assisted: yes (Claude Code)
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T09:59:37Z.
Review: DISMISSED
Re-review — changes requested
The new head addresses the earlier concrete findings: the PS4
video_out_flip_ps4case now expects tiling mode 0 to register with the padded GCN pitch and retains a rejected mode-2 case; the tiledsceVideoOutSubmitChangeBufferAttribute2path also updates its pitch. The PR adds aguest_gnm_driversmoke test, handles type-2 filler packets in draw and constant streams, and rejects malformed DCB/CCB submissions before parsing. BunnyFl’s firmware disassembly report supplies direct support for the CU-mask identity behavior and records the observed engine limits.The current-main integration is now the blocker. I refreshed upstream
maintof7e84c4cf1609cc10bac95a44cd431805e5ebc8aand checked exact headf2928f44d427ff146e00b80683785feabdb5a16e.tools/check_main_sync.pyreports six conflicts, includingGuestTextureResource.hpp,State.hpp,DepthSurface.cpp,State.cpp,libSceVideoOut/tests/Flip.cpp, anddocs/dev/debt/libSceVideoOut.md; 38 paths changed on both sides since merge basea13d01bcc. The reported validation/tests are from the older7e2ba73e4integration and do not cover these combined paths.Please reconcile current
main, preserving this PR’s PS4 GNM behavior and regression cases alongside the newer texture, state, and VideoOut changes. Then rerun the focused GNM submission, GCN texture/mip, and VideoOut flip tests with Vulkan validation where applicable. The current merge preview has conflicts;git diff --checkpasses. Hosted product jobs are skipped, and I did not run the GPU tests locally.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T22:41:20Z.
Review: DISMISSED
Reviewed — changes requested
The merge with
mainbuilds andguest_gnm_driverpasses (it also fails when filler handling is switched off), butpublic_headersfails on the merged tree becauselibSceGnmDriverhas no umbrella header.What I ran
Head
328a2bca8536896dd8354354429a869c4fab9b36,main1c8c0efc8c41314402e6966da5bef6ea3d639d10, merged tree8499d4beb959b79e94e11165ca79428fd2a8ad60(Release, GCC 14.2.0, Ninja, Debian 13 VM, lavapipe Mesa 26.1.6).Results
git diff --checkcheck_conventions.pylibs(script)guest_gnm_driverguest_gnm_neo_*(6 tests, same area onmain)public_headersmainbaselinevideo_out_flip_ps4SDL_VIDEODRIVER=offscreenon this machinenew_vuidentry isagc_driver_image_gather_volume, which was not in the older baseline. It comes frommain(see below)git status --porcelainafter the controlspublic_headers
agc_driver_image_gather_volume with the PR's VideoOut files restored from main
These are the same 8 lines the script reports for the merged tree. The PR changes no
libSceAgcDriverfile, and amaincommit after the baseline SHA touches this test. So these VUIDs come frommainand are not a finding here.Negative control
IsFillerincore/libs/prx/libSceGnmDriver/Export.cppreturnfalseand rebuilt.guest_gnm_driverthen failed withGnmDriver: unsupported PM4 packet type in the draw command buffer, as the description says. I restored the merged file, rebuilt, and the test passed again.main, but only for the VUID attribution above. I could not use them as a control for the changedvideo_out_flip_ps4, because that test skips on this machine.Findings
Blocking
public_headersfails on the merged tree. core/libs/prx/libSceGnmDriver has nolibSceGnmDriver.hppand no header declaring its 45APS5_VABIexports. Also, core/libs/tests/GuestGnmDriver.cpp:12-22 declares eight exports locally, which CONTRIBUTING.md forbids. ntamas94 and oneandonlydean already reported this; I confirm it with the test output above on the current merge. The merge commit328a2bca85brought inmainbut not the fix. Suggested fix: add the umbrella header andinclude/Api.hppwith every export (for example by cherry-picking108fd28b0eas offered), include it fromExport.cppand the test, drop the local declarations, and declaresceVideoOutCursorSetHotSpotin a VideoOut header if the check requires it.Non-blocking
sceVideoOutRegisterBuffers"accepts only linear A8R8G8B8_SRGB (0x80000000) and A8B8G8R8_SRGB (0x80002200)" and that "tiled PS4 buffers throw". This PR makes tiling mode 0 register and adds 0x88000000 (Buffer.cpp:87). Per the documentation rule, cut that entry to what is still open instead of only adding a new one on line 36.0x88000000 → 0x8100000000000000is not exercised byvideo_out_flip_ps4, and nothing records where the PS5 value comes from. Add a registration case to the flip test, and either name the source or note it as unverified in the debt entry.TIMEOUT 60for a test that runs in 0.03 s here. CONTRIBUTING.md asks for tests to finish in 30 s and not to raise timeouts. Drop the property or lower it.Not verified
video_out_flip_ps4skipped on this machine (no display or Vulkan surface under the offscreen SDL driver). So the new tiled-registration and attribute-change checks, and thesceVideoOutSubmitChangeBufferAttribute2pitch fix, were neither run nor negative-controlled here.PatchFlip) or the EOP, EOS and SURFACE_SYNC lowering:guest_gnm_drivercovers neither.To get this to a good state
libSceGnmDriverumbrella header and its export declarations, remove the local declarations fromGuestGnmDriver.cpp, and confirmpublic_headers(and its compile batches) pass on a merge with currentmain.