Skip to content

feat(libSceGnmDriver): expose base draw default state - #464

Open
Thimo188 wants to merge 4 commits into
mainfrom
upstream-pr/18206
Open

Thimo188 wants to merge 4 commits into
mainfrom
upstream-pr/18206

Conversation

@Thimo188

@Thimo188 Thimo188 commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Imported from boykopovar/AnyPS5#18206, originally opened by DonRyuzaki.

Source commit: 21ec57969d7deec7fbd045670cfdd5960617067e. The import branch preserves this fetched upstream PR snapshot. The description and validation below are copied from upstream; no new code changes or test runs were made for this import. Original reviews, discussions, and attachments remain at the linked upstream PR.


What

GTA V (CUSA00419, bring-up #18084) imports NID Idffwf3yh8s as sceGnmDrawInitDefaultHardwareState from the regular libSceGnmDriver. Current main provides that name only from libSceGnmDriverForNeoMode, so the regular PRX leaves the import unresolved. Add a regular-provider export, using _nid_disambig1 to keep its host symbol distinct while retaining the guest NID.

Share the existing 256-dword draw-state writer with sceGnmDrawInitDefaultHardwareState175, selecting SC_MODE_CNTL_1 = 0x06000000 for the unversioned function and preserving 0x06020000 for 175. Both refuse a buffer shorter than 256 dwords without writing. The pinned shadPS4 writer and packet arrays use this signature and sequence; their base and 175 arrays differ in only that mode word. The existing GNM technical debt records that these packets have not been checked on a console. Null and invalid-pointer behavior is also unmeasured; this follows the existing regular 175 writer's size-first path, without a new success fallback.

This change is independent of boykopovar#18087's _padebug dependency mapping. It removes one regular-library import gap; the title was not retested and still has the other local conversion/runtime dependencies listed in boykopovar#18084. No title-start or in-game claim is made.

Tested

Latest refresh (15 November 2026): current head 21ec57969d7deec7fbd045670cfdd5960617067e includes upstream main eef73731fc926d18e3e8b19849ed42511a1adb09 and merged #20844, which fixes the shared ICU test linker error that caused the preceding Windows Build failure. This PR’s patch relative to main remains confined to its intended files. The diff check and tools/check_conventions.py passed on this current head. The GNM driver targets built and guest_gnm_driver plus guest_gnm_driver_init_modes passed (2/2) on prior head 3235048a3b356d9afc8df3bfcad684e72000a06f. The current-head Build, Progress report, and Emscripten portability workflows passed; previous evidence below applies to its stated older heads.

Rebased-head validation (November 10)

The current head is c763323258dceaf91c8d4bf1b6a16ceaf72144a2, rebased onto upstream 4306c608e2a552d5c96f11679332a222a4683ef9 with the two worker-spin fixes. The feature patch is unchanged. On this exact source, the full Linux libs target and guest_gnm_driver_tests rebuilt successfully (831 pending steps, two below-normal compiler jobs). guest_gnm_driver and public_headers each passed three consecutive runs (6/6, no skips); the changed source files matched this head byte-for-byte. The earlier dynamic NID and packet test was on the prior head and has not been repeated on this rebase. Emscripten portability, Progress report and Conventions passed on the new head; the hosted Windows job passed. Hosted Linux and specialized PR jobs were skipped.

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

Summary by CodeRabbit

  • New Features
    • Added support for an additional default hardware-state initialization option. The existing option remains available, with each producing its corresponding hardware state.
  • Bug Fixes
    • Initialization now rejects buffers that are too small without writing to them. For sufficiently large buffers, it reports the fixed amount written and leaves any extra space untouched.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Draw Default Hardware State

Layer / File(s) Summary
Shared writer and entry-point validation
core/libs/prx/libSceGnmDriver/Export.cpp, core/libs/prx/libSceGnmDriver/include/Api.hpp, core/libs/tests/GuestGnmDriver.cpp
The new base entry point and the 175 entry point call a shared writer with different SC_MODE_CNTL_1 values. The writer rejects buffers smaller than HwInitPacketWords; tests check buffer boundaries, output packets, and the variants’ differing values.

Suggested reviewers: get-fix, donryuzaki

Change: Feature

Merge Risk: Minimal · up to 21ec5

This adds the missing base draw default hardware state import and reuses the existing writer for the 175 variant. Tests cover the buffer bounds and the difference between the two variants. No merge-blocking risk was found. Behavior on real hardware and in the actual title has not been tested.

Security architecture risk: Minimal · up to 21ec5

The regular libSceGnmDriver adds the base initializer without changing the existing 175 behavior. The new entry point fills a caller-supplied command buffer through the same writer and does not submit GPU work. The review found no material expansion of guest authority.

Security review details

Security Blast Radius

  • inferred — A guest that can resolve the new regular-provider import gains another way to fill a command buffer. The wrapper does not select a different destination address space or invoke a privileged submission path relative to the existing 175 writer.

Trust Boundaries and Controls

  • observed — The guest supplies the buffer pointer and count. The wrapper supplies the mode word as a constant, and the shared writer checks the count before performing any stores.
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

  • Mode: Continue automatically
  • Reviewed files: 3
  • Waived: $0.75 (charged $0.00)
  • View usage details

Note

This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d768e13e-8ebd-46b1-b3f0-8b2a55a5c33f
Commits

Reviewing files that changed from the base of the PR and between 4131f51 and 21ec579.

Files selected for processing: 3

  • core/libs/prx/libSceGnmDriver/Export.cpp
  • core/libs/prx/libSceGnmDriver/include/Api.hpp
  • core/libs/tests/GuestGnmDriver.cpp

Limit details: You’ve used all 10 included reviews currently available.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

Exports with a name or library/NID already present in main:

  • sceGnmDrawInitDefaultHardwareState (also exported by another library in main: core/libs/prx/libSceGnmDriverForNeoMode; may be intentional)

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

Progress report (4131f51 → 21ec579)

📈 System libraries: 47.94% (+0.0013%, +1 implemented function)

✅ 1 implemented
Library Name
libSceGnmDriver sceGnmDrawInitDefaultHardwareState_nid_disambig1

Changed libraries (implemented exports)

Library Before After Change
libSceGnmDriver 68/99 (68.69%) 69/100 (69.00%) +0.31%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants