feat(libSceGnmDriver): export sceGnmDrawInitDefaultHardwareState200 from the regular driver #19990

Merged
Gag21 merged 1 commit from upstream-pr/19990 into main 2026-11-14 13:42:08 +00:00
Gag21 commented 2026-11-14 10:26:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Gag21 on 2026-11-14T10:26:47Z.


What

A PS4 title can import sceGnmDrawInitDefaultHardwareState200 (0H2vBYbTLHI) from the regular libSceGnmDriver. main exports that function only from libSceGnmDriverForNeoMode, so the import stays unresolved and the title stops at load (FAIL: unresolved ELF import 0H2vBYbTLHI). This adds the export to the regular driver.

  • sceGnmDrawInitDefaultHardwareState200_nid_disambig1 keeps the guest NID with a distinct host symbol, as the other regular-driver exports that also exist in the Neo provider do.
  • It writes the context reset, then the register sequence, then one NOP up to 256 dwords, and returns 256. A buffer below 256 dwords returns 0 and is not written, as sceGnmDrawInitDefaultHardwareState175 does.
  • The sequence follows shadPS4 at a808e762, the reference the GNM libraries already cite: its InitSequence200 for a base title, and its InitSequence200Neo (the array libSceGnmDriverForNeoMode already writes) when sceKernelIsNeoMode answers 1. The base sequence is derived at compile time from the Neo array by leaving out the three packets that only the Neo sequence has; the test compares it with the full base sequence written out word by word.
  • libSceGnmDriver now links libkernel_sys for sceKernelIsNeoMode. The mode is read before anything is written, so where that function throws (a title with param.json, or no metadata) the buffer is untouched.
  • docs/dev/debt/libSceGnmDriver.md records what is not measured: neither sequence is compared with console output, whether the console's regular module chooses by Neo mode, and the answer for a null buffer.

This is one of five imports of that kind in the title below. The other four (sceGnmUpdatePsShader, sceGnmUpdateVsShader, sceGnmUpdateHsShader, sceGnmUpdateGsShader) are in #17711 and are not touched here. #18206 (unversioned sceGnmDrawInitDefaultHardwareState) and #18217 (...State350, ...ContextState400) add neighbouring exports and do not add this one. tools/pr_overlap.py --branch reports no shared exports and two textual conflicts: #18217 (Export.cpp includes and the lines after sceGnmDrawInitDefaultHardwareState175, Api.hpp) and #17942 (Export.cpp includes). Whichever merges second needs a routine rebase; this PR does not build on either.

Tested

Windows 11 Pro 10.0.26300, i5-6600K, WinLibs GCC 16.2.0, CMake 4.4.4, Ninja, Release, BUILD_TESTING=ON, on main 2cebbe43ee.

  • New test gnm_default_state_200 (tests/DefaultState200.cpp) runs itself in a child process per case, each with its own param.sfo: a base title (ATTRIBUTE 0, and ATTRIBUTE with other bits set), a Neo title (ATTRIBUTE bit 23), and no metadata. It checks the full 256 dwords against the expected sequence for the mode, the single trailing NOP, whole PM4 packets, that a 255-dword buffer returns 0 unwritten, that nothing is written before or after the 256 dwords, and that without metadata the call throws with the buffer untouched.

  • Does it fail without the change? With the mode choice reversed in Export.cpp, the base, other and neo cases each fail with the register sequence differs. Without the export the test does not link.

  • gnm_default_state_200, guest_gnm_driver, gnm_driver_packets, gnm_driver_submit_wait, gnm_shader_writers and the six guest_gnm_neo* tests: 11 of 11 pass. public_headers passes.

  • A title: a PS4 game dump (CUSA01709 01.02), converted with relinker --windows and started for up to 40 s. The eboot needs #19959 to unwrap and a local relinker change equivalent to #17105 to convert; its DT_NEEDED names libSceGnmDriver_padebug, so a copy of libSceGnmDriver.prx under that name stood in for #18087. None of that is in this PR.

    Build Unresolved imports at start
    main b6717527ce (libSceGnmDriver unchanged up to 2cebbe43ee) 5: 0H2vBYbTLHI and the four in #17711
    this PR 4: the four in #17711

    The title still stops at load, so the function was not called by it.

  • python tools/check_conventions.py --base origin/main passes. python tools/pr_overlap.py --names sceGnmDrawInitDefaultHardwareState200 reports main: core/libs/prx/libSceGnmDriverForNeoMode (implemented) and open: none; --branch ran over 1,595 open pull requests with the result above.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5310230905 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19990). Originally posted by [Gag21](https://github.com/Gag21) on 2026-11-14T10:26:47Z. --- ### What A PS4 title can import `sceGnmDrawInitDefaultHardwareState200` (`0H2vBYbTLHI`) from the regular `libSceGnmDriver`. `main` exports that function only from `libSceGnmDriverForNeoMode`, so the import stays unresolved and the title stops at load (`FAIL: unresolved ELF import 0H2vBYbTLHI`). This adds the export to the regular driver. - `sceGnmDrawInitDefaultHardwareState200_nid_disambig1` keeps the guest NID with a distinct host symbol, as the other regular-driver exports that also exist in the Neo provider do. - It writes the context reset, then the register sequence, then one NOP up to 256 dwords, and returns 256. A buffer below 256 dwords returns 0 and is not written, as `sceGnmDrawInitDefaultHardwareState175` does. - The sequence follows [shadPS4 at `a808e762`](https://github.com/shadps4-emu/shadPS4/blob/a808e7626e3c7de8d0f0fda6a91f620b42f6c762/src/core/libraries/gnmdriver/gnmdriver.cpp), the reference the GNM libraries already cite: its `InitSequence200` for a base title, and its `InitSequence200Neo` (the array `libSceGnmDriverForNeoMode` already writes) when `sceKernelIsNeoMode` answers 1. The base sequence is derived at compile time from the Neo array by leaving out the three packets that only the Neo sequence has; the test compares it with the full base sequence written out word by word. - `libSceGnmDriver` now links `libkernel_sys` for `sceKernelIsNeoMode`. The mode is read before anything is written, so where that function throws (a title with `param.json`, or no metadata) the buffer is untouched. - `docs/dev/debt/libSceGnmDriver.md` records what is not measured: neither sequence is compared with console output, whether the console's regular module chooses by Neo mode, and the answer for a null buffer. This is one of five imports of that kind in the title below. The other four (`sceGnmUpdatePsShader`, `sceGnmUpdateVsShader`, `sceGnmUpdateHsShader`, `sceGnmUpdateGsShader`) are in #17711 and are not touched here. #18206 (unversioned `sceGnmDrawInitDefaultHardwareState`) and #18217 (`...State350`, `...ContextState400`) add neighbouring exports and do not add this one. `tools/pr_overlap.py --branch` reports no shared exports and two textual conflicts: #18217 (`Export.cpp` includes and the lines after `sceGnmDrawInitDefaultHardwareState175`, `Api.hpp`) and #17942 (`Export.cpp` includes). Whichever merges second needs a routine rebase; this PR does not build on either. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 Pro 10.0.26300, i5-6600K, WinLibs GCC 16.2.0, CMake 4.4.4, Ninja, Release, `BUILD_TESTING=ON`, on `main` `2cebbe43ee`. - **New test** `gnm_default_state_200` (`tests/DefaultState200.cpp`) runs itself in a child process per case, each with its own `param.sfo`: a base title (`ATTRIBUTE` 0, and `ATTRIBUTE` with other bits set), a Neo title (`ATTRIBUTE` bit 23), and no metadata. It checks the full 256 dwords against the expected sequence for the mode, the single trailing NOP, whole PM4 packets, that a 255-dword buffer returns 0 unwritten, that nothing is written before or after the 256 dwords, and that without metadata the call throws with the buffer untouched. - **Does it fail without the change?** With the mode choice reversed in `Export.cpp`, the `base`, `other` and `neo` cases each fail with `the register sequence differs`. Without the export the test does not link. - `gnm_default_state_200`, `guest_gnm_driver`, `gnm_driver_packets`, `gnm_driver_submit_wait`, `gnm_shader_writers` and the six `guest_gnm_neo*` tests: 11 of 11 pass. `public_headers` passes. - **A title**: a PS4 game dump (CUSA01709 01.02), converted with `relinker --windows` and started for up to 40 s. The eboot needs #19959 to unwrap and a local relinker change equivalent to #17105 to convert; its `DT_NEEDED` names `libSceGnmDriver_padebug`, so a copy of `libSceGnmDriver.prx` under that name stood in for #18087. None of that is in this PR. | Build | Unresolved imports at start | |---|---| | `main` `b6717527ce` (`libSceGnmDriver` unchanged up to `2cebbe43ee`) | 5: `0H2vBYbTLHI` and the four in #17711 | | this PR | 4: the four in #17711 | The title still stops at load, so the function was not called by it. - `python tools/check_conventions.py --base origin/main` passes. `python tools/pr_overlap.py --names sceGnmDrawInitDefaultHardwareState200` reports `main: core/libs/prx/libSceGnmDriverForNeoMode (implemented)` and `open: none`; `--branch` ran over 1,595 open pull requests with the result above. ### 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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-14 13:16:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T13:16:52Z.

Review: APPROVED


Reviewed — looks good

The reviewed change at head b3cb05bdcf4158bcf639a45edf7d34f1999706f7 adds the regular-driver export and mode-specific state sequence; the inspected implementation and tests support the stated behavior, while no checks were run during this review.

What I ran

No commands or tests were run. I read the prepared diff and changed files, then inspected the relevant kernel mode query, Neo sequence, and driver export context through repo_read.py.

Results

Check Result Note
Diff and changed files passed All five changed files read
Targeted repository context passed Mode query and Neo sequence read
Build and tests not run Results in the PR description are author-reported
Console behavior not run The description identifies this as unmeasured

Findings

Blocking

None.

Non-blocking

None.

Not verified

Builds, tests, and title runs were not independently verified. The prepared files bundle was empty; all five changed files were read from the pinned repository head with repo_read.py. No exclusions were listed in the manifest.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5904492084 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19990#pullrequestreview-5904492084). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T13:16:52Z. **Review:** APPROVED --- # Reviewed — looks good The reviewed change at head `b3cb05bdcf4158bcf639a45edf7d34f1999706f7` adds the regular-driver export and mode-specific state sequence; the inspected implementation and tests support the stated behavior, while no checks were run during this review. ## What I ran No commands or tests were run. I read the prepared diff and changed files, then inspected the relevant kernel mode query, Neo sequence, and driver export context through `repo_read.py`. ## Results | Check | Result | Note | |---|---|---| | Diff and changed files | passed | All five changed files read | | Targeted repository context | passed | Mode query and Neo sequence read | | Build and tests | not run | Results in the PR description are author-reported | | Console behavior | not run | The description identifies this as unmeasured | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Builds, tests, and title runs were not independently verified. The prepared files bundle was empty; all five changed files were read from the pinned repository head with `repo_read.py`. No exclusions were listed in the manifest. ## To get this to a good state Nothing is required.
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!19990
No description provided.