feat(libSceGnmDriverForNeoMode): write the draw, dispatch, compute wait and VGT control packets #9208

Merged
YossiYad merged 7 commits from upstream-pr/9208 into main 2026-10-23 11:02:59 +00:00
YossiYad commented 2026-10-21 15:17:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-21T15:17:12Z.


What

17 libSceGnmDriverForNeoMode command writers threw. They now write the PM4 packets shadPS4's gnmdriver.cpp writes, with its signatures, size checks and -1 refusals:

  • direct draws: sceGnmDrawIndexAuto, sceGnmDrawIndex, sceGnmDrawIndexOffset, and sceGnmInsertDingDongMarker
  • dispatches: sceGnmDispatchDirect, sceGnmDispatchIndirect, sceGnmDispatchIndirectOnMec
  • indirect draws: sceGnmDrawIndirect, sceGnmDrawIndexIndirect, both *Multi and both *CountMulti forms
  • compute waits: sceGnmComputeWaitSemaphore, sceGnmComputeWaitOnAddress
  • sceGnmSetVgtControl and sceGnmResetVgtControl

This module is the Neo-mode driver, so the writers take shadPS4's Neo-mode branch:

  • Draw initiators keep flag bits 29 to 31.
  • The VGT calls write IA_MULTI_VGT_PARAM through SET_UCONFIG_REG, since shadPS4's UseNeoCompatSequences is false.
  • The NOP padding writes only its header and first word, as shadPS4's WriteNop does.

The packets are not compared with console output, and nothing in AnyPS5 consumes a GNM command buffer yet; the debt entry says both. The pending count drops from 65 to 48.

Tested

Linux (Fedora 44, GCC, Ninja, -DBUILD_TESTING=ON), based on main cecb540a63:

  • guest_gnm_neo_packets (core/libs/tests/GuestGnmNeoPackets.cpp) fills a buffer with a marker, calls each writer and compares every word, including the words that must stay untouched. It also checks each refusal leaves the buffer untouched. It aborts on main. Twelve mutations each make it fail: the predicate bit, the NOP first word, the LS SGPR base, the dispatch ordered-append bit, the count-address enable bit, the VGT reset value, the uconfig bits, the wait compare mask, the odd index address check, the indexed indirect stage check, the semaphore wait bits and the wait poll interval.
  • Full ctest: 1794 of 1802 pass. The 8 failures fail the same way on main on this machine and do not link this library: application_heap_scripting, application_heap_lazy, agc_driver_guest_memory_lifetime, agc_driver_image_array_window_past_layer_limit, agc_driver_tessellation and the three net_dontwait_blocking_* cases.
  • tools/progress.py --compare: libraries +0.16%, 17 functions implemented, none lost.
  • tools/check_conventions.py --base upstream/main passes. tools/pr_overlap.py only finds core/libs/CMakeLists.txt shared with other PRs. #9212 and #9221 (mine) edit the same Export.cpp and debt file for other functions of this module; whichever merges later needs a rebase of the pending count.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4953933092 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9208). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-10-21T15:17:12Z. --- ### What 17 libSceGnmDriverForNeoMode command writers threw. They now write the PM4 packets [shadPS4's gnmdriver.cpp](https://github.com/shadps4-emu/shadPS4/blob/a808e76/src/core/libraries/gnmdriver/gnmdriver.cpp) writes, with its signatures, size checks and -1 refusals: - direct draws: `sceGnmDrawIndexAuto`, `sceGnmDrawIndex`, `sceGnmDrawIndexOffset`, and `sceGnmInsertDingDongMarker` - dispatches: `sceGnmDispatchDirect`, `sceGnmDispatchIndirect`, `sceGnmDispatchIndirectOnMec` - indirect draws: `sceGnmDrawIndirect`, `sceGnmDrawIndexIndirect`, both `*Multi` and both `*CountMulti` forms - compute waits: `sceGnmComputeWaitSemaphore`, `sceGnmComputeWaitOnAddress` - `sceGnmSetVgtControl` and `sceGnmResetVgtControl` This module is the Neo-mode driver, so the writers take shadPS4's Neo-mode branch: - Draw initiators keep flag bits 29 to 31. - The VGT calls write `IA_MULTI_VGT_PARAM` through `SET_UCONFIG_REG`, since shadPS4's `UseNeoCompatSequences` is false. - The NOP padding writes only its header and first word, as shadPS4's `WriteNop` does. The packets are not compared with console output, and nothing in AnyPS5 consumes a GNM command buffer yet; the debt entry says both. The pending count drops from 65 to 48. ### Tested Linux (Fedora 44, GCC, Ninja, `-DBUILD_TESTING=ON`), based on `main` `cecb540a63`: - `guest_gnm_neo_packets` (`core/libs/tests/GuestGnmNeoPackets.cpp`) fills a buffer with a marker, calls each writer and compares every word, including the words that must stay untouched. It also checks each refusal leaves the buffer untouched. It aborts on `main`. Twelve mutations each make it fail: the predicate bit, the NOP first word, the LS SGPR base, the dispatch ordered-append bit, the count-address enable bit, the VGT reset value, the uconfig bits, the wait compare mask, the odd index address check, the indexed indirect stage check, the semaphore wait bits and the wait poll interval. - Full `ctest`: 1794 of 1802 pass. The 8 failures fail the same way on `main` on this machine and do not link this library: `application_heap_scripting`, `application_heap_lazy`, `agc_driver_guest_memory_lifetime`, `agc_driver_image_array_window_past_layer_limit`, `agc_driver_tessellation` and the three `net_dontwait_blocking_*` cases. - `tools/progress.py --compare`: libraries +0.16%, 17 functions implemented, none lost. - `tools/check_conventions.py --base upstream/main` passes. `tools/pr_overlap.py` only finds `core/libs/CMakeLists.txt` shared with other PRs. #9212 and #9221 (mine) edit the same Export.cpp and debt file for other functions of this module; whichever merges later needs a rebase of the pending count. ### 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) - [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 - [x] AI-assisted: yes
YossiYad commented 2026-10-22 12:58:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-22T12:58:40Z.


Rebased onto main 8b3a6ba88 after #9201 (head 9254aafe8). This PR's helpers now share one anonymous namespace with #9201's error constants, and the pending count is 53, which matches the throwing exports left in Export.cpp. guest_gnm_neo_packets and #9201's guest_gnm_neo_retail pass 3 of 3.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6341338977 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9208#issuecomment-6341338977). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-10-22T12:58:40Z. --- Rebased onto `main` `8b3a6ba88` after #9201 (head `9254aafe8`). This PR's helpers now share one anonymous namespace with #9201's error constants, and the pending count is 53, which matches the throwing exports left in `Export.cpp`. `guest_gnm_neo_packets` and #9201's `guest_gnm_neo_retail` pass 3 of 3.
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!9208
No description provided.