feat(libSceGnmDriverForNeoMode): write the shader register packets and answer the workload and clock queries #9212

Merged
YossiYad merged 8 commits from upstream-pr/9212 into main 2026-10-24 12:51:39 +00:00
YossiYad commented 2026-10-21 15:21:53 +00:00 (Migrated from github.com)

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


What

12 libSceGnmDriverForNeoMode exports threw. They now follow shadPS4's gnmdriver.cpp, with its signatures, size checks and -1 refusals:

  • shader registers: sceGnmUpdateVsShader, sceGnmUpdatePsShader, sceGnmUpdatePsShader350, sceGnmSetPsShader350, sceGnmUpdateGsShader, sceGnmUpdateHsShader and sceGnmSetCsShaderWithModifier write their SET_SH_REG and SET_CONTEXT_REG packets. The update forms carry the context registers inside NOP packets, as in shadPS4. A null PS register block writes the packets that disable the pixel shader.
  • workloads: sceGnmCreateWorkloadStream, sceGnmBeginWorkload and sceGnmEndWorkload return shadPS4's values and keep no state:
    • 3 for a null output or name
    • 1 for a stream above 15
    • 2 for workload 0 or one whose top byte is above 15
  • sceGnmGetGpuCoreClockFrequency returns 911 MHz, shadPS4's Neo-mode value (this module is the Neo-mode driver).
  • sceGnmGetOffChipTessellationBufferSize returns 0x800000.

Not compared with console output, and nothing in AnyPS5 consumes a GNM command buffer yet; the debt entries say both. The pending count drops from 65 to 53.

Tested

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

  • guest_gnm_neo_shaders (core/libs/tests/GuestGnmNeoShaders.cpp) fills a buffer with a marker and compares every word each writer produces, including the words past the packet. It also checks that each refusal leaves the buffer untouched, and it checks the workload and query values. It aborts on main.
  • Each of 16 mutations makes the test fail:
    • each of the three modifier masks
    • the PS NOP sizes and the CB_SHADER_MASK default
    • the VS and HS register sources
    • the CS thread count packet
    • the GS size bound
    • the three workload results
    • the clock value
    • the NOP first word
  • 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.11%, 12 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 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:4953997851 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9212). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-10-21T15:21:53Z. --- ### What 12 libSceGnmDriverForNeoMode exports threw. They now follow [shadPS4's gnmdriver.cpp](https://github.com/shadps4-emu/shadPS4/blob/a808e76/src/core/libraries/gnmdriver/gnmdriver.cpp), with its signatures, size checks and -1 refusals: - shader registers: `sceGnmUpdateVsShader`, `sceGnmUpdatePsShader`, `sceGnmUpdatePsShader350`, `sceGnmSetPsShader350`, `sceGnmUpdateGsShader`, `sceGnmUpdateHsShader` and `sceGnmSetCsShaderWithModifier` write their `SET_SH_REG` and `SET_CONTEXT_REG` packets. The update forms carry the context registers inside NOP packets, as in shadPS4. A null PS register block writes the packets that disable the pixel shader. - workloads: `sceGnmCreateWorkloadStream`, `sceGnmBeginWorkload` and `sceGnmEndWorkload` return shadPS4's values and keep no state: - 3 for a null output or name - 1 for a stream above 15 - 2 for workload 0 or one whose top byte is above 15 - `sceGnmGetGpuCoreClockFrequency` returns 911 MHz, shadPS4's Neo-mode value (this module is the Neo-mode driver). - `sceGnmGetOffChipTessellationBufferSize` returns `0x800000`. Not compared with console output, and nothing in AnyPS5 consumes a GNM command buffer yet; the debt entries say both. The pending count drops from 65 to 53. ### Tested Linux (Fedora 44, GCC, Ninja, `-DBUILD_TESTING=ON`), based on `main` `cecb540a63`: - `guest_gnm_neo_shaders` (`core/libs/tests/GuestGnmNeoShaders.cpp`) fills a buffer with a marker and compares every word each writer produces, including the words past the packet. It also checks that each refusal leaves the buffer untouched, and it checks the workload and query values. It aborts on `main`. - Each of 16 mutations makes the test fail: - each of the three modifier masks - the PS NOP sizes and the CB_SHADER_MASK default - the VS and HS register sources - the CS thread count packet - the GS size bound - the three workload results - the clock value - the NOP first word - 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.11%, 12 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 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
YossiYad commented 2026-10-22 12:58:41 +00:00 (Migrated from github.com)

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


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

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