feat(libSceGnmDriver): share mode-independent command writers #17711

Merged
HenriksApsitis merged 8 commits from upstream-pr/17711 into main 2026-11-25 21:02:39 +00:00
HenriksApsitis commented 2026-11-09 11:47:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by HenriksApsitis on 2026-11-09T11:47:08Z.


What

Make ten mode-independent command writers available from the normal libSceGnmDriver, using the same implementation as libSceGnmDriverForNeoMode.

Related: #17581 (inFAMOUS Second Son, CUSA00223, bring-up #8214). Nine of these functions are among its 47 missing imports; sceGnmUpdatePsShader is the additional shared writer. This is a partial contribution, not a fix for the whole issue or a title-start claim. This PR does not claim to resolve the other reported blockers or establish title execution.

  • Share the existing packet/refusal bodies through internal-linkage helpers; retain the existing packet/refusal semantics and guest size contracts, including HS acceptance and guarded copy of 29 words (0x1d). Each library keeps its own exported wrappers, so per-library source inventories remain correct. The normal wrappers use the established _nid_disambig1 mechanism (as existing PosixForWebKit and Ajmi wrappers do), retaining the guest NIDs with distinct host symbols instead of violating the duplicate-export rule. Both pinned PS5 3.20 provider inventories list these ten names.
  • Declare each distinct host export once in its provider's public API; both library umbrellas compile together. Do not add a loader fallback or make the normal provider depend on the Neo PRX.
  • Run the same packet/refusal/sentinel fixture against each provider in a separate executable. Cover dispatch flag combinations and boundary values, valid pixel-shader clear paths, null buffers, shader modifiers and rejected-input non-mutation.

The mode-independent reference is shadPS4 gnmdriver.cpp at a808e7626e3c7de8d0f0fda6a91f620b42f6c762, already used for the Neo implementation. Console packet equivalence remains unmeasured and is recorded in debt.

  • Preserve guest-memory safety in both providers: copy shader inputs into host arrays, build packets in host storage and use guarded guest copies for output. Regression cases cover invalid/read-only guest addresses and rejected-input non-mutation.
  • Preserve the inherited HS mismatch rather than guessing the console contract: its packet headers declare 30 words while main accepts and copies 29. The shared fixture explicitly characterizes the invalid extent and untouched following command, and debt records the need for console evidence before a separate behavioral fix. GuestGnmNeoShaders.cpp is restored byte-for-byte to the pinned main version, as requested by @oneandonlydean.

Tested

Current candidate: b497248874b1b916802e001cc328a2b43b95c173; retains the integration of main fa86dfcd3b0715edb4a0db2c552ae76a3df29111. This revision addresses @oneandonlydean's review by restoring HS acceptance/copy of 29 words and deferring the unmeasured 30-word packet discrepancy to debt. No console contract change is claimed.

  • CachyOS Linux, NVIDIA GeForce RTX 5070, driver 615.78.08; Release configuration. Rebuilt the 18 executable targets for all 31 registered ^(guest_gnm_|gnm_) tests.
  • 31/31 passed, each repeated three times, including the restored guest_gnm_neo_shaders and both shared-writer providers. No skips. Runs used ANYPS5_GPU='NVIDIA GeForce RTX 5070', ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer, and verbose CTest. Logs confirm NVIDIA selection and validation-layer insertion with no VUID- errors. Packet-only tests do not execute guest shaders.
  • Byte comparisons verified that CommandWriters.hpp matches the original PR's d20cbd0... helper bodies and GuestGnmNeoShaders.cpp matches pinned main fa86dfcd3b... exactly. The safe guest-copy wrappers added during conflict resolution remain in both providers.
  • Independent review of the exact frozen correction diff passed. python3 tools/check_conventions.py --base origin/main and git diff --check origin/main...HEAD passed against the committed candidate. Remote head and all six changed files were independently read back and byte-verified after pushing.
  • Author-side logs: /home/hermes/work/anyps5-gnm-imports/logs/build-17711-hs-main-compat.log, ctest-17711-hs-main-compat.log, ctest-17711-hs-main-compat-committed.log. These are local evidence paths, not public attachments or repository files.

