feat(libSceGnmDriverForNeoMode): set the embedded fullscreen VS and PS shaders #9221

Merged
YossiYad merged 4 commits from upstream-pr/9221 into main 2026-10-24 15:16:30 +00:00
YossiYad commented 2026-10-21 15:32:12 +00:00 (Migrated from github.com)

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


What

sceGnmSetEmbeddedVsShader and sceGnmSetEmbeddedPsShader threw. They now write the register packets of shadPS4's gnmdriver.cpp:

  • VS id 0: a fullscreen triangle with one UV set
  • PS id 0: writes black
  • PS id 1: exports depth only
  • any other id returns 0x8EEE00FF

The program address points at the shader code in include/EmbeddedShaders.hpp, 256-byte aligned. That code is the instruction listing shadPS4 writes next to its words, assembled with LLVM 19 llvm-mc -arch=amdgcn -mcpu=bonaire; the steps are in this comment. The binary header and register block that follow the code on the console are left out, since nothing here reads them. On the console the shaders sit at 0xfe000f00; shadPS4 also points at its own copy. As in shadPS4, the size and modifier arguments are not checked.

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 63.

Tested

Linux (Fedora 44, GCC, Ninja, -DBUILD_TESTING=ON), based on main 5d3ab7791d (the full ctest line is from the earlier base cecb540a63):

  • guest_gnm_neo_embedded (core/libs/tests/GuestGnmNeoEmbedded.cpp) compares every packet word and checks that nothing past the packets is written.
  • It rebuilds the program address from the SPI_SHADER_PGM_LO/HI words and checks the shader code found there: the first instruction, the export and s_endpgm.
  • It checks that each refused id leaves the buffer untouched. It aborts on main.
  • Each of 8 mutations makes the test fail:
    • each id bound
    • the CB_SHADER_MASK and SPI_SHADER_COL_FORMAT choices
    • the address high-word shift
    • the position format
    • swapping the two pixel shaders
    • one instruction 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.02%, 2 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 #9212, which implement 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:4954142615 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9221). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-10-21T15:32:12Z. --- ### What `sceGnmSetEmbeddedVsShader` and `sceGnmSetEmbeddedPsShader` threw. They now write the register packets of [shadPS4's gnmdriver.cpp](https://github.com/shadps4-emu/shadPS4/blob/a808e76/src/core/libraries/gnmdriver/gnmdriver.cpp): - VS id 0: a fullscreen triangle with one UV set - PS id 0: writes black - PS id 1: exports depth only - any other id returns `0x8EEE00FF` The program address points at the shader code in `include/EmbeddedShaders.hpp`, 256-byte aligned. That code is the instruction listing shadPS4 writes next to its words, assembled with LLVM 19 `llvm-mc -arch=amdgcn -mcpu=bonaire`; the steps are in [this comment](https://github.com/boykopovar/AnyPS5/pull/9221#issuecomment-6382744010). The binary header and register block that follow the code on the console are left out, since nothing here reads them. On the console the shaders sit at `0xfe000f00`; shadPS4 also points at its own copy. As in shadPS4, the size and modifier arguments are not checked. 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 63. ### Tested Linux (Fedora 44, GCC, Ninja, `-DBUILD_TESTING=ON`), based on `main` `5d3ab7791d` (the full `ctest` line is from the earlier base `cecb540a63`): - `guest_gnm_neo_embedded` (`core/libs/tests/GuestGnmNeoEmbedded.cpp`) compares every packet word and checks that nothing past the packets is written. - It rebuilds the program address from the `SPI_SHADER_PGM_LO`/`HI` words and checks the shader code found there: the first instruction, the export and `s_endpgm`. - It checks that each refused id leaves the buffer untouched. It aborts on `main`. - Each of 8 mutations makes the test fail: - each id bound - the CB_SHADER_MASK and SPI_SHADER_COL_FORMAT choices - the address high-word shift - the position format - swapping the two pixel shaders - one instruction 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.02%, 2 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 #9212, which implement 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:44 +00:00 (Migrated from github.com)

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


Rebased onto main 8b3a6ba88 after #9201 (head e75e66348). #9201 already defines Failure (0x8EEE00FF) for this module, so I dropped this PR's copy and merged the two anonymous namespaces. The pending count is 68, which matches the throwing exports left in Export.cpp. guest_gnm_neo_embedded and guest_gnm_neo_retail pass 3 of 3.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6341340262 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9221#issuecomment-6341340262). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-10-22T12:58:44Z. --- Rebased onto `main` `8b3a6ba88` after #9201 (head `e75e66348`). #9201 already defines `Failure` (`0x8EEE00FF`) for this module, so I dropped this PR's copy and merged the two anonymous namespaces. The pending count is 68, which matches the throwing exports left in `Export.cpp`. `guest_gnm_neo_embedded` and `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!9221
No description provided.