feat(libSceGnmDriverForNeoMode): write the Neo default hardware and context state #9219

Merged
YossiYad merged 4 commits from upstream-pr/9219 into main 2026-10-23 07:06:45 +00:00
YossiYad commented 2026-10-21 15:29:34 +00:00 (Migrated from github.com)

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


What

Five libSceGnmDriverForNeoMode default-state writers threw. They now write the sequences from shadPS4's gnmdriver_init.h, with the size checks and returned sizes of gnmdriver.cpp:

  • sceGnmDrawInitDefaultHardwareState, ...200 and ...350 return 0 below 0x100 words. Otherwise each writes the clear-state preamble, its register sequence and a NOP that pads to 0x100 words, then returns 0x100.
  • sceGnmDrawInitToDefaultContextState (0x20 words) and ...400 (0x100 words) write their sequence only when the size matches exactly, and return 0 otherwise.

This module is the Neo-mode driver, so the 200, 350 and context sequences are shadPS4's Neo ones. Those end by resetting IA_MULTI_VGT_PARAM through SET_UCONFIG_REG, the same packet sceGnmResetVgtControl writes in Neo mode. The plain hardware state is the one sequence shadPS4 also writes unchanged in Neo mode.

The tables live in include/InitSequences.hpp with shadPS4's SPDX header, as libSceFont/include/FontDriver.hpp does for its ported code. 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 70 to 65.

sceGnmDrawInitToDefaultContextStateInternalCommand and ...InternalSize stay unimplemented. They choose by the title's compiled SDK version, and sceKernelGetCompiledSdkVersion still throws in AnyPS5.

Tested

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

  • guest_gnm_neo_default_state (core/libs/tests/GuestGnmNeoDefaultState.cpp) fills a buffer with a marker. For each writer it checks the refusal sizes leave the buffer untouched, and that the return value is right. It also checks the preamble, the first and last packets of the sequence, the padding NOP and every untouched word, including past 0x100. It aborts on main.
  • Each of 8 mutations makes the test fail:
    • the lower size bound
    • the padding count
    • the NOP first word
    • the exact context size
    • the returned size
    • swapping the 200 and 350 tables
    • one preamble word
    • one Neo VGT word in a table
  • 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.05%, 5 functions implemented, none lost.
  • tools/check_conventions.py --base upstream/main passes.
  • tools/pr_overlap.py finds core/libs/CMakeLists.txt shared with other PRs. It also finds my #9208, #9212 and #9221, which implement other functions of this module in the same Export.cpp and debt file; 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:4954106119 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9219). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-10-21T15:29:34Z. --- ### What Five libSceGnmDriverForNeoMode default-state writers threw. They now write the sequences from [shadPS4's gnmdriver_init.h](https://github.com/shadps4-emu/shadPS4/blob/a808e76/src/core/libraries/gnmdriver/gnmdriver_init.h), with the size checks and returned sizes of [gnmdriver.cpp](https://github.com/shadps4-emu/shadPS4/blob/a808e76/src/core/libraries/gnmdriver/gnmdriver.cpp): - `sceGnmDrawInitDefaultHardwareState`, `...200` and `...350` return 0 below 0x100 words. Otherwise each writes the clear-state preamble, its register sequence and a NOP that pads to 0x100 words, then returns 0x100. - `sceGnmDrawInitToDefaultContextState` (0x20 words) and `...400` (0x100 words) write their sequence only when the size matches exactly, and return 0 otherwise. This module is the Neo-mode driver, so the 200, 350 and context sequences are shadPS4's Neo ones. Those end by resetting `IA_MULTI_VGT_PARAM` through `SET_UCONFIG_REG`, the same packet `sceGnmResetVgtControl` writes in Neo mode. The plain hardware state is the one sequence shadPS4 also writes unchanged in Neo mode. The tables live in `include/InitSequences.hpp` with shadPS4's SPDX header, as `libSceFont/include/FontDriver.hpp` does for its ported code. 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 70 to 65. `sceGnmDrawInitToDefaultContextStateInternalCommand` and `...InternalSize` stay unimplemented. They choose by the title's compiled SDK version, and `sceKernelGetCompiledSdkVersion` still throws in AnyPS5. ### Tested Linux (Fedora 44, GCC, Ninja, `-DBUILD_TESTING=ON`), based on `main` `cecb540a63`: - `guest_gnm_neo_default_state` (`core/libs/tests/GuestGnmNeoDefaultState.cpp`) fills a buffer with a marker. For each writer it checks the refusal sizes leave the buffer untouched, and that the return value is right. It also checks the preamble, the first and last packets of the sequence, the padding NOP and every untouched word, including past 0x100. It aborts on `main`. - Each of 8 mutations makes the test fail: - the lower size bound - the padding count - the NOP first word - the exact context size - the returned size - swapping the 200 and 350 tables - one preamble word - one Neo VGT word in a table - 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.05%, 5 functions implemented, none lost. - `tools/check_conventions.py --base upstream/main` passes. - `tools/pr_overlap.py` finds `core/libs/CMakeLists.txt` shared with other PRs. It also finds my #9208, #9212 and #9221, which implement other functions of this module in the same Export.cpp and debt file; 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
github-actions[bot] commented 2026-10-21 15:30:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T15:30:27Z.


Progress report (3ca07d0 → f6d5447)

📈 System libraries: 43.28% (+0.05%, +5 implemented functions)

✅ 5 implemented
Library Name
libSceGnmDriverForNeoMode sceGnmDrawInitDefaultHardwareState
libSceGnmDriverForNeoMode sceGnmDrawInitDefaultHardwareState200
libSceGnmDriverForNeoMode sceGnmDrawInitDefaultHardwareState350
libSceGnmDriverForNeoMode sceGnmDrawInitToDefaultContextState
libSceGnmDriverForNeoMode sceGnmDrawInitToDefaultContextState400
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6319782057 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9219#issuecomment-6319782057). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-21T15:30:27Z. --- <!-- progress-report --> ### Progress report (3ca07d0 → f6d5447) 📈 **System libraries**: 43.28% (+0.05%, +5 implemented functions) <details> <summary>✅ 5 implemented</summary> | Library | Name | | - | - | | libSceGnmDriverForNeoMode | `sceGnmDrawInitDefaultHardwareState` | | libSceGnmDriverForNeoMode | `sceGnmDrawInitDefaultHardwareState200` | | libSceGnmDriverForNeoMode | `sceGnmDrawInitDefaultHardwareState350` | | libSceGnmDriverForNeoMode | `sceGnmDrawInitToDefaultContextState` | | libSceGnmDriverForNeoMode | `sceGnmDrawInitToDefaultContextState400` | </details>
YossiYad commented 2026-10-22 12:58:42 +00:00 (Migrated from github.com)

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


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

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