Overlap: python3 tools/pr_overlap.py --branch feat/gnm-shared-command-writers --head-repo HenriksApsitis/AnyPS5 --repo boykopovar/AnyPS5 --jobs 4 --base main examined 2,659 open PRs and compared 11 shared-file candidates. It exited 2, not clean: four branches conflict with main. Their live heads remain unchanged from the manual merge-base comparisons:

  • #20730 fdc542d375e8df9bf9bf4ac1c141ff27fb9866c8: submission pacing, not these packet writers.
  • #21225 9e142fb3703aa585df8a89cafb3b06f4fb895f68: compute/graphics ordering and CMake test registration.
  • #23696 7133e14c341e4a2d01be7942fde546694b2949bf: flip-and-submit implementation/API and VideoOut test linkage.
  • #26370 3aec109413b7a30a3db672cc09e90dd71dfb74f0: compiled-SDK-version access in Neo.

None of these manually reviewed diffs duplicates the ten shared writer implementations or is required by them. That conclusion does not turn the automated exit 2 into a pass. The cross-library name/NID warnings are intentional normal-provider counterparts to Neo writers using host-name disambiguation. Full output is retained in logs/overlap-17711-parent-final.log.

Hosted CI on this new head is pending, not confirmed green. The preceding c809b0ed... Windows run passed the GNM tests but failed on guest_icu_utf_conversions and guest_relative_sleep_large timeouts; it does not qualify this new head. This correction changes neither those timeouts nor test selection.

Historical evidence only: the original contribution reproduced missing normal-provider linkage, and earlier raw/NID-patched dynamic-loader runs and public-header audits were performed on an earlier head. They have not been rerun as part of this qualification.

Not tested: console packet equivalence or the correct HS reservation/NOP length, Bloodborne, inFAMOUS or any other title, native Windows/macOS locally, or the complete runtime suite. Synthetic checks do not establish title compatibility.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: NVIDIA GeForce RTX 5070, NVIDIA 615.78.08, CachyOS Linux 7.3.1-1-cachyos
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5223348943 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17711). Originally posted by [HenriksApsitis](https://github.com/HenriksApsitis) on 2026-11-09T11:47:08Z. --- ### What Make ten mode-independent command writers available from the normal `libSceGnmDriver`, using the same implementation as `libSceGnmDriverForNeoMode`. Related: #17581 (inFAMOUS Second Son, CUSA00223, bring-up #8214). Nine of these functions are among its 47 missing imports; `sceGnmUpdatePsShader` is the additional shared writer. **This is a partial contribution, not a fix for the whole issue or a title-start claim.** This PR does not claim to resolve the other reported blockers or establish title execution. - Share the existing packet/refusal bodies through internal-linkage helpers; retain the existing packet/refusal semantics and guest size contracts, including HS acceptance and guarded copy of 29 words (`0x1d`). Each library keeps its own exported wrappers, so per-library source inventories remain correct. The normal wrappers use the established `_nid_disambig1` mechanism (as existing PosixForWebKit and Ajmi wrappers do), retaining the guest NIDs with distinct host symbols instead of violating the duplicate-export rule. Both pinned PS5 3.20 provider inventories list these ten names. - Declare each distinct host export once in its provider's public API; both library umbrellas compile together. Do not add a loader fallback or make the normal provider depend on the Neo PRX. - Run the same packet/refusal/sentinel fixture against each provider in a separate executable. Cover dispatch flag combinations and boundary values, valid pixel-shader clear paths, null buffers, shader modifiers and rejected-input non-mutation. The mode-independent reference is [shadPS4 gnmdriver.cpp at a808e7626e3c7de8d0f0fda6a91f620b42f6c762](https://github.com/shadps4-emu/shadPS4/blob/a808e7626e3c7de8d0f0fda6a91f620b42f6c762/src/core/libraries/gnmdriver/gnmdriver.cpp), already used for the Neo implementation. Console packet equivalence remains unmeasured and is recorded in debt. - Preserve guest-memory safety in both providers: copy shader inputs into host arrays, build packets in host storage and use guarded guest copies for output. Regression cases cover invalid/read-only guest addresses and rejected-input non-mutation. - Preserve the inherited HS mismatch rather than guessing the console contract: its packet headers declare 30 words while main accepts and copies 29. The shared fixture explicitly characterizes the invalid extent and untouched following command, and debt records the need for console evidence before a separate behavioral fix. `GuestGnmNeoShaders.cpp` is restored byte-for-byte to the pinned main version, as requested by @oneandonlydean. ### 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. --> Current candidate: `b497248874b1b916802e001cc328a2b43b95c173`; retains the integration of main `fa86dfcd3b0715edb4a0db2c552ae76a3df29111`. This revision addresses @oneandonlydean's review by restoring HS acceptance/copy of 29 words and deferring the unmeasured 30-word packet discrepancy to debt. No console contract change is claimed. - CachyOS Linux, NVIDIA GeForce RTX 5070, driver 615.78.08; Release configuration. Rebuilt the 18 executable targets for all 31 registered `^(guest_gnm_|gnm_)` tests. - **31/31 passed, each repeated three times**, including the restored `guest_gnm_neo_shaders` and both shared-writer providers. No skips. Runs used `ANYPS5_GPU='NVIDIA GeForce RTX 5070'`, `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `VK_LOADER_DEBUG=layer`, and verbose CTest. Logs confirm NVIDIA selection and validation-layer insertion with no `VUID-` errors. Packet-only tests do not execute guest shaders. - Byte comparisons verified that `CommandWriters.hpp` matches the original PR's `d20cbd0...` helper bodies and `GuestGnmNeoShaders.cpp` matches pinned main `fa86dfcd3b...` exactly. The safe guest-copy wrappers added during conflict resolution remain in both providers. - Independent review of the exact frozen correction diff passed. `python3 tools/check_conventions.py --base origin/main` and `git diff --check origin/main...HEAD` passed against the committed candidate. Remote head and all six changed files were independently read back and byte-verified after pushing. - Author-side logs: `/home/hermes/work/anyps5-gnm-imports/logs/build-17711-hs-main-compat.log`, `ctest-17711-hs-main-compat.log`, `ctest-17711-hs-main-compat-committed.log`. These are local evidence paths, not public attachments or repository files. Overlap: `python3 tools/pr_overlap.py --branch feat/gnm-shared-command-writers --head-repo HenriksApsitis/AnyPS5 --repo boykopovar/AnyPS5 --jobs 4 --base main` examined 2,659 open PRs and compared 11 shared-file candidates. It **exited 2, not clean**: four branches conflict with main. Their live heads remain unchanged from the manual merge-base comparisons: - #20730 `fdc542d375e8df9bf9bf4ac1c141ff27fb9866c8`: submission pacing, not these packet writers. - #21225 `9e142fb3703aa585df8a89cafb3b06f4fb895f68`: compute/graphics ordering and CMake test registration. - #23696 `7133e14c341e4a2d01be7942fde546694b2949bf`: flip-and-submit implementation/API and VideoOut test linkage. - #26370 `3aec109413b7a30a3db672cc09e90dd71dfb74f0`: compiled-SDK-version access in Neo. None of these manually reviewed diffs duplicates the ten shared writer implementations or is required by them. That conclusion does not turn the automated exit 2 into a pass. The cross-library name/NID warnings are intentional normal-provider counterparts to Neo writers using host-name disambiguation. Full output is retained in `logs/overlap-17711-parent-final.log`. Hosted CI on this new head is pending, not confirmed green. The preceding `c809b0ed...` Windows run passed the GNM tests but failed on `guest_icu_utf_conversions` and `guest_relative_sleep_large` timeouts; it does not qualify this new head. This correction changes neither those timeouts nor test selection. Historical evidence only: the original contribution reproduced missing normal-provider linkage, and earlier raw/NID-patched dynamic-loader runs and public-header audits were performed on an earlier head. They have not been rerun as part of this qualification. Not tested: console packet equivalence or the correct HS reservation/NOP length, Bloodborne, inFAMOUS or any other title, native Windows/macOS locally, or the complete runtime suite. Synthetic checks do not establish title compatibility. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: NVIDIA GeForce RTX 5070, NVIDIA 615.78.08, CachyOS Linux 7.3.1-1-cachyos <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-11-21 06:16:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T06:16:35Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the points below are optional.

What I ran

Reviewed head d20cbd0eb3695d6c59e6a6a520a0ef40abf2c737. I read the prepared description, commits, manifest, diff, and all eight changed files included in the review folder. No commands or tests were run; runtime and build results below are author-reported.

Results

Check Result Note
Changed code review passed Eight changed files read
Build and runtime tests not run Results supplied by author
Console behavior not run No console or title tested here

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not independently run the tests, build, convention checks, or overlap checks described in the PR body. Console packet behavior and title compatibility remain unverified, as the author also notes. No changed files were excluded; files.json was not available as a review document, and list_files showed all eight changed files as included.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6003439983 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17711#pullrequestreview-6003439983). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T06:16:35Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the points below are optional. ## What I ran Reviewed head `d20cbd0eb3695d6c59e6a6a520a0ef40abf2c737`. I read the prepared description, commits, manifest, diff, and all eight changed files included in the review folder. No commands or tests were run; runtime and build results below are author-reported. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | Eight changed files read | | Build and runtime tests | not run | Results supplied by author | | Console behavior | not run | No console or title tested here | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not independently run the tests, build, convention checks, or overlap checks described in the PR body. Console packet behavior and title compatibility remain unverified, as the author also notes. No changed files were excluded; `files.json` was not available as a review document, and `list_files` showed all eight changed files as included. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-25 02:57:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T02:57:46Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the shared packet writers, provider wrappers, and HS reservation boundary check are consistent in the inspected code.

What I ran

Reviewed head c809b0ed5e78ddc02ae4086fac8929d613fe9128. No commands or tests were run; repo_read.py was unavailable as an executable in this read-only review environment. I read all nine changed files listed as included in the manifest through the pinned reader, along with the prepared description, commits, manifest, and diff. No files were excluded by rule in the manifest.

Results

Check Result Note
Diff and targeted source review passed All nine changed files inspected
Build and tests not run Author reports six focused tests passed; not independently verified
Console behavior not run Packet equivalence remains unmeasured

Findings

Blocking

None.

Non-blocking

  • The hosted Windows run reported two timing-related test timeouts and is not green; a rerun would strengthen the evidence. The description appropriately does not claim their cause is known.

Not verified

I did not run builds, tests, conventions, overlap checks, or console/title testing. I did not independently verify the author-reported CI or local logs. The manifest marks all nine changed files as included, and each was read; files.json was unavailable through the reader, so any additional rule-based exclusions are not verified.

To get this to a good state

Nothing is required. Optional: rerun the hosted Windows suite to resolve the reported timeouts.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6051192870 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17711#pullrequestreview-6051192870). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T02:57:46Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the shared packet writers, provider wrappers, and HS reservation boundary check are consistent in the inspected code. ## What I ran Reviewed head `c809b0ed5e78ddc02ae4086fac8929d613fe9128`. No commands or tests were run; `repo_read.py` was unavailable as an executable in this read-only review environment. I read all nine changed files listed as included in the manifest through the pinned reader, along with the prepared description, commits, manifest, and diff. No files were excluded by rule in the manifest. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted source review | passed | All nine changed files inspected | | Build and tests | not run | Author reports six focused tests passed; not independently verified | | Console behavior | not run | Packet equivalence remains unmeasured | ## Findings ### Blocking None. ### Non-blocking - The hosted Windows run reported two timing-related test timeouts and is not green; a rerun would strengthen the evidence. The description appropriately does not claim their cause is known. ## Not verified I did not run builds, tests, conventions, overlap checks, or console/title testing. I did not independently verify the author-reported CI or local logs. The manifest marks all nine changed files as included, and each was read; `files.json` was unavailable through the reader, so any additional rule-based exclusions are not verified. ## To get this to a good state Nothing is required. Optional: rerun the hosted Windows suite to resolve the reported timeouts.
MarcZX10 commented 2026-11-25 08:02:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T08:02:31Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change; the points below are optional.

What I ran

Reviewed head b497248874b1b916802e001cc328a2b43b95c173 from the prepared diff and reader-pinned source. No commands or tests were run; the test results in the description are author-reported.

Results

Check Result Note
Diff and targeted source review passed All nine changed files were read
Automated checks not run Author reports Linux GNM tests passed; hosted CI is pending

Findings

Blocking

None.

Non-blocking

  • sceGnmUpdateHsShader preserves a 29-word accepted/copy extent while its final NOP declares a packet extent of 30 words. This can consume the following command as NOP payload. The PR documents the mismatch and defers changing behavior until console evidence is available (core/libs/prx/libSceGnmDriver/include/CommandWriters.hpp:122).

Not verified

No tests were run in this review. Console packet equivalence, hosted CI on this head, and behavior outside the reviewed GNM writer paths were not verified. The description reports test runs, but these were not independently confirmed. Files read: description.md, commits.md, manifest.json, diff.patch, core/libs/prx/libSceGnmDriver/CMakeLists.txt, core/libs/prx/libSceGnmDriver/Export.cpp, core/libs/prx/libSceGnmDriver/include/Api.hpp, core/libs/prx/libSceGnmDriver/include/CommandWriters.hpp, core/libs/prx/libSceGnmDriverForNeoMode/Export.cpp, core/libs/prx/libSceGnmDriverForNeoMode/include/Api.hpp, core/libs/tests/GuestGnmSharedWriters.cpp, and docs/dev/debt/libSceGnmDriver.md. All nine changed files listed in the manifest were read; files.json was not available through the reader.

To get this to a good state

Nothing is required. Optional: retain the documented HS packet extent discrepancy as follow-up debt until console measurements support a separate behavior change.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6053830196 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17711#pullrequestreview-6053830196). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T08:02:31Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change; the points below are optional. ## What I ran Reviewed head `b497248874b1b916802e001cc328a2b43b95c173` from the prepared diff and reader-pinned source. No commands or tests were run; the test results in the description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted source review | passed | All nine changed files were read | | Automated checks | not run | Author reports Linux GNM tests passed; hosted CI is pending | ## Findings ### Blocking None. ### Non-blocking - `sceGnmUpdateHsShader` preserves a 29-word accepted/copy extent while its final NOP declares a packet extent of 30 words. This can consume the following command as NOP payload. The PR documents the mismatch and defers changing behavior until console evidence is available (`core/libs/prx/libSceGnmDriver/include/CommandWriters.hpp:122`). ## Not verified No tests were run in this review. Console packet equivalence, hosted CI on this head, and behavior outside the reviewed GNM writer paths were not verified. The description reports test runs, but these were not independently confirmed. Files read: `description.md`, `commits.md`, `manifest.json`, `diff.patch`, `core/libs/prx/libSceGnmDriver/CMakeLists.txt`, `core/libs/prx/libSceGnmDriver/Export.cpp`, `core/libs/prx/libSceGnmDriver/include/Api.hpp`, `core/libs/prx/libSceGnmDriver/include/CommandWriters.hpp`, `core/libs/prx/libSceGnmDriverForNeoMode/Export.cpp`, `core/libs/prx/libSceGnmDriverForNeoMode/include/Api.hpp`, `core/libs/tests/GuestGnmSharedWriters.cpp`, and `docs/dev/debt/libSceGnmDriver.md`. All nine changed files listed in the manifest were read; `files.json` was not available through the reader. ## To get this to a good state Nothing is required. Optional: retain the documented HS packet extent discrepancy as follow-up debt until console measurements support a separate behavior change.
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!17711
No description provided.