679 Commits
Author SHA1 Message Date
boykopovar fe1935ef68 Merge pull request #109 from boykopovar/fix/linux-savedata-build
fix(build): use portable save paths and validate all PRX libraries in CI
2026-09-29 02:29:58 +03:00
boykopovar b01e0bbf52 fix(build): use portable save paths and validate all PRX libraries in CI 2026-09-29 02:24:56 +03:00
boykopovar 1ff73445b1 Merge pull request #108 from boykopovar/refactor/relinker-friendly-usage
fix(relinker): use app0 guest module layout and clarify output diagnostic
2026-09-29 02:18:17 +03:00
boykopovar 7445c65994 chore(readme): return percent calculation info 2026-09-29 02:17:56 +03:00
boykopovar c8beb90a5e build(release): package libraries under libs subfolder 2026-09-29 02:13:22 +03:00
boykopovar 6742ecf70f fix(relinker): use app0 guest module layout and clarify output diagnostics 2026-09-29 02:05:02 +03:00
boykopovar cc41e847c8 Merge pull request #105 from SamG-Coder/codex/quake-native-imports
fix(relinker,libs): decode EMMS and add native string and thread APIs
2026-09-29 01:59:28 +03:00
boykopovar a1e0b95f76 Merge pull request #96 from SamG-Coder/main
feat(shader): support scalar 64-bit reverse and arithmetic shift
2026-09-29 01:55:08 +03:00
boykopovar 9e3df3331c Merge pull request #107 from asimplestray/feat/libc-mspace-reallocalign
feat(libc): implement sceLibcMspaceReallocalign
2026-09-29 01:46:19 +03:00
boykopovar c4c34ea3be Merge pull request #80 from OverkillLabs/feat/avplayer-native-state-machine
feat(libSceAvPlayer): implement full AvPlayer state machine
2026-09-29 01:35:13 +03:00
boykopovar a5e7d1fb32 Merge pull request #79 from OverkillLabs/feat/net-rudp-offline-stack
feat(net): offline socket/epoll/resolver stack with FreeBSD errno mapping
2026-09-29 01:31:33 +03:00
boykopovar 23dad6b4d7 Merge pull request #78 from OverkillLabs/fix/msgdialog-state-machine
fix(libSceMsgDialog): real dialog state machine, auto-answer without UI
2026-09-29 01:27:31 +03:00
boykopovar 0d70866817 Merge pull request #77 from OverkillLabs/feat/savedata-core
feat(savedata): general mount/directory/memory-slot save-data core
2026-09-29 01:24:12 +03:00
asimplestray 02b431eb6d feat(libc): implement sceLibcMspaceReallocalign 2026-09-28 22:15:25 +00:00
boykopovar 4c2b052e35 Merge pull request #58 from oneandonlydean/feat/font-freetype
feat(font): port shadPS4's sceFont and sceFontFt on FreeType
2026-09-29 01:07:30 +03:00
boykopovar d807f36b63 Merge pull request #104 from boykopovar/fix/ci-release-win-bash
Windows tests were run via Git Bash. Windows build, tests, and libs target now use cmd.
2026-09-29 00:43:15 +03:00
SamG-Coder 5e708c1608 feat(kernel): add native pthread barriers and thread helpers 2026-09-29 07:39:01 +10:00
SamG-Coder 96b622c6ac feat(libc): add allocating strings and C locale wide conversion 2026-09-29 07:39:01 +10:00
SamG-Coder ee57519cb0 fix(relinker): decode EMMS without a ModRM byte 2026-09-29 07:39:01 +10:00
boykopovar 141b7d7ff0 fix(ci): use git bash for windows release 2026-09-29 00:38:21 +03:00
boykopovar 64066b6e9a Merge pull request #103 from boykopovar/feat/provide-release
Feat/provide release
Added a release workflow for v* tags: build Windows and Linux, run tests, and publish only if both platforms are successful. The release contains PRX archives, relinker executables, and documentation from docs/user. The build cache is reused.

- `prx-windows-v0.1.0.zip`
- `prx-windows-v0.1.0.tar.gz`
- `prx-linux-v0.1.0.zip`
- `prx-linux-v0.1.0.tar.gz`
- `relinker-v0.1.0.exe`
- `relinker-v0.1.0`
- `COMPATIBILITY.md`
- `INPUT_MAPPING.md`
2026-09-29 00:25:39 +03:00
boykopovar 1bc7f01511 feat(ci): add version to release file names 2026-09-29 00:22:44 +03:00
boykopovar 1071c9e09c feat(ci): add release workflow + update readme 2026-09-29 00:15:21 +03:00
boykopovar 49a78191e6 Merge pull request #99 from boykopovar/fix/libcohtml-cmake-rule
fix(libcohtml): fix build libcohtml with target libs on linux
2026-09-28 23:25:45 +03:00
boykopovar 46382612cb fix(libcohtml): fix build libcohtml with target libs o linux 2026-09-28 23:15:22 +03:00
boykopovar 00261033fa refactor(docs): separated user and dev in docs + compatibility file 2026-09-28 22:58:17 +03:00
SamG-Coder 86401fe5ab feat(shader): support scalar 64-bit reverse and arithmetic shift 2026-09-29 05:09:29 +10:00
boykopovar dee7ecb3d8 Merge pull request #27 from QDarkRex/refactor/kernel-error-header
refactor(kernel): share SCE kernel error codes through KernelErrors.hpp
2026-09-28 22:07:32 +03:00
boykopovar 14a6d28cce Merge pull request #90 from adriadam10/ci-conflict-label
ci: label pull requests that conflict with main
2026-09-28 21:53:51 +03:00
boykopovar 4e418f1c98 Merge pull request #91 from adriadam10/ci-area-labels
ci: label pull requests by area
2026-09-28 21:53:10 +03:00
boykopovar fac193057c Merge pull request #41 from adriadam10/ci-build
ci: build and test on Linux and Windows
2026-09-28 21:50:51 +03:00
boykopovar 4c6a929657 Merge pull request #89 from adriadam10/pr-template
docs: add pull request template with the review checklist
2026-09-28 21:45:35 +03:00
boykopovar 8ccfbb9fe6 Merge pull request #95 from boykopovar/fix/tests-agc-main
Fix/tests agc main
For tests:
- `agc_driver`
- `agc_driver_flip`
- `agc_driver_pm4`

Fixed dispatch error propagation and updated checks for asynchronous suspend points and memory synchronization. All 54 tests pass with these changes, restoring a passing test suite on `main` after merge.
2026-09-28 19:39:59 +03:00
boykopovar 829e8c14ae fix(tests): align agc flip waits and memory synchronization checks 2026-09-28 19:32:43 +03:00
boykopovar 1f595d883a fix(agc): propagate dispatch worker failures to waiting threads 2026-09-28 19:29:49 +03:00
boykopovar 53bda68c2b Merge pull request #11 from adriadam10/main
feat(tools): progress map and pull request progress reports
2026-09-28 18:50:00 +03:00
boykopovar 5b4c9c6f73 Merge branch 'main' into main 2026-09-28 18:45:15 +03:00
boykopovar 87633fc4e8 chore(tools): move progress.py description from repo to pr 2026-09-28 18:42:44 +03:00
boykopovar 417b66323f chore(readme): remove dup progress map info from readme 2026-09-28 18:39:17 +03:00
boykopovar f105cb9bdf Merge pull request #94 from boykopovar/fix/black-frame-blick
fix(agc): preserve  inputs for deferred  buffer copies
Closing the display window now requests a normal exit instead of calling std::terminate(). Shutdown cancels queued work, wakes blocked waits, joins GPU workers and background helpers, and releases GPU resources before destroying the window on its owning thread. Shutdown cancellation is handled separately from runtime errors.
2026-09-28 18:35:41 +03:00
boykopovar 39fd90b050 fix(kernel): orderly shutdown when closing the display window 2026-09-28 18:30:34 +03:00
boykopovar 143aec54c2 fix(agc): preserve inputs for deferred buffer copies 2026-09-28 18:08:09 +03:00
Adrià Franch 682fb3d73c ci: time out hung tests 2026-09-28 16:40:34 +02:00
adriadam10andClaude Opus 5.5 5ad7c5793a ci: build and test on Linux and Windows
Builds with tests enabled and runs ctest on every push to main and every
pull request: GCC on Linux, and on Windows the MinGW-w64 winlibs GCC
15.2.0 toolchain required by the README. ccache and the toolchain are
cached, and only pushes to main save the ccache, so pull requests reuse
it without evicting it.

Windows build steps run in cmd because Git Bash puts its own mingw64 DLLs
first in PATH, which breaks build tools such as nid_patcher that link
libstdc++ dynamically.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 16:40:34 +02:00
Adrià FranchandClaude d074f6e36f docs: link the pull request template to the contributing guide
Co-Authored-By: Claude <noreply@anthropic.com>
2026-09-28 16:06:33 +02:00
Adrià FranchandClaude d8db8192b4 ci: label pull requests that conflict with main
Co-Authored-By: Claude <noreply@anthropic.com>
2026-09-28 15:50:48 +02:00
Adrià FranchandClaude a8e48f48aa ci: label pull requests by area
Co-Authored-By: Claude <noreply@anthropic.com>
2026-09-28 15:50:48 +02:00
Adrià FranchandClaude Opus 5.5 b4c1887752 docs: add pull request template with the review checklist
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 15:42:29 +02:00
boykopovar c6a3e25573 Merge pull request #88 from boykopovar/fix/static-link-nid-patcher
fix(nid): always static linking for nid patcher
Using static linking of the standard library for nid patcher.
2026-09-28 16:38:06 +03:00
boykopovar 8e78ea0c28 fix(nid): always static linking for nid patcher 2026-09-28 16:28:11 +03:00
boykopovar 7b81a4de3d Merge pull request #87 from boykopovar/fix/build-test-json2fiber
fix(build): link json and fiber tests with libc
Fix test linking by adding `libc` to the `guest_json_tests` and `fiber_tests` link dependencies, resolving the missing `__gxx_personality_v0` symbol.

Ran all 54 CTest tests in. The build was successful.
Currently **50 passed, 4 failed**.
`guest_json` and `fiber` passed.

The following tests failed with code `0xc0000139`:

- `agc_driver`
- `agc_shader_memory`
- `agc_driver_flip`
- `agc_driver_pm4`
2026-09-28 14:25:12 +03:00
boykopovar 64732a64b6 fix(build): link json and fiber tests with libc 2026-09-28 14:18:35 +03:00
boykopovar d65a8ee633 Merge pull request #74 from SamG-Coder/main
fix(shader): support byte permutation and fix compiler lifetime bugs
Adds `V_PERM_B32` byte selection and fixes two existing bugs exposed while testing it: IR equality could merge buffer reads with different metadata, and concurrent shader compilation could crash during Windows thread-local destruction.

- Include instruction flags when comparing IR values so selections between different buffer offsets survive constant folding.
- Decode RDNA2 opcode `0x344` and translate all byte selectors through existing integer IR and the SPIR-V backend, including sign replication, zero/ones fill, and overlapping destinations.
- Reuse the existing `HostThreadLocal` helper for six destructible compiler scratch objects. Add async worker/destructor checks to the existing lifetime test. Scratch storage remains reusable.
2026-09-28 13:51:18 +03:00
boykopovar 0fe554943a Merge pull request #73 from julienlgy/feat/lib-sce-mouse
feat(libSceMouse): implement stateful mouse API exports
Replace the libSceMouse stubs with an implementation that follows AnyPS5’s existing NID-based library integration. Mouse input comes from the host SDL event loop; this change does not add memory hooks or direct access to console HID devices.

Manage the mouse handle, button state, timestamps, and a thread-safe, 64-event history in src/mouse_impl.cpp. Reads are non-blocking.

Forward relative motion, supported buttons, vertical scrolling, and horizontal scrolling from libSceVideoOut’s SDL event loop.

Release pressed buttons when the window loses focus without reporting a hardware disconnection.
2026-09-28 13:45:13 +03:00
boykopovar 0bbc29ee14 Merge pull request #76 from boykopovar/fix/frame-flicking
Fix/frame flicking
## Summary

Fixed corrupted frames caused by guest input buffers being overwritten before GPU execution.

## Cause

Draws referenced mutable guest memory. The CPU could overwrite an input buffer after the draw was recorded but before the GPU consumed it.

## Detection

Instrumentation compared input-buffer contents at draw recording and GPU execution. Corrupted frames contained mismatches in buffers used by affected draws; adjacent correct frames did not.

## Changes

The recorder now creates per-draw copies of read-only CPU input buffers and keeps them alive until GPU completion. Each draw uses descriptors referencing its preserved data.

Buffers with pending GPU writes remain on the existing path and are not copied from CPU memory.
2026-09-28 13:41:13 +03:00
boykopovar 9f1c680b38 fix(agc): preserve per-draw input buffer contents until gpu completion 2026-09-28 13:35:53 +03:00
OverkillLabs e629f37481 feat(libSceAvPlayer): implement full AvPlayer state machine
Replace the stub AvPlayer export set with a general-purpose player state
machine covering the full API surface: sceAvPlayerInit/InitEx/PostInit,
AddSource/AddSourceEx, Start/StartEx, Pause/Resume/Stop/Close, IsActive,
CurrentTime, JumpToTime, SetLooping, SetAvSyncMode, SetTrickSpeed,
SetAvailableBandwidth, StreamCount/EnableStream/DisableStream/ChangeStream/
GetStreamInfo(Ex), and GetVideoData(Ex)/GetAudioData.

No real decoder is wired up: the player tracks lifecycle and timing state
and serves a fixed-length blank clip on a wall-clock media clock, firing
the READY/PLAY/PAUSE/STOP event callbacks a title expects from a real
playback session. This is enough for titles that gate progression on
AvPlayer's polling/event surface rather than on decoded frame content.

The non-native libSceAvPlayer/Export.cpp now forwards to the native
implementation via #include rather than carrying its own duplicate stub
definitions, consistent with how other libSceX/libSceX.native pairs in
this tree share one implementation.
2026-09-28 13:29:23 +03:00
OverkillLabs 2e8c1096fd feat(libSceMsgDialog): real dialog state machine, auto-answer without UI
Replace the unimplemented stubs with a working NONE -> INITIALIZED ->
RUNNING -> FINISHED state machine for the message dialog PRX. Open()
best-effort parses the SceMsgDialogParam layout to pick a sensible
default button (auto-focus-no variants answer No, everything else
answers Yes/OK), then auto-finishes the dialog after a couple of status
polls so a title that waits on a dialog for user input never blocks
forever. Progress-bar mode is instead closed by the title itself via
sceMsgDialogClose, with a time cap as a safety net. GetResult now fills
in a real SceMsgDialogResult (mode/result/buttonId) instead of leaving
the caller's buffer untouched.
2026-09-28 13:28:49 +03:00
boykopovar 76f1d48e60 debug(agc): detect gpu input buffer changes between recording and execution 2026-09-28 13:27:14 +03:00
boykopovar 73e031a4dd perf(agc): downsample frame captures on GPU and queue disk writes 2026-09-28 13:06:15 +03:00
SamG-Coder 8cef034172 fix(shader): safely destroy compiler thread-local storage on Windows 2026-09-28 19:54:01 +10:00
OverkillLabs 77ed5e6d0c feat(savedata): mount aliasing, wildcard search, memory slots, async events
Rework the local SaveData implementation into a general-purpose, title-agnostic
backend used by both the native library and the standard libSceSaveData path:

- Directory aliasing: long save directory names are hashed into short mount
  point aliases (persisted to disk) so they fit the SDK's fixed-size mount
  point buffer, with the aliases reversed on directory search.
- Wildcard directory-name search (%/_ patterns) with sorting and optional
  reverse order, matching the DirNameSearch contract.
- Save-data "memory" slots: small per-user, per-slot blobs the title can
  set up, read and write without mounting a directory, backed by files under
  the save root with a companion parameter blob, size and range validation
  on every access, and a dirty flag consulted on commit.
- Async-flavored operations (backup, commit, memory sync) that queue
  SaveDataEvent records consumed through GetEventResult and can be bound to
  kernel event flags, plus transaction-resource and cancel/abort bookkeeping.
- Atomic file writes (temp file + rename) so a mid-write crash never leaves a
  torn save on disk, and corrected/duplicated SDK error code constants.
- Local storage app-status get/set/delete and transferring-mount support for
  PS4-to-PS5 style save transfers.

The native library keeps its own lighter-weight mount/memory implementation
(short "/_sm/<slot>" mount point aliases via the path-alias table) while
gaining the same per-user memory-slot separation, atomic writes and bounds
checking; the two implementations were merged by hand where upstream had
independently touched the native Export.cpp in the same area (backup/event
queue, short mount points) to keep both sets of improvements.

None of this is game-specific: it is a general local save-data backend that
works for any title and tolerates any user id.
2026-09-28 12:48:09 +03:00
OverkillLabs 3230352202 feat(net): offline socket/epoll/resolver stack with FreeBSD errno mapping
libSceNet: replace the always-fail stubs with a real offline network
stack. Sockets, epoll instances, memory pools and resolvers are tracked
in proper registries with create/destroy lifecycles; bind/listen/accept/
connect/send/recv/getsockopt/setsockopt/getsockname behave the way they
would on a console with no link up (bind and listen succeed locally,
connect/send fail with the errno a routeless host would give, blocking
calls such as accept/recv/epoll_wait return on close, abort or their
timeout). Infinite ("wait forever") timeouts are serviced in bounded
slices so a caller can never deadlock the process. Errno values match
the FreeBSD numbering the guest expects through sceNetErrnoLoc. Restored
sceNetGetsockopt and sceNetResolverStartAton (present upstream) using
the same registry-backed conventions as the rest of the rewrite.

libSceRudp: companion change giving the reliable-UDP library a genuine
context registry (init/create/bind/set-option/get-status) with
consistent error codes; connection attempts consistently fail since no
peer can ever be reached offline.
2026-09-28 12:45:34 +03:00
Julien LegayandCopilot ddb8add753 feat(libSceVideoOut): route SDL mouse events to libSceMouse
Forward relative motion, supported button transitions, and horizontal and vertical scrolling from the existing SDL event loop. Reset pressed buttons on focus loss without reporting a device disconnect, and track window close and refocus transitions.

Link libSceVideoOut to the mouse library using the existing Pad integration pattern. Add targeted coverage for API errors, event mapping, focus changes, history overflow, and reopening.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-28 11:45:31 +02:00
Julien LegayandCopilot 8fac768b9c feat(libSceMouse): implement stateful mouse API exports
Keep the existing Export.cpp entry point and System V ABI while moving mouse state into the library implementation.`n`nTrack initialization, a single handle, button state, timestamps, and a bounded non-blocking event queue. Define and assert the guest MouseData layout and expose an input publisher for the host backend.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-28 11:45:04 +02:00
SamG-Coder 730de17774 fix(shader): support V_PERM_B32 byte selection 2026-09-28 19:35:18 +10:00
SamG-Coder 80a64ccd6b fix(shader): distinguish IR values with different instruction flags 2026-09-28 19:35:18 +10:00
Dean GalvinandClaude Opus 5.5 588b5bb2bf build(font): build FreeType from a submodule instead of requiring a system package
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 22:03:39 +13:00
boykopovar cdc95d9a70 Merge pull request #70 from SamG-Coder/main
fix(shader): support scalar bit operations and 64-bit SAVEEXEC
2026-09-28 11:57:56 +03:00
boykopovar 45817c1b4c Merge pull request #72 from boykopovar/fix/stop-if-window-closed
fix(video): terminate process on gpu and presentation thread failures
Now, any expression that reaches the handlers of a GPU worker, presentation thread, or vblank calls std::terminate() and terminates the entire process.

A closed window is just one of these cases. Previously, the handlers stored and propagated the error, which allowed the process to continue.

The normal shutdown with stopping all guest threads is not implemented.
2026-09-28 11:53:43 +03:00
boykopovar 0d29a0a316 fix(video): terminate process on gpu and presentation thread failures 2026-09-28 11:46:18 +03:00
SamG-Coder 198b43c985 fix(shader): support additional 64-bit saveexec operations 2026-09-28 18:37:51 +10:00
Claude 89ba1019e6 Merge upstream main into refactor/kernel-error-header
Upstream merged #25 and #26. Resolve DirectMemory.hpp and Equeue.hpp
by keeping this branch's side: the local error constants #26 fixed are
replaced by KernelErrors.hpp here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018emyZ4Rk8yoSJvxTFBe4DL
2026-09-28 08:34:25 +00:00
SamG-Coder 2e398be5a0 fix(shader): support scalar conditional move and zero-bit operations 2026-09-28 18:21:34 +10:00
boykopovar 8bd030d531 Merge pull request #26 from QDarkRex/fix/kernel-error-codes
fix(kernel): use SCE kernel error codes in equeue, direct memory and mutex
| Constant | Before | After |
|---|---|---|
| `EQUEUE_ERROR_ETIMEDOUT` | `0x80010023` | `0x8002003C` |
| `EQUEUE_ERROR_EBADF` | `0x80010016` | `0x80020009` |
| `EQUEUE_ERROR_ENOENT` | `0x80010011` | `0x80020002` |
| `EQUEUE_ERROR_EINVAL` / `SCE_KERNEL_ERROR_EINVAL` (DirectMemory) | `0x80010005` | `0x80020016` |
| `EQUEUE_ERROR_EFAULT` / `SCE_KERNEL_ERROR_EFAULT` (DirectMemory) | `0x80010009` | `0x8002000E` |
| `SCE_KERNEL_ERROR_EAGAIN` (DirectMemory) | `0x80010002` | `0x80020023` |
| `SCE_KERNEL_ERROR_ENOMEM` (DirectMemory) | `0x80010007` | `0x8002000C` |
| `SCE_KERNEL_ERROR_EACCES` (DirectMemory) | `0x80010004` | `0x8002000D` |
| `SCE_KERNEL_ERROR_EDEADLK` (Mutex.cpp) | `0x80020023` (= EAGAIN) | `0x8002000B` |
2026-09-28 11:18:14 +03:00
boykopovar 089685b93d Merge pull request #25 from QDarkRex/fix/audit-2026-09
fix(kernel,audioout,relinker): thread/mutex correctness fixes and --windows-gui
### libkernel (threads, mutexes, condition variables)
- **Deadlock in `scePthreadCondTimedwait` (normal/error-check mutexes):** `_owner` was not restored after the wait. If another thread locked and unlocked the mutex during the wait, the waiter woke up owning the mutex while `_owner` was empty. Its next `scePthreadMutexUnlock` returned `EPERM`, leaving the mutex locked forever (`lock → timedwait → unlock` pattern).
- **Wrong timeout code:** `SCE_KERNEL_ERROR_ETIMEDOUT` in `Cond.cpp` was `0x80020062`; it is `0x8002003C` (FreeBSD `ETIMEDOUT` = 60, matching `Semaphore.hpp`).
- **`scePthreadSelf()`** returned `nullptr` on Linux, and on both platforms for threads not created by `scePthreadCreate` (including the main thread). Such threads now get a lazily adopted, non-joinable handle (`scePthreadJoin`/`Detach` on it return `EINVAL`).
- **Linux `scePthreadExit`** skipped `FinishThread`, so `scePthreadJoin` got a garbage return value. Cleanup now runs from an RAII guard, so it survives glibc forced unwinding.
- **Linux detached threads** were never freed. They now use the same reference count as on Windows.
- **Recursive mutex unlock** by a non-owner, or with a zero count, was UB (`std::recursive_timed_mutex::unlock`). It now returns `SCE_KERNEL_ERROR_EPERM`, and `_owner`/`_count` are also saved and restored around a recursive cond wait.
- **`sceKernelLseek`** returned `int` instead of `off_t`; offsets above `INT_MAX` threw.
- **`sceKernelDeleteSema`** implemented: waiters are woken with `SCE_KERNEL_ERROR_EACCES` and the object is freed once they leave.

- `sceAudioOutOpen` accepted `freq == 0` / `len == 0`; the frequency was later used as a divisor. It now returns `SCE_AUDIO_OUT_ERROR_INVALID_SAMPLE_FREQ` / `INVALID_SIZE`.
2026-09-28 11:09:59 +03:00
boykopovar c745e276c1 Merge pull request #66 from SamG-Coder/main
fix(shader): translate scalar byte and short sign extension
2026-09-28 11:00:37 +03:00
boykopovar accc5e5a6c Merge pull request #67 from boykopovar/refactor/optional-timing-logs
refactor(agc): make frame timing logs optional by cmake option
Added the CMake option `APS5_ENABLE_TIMING_LOG`, which defaults to `OFF`. To enable it: `-DAPS5_ENABLE_TIMING_LOG=ON`.
`[FrameTiming]` log for each frame is only output if this option is enabled.
2026-09-28 10:55:48 +03:00
boykopovar 94c443e32f refactor(agc): make frame timing logs optional by cmake option 2026-09-28 10:51:29 +03:00
SamG-Coder f7f60b4ec5 fix(shader): translate scalar byte and short sign extension 2026-09-28 17:49:09 +10:00
Claude 0b560c6af1 Merge fix/audit-2026-09 into refactor/kernel-error-header
Bring in the Linux scePthreadExit fix from #25.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018emyZ4Rk8yoSJvxTFBe4DL
2026-09-28 07:47:20 +00:00
Claude a60256ea4d fix(kernel): exit POSIX guest threads without forced unwinding
On Linux scePthreadExit called pthread_exit, whose forced unwind runs
the personality routine of every guest frame. Those resolve to
libc.prx's __gxx_personality_v0, which cannot read libgcc's unwind
context and aborts, so guest_thread_self crashed on Linux.

Record a jump target in the thread start routine and longjmp back to it
from scePthreadExit instead. Like _endthreadex on Windows, this skips
the guest frames without unwinding them; the start routine still
releases the thread normally. Threads not created by scePthreadCreate
keep the pthread_exit fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018emyZ4Rk8yoSJvxTFBe4DL
2026-09-28 07:47:12 +00:00
Claude 2aced8e8d9 Merge fix/audit-2026-09 (with upstream main) into refactor/kernel-error-header
Bring in the resolved #25 branch, which already carries upstream main
including boykopovar/AnyPS5#10, and re-apply the KernelErrors.hpp
refactor onto the rewritten files:

- Equeue: drop the local EQUEUE_ERROR_* constants and use the shared
  SCE_KERNEL_ERROR_* names.
- Pthread Attr/Thread: drop local error constants and include
  KernelErrors.hpp.
- Pthread Cond/Mutex: take upstream; they no longer define local
  SCE_KERNEL_ERROR_* constants.
- Semaphore: drop KERNEL_SEMA_ERROR_* in favour of KernelErrors.hpp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018emyZ4Rk8yoSJvxTFBe4DL
2026-09-28 07:40:42 +00:00
Claude a28cfb7585 Merge upstream main into fix/kernel-error-codes
Resolve the conflict with boykopovar/AnyPS5#10 in Pthread/src/Mutex.cpp
by taking upstream: its rewrite already returns EDEADLK as 0x8002000B.
The equeue and direct memory error code fixes are unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018emyZ4Rk8yoSJvxTFBe4DL
2026-09-28 07:36:16 +00:00
Claude 210987745c Merge upstream main into fix/audit-2026-09
Resolve conflicts with boykopovar/AnyPS5#10 (sce module loading) and
later upstream changes.

- Pthread Cond/Mutex: take upstream. It already releases mutex
  ownership across condition waits, returns ETIMEDOUT 0x8002003C, and
  rejects unlocks from non-owners for every mutex type.
- Pthread Thread: keep upstream's lifecycle, Windows adoption and job
  affinity; re-apply the POSIX fixes on top: reference-counted
  release on join/detach/exit, self-join rejection on both platforms,
  and scePthreadSelf adoption for threads not created by
  scePthreadCreate.
- Semaphore: keep upstream's TimedWait::Condition and wait tracing;
  re-apply sceKernelDeleteSema waking waiters with EACCES.
- Relinker: keep --windows-gui alongside upstream's --skip-sce-module,
  trampoline-aware Patch signature and new Python tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018emyZ4Rk8yoSJvxTFBe4DL
2026-09-28 07:34:25 +00:00
boykopovar 34f0379d8a Merge pull request #48 from oneandonlydean/feat/linux-fibers
feat(fiber): implement fibers on linux
The state machine, the cross-thread resume handling and the entry trampoline are now shared between platforms. Only the context switch differs:
- `Aps5FiberSwitchStack` saves the SysV callee-saved set (`rbp rbx r12–r15`, MXCSR and the x87 control word) instead of the Win64 set.
- `Aps5FiberTrampoline` passes the fiber in `rdi`.
- There is no TIB to update, so `CurrentBounds`/`SetBounds` do nothing on Linux.
2026-09-28 10:22:04 +03:00
boykopovar 3b4e4f6de6 Merge pull request #65 from SamG-Coder/main
fix(agc): keep BGRA color targets resident between draws
BGRA color targets fail the exact guest-texture-format lookup and fall back to a synchronous framebuffer round-trip for every draw. This keeps them resident using compatible RGBA storage with the original BGRA attachment view. Presentation checks the actual display channel order, attachment views request only attachment usage, and host-write barriers include the host stage.

This follows the existing linked PRX/Vulkan path. It adds no interpreter, separate runtime process, or new shader compilation path.
2026-09-28 10:07:16 +03:00
boykopovar 861e79acfc Merge pull request #62 from oneandonlydean/feat/agc-acb-markers
feat(agc): ACB markers, index buffer unbinding and address in errors
- The DCB marker helpers move from an anonymous namespace in `DcbState/src/Marker.cpp` to `Agc::Marker::Push`/`Pop` (declared in `Marker.hpp`). The ACB entry points use the same helpers, so ACB and DCB markers produce the same custom NOP packets. `SetMarker` is a push followed by a pop, and returns the push packet, as on the DCB. The color is ignored on both, as before.
- `sceAgcDcbSetIndexBuffer` emits the packet with address 0 instead of rejecting it. A non-null address still has to be 2-byte aligned.
- `Agc::Command::CheckAddress` includes the rejected address in its message.
2026-09-28 10:03:44 +03:00
boykopovar 6686e15ee4 Merge pull request #61 from oneandonlydean/feat/agc-dma-gds
feat(agc): DMA_DATA cache policy hints and GDS source/destination
- **Cache policy:** the source (bits 13–14) and destination (bits 25–26) cache-policy fields of `DMA_DATA` dword 1 are accepted. They're cache hints with no effect on the copied data. The remaining reserved bits are still rejected.
- **GDS storage:** GDS is modelled as one 64 KiB, zero-initialised store shared by the whole device, behind a mutex.
- **GDS source/destination:** select `1` reads from or writes to that store:
  - the validator requires the high address dword to be 0 and the range to fit inside the 64 KiB;
  - `Execute` copies between memory, immediate data and GDS in any combination;
  - `ResolveStore` returns nothing for a GDS destination, since there's no guest memory to write, and for a GDS source it resolves the bytes from the store.
- Register and prefetch destinations are still rejected.
- Nothing is faked for shaders: a shader that uses GDS still fails validation (unsupported descriptor role).
2026-09-28 09:59:54 +03:00
boykopovar 3fe80624f7 Merge pull request #60 from oneandonlydean/fix/primitive-restart-indexed
fix(agc): reject primitive restart only for indexed draws
- `DecodeState` still reads `0x24b` (so it stays in the recorded draw-key registers) but no longer rejects on it.
- `DrawRejection` takes an `indexed` flag, and reports restart only for indexed draws.
- The driver's draw path rejects an indexed draw with restart enabled before the precheck, so indexed draws with restart are still refused when the precheck is off. Restart itself is still not implemented.
2026-09-28 09:56:37 +03:00
boykopovar 9f2da178ef Merge pull request #59 from oneandonlydean/fix/retain-replaced-device
fix(agc): keep a replaced Vulkan device alive
In the presenter path, after `PrepareForReplacement()` (which flushes cached textures, publishes shadows and waits for idle), the old device is kept in a function-local static list instead of being released. Its child objects stay valid for as long as anything still refers to them. The cost is one idle device for the life of the process; the replacement happens once, at the first flip.
2026-09-28 09:51:55 +03:00
Dean GalvinandClaude Opus 5.5 0c06382d89 feat(agc): ACB markers, index buffer unbinding and address in errors
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 19:47:33 +13:00
Dean GalvinandClaude Opus 5.5 41fb65761f refactor(fiber): keep the assembly entry points out of NID patching with _nid_no_patch
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 19:46:38 +13:00
Dean GalvinandClaude Opus 5.5 ba9201874f feat(fiber): implement fibers on linux
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 19:46:38 +13:00
boykopovar d942a604a9 Merge branch 'main' into feat/font-freetype 2026-09-28 09:44:53 +03:00
boykopovar b985d17f82 Merge pull request #57 from oneandonlydean/feat/json2
feat(json2): implement sce::Json values, strings, arrays, objects, parser and null-access callback
- **Layouts:** `String`, `Array`, `Object` and `Value` are pointer-sized handles to host-side storage. The title stores `String`/`Array`/`Object` at an 8-byte stride and `Value` in 0x20-byte slots, so none of them can be bigger. The pair an `Object::iterator` dereferences to has its key at +0x00 and its `Value` at +0x10, which the title reads directly. Array and object iterators are 8 bytes.
- **Parser:** a strict RFC 8259 parser.
  - Numbers: integers that fit `int64` become `Integer`, larger non-negative ones `UInteger`, and everything else `Real`.
  - Strings: `\u` escapes, including surrogate pairs, are decoded to UTF-8.
  - Errors: on any error `parse` returns a negative code (`0x80920101`) and leaves the target value untouched.
- **Serialisation:** compact output. Strings are escaped; reals use `%.17g`, and a non-finite real throws.
- **Null access:** a typed getter on a value of another type, a missing key or an out-of-range index goes through the null-access callback. The callback's result is used when its type matches (any type for `operator[]`). Otherwise a static default value of the requested type is returned. `terminate` clears the callback.
- **Integer getters:** `getInteger`/`getUInteger`/`getReal` convert between the integer kinds and to real where the value fits.
- `setGlobalNullAccessCallBack` (NID `00oCq0RwSAY`) was identified by hashing its mangled name.
- `MemAllocator`'s base constructor and destructor install the abstract class's vtable. A derived allocator replaces it with its own, so its entries (which throw, like a pure virtual call) run only if a pure virtual is called. `Initializer::initialize` throws on a null parameter instead of silently accepting it.
- Mutating a value that isn't the expected type (`referArray` on a string, etc.) throws.
2026-09-28 09:42:21 +03:00
boykopovar 73d014ed83 Merge pull request #56 from oneandonlydean/feat/linux-pread-getdents
feat(libkernel): pread, pwrite, getdents and getdirentries on linux
- **pread/pwrite:** use the existing `NativePread`/`NativePwrite` and don't move the file offset. A null buffer with a non-zero size returns `EFAULT`, a negative offset `EINVAL`, and host failures go through `SceErrorFromErrno`.
- **getdirentries:**
  - reads host `getdents64` records and converts them to the FreeBSD `struct dirent` layout the guest expects (`d_fileno` u32, `d_reclen` u16, `d_type` u8, `d_namlen` u8, NUL-terminated name, record padded to 4 bytes);
  - `*basep` gets the directory position from before the read;
  - when a record doesn't fit in the guest buffer, the descriptor is moved with `lseek` back to that entry's cookie, so the next call resumes there;
  - if not even the first record fits, the call returns `EINVAL` without consuming anything, and a name longer than 255 bytes returns `ENAMETOOLONG`.
- **getdents** is `getdirentries` without `basep`.
- Adds the guest `EFAULT`, `EINVAL` and `ENAMETOOLONG` constants.
2026-09-28 09:38:47 +03:00
boykopovar a6bb98d4d5 Merge pull request #54 from oneandonlydean/feat/extrq-register-form
feat(relinker): lower register-form EXTRQ and relocate following instructions for short sites
- **Lowering:** register-form EXTRQ is emitted out of line with SSE2 only. Two scratch XMM registers (distinct from both operands) are spilled; one gets the index (`src >> 8 & 63`), the other `(64 - length) & 63` (`length` masked to 6 bits, so 0 means 64). The destination is shifted right by the index, then left and right by the complement, which keeps the low `length` bits. INSERTQ register form is still reported as unsupported.
- **Short sites:** when a site is shorter than a `jmp rel32`, the converter extends it over the instructions that follow it until it's 5 bytes long:
  - following EXTRQ/INSERTQ instructions (before any other instruction) are lowered into the same stub, via a new `MatchSequence`;
  - other instructions are copied after the lowered body (`LowerOutOfLine`'s new `trailing` bytes), but only if they're sequential, have no RIP-relative operand and no branch target;
  - anything else (a return, a branch, RIP-relative code, the segment ending) still fails the relink, as does a branch target inside the extended site.
- `docs/TechnicalDebt.md` now lists only the INSERTQ register form, MONITORX/MWAITX/CLZERO/RDPRU/MCOMMIT and SHA-NI.
2026-09-28 09:35:28 +03:00
boykopovar ae4e38f3f9 Merge pull request #53 from oneandonlydean/feat/userservice-profile
feat(userservice): user name, user number and accessibility settings of the initial user
They report the initial user, following `sceUserServiceGetGamePresets`:
- **Name:** `Player`. A buffer shorter than 17 bytes returns `SCE_USER_SERVICE_ERROR_BUFFER_TOO_SHORT` (`0x8096000A`).
- **User number:** 1.
- **Accessibility settings:** 0, the setting-off value on a fresh console.
2026-09-28 09:29:01 +03:00
SamG-Coder fa787cfbe9 fix(agc): keep BGRA color targets resident between draws 2026-09-28 16:26:02 +10:00
boykopovar c36881727c Merge pull request #51 from oneandonlydean/feat/libc-runtime-functions
feat(libc): operator new/delete, bounds-checked functions, char locale facets and runtime helpers
2026-09-28 09:23:33 +03:00
boykopovar f558a7bcec Merge pull request #52 from oneandonlydean/fix/libc-unhandled-exception-report
fix(libc): don't walk guest frame pointers when reporting an unhandled exception
Only log __builtin_return_address(0), which doesn't depend on the guest's frames. After the fix, the log prints the exception type and the terminate handler prints what().
2026-09-28 09:10:38 +03:00
boykopovar 244b915c75 Merge branch 'main' into feat/libc-runtime-functions 2026-09-28 09:01:41 +03:00
boykopovar ce6ac25b7e Merge pull request #49 from oneandonlydean/feat/mspace-extensions
feat(libc): mspace memalign, malloc stats, thread-unsafe flag and nested mspaces
- Memalign uses the existing aligned allocation.
- Stats fill `SceLibcMallocManagedSize` (size checked against 0x28) from new `inUse`/`peakInUse` counters on the arena. The system size is the arena's extent.
- The thread-unsafe flag is accepted: the implementation always locks, so skipping locks is only an optimisation it doesn't need. Other flags are still rejected.
- An overlapping create is allowed only when the new range lies entirely inside a live block of the other mspace. Every other overlap is still rejected.
2026-09-28 08:58:28 +03:00
boykopovar d653d85538 Merge pull request #50 from oneandonlydean/feat/libkernel-mappings
feat(libkernel): hinted and no-overwrite mappings, virtual range names and usleep
- **Non-fixed mapping with an address hint:** `MapAligned` threw `Non-fixed mapping address hints are not implemented`. On the PS5 the hint is where the search starts. On Linux the mapping is now placed at the first free, aligned range at or above the hint, found from `/proc/self/maps` and mapped with `MAP_FIXED_NOREPLACE` so nothing existing can be replaced. `RequireAvailable` is now only checked for fixed mappings, because a hint may point at used memory. Windows still throws.
- **`SCE_KERNEL_MAP_NO_OVERWRITE` (`0x80`):** it was rejected as an unknown flag. With `MAP_FIXED` on Linux it maps with `MAP_FIXED_NOREPLACE`, and it no longer takes the "remap fixed into registered" path, so it fails instead of replacing a registered range. The unsupported-flags error now includes the flag value.
- **Virtual range names:** `sceKernelSetVirtualRangeName` was `NotImplemented` and `sceKernelClearVirtualRangeName` wasn't exported. Names are now kept in a registry, split and trimmed on overlap. `sceKernelVirtualQuery` reports the name and splits its reported region at name boundaries. `sceKernelMapNamedDirectMemory` and `sceKernelMapNamedFlexibleMemory` now name the range instead of ignoring the name.
- **`usleep`** is exported (POSIX, beside `nanosleep`).
2026-09-28 08:54:42 +03:00
boykopovar f354dbd17e Merge pull request #47 from oneandonlydean/fix/linux-load-alignment
fix(relinker): align the linux header load segment to the largest segment alignment
2026-09-28 08:44:02 +03:00
boykopovar 615dd7f254 Merge pull request #64 from boykopovar/fix/pad-input-header
fix(pad): add missing header for log macros to pad input cpp
2026-09-28 08:41:51 +03:00
boykopovar 9dd86e99bf fix(pad): add missing header for log macros to pad input cpp 2026-09-28 08:41:20 +03:00
boykopovar a878b31e52 Merge pull request #46 from MartinCajiao/feat/configurable-input-mapping
feat(input): support game controllers and configurable bindings
- Add optional per-game keyboard and mouse bindings through `anyps5-input.ini` or `ANYPS5_INPUT_CONFIG`. Unspecified actions keep their built-in bindings, and repeated action entries provide alternatives.
- Keep wheel presses and focus-loss state handling compatible with dynamically sized bindings. Report configuration errors through the existing video and pad failure path.
- Document the format and remove the resolved input-mapping debt item.
2026-09-28 08:34:29 +03:00
boykopovar 20e5c359d9 Merge pull request #45 from oneandonlydean/fix/linux-guest-dynlibdata
fix(relinker): skip the flagless dynlib data segment in linux guest modules
2026-09-28 08:31:05 +03:00
boykopovar 7b761115b2 Merge pull request #44 from oneandonlydean/fix/linux-virtualquery
fix(libkernel): build sceKernelVirtualQuery on linux
2026-09-28 08:28:45 +03:00
boykopovar 6548946cd6 Merge pull request #43 from gdarko/fix/relinker-write-errors
fix(relinker): report buffered output write failures
Small buffered writes can report success even when flushing fails. Both FileWriter::Write overloads now close the stream before checking for errors.

Added Linux regression tests using /dev/full. Both fail before the fix
2026-09-28 08:25:56 +03:00
boykopovar f65ca6806c Merge pull request #39 from Pacuka/fix/recompiler-64bit-constants
fix(recompiler): widen constants of 64-bit operands instead of repeating them
TranslationContext::readU32Pair builds a 64-bit source from two 32-bit reads, taking the high half from offsetOperand(operand, 1). For registers that is the next register. For a literal or an inline constant, offsetOperand returns the same operand, so the constant ended up in both halves: the literal L was read as L:L instead of 0:L.
2026-09-28 08:22:01 +03:00
boykopovar a8d6f8664e Merge pull request #63 from oneandonlydean/feat/libc-sscanf-s
feat(libc): sscanf_s on linux
sscanf_s was a NotImplemented placeholder in libc/Export.cpp, and a retail title uses it to parse strings. It's now implemented on Linux. Windows still throws NotImplemented.
2026-09-28 08:18:32 +03:00
boykopovar a8151f17d9 fix(libc): add missing header for not impl helper 2026-09-28 08:13:48 +03:00
boykopovar f38e97658f Merge pull request #40 from Pacuka/feat/agc-draw-index-indirect
feat(agc): emit indexed indirect draws
This implements `sceAgcDcbDrawIndexIndirect` and `sceAgcDcbDrawIndexIndirectMulti`. They were stubs that aborted with "not implemented".

They follow the existing non-indexed `sceAgcDcbDrawIndirect` / `DrawIndirectMulti`:

- `DrawIndexIndirect` emits `DRAW_INDEX_INDIRECT` (0x25): data offset, base vertex / start instance SGPR locations, draw initiator (5 dwords, matching `GetSize` = 20).
- `DrawIndexIndirectMulti` emits `DRAW_INDEX_INDIRECT_MULTI` (0x38): the same fields, plus the draw-index location / count-indirect control word, count, count address and stride (10 dwords, matching `GetSize` = 40). The stride must be at least 20, the size of an indexed record.
2026-09-28 08:08:47 +03:00
boykopovar d1238299b7 Merge pull request #24 from SamG-Coder/main
fix: support SDK startup, linear framebuffers and indexed draws
Fix SDK startup with an empty allocator replacement table, add linear framebuffer presentation through the current presentation path, and implement explicit indexed draws with packet validation. Retain buffer-address regression coverage for the correction already upstream, and restrict the POSIX exception-runtime test to Unix so Windows test builds succeed.

Also fix two issues reproduced after rebasing: render-target format lookup probed unsupported formats by repeatedly throwing exceptions, costing about 78 ms per draw; the lookup now searches supported entries directly. Recorder buffers now use Windows FLS cleanup to avoid MinGW freeing emulated TLS storage before running their destructors. Cross-DLL tests check independent values and destruction on standard and native Windows threads.
2026-09-28 08:03:34 +03:00
boykopovar b1509a17a6 Merge pull request #34 from Pouare514/idea/prx-cohtml
libs: add libcohtml stub prx (50 NIDs) + Prospero deploy rename
2026-09-28 07:55:22 +03:00
boykopovar 368385ebb3 Merge pull request #33 from Pouare514/idea/prx-fmod
libs: libfmod/libfmodstudio with real FMOD signatures + SDL audio backend
66/93 NIDs mapped to real Itanium-mangled FMOD signatures (byte-verified), 27 stubs. Real SDL audio output (WAV/RAW audible, mixer, volumes), silent fallback via env. Coverage 51/51 + 42/42. Remaining: compressed decoders, Studio mixer, 5 unknown NIDs.
2026-09-28 07:51:08 +03:00
Dean GalvinandClaude Opus 5.5 20cc23438f feat(libc): sscanf_s on linux
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 16:53:29 +13:00
Dean GalvinandClaude Opus 5.5 e1a8371bff feat(agc): DMA_DATA cache policy hints and GDS source/destination
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 16:51:01 +13:00
Dean GalvinandClaude Opus 5.5 0479a5f5f0 fix(agc): reject primitive restart only for indexed draws
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 16:49:29 +13:00
Dean GalvinandClaude Opus 5.5 f6a23c9d15 fix(agc): keep a replaced Vulkan device alive
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 16:47:02 +13:00
Dean GalvinandClaude Opus 5.5 00e4f7678d feat(font): port shadPS4's sceFont and sceFontFt on FreeType
Ported from shadPS4 (GPL-2.0-or-later) with system fonts removed, stubs made to throw,
and sceFontCloseFont implemented.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 16:45:30 +13:00
Dean GalvinandClaude Opus 5.5 390e4cd800 feat(json2): implement sce::Json values, strings, arrays, objects, parser and null-access callback
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 16:42:29 +13:00
Dean GalvinandClaude Opus 5.5 f7e1bdf0b9 feat(libkernel): pread, pwrite, getdents and getdirentries on linux
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 16:40:22 +13:00
Dean GalvinandClaude Opus 5.5 ff1fa9eb69 feat(relinker): lower register-form EXTRQ and relocate following instructions for short sites
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 16:37:15 +13:00
MartinCajiao 0644a8c38f feat(input): support SDL game controllers 2026-09-27 20:27:22 -05:00
Dean GalvinandClaude Opus 5.5 99bdf81364 feat(userservice): user name, user number and accessibility settings of the initial user
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 14:22:48 +13:00
Dean GalvinandClaude Opus 5.5 eb79f0d412 fix(libc): don't walk guest frame pointers when reporting an unhandled exception
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 14:22:48 +13:00
Dean GalvinandClaude Opus 5.5 a599eca727 feat(libc): operator new/delete, bounds-checked functions, char locale facets and runtime helpers
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 14:22:48 +13:00
Dean GalvinandClaude Opus 5.5 3058980d96 feat(libc): mspace memalign, malloc stats, thread-unsafe flag and nested mspaces
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 14:22:48 +13:00
Dean GalvinandClaude Opus 5.5 9754937a5d feat(libkernel): hinted and no-overwrite mappings, virtual range names and usleep
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 14:22:48 +13:00
Dean GalvinandClaude Opus 5.5 06b3413961 fix(relinker): align the linux header load segment to the largest segment alignment
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 14:22:48 +13:00
MartinCajiao 1007f6d64e fix(input): load per-game config beside executable 2026-09-27 20:20:17 -05:00
MartinCajiao 6dfa449e52 fix(input): handle UTF-8 BOM and duplicate bindings 2026-09-27 19:58:38 -05:00
MartinCajiao c13f0eee67 feat(input): allow configurable keyboard and mouse bindings 2026-09-27 19:54:19 -05:00
Dean GalvinandClaude Opus 5.5 346b7280e2 fix(relinker): skip the flagless dynlib data segment in linux guest modules
GuestModuleWriter::WriteLinux adds read permission to every PT_LOAD, including
the SCE dynlib data segment, which has no flags and is never mapped on the PS5.
When that segment starts inside the last page of the preceding RW segment, the
read-only mapping covers the tail of its bss and the module's initializer faults
on its first write there. The symbol and relocation tables it holds are already
copied into the appended segment, so it no longer needs to be mapped.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 13:32:36 +13:00
Dean GalvinandClaude Opus 5.5 93a214836f fix(libkernel): build sceKernelVirtualQuery on linux
The host-region fallback added with the Demon's Souls work calls VirtualQuery and
includes windows.h unconditionally, so libkernel no longer compiles on Linux.
On Linux, read the containing mapping and its permissions from /proc/self/maps.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 13:32:36 +13:00
SamG-Coder e424b6b7bf fix(agc): preserve recorder buffers through Windows thread teardown 2026-09-28 09:55:01 +10:00
SamG-Coder 9814c93f75 fix(agc): avoid exception-driven render target format probing 2026-09-28 09:55:00 +10:00
SamG-Coder e1e3a12227 fix(build): restrict POSIX exception runtime test to Unix 2026-09-28 09:09:02 +10:00
SamG-Coder fc26cff30f test(shader): cover decoded buffer address operands 2026-09-28 09:09:02 +10:00
SamG-Coder b25025c682 fix(agc): support explicit indexed draw commands 2026-09-28 09:09:02 +10:00
SamG-Coder 07930c6726 feat(videoout): present linear framebuffer layouts 2026-09-28 09:05:49 +10:00
SamG-Coder 67fce999c5 fix(libc): support SDK startup without allocator replacements 2026-09-28 09:03:10 +10:00
Darko Gjorgjijoski 42594eecd4 fix(relinker): report buffered output write failures 2026-09-28 00:25:42 +02:00
boykopovar 7656458121 Merge pull request #5 from yumlevi/feat/demons-souls-boot
Boot Demon's Souls to its first level: AGC recorder driver, runtime, audio, Bink fixes
2026-09-28 00:40:24 +03:00
devilismyfriendandClaude Opus 5.5 9e5f8397f2 refactor(agc): drop outside references from the copy kernel comments
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-27 12:14:48 -07:00
devilismyfriendandClaude Opus 5.5 9325ac08de docs(md): relink titles that ship their own libc with --skip-sce-module
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-27 11:54:31 -07:00
devilismyfriendandClaude Opus 5.5 72336201b2 perf(libkernel): resolve initialised mutexes and conditions without the global lock
Every lock, unlock, signal and wait took the process-wide initialisation
mutex to read the handle, serialising all guest synchronisation. The
handle is now read atomically and the lock is only taken to initialise a
static initializer or to report a destroyed object.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-27 11:26:59 -07:00
devilismyfriendandClaude Opus 5.5 e764385d51 fix(libkernel): drop the scePthreadOnce stub that shadowed the implementation
The merge brought a NotImplemented scePthreadOnce_nid_postfix next to the
existing scePthreadOnce. The NID patcher gives the NID to the postfixed
symbol, so the stub replaced the working export and the title aborted at
its first once-initialisation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-27 11:26:58 -07:00
1e4430e917 fix(agc): drop cached textures on Vulkan device replacement
When the presentation device was replaced, textures created on the old
device stayed in the global sampled and storage texture caches and kept a
reference to the destroyed TextureDetiler, whose VkDevice was then read
corrupted ("missing Vulkan function: vkResetDescriptorPool" at startup).
The replacement now flushes the old device's cached storage textures and
publishes every unit shadow before waiting for the device, and the device
teardown erases the cache entries that belong to it.

Patch author: boykopovar (fix-vulkan-texture-lifetime.patch, PR #5 review).

Co-Authored-By: boykopovar <boykopovar@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-27 10:53:11 -07:00
devilismyfriendandClaude Opus 5.5 a503d0b617 Merge remote-tracking branch 'origin/main' into feat/demons-souls-boot
Brings in main up to 9958d26 (homebrew runtime, POSIX wrappers in
libkernel, sce_module guest modules and --skip-sce-module, the --to-intel
general pipeline, libSceRandom, libSceRtc, libScePosixForWebKit,
libRenoirCore, test wiring).

Resolutions where both sides implemented the same thing:
- libkernel pthread: main's structure (lazy static initialisation,
  destroyed markers, MutexOperations/CondOperations, mutex protocol and
  condattr clock) with this branch's TimedWait deadlines and condition
  (precise timed lock/wait on Windows), wait tracing, the adaptive mutex
  type 4, POSIX default ERRORCHECK mutexes, EDEADLK/EPERM results instead
  of throws, and condition clocks honoured for absolute timeouts.
- libc locale: the guest Dinkumware ABI (_Locimp, facet vtables, short
  ctype/case tables, locale ids, stream storage) is kept because guest code
  inlines those layouts; main's C character functions are kept on top.
- libc stdio/strings/math: main's stream functions (guest FILE status
  sync), strerror/perror, remove, formatting, string and math exports win
  over this branch's duplicates.
- libc paths: main's working directory with this branch's path aliases
  resolved on the normalised guest path.
- libkernel file: this branch's sceKernel* results as SCE errors, main's
  POSIX wrappers and both fstat helpers.
- relinker: this branch's stub lowering keeps its trampolines through the
  main executable path; guest modules refuse lowerings that need stubs.
- AGC driver: main's rendering wait is executed by this branch's workers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-27 10:52:21 -07:00
PacukaandClaude Opus 5.5 83f43d1004 feat(agc): emit indexed indirect draws
sceAgcDcbDrawIndexIndirect and sceAgcDcbDrawIndexIndirectMulti emit
DRAW_INDEX_INDIRECT (0x25) and DRAW_INDEX_INDIRECT_MULTI (0x38) like their
non-indexed counterparts, with 20-byte records.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 19:43:16 +02:00
PacukaandClaude Opus 5.5 5fdcd571cd fix(recompiler): widen constants of 64-bit operands instead of repeating them
readU32Pair read a literal or inline constant into both halves of a 64-bit
source. A literal is now zero-extended, an integer inline constant
sign-extended and a float inline constant becomes the matching double.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 18:59:46 +02:00
adriadam10andClaude Opus 5.5 e73cd7dec3 feat(tools): report progress changes on pull requests
progress.py stores the names of implemented and pending items, can
measure another source tree with --root and prints a Markdown diff of
two runs with --compare. The Progress report workflow compares every
pull request with its base, and Progress comment posts the result as a
single comment, updated on every push and removed when progress no
longer changes. Commenting runs as a separate workflow_run so pull
requests from forks never run with write permissions.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 18:47:32 +02:00
adriadam10andClaude Opus 5.5 3c6b0af6f7 feat(tools): add progress map for system libraries and shader instructions
tools/progress.py counts implemented prx functions and RDNA instructions
recognized by the shader recompiler, and renders treemaps, badges and an
index page. The Progress workflow deploys them to GitHub Pages on every
push to main, so nothing generated is committed to the repository.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 18:21:34 +02:00
boykopovar 9958d26f4f Merge pull request #31 from Pouare514/idea/prx-renoir
libs: add libRenoirCore.PS5 stub prx (23 NIDs)
2026-09-27 18:12:16 +03:00
Pouare514 5099184d4d feat(prx): fmodstudio unknown NIDs throw via NotImplemented
Convert 5 remaining pure stubs (log + return 0) to throwing with
literal NID, keep trailing return 0. Real SDL/state-tracking impls
(20 studio + 2 libfmod + C++ classes) untouched. Remove stale
logging-stub comments only around touched stubs.

Throwing: Cm2cmtCv8cA, EfM9xXvBmxk, Js90KQXVS4s, oCYWES02VPc, vVwA2cZA5e4
2026-09-27 16:10:41 +02:00
Pouare514 7cdb23eacd fix(libcohtml): throw via NotImplemented_nid_no_patch for 50 stubs 2026-09-27 16:06:18 +02:00
Pouare514 b6dea0b51b Renoir stubs throw with NID name for progress monitoring 2026-09-27 15:53:27 +02:00
Pouare514 a719359cd1 prx: make libRenoirCore.PS5 stubs throw NotImplemented 2026-09-27 15:49:18 +02:00
boykopovar e06dbff7d6 Merge pull request #10 from boykopovar/feat/sce-module-load
Feat/sce module load
The game can expect its modified prx from the `sce_module`/`sce_modules` folder. The relinker now converts PRX files from sce_module to `dll`/`so` format with `.guest.prx` postfix. During linking, libraries from `sce_module` are given priority. If a library from `sce_module` fails to import a symbol or contains a syscall, an exception will be thrown.

This made it possible to remove the GuestLocale formats that were customized for specific guests. Launched apps now use their own PRX files from the `sce_module` folder.
Locale handling functions now use `std::locale`.

Added a lot of posix functions to `libkernel` (they are thin wrappers and do what the existing non-posix versions do)
2026-09-27 15:47:36 +03:00
Pouare514 030e62dfa3 feat(prx): fmod real audio output via SDL + identify 22/27 NIDs
- libfmod: route createSound (OPENMEMORY WAV/RAW, file placeholder sine)
  + playSound + update() mixer pump into SDL queue (48k stereo F32,
  mirrors libSceAudioOut). Channel::setVolume/isPlaying/position now
  track real PCM cursor with loop support. Silent fallback via
  ANYPS5_FMOD_SILENT=1, NOSOUND output, or SDL open failure.
  Link SDL2-static like libSceAudioOut.
- NIDs: recompute from public FMOD headers (fmod.h/hpp + fmod_studio
  2.0) with exact Itanium manglings (g++ nm) + SHA1+suffix
  (NidCompute.cpp). Identify 2/2 libfmod (setFileSystem, setCallback)
  + 20/25 studio (const createInstance, getEvent, getCoreSystem,
  getSoundInfo, etc.). Replace stubs with ABI-compatible real
  impls; 5 studio remain unknown (Cm2cmtCv8cA, EfM9xXvBmxk,
  Js90KQXVS4s, oCYWES02VPc, vVwA2cZA5e4).
- Tests: coverage OK (51+42 Legends NIDs, missing 0), audio smoke
  (WAV 4800f + RAW 2048f, volume, channelsPlaying, stop) OK real
  and silent.
2026-09-27 13:24:34 +02:00
Pouare514 279587cb16 fix(libcohtml): provide libcohtml.Prospero.prx for DT_NEEDED
Copy the patched libcohtml.prx to libcohtml.Prospero.prx (exact DT_NEEDED name) via a post-build copy in the module CMakeLists, wired into the libs umbrella target. OUTPUT_NAME with a dot was rejected: the parent pipeline derives unpatched/patched paths from the directory target name, so renaming output would break it; dotted CMake target names are supported (e.g. libSceSaveData.native) but the parent-owned NID-patch rule is kept untouched. Adds DEPLOY.md deploy note. All 50 raw NIDs re-verified in the renamed file export table.
2026-09-27 12:57:23 +02:00
Pouare514 c0515bdcce feat(prx): add libfmod and libfmodstudio replacements covering Legends NIDs 2026-09-27 12:32:13 +02:00
boykopovar 179841caff feat(relinker): report full module path when windows loading fails 2026-09-27 13:10:06 +03:00
Pouare514 a4248cb114 feat(libcohtml): add stub prx exporting 50 Minecraft Legends NIDs 2026-09-27 12:00:15 +02:00
Pouare514 0722f3e5fc prx: add libRenoirCore.PS5 replacement with 23 Renoir stubs for libcohtml
Minecraft Legends' libcohtml.Prospero.prx imports 23 NIDs from lib
libRenoirCore.PS5_v1 (docs/legends-unresolved-nids.json). Clear names are
unknown, so each export is exposed under its raw NID via APS5_EXPORT
alias (<NID>_nid_no_patch_cut), which nid_patcher strips to the
literal NID instead of hashing.

Stubs follow KytyPS5 UnresolvedImportStub policy (log call + return 0)
via APS5_LOG_OUT rather than throwing NotImplemented.
2026-09-27 11:57:54 +02:00
boykopovar 43d2e8b4dc fix(codegen): decode xadd byte and popcnt instruction lengths fix 2026-09-27 12:49:46 +03:00
boykopovar e3dc9a6acc fix(relinker): accept zero alignment for empty tls segments 2026-09-27 12:41:52 +03:00
boykopovar 52b683d208 fix(relinker): skip generated guest prx files during sce module scan 2026-09-27 11:43:42 +03:00
boykopovar e526f1f528 feat(libc): replace guest locale implementation with std::locale 2026-09-27 11:43:42 +03:00
boykopovar bfa1ac0751 fix(relinker): scan complete function ranges for windows tls accesses 2026-09-27 11:43:41 +03:00
boykopovar 9cc36a02fe feat(libkernel): add __progname str value 2026-09-27 11:43:40 +03:00
boykopovar f5ea673c10 feat(libkernel): impl posix stdio wrappers, reusing sceKernel file ops 2026-09-27 11:43:40 +03:00
boykopovar 7a925c68e5 fix(libkernel): handle clock_second 13 in clock_gettime and clock_getres 2026-09-27 11:43:39 +03:00
boykopovar 13c648bebb feat(libkernel): impl file, time, process, signal for posix 2026-09-27 11:43:38 +03:00
boykopovar 62c16792ff feat(libkernel): impl pthread condition variables + posix thread attribute queries 2026-09-27 11:43:37 +03:00
boykopovar a709e220f2 feat(libkernel): implement posix mutex locking and timed waits 2026-09-27 11:43:37 +03:00
boykopovar ae2e5cba7e feat(libc): implement heap trace info 2026-09-27 11:43:36 +03:00
boykopovar c9cb3cae39 feat(libkernel): implement disabled address sanitizer state + replacement tables 2026-09-27 11:43:36 +03:00
boykopovar 9fd6816356 fix(libkernel): store rtld allocator table separately from application heap 2026-09-27 11:43:35 +03:00
boykopovar dbb56adcf6 feat(libkernel): implement process, cpu, uuid, gpi, gpo, sync funcs 2026-09-27 11:43:34 +03:00
boykopovar 55e1c4a238 feat(libkernel): implement application heap and thread atexit registration 2026-09-27 11:43:33 +03:00
boykopovar 2e654e4f89 feat(relinker): scan sce modules for syscalls 2026-09-27 11:43:33 +03:00
boykopovar 630cb018c0 feat(relinker): add --skip-sce-module flag 2026-09-27 11:43:32 +03:00
boykopovar 5887c8d6e2 feat(libkernel): add memory segment, backtrace, heap error report definitions 2026-09-27 11:43:32 +03:00
boykopovar 40101471ee feat(libkernel): add new posix, pthread, semaphore, process funcs definitions 2026-09-27 11:43:31 +03:00
boykopovar 0783e369da feat(libkernel): add definitions for standard guest libc imports 2026-09-27 11:43:31 +03:00
boykopovar 337e763597 fix(relinker): support operand-size prefixes on fs:[0] access 2026-09-27 11:43:30 +03:00
boykopovar 2cc34985c0 fix(codegen): decode int imm8 instruction length correctly 2026-09-27 11:43:30 +03:00
boykopovar fa10c6d7eb fix(relinker): scan reachable code for windows guest tls accesses 2026-09-27 11:43:30 +03:00
boykopovar 6b2db1d8a8 fix(relinker): support windows guest tls relocations and accesses 2026-09-27 11:43:29 +03:00
boykopovar 0c6765e6a6 fix(relinker): ignore non-loadable SCE segments outside file bounds 2026-09-27 11:43:29 +03:00
boykopovar 1379ec001b feat(relinker): add native guest module loading with export priority 2026-09-27 11:43:28 +03:00
boykopovar fce5889d91 Merge pull request #21 from obelisk-complex/test/wire-up-exception-runtime-test
test: wire up the orphaned exception runtime test
- `core/libs/CMakeLists.txt`: registered `ExceptionRuntime.cpp` as `exception_runtime_tests`/`exception_runtime`, following the existing `Guest*.cpp` test pattern, linked against `libc`.
2026-09-27 11:39:23 +03:00
boykopovar 228802b7f5 Merge pull request #23 from obelisk-complex/test/fix-agc-driver-test-bitrot
test(agc): fix and re-enable 3 of 8 bitrotted AGC driver tests
- `agc_driver_graphics_tests`: fixed the link failure by adding the three missing source files and linking `shader_recompiler_agc_driver`. Still fails at runtime against stale assertions accumulated over many commits of not being built (an expected "not implemented" message that texture support since removed, and a sampler test fixture value that no longer fits its 12-bit field). Left `EXCLUDE_FROM_ALL`; fixing the assertions is a separate pass across the whole 1150-line test file, not a build fix.
- `agc_driver_recompiler_tests`: root-caused but not fixed. It needs `COMPUTE_NUM_THREAD_X` set, and its pass condition checks for a "not implemented" stub error that no longer exists now that the real recompiler is in. Restoring its original intent needs a shader deliberately built to fail recompilation, which is a design decision, not something this PR should decide unilaterally. Left `EXCLUDE_FROM_ALL`.
- `agc_driver_tests`, `agc_shader_memory_tests`, `agc_driver_flip_tests` and `agc_driver_pm4_tests` already passed; registered them with `add_test` so none of the four can bitrot silently again.
2026-09-27 11:34:45 +03:00
boykopovar 7894745fba Merge pull request #15 from obelisk-complex/fix/sscanf-signedness-and-substr-copy
fix: correct sscanf %x signedness and avoid a substr copy
- `core/libs/prx/libSceSysmodule/Export.cpp`: `devMajor`/`devMinor` now `unsigned int`.
- `core/libs/nid/include/nid/NidPatcherUtils.hpp`: two `substr(0, n)` calls replaced with `resize(n)`.
2026-09-27 11:30:50 +03:00
boykopovar 0b262e9987 Merge pull request #14 from obelisk-complex/fix/linux-exception-unwind-interposition
fix(exceptions): interpose libstdc++ ABI on Linux so the project's own unwinder drives it
- `OwnPersonality()` in `Unwind.cpp` now recognises the bare `__gxx_personality_v0` wrapper on Linux too (previously Windows-only).
- `Exports.cpp` exports the real ABI names (`__cxa_throw`, `__cxa_begin_catch`/`end_catch`, `__cxa_rethrow`, `__cxa_allocate`/`free_exception`, `__cxa_call_terminate`, `__cxa_get_exception_ptr`, `__cxa_current_exception_type`, `__cxa_init_primary_exception`, the `std::terminate`/`uncaught_exception(s)` mangled names, and the core `_Unwind_*` entry points) through the existing `GCC_GLOBAL_ALIAS` assembler-alias macro rather than new C++ definitions (a plain redefinition under these names conflicts with `<cxxabi.h>`'s own declarations). This lets ELF symbol interposition make this project's own implementation win process-wide over `libgcc_s.so.1`/`libstdc++.so.6`.
- `__cxa_init_primary_exception_nid_postfix` is new: GCC 13's inline `std::make_exception_ptr` calls `__cxa_init_primary_exception`, and nothing implemented it before.
- Deliberately did not alias `__dynamic_cast`, `__cxa_pure_virtual` or `__cxa_deleted_virtual`. Nothing in `core/libs/prx` needs them rerouted, and doing so would divert every RTTI cast in libstdc++ and third-party code (SDL2, glslang) through this project's slower walker for no benefit.
2026-09-27 11:27:36 +03:00
boykopovar aa7d8b1072 Merge pull request #16 from obelisk-complex/docs/spirv-validation-is-opt-in
docs: correct SPIR-V validation claim and a stale line citation
2026-09-27 11:17:01 +03:00
QDarkRexandClaude Opus 5.5 2081071237 refactor(kernel): share SCE kernel error codes through KernelErrors.hpp
Kernel error codes were redeclared per file under three prefixes
(SCE_KERNEL_ERROR_, EQUEUE_ERROR_, KERNEL_SEMA_ERROR_), which let wrong
values go unnoticed. Define them once as 0x80020000 | errno for errno
1..94 and use the SCE_KERNEL_ERROR_ names everywhere. Values are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 13:32:28 +07:00
QDarkRexandClaude Opus 5.5 ac0f8af228 fix(kernel): use SCE kernel error codes in equeue, direct memory and mutex
SCE kernel errors are 0x80020000 plus the FreeBSD errno. The equeue and
direct memory constants used an unrelated 0x8001xxxx range with mismatched
errno values (e.g. ETIMEDOUT was 0x80010023), so a guest checking
sceKernelWaitEqueue for SCE_KERNEL_ERROR_ETIMEDOUT saw an unexpected error.
SCE_KERNEL_ERROR_EDEADLK in Mutex.cpp held the EAGAIN value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 13:27:23 +07:00
QDarkRexandClaude Opus 5.5 97cae1458e fix(kernel): use SCE kernel error codes in equeue, direct memory and mutex
SCE kernel errors are 0x80020000 plus the FreeBSD errno. The equeue and
direct memory constants used an unrelated 0x8001xxxx range with mismatched
errno values (e.g. ETIMEDOUT was 0x80010023), so a guest checking
sceKernelWaitEqueue for SCE_KERNEL_ERROR_ETIMEDOUT saw an unexpected error.
SCE_KERNEL_ERROR_EDEADLK in Mutex.cpp held the EAGAIN value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 13:22:01 +07:00
QDarkRexandClaude Opus 5.5 be127fd0f1 feat(kernel): implement sceKernelDeleteSema
Waiters are woken with SCE_KERNEL_ERROR_EACCES and the semaphore is freed
once they have left.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 12:38:59 +07:00
QDarkRexandClaude Opus 5.5 15b749c2ba fix(kernel): return 64-bit offsets from sceKernelLseek
The SCE ABI returns off_t; offsets above INT_MAX threw instead of being returned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 12:38:59 +07:00
QDarkRexandClaude Opus 5.5 76b7f998f5 fix(kernel): give every thread a pthread handle and keep mutex ownership consistent
- scePthreadSelf returned null on Linux and for threads not created by
  scePthreadCreate (including the main thread); such threads now get a
  lazily adopted, non-joinable handle
- scePthreadExit on Linux skipped FinishThread, losing the join value
- detached threads on Linux were never freed; use the reference count
  already used on Windows
- unlocking a recursive mutex from a non-owner was undefined behaviour;
  return SCE_KERNEL_ERROR_EPERM
- scePthreadCondTimedwait did not restore the mutex owner after waking,
  so another thread locking during the wait made the waiter's unlock
  fail with EPERM and left the mutex locked forever
- SCE_KERNEL_ERROR_ETIMEDOUT in Cond.cpp was 0x80020062 instead of 0x8002003C

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 12:38:59 +07:00
ownerandClaude Sonnet 5 6e810feb50 docs: drop SPIR-V gate note from TechnicalDebt.md per maintainer feedback
Maintainer noted the opt-in-via-documented-flag SPIR-V validation gap
isn't the silent-stub category this doc tracks; the README correction
stands on its own.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-26 23:30:21 -06:00
QDarkRexandClaude Opus 5.5 908befe81d feat(relinker): add --windows-gui to emit a GUI subsystem executable
Generated executables always used the console subsystem and opened a
console window on launch. The opt-in flag writes IMAGE_SUBSYSTEM_WINDOWS_GUI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 12:24:15 +07:00
QDarkRexandClaude Opus 5.5 7ac1198e74 fix(audioout): reject zero sample count and frequency in sceAudioOutOpen
A zero frequency was stored and later used as a divisor when computing
the output block duration. Return SCE_AUDIO_OUT_ERROR_INVALID_SIZE and
SCE_AUDIO_OUT_ERROR_INVALID_SAMPLE_FREQ instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 12:24:15 +07:00
QDarkRexandClaude Opus 5.5 f8485ce6a6 fix(relinker): return unpacked exit status and wait for a single Enter in autorun
std::system returns a wait status on POSIX, so returning it from main
truncated a guest exit code of 1 (status 256) to 0. The prompt also
required pressing Enter twice because cin.get followed cin.ignore.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 12:24:14 +07:00
devilismyfriendandClaude Fable 5.1 29b4601564 perf(agc): dispatch and draw recipes, data-only cache hits, unit shadows, bindless image tables
Dispatch cache with per-key value variants and data-only hits (flat-SRT leaves the recompiler
proves pure are refreshed into the resource template instead of re-captured), dispatch and draw
recipes replaying a proven prepare, register-keyed draw entries, template data refresh, unit
shadows in device-local slabs, 64 KiB block-unit storage tracking with windowed detile, DCC
clear-key proofs, per-class GPU timing, a CPU copy path with batch read tracking, present slot
ring, rate-limited reaps and lazy completion counting, plan-failure and poisoned source memos,
bindless image tables (runtime-indexed descriptor arrays from a CPU-read table) so the
per-frame compute program that failed its plan now compiles. Worker affinity opt-in, per-draw
logs behind APS5_TRACE_DRAWS, wait-timeout reports include the recorder's view of the label.
Fixes a use-after-free behind BDA-miss dispatch snapshots and the CPU-write stamp of
UnchangedSinceCollected. Intro-video stage: 154 -> ~500 presents per 10 s at 4K.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-26 19:00:40 -07:00
devilismyfriendandClaude Fable 5.1 01c4e3edf7 feat(relinker): --to-intel lowers SSE4a sites to same-length jumps into an appended stub section
EXTRQ, INSERTQ, MOVNTSS and MOVNTSD are rewritten at relink time: same-length in-place forms
where they exist, otherwise a jmp rel32 into an appended executable section holding a
scratch-free SSE body and a jump back, so no code shifts and no RIP-relative or jump-table
operand needs adjusting. Decoder fixes for POPCNT and 0F BB (BTC), codegen and elfpatcher
tests, README and technical-debt notes. The runtime illegal-instruction trap stays as a
fallback.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-26 19:00:39 -07:00
devilismyfriendandClaude Fable 5.1 af3c2024ed feat(runtime): timed waits, sync primitive fixes, heap and RTC fixes, unattended-run switches
libkernel: a TimedWait service for condition variables, semaphores, event flags, rwlocks and
equeues with the scheduler tick; mutex/cond/sem corner cases the title hits; job worker
affinity is opt-in (APS5_JOB_AFFINITY). libc: calloc/realloc heap slot swap, a default
terminate handler with a backtrace, CPU topology helper. libSceRtc export fixes with tests.
libSceVideoOut: APS5_NO_PAD_INPUT ignores host input for unattended measurements,
APS5_FLIP_QUEUE_WAIT keeps a stalled process alive for a debugger. ApplicationHeap and
GuestRtc tests wired into the test build.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-26 19:00:39 -07:00
ownerandClaude Sonnet 5 f4ff3be07f test(agc): fix and re-enable 3 of 8 bitrotted AGC driver tests
These EXCLUDE_FROM_ALL targets weren't registered with add_test, so
they silently bitrotted with no CI/ctest visibility:

- agc_driver_graphics_tests: fixed a link failure (Draw.cpp, Pipeline.cpp
  and GraphicsPipelineCache.cpp were never added to the target's sources
  when the test started calling into them). Still fails at runtime against
  several stale assertions (a removed "not implemented" error message, a
  sampler fixture value that doesn't fit its bitfield) accumulated over
  many commits of not being built; left EXCLUDE_FROM_ALL pending an
  assertion-maintenance pass.
- agc_driver_recompiler_tests: root-caused (missing COMPUTE_NUM_THREAD_X
  register setup, plus a pass condition checking for a stub error message
  that no longer exists now that the real recompiler is implemented) but
  left unfixed and EXCLUDE_FROM_ALL — restoring its original intent needs
  a shader deliberately built to fail recompilation, a design decision.

agc_driver_tests, agc_shader_memory_tests, agc_driver_flip_tests and
agc_driver_pm4_tests already passed; registered them with add_test too
so none of the five can bitrot silently again.

agc_driver_bda_device_tests: dropped from this commit's scope. Upstream
PR #20 already proposes the same one-line BdaContracts.cpp fix (matching
the runtime message's "signature" text), so BdaContracts.cpp is left
untouched here to avoid duplicating that fix. The test target stays
defined (EXCLUDE_FROM_ALL, still buildable by name) but is no longer
registered with add_test until #20 or an equivalent fix lands.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-26 14:49:14 -06:00
ownerandClaude Sonnet 5 d3a1b89be3 test: wire up the orphaned exception runtime test
ExceptionRuntime.cpp existed complete and working but was never
registered in CMakeLists.txt, so it never built or ran. Wired it in
following the existing Guest*.cpp test pattern.

The other three orphaned test files (PthreadStart.cpp, FileStreams.cpp,
Formatting.cpp) were left out: each has genuine bitrot against current
code (a moved header, fseek returning errno instead of throwing on an
invalid whence, and vsnprintf's expected va_list mutation) that needs a
source-level decision, not a CMake wiring fix.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-26 14:36:33 -06:00
ownerandClaude Sonnet 5 156d4c5f46 docs: correct SPIR-V validation claim and a stale line citation
README stated SPIR-V is "successfully produces validated via Spirv-Tools"
unconditionally, but ANYPS5_ENABLE_SPIRV_TOOLS defaults OFF and the only
validation call is gated behind it, so this doesn't happen in a default
build. Caveated the README line and added the gap to TechnicalDebt.md's
silent-stubs list. Also fixed a stale line-number citation there (a prior
refactor moved the SpirvTargetOptions assignment block from row 219 to 212).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-26 14:13:53 -06:00
ownerandClaude Sonnet 5 63209b584f fix: correct sscanf %x signedness and avoid a substr copy
libSceSysmodule/Export.cpp parsed /proc/self/maps device major/minor
numbers into signed int with a %x format, which is undefined behaviour
per the C standard even though it happened to work on this target;
switched to unsigned int to match the format specifier.

NidPatcherUtils.hpp's StripNidPostfix built a truncated copy with
substr(0, n) where the prefix is already the string itself; resize(n)
does the same truncation without the extra allocation and copy.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-26 14:11:50 -06:00
ownerandClaude Sonnet 5 d01be2b0e9 fix(exceptions): alias uncaught_exception(s) to their purpose-built wrappers
Exports.cpp aliased the real std::uncaught_exception(s) mangled names
directly to __cxa_uncaught_exception(s)_nid_postfix instead of the
existing _ZSt18uncaught_exceptionv_nid_postfix/_ZSt19uncaught_exceptionsv_nid_postfix
wrappers, leaving the latter as dead code and breaking the file's own
bare-name -> matching-nid_postfix alias pattern (caught by fleet QA
review, no functional impact since it's a raw symbol alias and both
sides return in the same register).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-26 13:39:10 -06:00
ownerandClaude Sonnet 5 a4c519b262 fix(exceptions): interpose libstdc++ ABI on Linux so the project's own unwinder drives it
On native Linux these PRX shared libraries and their test executables
dynamically link real libstdc++/libgcc, so a plain throw went through the
system's __cxa_throw/_Unwind_RaiseException. That still invoked this
project's own __gxx_personality_v0_nid_postfix (the CIE's personality
pointer is a raw function address, agnostic to which unwinder is walking
the stack), but handed it libgcc's incompatible private _Unwind_Context
layout, corrupting every field Personality.cpp reads and aborting with no
exception message.

Fix: OwnPersonality() now recognises the bare __gxx_personality_v0 wrapper
on Linux too (previously Windows-only), and Exports.cpp exports the real
ABI names (__cxa_throw, __cxa_begin_catch/end_catch, __cxa_rethrow,
__cxa_allocate/free_exception, __cxa_call_terminate, __cxa_get_exception_ptr,
__cxa_current_exception_type, __cxa_init_primary_exception, the std::
terminate/uncaught_exception(s) mangled names, and the core _Unwind_*
entry points) via the existing GCC_GLOBAL_ALIAS assembler-alias mechanism,
so ELF symbol interposition makes this project's own implementation win
process-wide over libgcc_s.so.1/libstdc++.so.6. __cxa_init_primary_exception
is newly implemented; GCC 13's inline std::make_exception_ptr needs it and
nothing provided it before.

Fixes 7 previously-aborting tests: guest_rendering_wait, guest_buffer_reuse,
guest_shader_link, guest_system_exit_parameters, guest_once, guest_memory,
guest_search.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-26 13:39:10 -06:00
boykopovar 1a0ebbc849 Merge pull request #9 from Pacuka/feat/scertc
feat(rtc): implement libSceRtc date and tick functions
- Ticks count microseconds since 0001-01-01 00:00:00 in the proleptic Gregorian calendar, up to 9999-12-31 23:59:59.999999. `sceRtcGetTickResolution` returns 1000000.
- Validation (`sceRtcCheckValid`, `sceRtcIsLeapYear`, `sceRtcGetDayOfWeek`) returns the matching `SCE_RTC_ERROR_INVALID_*` code (`0x80B50002`–`0x80B5000E`).
- Conversions: `sceRtcGetTick`/`SetTick`, `GetTime_t`/`SetTime_t`, `GetWin32FileTime`/`SetWin32FileTime`.
- Current time: `sceRtcGetCurrentTick`, `GetCurrentClock`, `GetCurrentClockLocalTime`. `sceRtcGetCurrentNetworkTick` uses the host clock.
- UTC and local time conversion through the host time zone.
- `sceRtcFormatRFC3339` (`YYYY-MM-DDThh:mm:ss.cc` plus `Z` or `±hh:mm`) and `sceRtcParseRFC3339`.
- Tick arithmetic (`sceRtcTickAdd*`) rejects results outside the valid range with `SCE_RTC_ERROR_INVALID_VALUE`.
- New exports: `sceRtcGetDaysInMonth`, `sceRtcTickAddMonths` and `sceRtcTickAddYears`. The last two clamp the day to the end of the target month (2024-01-31 + 1 month = 2024-02-29).
2026-09-26 13:41:16 +03:00
boykopovar ae82942bcb Merge pull request #8 from Pacuka/feat/scerandom
feat(random): implement sceRandomGetRandomNumber
- Fill the buffer from `std::random_device`.
- Return `SCE_RANDOM_ERROR_INVALID` (`0x817C0016`) for a null buffer or a size above `SCE_RANDOM_MAX_SIZE` (64), matching the system library, and leave the buffer untouched in that case.
- Add a `guest_random` test that covers the invalid arguments, a zero size, partial-word sizes (no write past `size`), and two 64-byte draws that differ.
2026-09-26 13:34:23 +03:00
PacukaandClaude Opus 5.5 c0508a7f5f feat(rtc): implement libSceRtc date and tick functions
Ticks count microseconds since 0001-01-01 in the proleptic Gregorian
calendar, up to 9999-12-31 23:59:59.999999. Implement validation, tick
and date conversion, time_t and Win32 FILETIME conversion, UTC and
local time conversion through the host time zone, RFC 3339 formatting
and parsing, and tick arithmetic. Add sceRtcGetDaysInMonth,
sceRtcTickAddMonths and sceRtcTickAddYears, which clamp the day to the
end of the target month.

The network clock uses the host clock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 12:21:23 +02:00
PacukaandClaude Opus 5.5 d1c25097e3 feat(random): implement sceRandomGetRandomNumber
Fill the buffer from std::random_device and reject a null buffer or a
size above SCE_RANDOM_MAX_SIZE (64) with SCE_RANDOM_ERROR_INVALID, as
the system library does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 12:14:46 +02:00
boykopovar fb5f582e52 Merge pull request #7 from Pacuka/fix/linux-runtime
fix: Linux build and runtime fixes found while booting a retail UE title
2026-09-26 13:04:53 +03:00
boykopovar 2f30b62a69 fix(relinker): use general pipeline after converting for --to-intel flag 2026-09-26 12:47:31 +03:00
PacukaandClaude Opus 5.5 37074ab893 fix(build): link guest library tests dynamically on Linux
Tests in core/libs link against the prx shared libraries, which the
global -static flag rejects on Linux ("attempted static link of dynamic
object"). Drop -static in that directory on non-Windows hosts while
keeping the static GCC runtime.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 11:15:16 +02:00
PacukaandClaude Opus 5.5 f9695c1069 fix(agc): accept the SDK default GDS range in sceAgcCbReleaseMem
The SDK's inline release wrapper passes gdsOffset 0 and gdsSize 1 for
every release, not only GDS ones. The packet ignores the range unless the
GDS data selector is used, so accept that default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 11:15:16 +02:00
PacukaandClaude Opus 5.5 b98257b75d fix(libc): register the main guest image on Linux
Guest mprotect calls on the executable's own segments failed with
"guest protection or unmap range is not registered" because only the
Windows build registered the main image. Register the PT_LOAD segments of
the main executable page by page, merging the protections of segments that
share a page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 11:15:16 +02:00
PacukaandClaude Opus 5.5 ca23f10612 fix(kernel): accept AMPR and ACP access bits in memory protections
Retail titles pass protections such as 0xC2 (CPU read/write plus the
0x40 and 0x80 device access bits). The device bits do not affect CPU
access and were rejected as unsupported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 11:15:16 +02:00
PacukaandClaude Opus 5.5 d15e93681f fix(kernel): map SCE protections to readable host pages
SCE_KERNEL_PROT_CPU_RW (0x02) and CPU_EXEC (0x04) include read access,
but were translated to write-only and execute-only host pages. GPU read
and write bits also need host access because the emulated GPU reads and
writes guest memory from the CPU. Write-only mappings made the AGC driver
reject guest data segments as unreadable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 11:15:16 +02:00
PacukaandClaude Opus 5.5 998605fe4e fix(libc): swap calloc and realloc slots of the malloc replacement table
SceLibcMallocReplace lists calloc before realloc (malloc, free, calloc,
realloc, memalign, reallocalign, posix_memalign, ...), as the table in
retail titles shows. realloc therefore called the application's calloc
with the old pointer as the element count, and calloc called realloc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 11:15:16 +02:00
PacukaandClaude Opus 5.5 a4273c10dc fix(videoout): drop __stdcall from the window procedure
GCC on Linux rejects the attribute, which breaks the libs build since the
F11 fullscreen change. It has no effect on x86-64 Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 11:15:16 +02:00
PacukaandClaude Opus 5.5 c6f2d98fdd fix(build): configure bundled SDL2 without static executable linking
Distributions without static X11 libraries (such as Arch-based ones) fail
SDL2's X11 feature checks because the global -static linker flag also
applies to its try_compile probes. Restore the flag after SDL2 is added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 11:15:16 +02:00
boykopovar 223777d3df docs(dev): add item about custom sce_module load to tech debt 2026-09-26 11:00:59 +03:00
boykopovar e4825fbdc2 Merge pull request #3 from SamG-Coder/main
Expand native PS5 homebrew compatibility and regression coverage
2026-09-26 09:54:21 +03:00
SamG-Coder a1dedc4a63 docs: move Yamagi investigation to pull request 2026-09-26 14:55:02 +10:00
SamG-Coder cf3c8081fd fix(build): make Python relinker tests optional 2026-09-26 14:55:02 +10:00
devilismyfriendandClaude Fable 5.1 d677f970b2 chore(gitignore): ignore build_tools/ secondary CMake tree
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-25 16:27:49 -07:00
devilismyfriendandClaude Fable 5.1 9c2a75601d feat(libs): agc packet builders, savedata memory, offline service stubs
- libSceAgc: SetIndexCount, SetBaseIndirectArgs, DispatchIndirect, wait
  and write-data patch functions, relaxed checks for what titles send,
  NOP fillers for LOD stats and wait-until-safe, NotImplemented stubs.
- libSceSaveData.native: short mount points, backup events, save-data
  memory slots.
- user/system service, store dialog, video-out flip modes and queue-full
  error, pad read, fibers, offline behaviour for network/NP modules, and
  new export-only modules Ampr, JpegEnc, Json2, MsgDialog.native,
  NpCppWebApi, NpUtility.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-25 16:27:49 -07:00
devilismyfriendandClaude Fable 5.1 91557ebade feat(audio): AudioOut2 SDL output queue, ATRAC9 decoder in libSceAjm.native
- AudioOut2: one SDL device per context; the hardware grain queue level
  is derived from the SDL queued bytes so the title's poll-and-push loop
  runs at real time; ports are mixed per push with 7.1 folded to stereo.
- libSceAjm.native: instance and batch APIs; ATRAC9 decoding with
  variable-size frames inside superframes, padding, gapless parameters
  and handle re-creation on re-initialisation.
- AudioOut v1: sceAudioOutOutput(handle, NULL) drains instead of
  throwing.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-25 16:27:49 -07:00
devilismyfriendandClaude Fable 5.1 8a69fefe13 perf(agc): batch GPU work in a recorder with host-imported guest memory
Replaces the synchronous per-command execution model, and with it the
upstream render-target, pipeline-cache, tile-buffer, batched-draw and
memory-ownership commits (5a280ce, 7ed5a0b, 46c799d, 598caac, 40df528),
whose files are removed.

- Recorder: one open command buffer per device; dispatches, resident
  draws, uploads, write-backs, labels, fills and copies record into it;
  timeline-semaphore serials let drains wait without the GPU mutex;
  completions run in order at reap.
- one worker thread per PM4 queue; labels and stores written by the GPU
  into the host import; GPU-side DISPATCH_INDIRECT; the buffer-fill
  kernel replaced by vkCmdFillBuffer; a dispatch cache validated by
  write watch; filler packets tolerated; rejected submissions dumped.
- guest memory: page-state cache, 64 KiB write generations, host imports
  with VK_EXT_external_memory_host, persistent mirrors of the executable
  image, GPU copies of misaligned sub-ranges.
- textures: shader-written images stay resident with deferred
  write-back (adjacent-generation rule for packed video planes), sampled
  views of storage images, DCC key handling, addrlib swizzle equations,
  bidirectional detiler.
- draws: MRT, more formats, dynamic viewport/scissor, cached pipelines,
  resident 64 KiB targets, draws recorded into the recorder.
- ShaderResources: two-stage build, descriptor and sampler caches, a
  content-keyed resource cache; presentation from the resident image.
- a label deferred behind a completion is no longer re-stored by the
  CPU at reap time unless a write-back overwrote it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-25 16:27:49 -07:00
devilismyfriendandClaude Fable 5.1 87911b3bb5 fix(recompiler): saveexec operand order, atomic-zero rewrite, cache keys
- s_*_saveexec reads its source before writing the old EXEC into the
  destination, so the aliased form (vcc, vcc) computes exec & vcc; the
  per-lane exec bit comes from the lane's own bit. Every Bink 2 decoder
  kernel uses that form; this was the video corruption.
- buffer atomics add/sub/or/xor with a zero operand become an atomic
  load or nothing.
- DescriptorBinding carries bufferWritten/bufferAtomic/imageWritten;
  results expose a variantId and share SPIR-V copy-on-write; source
  keys use a length plus 64-bit hash; captures can be reused.
- wave-LDS ordering barriers, v_movrels/v_movreld lowering, SMEM with a
  VCC base, f16 conversion opcode fix, a per-function SPIRV-Tools pass
  list, env-gated IR dumps and probes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-25 16:27:49 -07:00
devilismyfriendandClaude Fable 5.1 f3ac61000d feat(runtime): guest arena, kernel thread/sync/file APIs, crash hooks
- libc: reserve guest memory in one arena below the PS5 map limit with
  MEM_WRITE_WATCH (GuestArena) and a caching guest heap; the allocation
  registry gains a generation counter, an invalidator callback for the
  driver's page cache and a pin waiter for leased ranges. This replaces
  the fault-based GuestMemoryTracking/GuestMemoryBacking layer, whose
  files are removed.
- libkernel: mmap/mprotect/munmap on the arena, flexible memory budget,
  real sceKernelVirtualQuery; POSIX pthread layer, rwlocks, timed locks,
  TSD, event flags; 0.5 ms scheduler tick and high-resolution sleeps;
  TSC/clock/time functions; file APIs return SCE errno codes; the APR
  file-streaming API.
- libc: vectored crash reporter with backtraces for fatal exceptions,
  SIGABRT, UCRT invalid parameters and process exit; SSE4a EXTRQ/INSERTQ
  emulation for Intel hosts; %ls/%lc/%S/%C with the guest's 16-bit
  wchar_t; hand-written setjmp/longjmp for the guest jmp_buf; a path
  alias table for short save-data mount points; more string, stdio and
  math exports.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-25 16:27:49 -07:00
boykopovar 40df5282e6 perf(agc): track guest memory ownership + optimize gpu synchronization 2026-09-25 19:47:18 +03:00
boykopovar e392506e0a feat(pad): add enums + edit mapping 2026-09-25 16:59:23 +03:00
boykopovar 0b885c9a18 docs(md): add commits and images info to conventions 2026-09-25 15:08:10 +03:00
boykopovar 7133eebabf docs(code): add en code style conventions 2026-09-25 14:56:13 +03:00
boykopovar b163c938f3 docs(md): add technical debt description 2026-09-25 14:43:07 +03:00
boykopovar dde8fa53e6 chore(pad): update circle, cross, r1 input to pad mapping 2026-09-25 12:26:41 +03:00
boykopovar 598caac0ce perf(agc): batch draws and cache descriptors, samplers, and buffers 2026-09-25 11:40:03 +03:00
boykopovar 6b8e16b73e feat(video): fullsceen mode by f11 2026-09-25 11:18:58 +03:00
boykopovar 9453f47828 feat(video): open centered window at 60% of display size 2026-09-25 11:13:03 +03:00
boykopovar 11bee5527d fix(video): preserve client aspect ratio when resizing 2026-09-25 11:07:51 +03:00
boykopovar a7fb4cbf72 fix(video): recreate swapchain after window minimization 2026-09-25 10:49:46 +03:00
boykopovar 46c799da67 perf(agc): use device-local tile buffers and cache spir-v validation 2026-09-25 09:14:03 +03:00
boykopovar 7ed5a0beea perf(agc): optimize pipeline cache key construction 2026-09-25 08:25:59 +03:00
boykopovar 5a280ced87 perf(agc): keep render targets on gpu across acquire_mem 2026-09-25 08:22:43 +03:00
boykopovar c91eda8e9a Merge pull request #2 from SamG-Coder/fix/relinker-ctest-registration
fix(build): register relinker tests with CTest
This change:
Defines BUILD_TESTING with a default of OFF and enables testing at the root when requested.
Registers the Windows dependency diagnostics test and includes its executable in normal builds when testing is enabled.
Allows CTest to discover the existing strict NID filter test.
2026-09-25 07:07:04 +03:00
SamG-Coder f8abc659cb docs: remove homebrew testing guide 2026-09-25 12:06:16 +10:00
SamG-Coder 51ab46d418 docs: remove homebrew testing guide 2026-09-25 12:06:10 +10:00
SamG-Coder acd98478ca docs: keep homebrew guide limited to instructions and links 2026-09-25 12:04:41 +10:00
SamG-Coder 24cb69f2a8 docs: keep homebrew guide limited to instructions and links 2026-09-25 12:04:26 +10:00
SamG-Coder 5a2790c93e style(libc): remove trailing blank line in process exports 2026-09-25 07:27:07 +10:00
SamG-Coder f37fffdacd feat(libc): expose guest vsprintf formatting 2026-09-25 07:26:06 +10:00
SamG-Coder 6cdf4a5be1 feat(libc): implement binary search with guest comparator ABI 2026-09-25 07:24:17 +10:00
SamG-Coder 473a4f8d1c fix(agc): preserve strict shader linkage failures 2026-09-25 07:22:06 +10:00
SamG-Coder 322dc24c9e feat(kernel): implement guest once initialization 2026-09-25 07:22:05 +10:00
SamG-Coder 95dc22c173 feat(agc): execute rendering waits against buffer reuse fences 2026-09-25 07:16:55 +10:00
SamG-Coder cca00c13ab feat(video): track ordered buffer reuse reservations 2026-09-25 07:13:15 +10:00
SamG-Coder 2187436d0d feat(agc): expose legacy register defaults entry point 2026-09-25 07:10:15 +10:00
SamG-Coder 2d8ec800c3 Merge remote-tracking branch 'upstream/main' 2026-09-25 07:08:17 +10:00
SamG-Coder d6f23df679 feat(agc): compose basic shader linkage register blocks 2026-09-25 07:08:10 +10:00
SamG-Coder 18ce03cba2 feat(libc): implement immediate guest process exit 2026-09-25 07:05:07 +10:00
SamG-Coder dd0debe967 feat(libc): reopen guest streams while preserving identity 2026-09-25 07:05:07 +10:00
boykopovar 05c8146744 refactor(pad): libScePad files structure refactor 2026-09-25 00:04:19 +03:00
SamG-Coder 2920c7f04c feat(system): handle console exit through runtime shutdown 2026-09-25 07:02:37 +10:00
SamG-Coder 79edb20f17 fix(libc): preserve 64-bit guest stream offsets 2026-09-25 07:00:45 +10:00
boykopovar ce287648bf feat(pad): add read input state logic to libScePad 2026-09-24 23:59:12 +03:00
SamG-Coder 39b81364b7 feat(libc): add C-locale character APIs and guest basename 2026-09-25 06:58:41 +10:00
SamG-Coder 7d07187ac8 feat(libc): add floating-point string conversions 2026-09-25 06:55:31 +10:00
SamG-Coder c7d26dda5e feat(libc): add missing guest math exports and 64-bit rounding 2026-09-25 06:54:49 +10:00
SamG-Coder 730afc79f8 feat(libc): add independent guest strtok state 2026-09-25 06:52:05 +10:00
SamG-Coder 1b45b0fe68 feat(libc): track guest working directory and resolve relative paths 2026-09-25 06:51:37 +10:00
SamG-Coder 453fec28c5 feat(kernel): add tracked dynamic module loading and NID lookup 2026-09-25 06:48:50 +10:00
SamG-Coder 91bf8e3a7a feat(libc): implement guest file removal and renaming 2026-09-25 06:45:30 +10:00
SamG-Coder 5301f89092 feat(libc): translate guest directory enumeration 2026-09-25 06:41:55 +10:00
SamG-Coder 18790691bd feat(libc): implement guest environment variable storage 2026-09-25 06:39:14 +10:00
SamG-Coder f49cace1ca feat(libc): implement guest formatted stream output 2026-09-25 06:35:32 +10:00
SamG-Coder b8c1097db4 feat(kernel): support socket nonblocking flags through fcntl 2026-09-25 06:34:30 +10:00
SamG-Coder e8ecb29170 feat(libc): expose guest standard streams and character IO 2026-09-25 06:30:30 +10:00
SamG-Coder 56c7a589db feat(kernel): bridge guest signal registration and delivery 2026-09-25 06:27:11 +10:00
SamG-Coder cbd22dd854 feat(kernel): implement guest system configuration queries 2026-09-25 06:25:16 +10:00
SamG-Coder 9cbefb7e04 feat(kernel): implement tracked UDP sockets and ioctl 2026-09-25 06:23:44 +10:00
SamG-Coder b42c33ca6c docs: record error and address conversion compatibility 2026-09-25 06:18:52 +10:00
SamG-Coder ff725218cb feat(kernel): translate guest IP address conversion APIs 2026-09-25 06:18:32 +10:00
SamG-Coder 97e6ce992b feat(libc): implement guest errno message APIs 2026-09-25 06:17:18 +10:00
SamG-Coder cbf8362251 feat(posix): translate guest address resolution APIs 2026-09-25 06:15:32 +10:00
SamG-Coder dec5841b2d feat(libc): implement caller-backed mspace heaps 2026-09-25 06:10:50 +10:00
SamG-Coder 8a4cc838e0 Merge remote-tracking branch 'upstream/main' into feat/homebrew-game 2026-09-25 06:06:31 +10:00
SamG-Coder 1bbdf7daa6 feat(kernel): support private anonymous guest memory mappings 2026-09-25 06:06:31 +10:00
SamG-Coder 9cc8f872cc docs: update Quake II import audit and startup progress 2026-09-25 06:00:07 +10:00
SamG-Coder f146a3d069 fix(windows): expose shared libc for internal runtime imports 2026-09-25 06:00:07 +10:00
SamG-Coder 6ba24a895c feat(libs): implement homebrew string compatibility functions 2026-09-25 05:59:07 +10:00
boykopovar 9a4c8eab8b fix(libc): update locale signatures + add sysv abi to math funcs 2026-09-24 22:57:49 +03:00
SamG-Coder 17ed098605 docs: record native Yamagi Quake II conversion and startup 2026-09-25 05:53:32 +10:00
SamG-Coder eca52b4725 fix(relinker): accept unused empty ELF TLS segments 2026-09-25 05:53:32 +10:00
SamG-Coder 221086beb6 fix(relinker): support ELF images without PLT relocations 2026-09-25 05:32:49 +10:00
SamG-Coder 0968c32b72 fix(build): register relinker tests with CTest 2026-09-25 05:27:19 +10:00
boykopovar 2778c1e86e perf(agc): keep render targets on gpu across draws 2026-09-24 21:30:00 +03:00
boykopovar bf43995e8e feat(shader): implement enable cache field in recompile request 2026-09-24 20:59:34 +03:00
boykopovar e98d2163f4 refactor(log): remove extra logs + refactor timing logging 2026-09-24 20:35:59 +03:00
boykopovar 2539e9787f perf(agc): avoid guest memory uploads for rect-list fault buffers 2026-09-24 14:57:39 +03:00
boykopovar fa6d023b1b feat(agc): support rendertarget64kb shader textures 2026-09-24 11:18:35 +03:00
boykopovar c9a82af00c fix(libc): add guest-compatible c++ locale abi 2026-09-24 10:51:11 +03:00
boykopovar 594656581e feat(libs): add new std symbols + unused filter off by default 2026-09-24 10:28:33 +03:00
boykopovar fa27b50832 chore(relinker): unused filter level = 1 by default 2026-09-24 08:14:05 +03:00
boykopovar ad68f86df1 chore(docs): update readme status for unused filter1 bug 2026-09-24 08:13:03 +03:00
boykopovar d765867146 feat(libs): add new sceAgcDriver functions def 2026-09-24 08:00:36 +03:00
boykopovar f5bc2d7649 feat(libs): add new sceAgc functions def 2026-09-24 07:54:15 +03:00
boykopovar 9f2b41b9a1 fix(libc): route guest allocations through application heap 2026-09-24 06:53:12 +03:00
boykopovar 7ed9ef1e9b perf(agc): move color transfers to + gpu resources cache 2026-09-23 22:32:42 +03:00
boykopovar 630d918b4a feat(agc): add timing logs for path after recompling 2026-09-23 22:11:41 +03:00
boykopovar 10e4d5e469 perf(shader): make -ools validation and optimization optional 2026-09-23 21:48:51 +03:00
boykopovar 65c6214a68 fix(agc): validate rect-list addressing model + logs refactor 2026-09-23 21:26:21 +03:00
boykopovar 3da19adf3f refactor(video): use presentation without maintenance extensions 2026-09-23 20:10:01 +03:00
boykopovar f129f6cde5 fix(agc): accept valid hardware screen offset values 2026-09-23 16:22:20 +03:00
boykopovar 069ee78158 feat(shader): generate tessellation shaders for rect-list primitives 2026-09-23 16:13:33 +03:00
boykopovar e341cd1b30 feat(window): add fps and frame counter to window title 2026-09-23 15:30:13 +03:00
boykopovar 762b91df59 feat(libkernel): app metadata param.json parsing impl 2026-09-23 15:18:48 +03:00
boykopovar cf1953058b feat(libkernel): add app metadata reading module 2026-09-23 15:09:31 +03:00
boykopovar 282257fd98 feat(video): add resizable aspect-ratio-aware window 2026-09-23 14:27:47 +03:00
boykopovar b1722c06e3 fix(shader): avoid mixing ir block ids with metadata indices 2026-09-23 13:57:22 +03:00
boykopovar bbde0f4680 feat(agc): support tiled color target layout 2026-09-23 13:15:30 +03:00
boykopovar 2df58cf09c fix(kernel): support page-aligned mprotect for loaded images 2026-09-23 12:45:39 +03:00
boykopovar 0b3ffe47b0 fix(shader): distinguish descriptor resources by register 2026-09-23 12:20:33 +03:00
boykopovar 30987b6543 fix(agc): allow texture descriptor performance modulation 2026-09-23 11:49:36 +03:00
boykopovar 8cd216e9d7 fix(agc): remove raw buffer restriction and decode guest buffer descriptors 2026-09-23 11:44:46 +03:00
boykopovar ab7d9a180a fix(agc): fix texture detiler context lifetime 2026-09-23 11:17:53 +03:00
boykopovar 352408ca51 feat(shader): derive descriptor image shape from rdna resources 2026-09-23 11:13:12 +03:00
boykopovar b521e1f811 test(agc): add texture resource and detiling coverage 2026-09-23 10:57:27 +03:00
boykopovar fa09114296 feat(agc): add texture and sampler descriptor bindings 2026-09-23 09:40:06 +03:00
boykopovar 7a5f5da623 feat(agc): add guest sampler creation 2026-09-23 09:28:03 +03:00
boykopovar d617677967 feat(agc): add guest texture upload - gpu detiling 2026-09-23 09:09:08 +03:00
boykopovar 596830be3e feat(agc): add gpu texture detiling shader 2026-09-23 08:56:52 +03:00
boykopovar 81d9dfde54 feat(agc): add gpu-based texture detiling 2026-09-23 08:48:29 +03:00
boykopovar efa62f3546 feat(agc): implement texture tiling layout 2026-09-23 08:31:56 +03:00
boykopovar 0bb7f38510 feat(agc): texture format mapping and properties 2026-09-23 08:11:40 +03:00
boykopovar 1fd955711b feat(agc): implement guest sampler resource decoding 2026-09-23 08:06:06 +03:00
boykopovar 8e05ec2fa3 feat(agc): implement guest texture resource decoding 2026-09-23 08:00:22 +03:00
boykopovar f50946adf0 build(agc): wire agc texture support into cmake 2026-09-23 07:40:22 +03:00
boykopovar 5c7dc027ea feat(agc): add agc texture support definitions (wip) 2026-09-23 07:25:23 +03:00
boykopovar 77f44a1a8d refactor(agc): report unimplemented image/sampler resources 2026-09-22 21:51:35 +03:00
boykopovar bb27de6fac feat(shader): add fragmentShaderBarycentricEnabled flag to recompiler 2026-09-22 21:35:45 +03:00
boykopovar 4734f43c60 feat(agc): add ACQUIRE_MEM handling in agc driver 2026-09-22 20:35:15 +03:00
boykopovar 8fd65f2a25 add EVENT_WRITE support for CS/GS/PS_PARTIAL_FLUSH + relinker return exit code from autorun 2026-09-22 20:27:49 +03:00
boykopovar f7aaa2fb86 feat(agc): add DRAW_INDEX_AUTO handling impl 2026-09-22 20:07:09 +03:00
boykopovar bf7e41bb8b feat(agc): add new context state op impl 2026-09-22 19:44:17 +03:00
boykopovar 7fa0e0c469 fix(libc): add sort function manual impl for compare abi 2026-09-22 18:35:09 +03:00
boykopovar a43f73163d feat(libs): no patch already exported from libc.prx symbols 2026-09-22 18:21:08 +03:00
boykopovar e3a960e4d1 feat(libs): add sce pad read state default value 2026-09-22 12:08:56 +03:00
boykopovar 79c9aa587b feat(agc): add fragment shader barycentric support 2026-09-22 11:43:39 +03:00
boykopovar 5e3a13041c feat(agc): implement vertex attribute input and buffer binding 2026-09-22 11:34:54 +03:00
boykopovar 5b424406a5 fix(agc): enable float controls and validate subgroup capabilities 2026-09-22 11:23:58 +03:00
boykopovar 7e0adc69f5 fix(shader): add missing spirv float controls declarations 2026-09-22 11:01:33 +03:00
boykopovar 1da8521ffc feat(shader): add spirv validation and opt via spirv-tools 2026-09-22 10:43:54 +03:00
boykopovar 798e38f47e fix(shader): fix recompile request memory snapshot and descriptors 2026-09-22 10:19:48 +03:00
boykopovar adcf14179b chore(shader): plan builder return for void + ssa pass init value 2026-09-22 10:00:42 +03:00
boykopovar e7633a7f07 fix(shader): thread cb_color0_info swap into pixel input color component mapping 2026-09-22 09:28:46 +03:00
boykopovar eccabe52ec feat(shader): add EmitNative impl + EmitGlsl for recompiler 2026-09-22 09:10:10 +03:00
boykopovar f38c6cd7af feat(shader): implement checked BDA reads and GPU fault reporting 2026-09-21 19:26:09 +03:00
boykopovar 2b7eec45ac test(agc): cover partial guest mappings 2026-09-21 19:02:06 +03:00
boykopovar 3028c87491 feat(agc): add bda memory mapping and resource management (wip) 2026-09-21 18:54:06 +03:00
boykopovar 48d08397d9 fix(shader): fix build break from bda cache page bits field 2026-09-21 18:08:03 +03:00
boykopovar fbb8a36f65 feat(shader): add bda cache page bits field to spirv target 2026-09-21 14:33:19 +03:00
boykopovar 1490c0386c refactor(agc): unify shader resource bindings and push constants 2026-09-21 13:48:44 +03:00
boykopovar cc0d0b776c feat(shader): add recompiler resource materialization and binding pipeline 2026-09-21 13:16:32 +03:00
boykopovar ccb223f125 feat(shader): implement spirv buffer and shared memory instructions 2026-09-21 10:03:58 +03:00
boykopovar 7a9c58030f feat(shader): implement spirv memory addressing and load/store logic (wip) 2026-09-21 09:39:58 +03:00
boykopovar 132306a7d1 feat(shader): add spirv memory instructions definitions 2026-09-21 09:23:15 +03:00
boykopovar a37a5a6c74 feat(shader): add spirv module setup impl 2026-09-21 07:29:04 +03:00
boykopovar 206175c8be feat(shader): implement tessellation in spirv emitter 2026-09-21 07:03:36 +03:00
boykopovar 93fef6b0f4 feat(shader): implement spirv program requirements analysis 2026-09-21 06:53:19 +03:00
boykopovar cf507a3b89 feat(shader): implement spirv tessellation emission 2026-09-21 06:49:35 +03:00
boykopovar 2bef9d7961 feat(shader): implement spirv module shader io and program emission 2026-09-21 06:46:25 +03:00
boykopovar c4ace2027e feat(shader): add spirv emit funcs impl from spirv module emitter (wip) 2026-09-20 21:04:28 +03:00
boykopovar 266c197380 feat(shader): add spirv module funcs impl 2026-09-20 20:09:28 +03:00
boykopovar 342fd6f052 fix(shader): remove already impl funcs from spirv module emitter 2026-09-20 19:59:28 +03:00
boykopovar f0e6556aea fix(shader): add local helpers + fix names for spirv memory 2026-09-20 19:56:09 +03:00
boykopovar cb9ac6b183 feat(shader): add spirv memory emitter impl + refactor (wip) 2026-09-20 10:44:32 +03:00
boykopovar 05a07353b0 refactor(shader): split spirv memory emitter to module 2026-09-19 13:20:16 +03:00
boykopovar 221fd0bf8e refactor(shader): add var for return values + spirv img emitter fix 2026-09-19 09:49:43 +03:00
boykopovar d1dd4590fa feat(shader): spirv image emitter functions impl (wip) 2026-09-19 07:33:30 +03:00
boykopovar 3c06704751 chore(agc): add vulkan device logs 2026-09-19 07:02:48 +03:00
boykopovar 3da76b9b33 refactor(graphics): add new graphics pipeline log + remove redunant ones 2026-09-18 21:03:11 +03:00
boykopovar 8be7c9d191 feat(shader): add test shaders return + graphic pipeline logs 2026-09-18 20:38:26 +03:00
boykopovar 9393018d73 feat(shader): add spirv buffer format header 2026-09-18 19:54:11 +03:00
boykopovar c2fa4a1d9d feat(shader): add spirv flow emitting functions impl 2026-09-18 16:49:36 +03:00
boykopovar a0276c512a feat(shader): add spirv alu emitter impl 2026-09-18 16:46:01 +03:00
boykopovar 8d911c0b91 feat(shader): impl ir descriptor structures primitives 2026-09-18 16:01:27 +03:00
boykopovar b970ff0ae7 fix(shader): provide translate input info to shader info collector 2026-09-18 15:49:21 +03:00
boykopovar 97a97ab2e1 feat(shader): use embedded vertex fetch analyzer in recompiler 2026-09-18 14:52:45 +03:00
boykopovar 58b9e60d23 feat(shader): add recompile request serialization on fail 2026-09-18 14:37:08 +03:00
boykopovar 760d1f660e fix(shader): resource tracker dword 0: pc instruction in ex 2026-09-18 12:54:47 +03:00
boykopovar 95df53181c fix(shader): buffer resource dword 0 detailed exception in tracker 2026-09-18 12:52:03 +03:00
boykopovar 3326614308 feat(shader): impl ir metadata eq operators 2026-09-18 12:33:02 +03:00
boykopovar bb2ce84019 refactor(shader): refactor ir metadata types to separated headers 2026-09-18 12:28:41 +03:00
boykopovar 6f0ccde6ff feat(shader): add ssa building impl for recompiler 2026-09-18 12:09:32 +03:00
boykopovar 3400a2b6e5 feat(shader): add srt walker impl + refactor 2026-09-18 11:31:21 +03:00
boykopovar 3dc20758a5 feat(shader): shader info collector impl for recompiler 2026-09-18 07:00:30 +03:00
boykopovar a1255c527d feat(shader): resource materializer impl for recompiler 2026-09-18 06:46:24 +03:00
boykopovar b18bec2150 feat(shader): add resource tracker impl 2026-09-17 17:43:03 +03:00
boykopovar 00fd1c2990 feat(shader): add dst sel packing helper to ir metadata 2026-09-17 14:02:22 +03:00
boykopovar c941b73a5e feat(shader): add bitfield accessors to ShaderBufferResource 2026-09-17 13:59:57 +03:00
boykopovar 225de15e50 feat(shader): add rdna descriptor format table for buffer formats 2026-09-17 13:55:36 +03:00
boykopovar 569b3b4038 feat(shader): read lane eliminator impl 2026-09-17 13:29:32 +03:00
boykopovar 38fdbc2a55 feat(shader): constants folding + dead code eliminating 2026-09-17 12:45:10 +03:00
boykopovar 78d9ef7567 feat(shader): fix scalar-load component count metadata for LoadAddressU32 2026-09-17 12:18:53 +03:00
boykopovar a529827753 feat(shader): ir typed value method impl 2026-09-17 12:16:04 +03:00
boykopovar f7b5df1711 feat(shader): decode embedded vertex fetch metadata for vertex-family stages 2026-09-17 12:00:14 +03:00
boykopovar 50226e4260 feat(shader): impl agc-side register decode and translator input wiring 2026-09-17 11:02:58 +03:00
boykopovar 268ae10936 feat(shader): impl instruction translator entry point 2026-09-17 07:30:25 +03:00
boykopovar 0679fbce1b feat(shader): add translation operand primitives helpers 2026-09-17 06:55:15 +03:00
boykopovar a585f2454f refactor(shader): translation context helpers module 2026-09-16 18:42:19 +03:00
boykopovar 5ad0305def feat(shader): add embedded vertex fetch for translator impl 2026-09-16 15:32:13 +03:00
boykopovar 8a0b230d18 feat(shader): impl new memory instruction translator functions 2026-09-16 15:13:52 +03:00
boykopovar 79eb125a5d feat(shader): add image instructions translator 2026-09-16 14:59:35 +03:00
boykopovar 6ae8fcbb53 feat(shader): impl flat, buffer, dispatch memory instructions tr 2026-09-16 14:43:57 +03:00
boykopovar 5e44bb042d refactor(shader): refactor memory instructions translator organization 2026-09-16 14:12:21 +03:00
boykopovar 99c9f01e26 feat(shader): impl vector instructions translator 2026-09-16 14:00:16 +03:00
boykopovar 3efd37596d feat(shader): add integer and scalar instruction translation 2026-09-16 13:39:55 +03:00
boykopovar c6dcc8bf6b feat(shader): translate float instructions functions 2026-09-16 13:24:40 +03:00
boykopovar 713e2b9606 feat(shader): impl dispatch instruction functions for translator 2026-09-16 13:16:09 +03:00
boykopovar fbb8fcbf4e feat(shader): add translation convert instructions impl 2026-09-16 13:00:51 +03:00
boykopovar 393a41fa2c feat(shader): add attr and compare instructions translators 2026-09-16 10:32:38 +03:00
boykopovar 4b2fe93080 feat(agc): add standalone shader test for libSceAgcDriver 2026-09-16 07:43:05 +03:00
boykopovar 9c78d10044 fix(agc): support unrestricted vulkan depth range 2026-09-16 07:24:00 +03:00
boykopovar f0b13b6652 fix(agc): support negative depth range and inactive color targets 2026-09-16 07:21:13 +03:00
boykopovar 05ec432f75 fix(agc): non-homogeneous positions with all viewport transforms enabled 2026-09-16 07:11:00 +03:00
boykopovar f73834ce2f fix(agc): complete initial context state and tighten shader validation 2026-09-16 07:04:23 +03:00
boykopovar 74613f7e0f feat(agc): extend graphics compiler contract and add mesh and tessellation paths 2026-09-15 21:19:06 +03:00
boykopovar 215e3cbf48 fix(agc): fix missing register at DWORD 677 (wip) 2026-09-15 12:38:01 +03:00
boykopovar 77b96978c7 feat(agc-driver): add strict vulkan indexed draw pipeline 2026-09-15 12:28:25 +03:00
boykopovar 0cb9ad8d2b feat(shader): ir builder convertions impl 2026-09-15 12:00:21 +03:00
boykopovar e4490a0272 feat(shader): arithmetic + ext regs + logic impl for ir builder 2026-09-15 11:44:42 +03:00
boykopovar 039b88b08e refactor(shader): refactor ir builder to separated module + som getters impl 2026-09-15 11:36:41 +03:00
boykopovar 5c8af9032b feat(shader): intermediate repr program impl 2026-09-15 10:59:28 +03:00
boykopovar 1589308466 feat(shader): add intermediate representation opcode impl 2026-09-15 10:37:56 +03:00
boykopovar af5a8c6235 feat(shader): add itermediate primitives impl 2026-09-15 10:24:34 +03:00
boykopovar af2ff821c4 feat(shader): shader control flow structurizer impl 2026-09-15 10:01:58 +03:00
boykopovar a6be72421e feat(shader): control flow graph impl 2026-09-15 09:18:06 +03:00
boykopovar 075e74b2c1 feat(shader): graph builder impl + rdna scalar op decoder adaptation 2026-09-15 09:03:46 +03:00
boykopovar 91f9dabea9 feat(shader): rdna instruction decoder impl 2026-09-15 08:17:31 +03:00
boykopovar 382384c5b7 feat(shader): rdna opcodes categorizing impl 2026-09-15 07:53:30 +03:00
boykopovar 16ce021b28 feat(shader): rdna vector op decoder impl 2026-09-15 07:41:44 +03:00
boykopovar 1867d649ff feat(shader): rdna scalar op decoder impl 2026-09-15 07:20:59 +03:00
boykopovar d084eed394 feat(shader): rdna memory op decoder impl 2026-09-15 07:07:50 +03:00
boykopovar 59fc5a5953 feat(shader): rdna image op decoder impl 2026-09-14 18:08:58 +03:00
boykopovar 9a6a19d1ac feat(shader): update translation defenitions 2026-09-14 18:03:44 +03:00
boykopovar 1cb380a110 feat(shader): update spirv backend definitions 2026-09-14 17:57:22 +03:00
boykopovar 86759f5c11 feat(shader): update optimization signatures 2026-09-14 16:56:29 +03:00
boykopovar de6588dd60 feat(shader) update ntermediateepresentation metadata and signatures 2026-09-14 16:41:50 +03:00
boykopovar e9be69c247 feat(shader): update control flow signatures 2026-09-14 16:33:21 +03:00
boykopovar f4a591a74c feat(shader): update rdna decoder signatures 2026-09-14 16:29:54 +03:00
boykopovar fc8b2e9e52 feat(shader): add new fields for rdna img op decoder 2026-09-14 16:07:04 +03:00
boykopovar 6da6ebad97 feat(shader): rdna export op decoder impl 2026-09-14 16:02:29 +03:00
boykopovar 6e9ad53bd5 feat(shaders): add shader recomp structure 2026-09-14 13:37:17 +03:00
boykopovar fd5e236aad feat(videoOut): add tiled buffer presentation and flip lifecycle handling 2026-09-14 12:38:16 +03:00
boykopovar b9cc7ffd85 feat(agcDriver): add draw handling and shader recompile preparation 2026-09-14 12:06:35 +03:00
boykopovar 699df8d5fa feat(agcDriver): add 54 PM4 execution and indirect dispatch support 2026-09-14 11:43:13 +03:00
boykopovar 990ae6a0ff feat(agcDriver): add opcode 18 handling as clearing 2026-09-14 11:18:21 +03:00
boykopovar 9f8225aa6d chore(libc): log only name for sibling file in fopen 2026-09-14 11:06:21 +03:00
boykopovar b0b1902b0f chore(libc): make file open slash preferred for system 2026-09-14 10:56:33 +03:00
boykopovar 1e4740ed4b fix(nid): no patch sdl exports for nid 2026-09-14 10:52:04 +03:00
boykopovar b11759bb13 chore(readme): update readme for main func reaching 2026-09-14 07:43:51 +03:00
boykopovar d31e35e1ab feat(agc): add flip presentation and suspend synchronization (wip) 2026-09-14 07:39:38 +03:00
boykopovar b024001a4a fix(libc): fix sprintf_nid_postfix register for linux 2026-09-14 07:23:23 +03:00
boykopovar ed171b23da feat(agc): add driver submission queue and vulkan compute path 2026-09-14 06:37:19 +03:00
boykopovar 87b52a99c8 feat(agc): add sceAgcGetDataPacketPayloadAddressUnk impl 2026-09-13 19:46:30 +03:00
boykopovar bed94ee90a fix(agc): add nullptr values handling for WriteRegisterRange 2026-09-13 19:41:29 +03:00
boykopovar bd0969c3a4 fix(libs): ex from libc prx: unwind for catch fix (mingw) 2026-09-13 19:21:31 +03:00
boykopovar bdff4874de feat(agc): add draw packets and register defaults with strict validation 2026-09-13 18:14:51 +03:00
boykopovar 8e95b27583 chore(cmake): add cmake option -DAPS5_AGC_CREATE_LOG 2026-09-13 17:44:17 +03:00
boykopovar 7e5f41aba3 feat(cli): add --windows-diagnostics arg - off by default 2026-09-13 17:21:13 +03:00
boykopovar 04e1bc0a2d refactor(codegen): separated x86 assembler 2026-09-13 17:04:02 +03:00
boykopovar 5d715ee549 refactor(libkernel): move from Export.cpp to separated files 2026-09-13 16:41:04 +03:00
boykopovar 8f2bca5481 refactor(libkernel): merged dup pthread functions from _sys and _web 2026-09-13 16:24:42 +03:00
boykopovar 1468fc7d6c refactor(libs): remove function dups from libSceAgcVsh 2026-09-13 15:17:07 +03:00
boykopovar 4863c251f1 refactor(AgcDriver): add subdirs to libSceAgcDriver + separated new src 2026-09-13 15:09:19 +03:00
boykopovar 888abd280f refactor(libSceAgc): add subdirs + new separated src 2026-09-13 15:06:31 +03:00
boykopovar 114c11aa88 feat(libSceAgc): implement command packet functions 2026-09-13 14:34:15 +03:00
boykopovar 7773bbcbf8 chore(sceVideoOut): throw ex instead of stubs 2026-09-13 13:52:41 +03:00
boykopovar 78f183ced8 feat(core): add and link to Agc not implemented shader recompilier 2026-09-13 13:47:13 +03:00
boykopovar fcb0764473 refactor(libs): organize libSceAgcDriver with cmakelists 2026-09-13 13:29:19 +03:00
boykopovar 7c44d13b3a feat(libs): global shared path resolver in libc 2026-09-13 12:45:50 +03:00
boykopovar f66a8fc5c4 feat(libkernel): libkernel file functions impl 2026-09-13 12:07:47 +03:00
boykopovar f19a234f38 feat(libkernel): add gettime getres gettimeofday impl 2026-09-13 11:21:37 +03:00
boykopovar 4781694512 feat(libs): NpTrophy2 impl + fopen not found logic update 2026-09-13 11:01:59 +03:00
boykopovar 0c2cfe0564 feat(NpTrophy2): add user data constants 2026-09-13 10:35:37 +03:00
boykopovar 42e1bad3d2 refactor(libs): move NpTrophy2 types from global SceTypes to libSceNpTrophy2 2026-09-13 10:30:13 +03:00
boykopovar 7d40561780 refactor(libs): organize NpTrophy2 with cmakelists 2026-09-13 10:19:56 +03:00
boykopovar 55df975d3b chore(readme): update readme for current status with npTrophy2 2026-09-12 19:56:43 +03:00
boykopovar 94ab47a417 feat(libkernel): some semaphore functions impl 2026-09-12 19:27:53 +03:00
boykopovar e38f76a823 refactor(libkernel): move some functions from export.cpp to new semaphore and file 2026-09-12 19:05:39 +03:00
boykopovar 8cd754c751 feat(libs) libSceNpGameIntent impl + refactor NpUniversalDataSystem 2026-09-12 18:53:36 +03:00
boykopovar 67996b7a69 feat(libs): libSceNpUniversalDataSystem functions impl (no net) 2026-09-12 18:29:57 +03:00
boykopovar 357d7fa373 refactor(libs): organize sceNpUniversalData with cmakelists 2026-09-12 18:12:18 +03:00
boykopovar b4db9fdd69 chore(sceSysmodule): log unknown module id loading 2026-09-12 18:00:34 +03:00
boykopovar d225df7449 feat(sceVideoOut): implement sdl2 window and present thread 2026-09-12 17:32:24 +03:00
boykopovar 49e200c88a feat(sceAudioOut): audio out init functions impl 2026-09-12 17:01:21 +03:00
boykopovar a7521f3a7e feat(libkernel): libkernel time functions impl 2026-09-12 16:33:29 +03:00
boykopovar 5d7bee9a1f refactor(libs): organize sceAuodioOut lib with cmakelists 2026-09-12 16:16:41 +03:00
boykopovar 37c8bafd13 fix(libkernel): fix export non-ps5 functions with extern c 2026-09-12 16:07:14 +03:00
boykopovar 9d7c255316 feat(windows): add import error chain diagnostic 2026-09-12 15:55:46 +03:00
boykopovar 31943e9a62 fix(sceVideoOut): add nid_postdfix to equeue libkernel exports 2026-09-12 11:21:01 +03:00
boykopovar 497821e94f feat(sceVideoOut): video out functions impl (wip) 2026-09-12 11:02:17 +03:00
boykopovar 69b8080ea4 feat(libkernel): add equeue functions impl 2026-09-12 10:40:27 +03:00
boykopovar bd16eaaacf refactor(libs): organize libSceVideoOut with cmakelists 2026-09-11 16:41:01 +03:00
boykopovar 792e0a1023 feat(repo): add git submodules to 3rdparty 2026-09-11 15:51:24 +03:00
boykopovar 4b643c6655 refactor(core): seprated folders for relinker and libs 2026-09-11 14:53:01 +03:00
boykopovar e9bbde1a6e refactor(libkernel): pthread functions separation 2026-09-11 14:12:44 +03:00
boykopovar 67b778055a refactor(libs): use local cmakelists in libc 2026-09-11 12:22:19 +03:00
boykopovar 2323a08de6 refactor(elfpatcher): move windows patcher headers to include 2026-09-11 10:05:54 +03:00
boykopovar 6c5afcce14 refactor(relinker): separate args parsing and autorun from main 2026-09-11 09:43:40 +03:00
boykopovar 08b1968b15 fix(libs): repack pe export names contiguously instead of edata no free space ex 2026-09-11 08:38:42 +03:00
boykopovar a1116fe948 feat(libc): windows way for ex handling (wip) 2026-09-11 08:17:12 +03:00
boykopovar ea3f7b5ae0 fix(windows): va_list sysv abi parse for fomatting functions 2026-09-11 07:49:14 +03:00
boykopovar e075f99757 chore(windows): loading prx info to stdout 2026-09-11 07:08:01 +03:00
boykopovar 999a723a5f fix(windows): precommit guest thread stacks to prevent guard page skips 2026-09-10 20:25:25 +03:00
boykopovar b765cefa42 fix(libs): fix args sysv abi for types (windows) 2026-09-10 19:54:03 +03:00
boykopovar d23e1ca84e feat(elfpatcher): build tls for fs access instructions (windows) 2026-09-10 18:34:54 +03:00
boykopovar 2a14912b65 feat(cli): relinker --lazy-binding flag 2026-09-10 14:57:27 +03:00
boykopovar c0c1ac4424 fix(libs): fix build sysv abi on mingw 2026-09-10 14:34:43 +03:00
boykopovar 36c29c9a66 feat(libs): sysv abi macros for windows exports 2026-09-10 13:30:05 +03:00
boykopovar 74de895ac0 feat(libs): add new libSceAgc unknown functions 2026-09-10 09:43:59 +03:00
boykopovar 8400150f80 feat(libs): add new declarations to libSceAgc 2026-09-10 09:09:08 +03:00
boykopovar 411a4d00a5 feat(libs): add change export name macros 2026-09-10 08:22:39 +03:00
boykopovar abc72da741 feat(libs): define vabi macros + add to declarations 2026-09-10 08:07:03 +03:00
boykopovar 5bf78ab8b4 feat(relinker): strict unused nids filtering mode 2026-09-09 19:29:25 +03:00
boykopovar 77cfe65b9c feat(relinker): unused nid filter fix + cli update 2026-09-09 18:17:10 +03:00
boykopovar febac8978e chore(relinker): protect .rela.plt + static jump_slot 2026-09-09 11:36:47 +03:00
boykopovar 3683c6e894 fix(codegen): classify FF 3 and FF 5 as indirect call instead of return 2026-09-09 10:18:32 +03:00
boykopovar 3b5ae707cd fix(relinker): exact opcode instead of any rip-relative disp in unused nid filter 2026-09-09 10:14:45 +03:00
boykopovar a81a1bf1b5 feat(relinker): upgrade unused import finder via graph 2026-09-09 09:56:52 +03:00
boykopovar e62c08f625 feat(libs): add new functions declarations 2026-09-09 09:12:30 +03:00
boykopovar 24620106c5 fix(nid): sort pe exports and preserve ordinal mappings 2026-09-09 08:46:43 +03:00
boykopovar af77abfa48 feat(relinker): detailed load prx logs for windows 2026-09-09 08:38:11 +03:00
boykopovar a369e0126c feat(libs): nid patching for non-std imports from prx 2026-09-09 08:12:27 +03:00
boykopovar 1078866097 chore(relinker): remove unused imports for windows pe 2026-09-08 18:28:51 +03:00
boykopovar 6af387172a fix(relinker): update elf to windows pe relinking 2026-09-08 18:24:03 +03:00
boykopovar 4f892eeb15 refactor(io): add new byte primitives for windows pe 2026-09-08 17:40:39 +03:00
boykopovar fce86b13b8 feat(relinker): add relinking to windows pe (wip) 2026-09-08 17:18:14 +03:00
boykopovar 81d7adea95 feat(log): log system detalization 2026-09-08 12:10:49 +03:00
boykopovar 13b30f93a9 feat(libSceAgc): libSceAgc shaderCreate impl 2026-09-08 11:16:02 +03:00
boykopovar 8730fa1e6e refactor(libSceAgc): create libSceAgc cmake project structure 2026-09-08 11:03:13 +03:00
boykopovar 814287ef47 feat(libs): libSce types impl + shaders refactor 2026-09-08 10:20:57 +03:00
boykopovar 7cf8576587 feat(build): all libs link libc + libkernel 2026-09-08 09:35:28 +03:00
boykopovar 6e8f04a65a feat(libkernel): cross platform libkernel build 2026-09-08 09:17:39 +03:00
boykopovar fca5dc8782 feat(libc): cross pltaform build 2026-09-08 09:08:00 +03:00
boykopovar fba8da58a2 chore(docs): update readme status for sceAgcCreateShader 2026-09-08 00:31:11 +03:00
boykopovar 07d1463ae1 fix(libkernel): replace throwing with return err code for invalid len 2026-09-08 00:16:56 +03:00
boykopovar 789699928a fix(relinker): gen r_x86_64_relative relocs for internal ptrs 2026-09-08 00:15:54 +03:00
boykopovar 8ad0a9897d feat(libs): libSceCommonDialog + stub libSceSaveDialog impl 2026-09-07 23:24:55 +03:00
boykopovar ce729fb9c7 fix(libkernel): fix random direct memory bug 2026-09-07 20:39:54 +03:00
boykopovar c5f82f0d5c chore(libc): add fopen error details 2026-09-07 20:06:51 +03:00
boykopovar fdd7049250 fix(libc): fix ftools exports 2026-09-07 19:54:01 +03:00
boykopovar 6c4d6c18b2 fix(libkernel): fix scePthreadCreate sync 2026-09-07 19:13:33 +03:00
boykopovar 5f7ef909f8 feat(libs): libcSceSaveData impl (wip) 2026-09-07 13:42:25 +03:00
boykopovar 96dd0e03dc chore(libs): skip monitor sensor check 2026-09-07 12:44:00 +03:00
boykopovar c3993df466 feat(libs): libScePad partial impl 2026-09-07 12:14:06 +03:00
boykopovar eb3af4e253 feat(libs): libSceuserService partial impl 2026-09-07 11:58:54 +03:00
boykopovar 73f0d15b63 feat(libs): add libSceSystemService impl 2026-09-07 11:53:43 +03:00
boykopovar 5ae2a810e9 feat(libult): add libsceult impl 2026-09-07 11:37:55 +03:00
boykopovar 7592031dc9 feat(libs): add windows branch for get sysmodule info 2026-09-07 11:21:44 +03:00
boykopovar 0bbf0923ef feat(sysmodule): add new modules mapping 2026-09-07 11:17:36 +03:00
boykopovar 14f8c16ac4 fix(libs): add _nid_no_patch_cut postfix and global cxa/unwind exports 2026-09-07 10:56:34 +03:00
boykopovar 1e0fc3f33a feat(libs): add libSysmodule impl 2026-09-07 10:55:32 +03:00
boykopovar bc14e4743c fix(relinker): map zero-flag ps5 load segments as rwx 2026-09-07 10:10:00 +03:00
boykopovar 9d4c87b686 fix(nid): fix updates detections for nid_patcher rerun 2026-09-07 09:55:41 +03:00
boykopovar d5bc6c9f66 refactor(libkernel): remove dup functions 2026-09-07 09:41:47 +03:00
boykopovar 975e4a72d4 refactor(libkernel): refactir direct memory exports organization 2026-09-07 09:08:59 +03:00
boykopovar e77d724a1b feat(libkernel): add pthread module impl(wip) 2026-09-07 08:50:31 +03:00
boykopovar e79f5ebc58 refactor(libkernel): separate direct memory impl 2026-09-07 08:08:31 +03:00
boykopovar 53b20aec77 refactor(nid): separate nid resolving logic 2026-09-07 07:52:09 +03:00
boykopovar 6ecfc35551 feat(libkernel): libkernel direct memory impl 2026-09-06 16:03:29 +03:00
boykopovar 72af167a9f fix(libc): add extern c for not impl helper header 2026-09-06 15:26:09 +03:00
boykopovar 8ac1af0513 fix(libc): no inline for not impl helper 2026-09-06 15:20:07 +03:00
boykopovar b000880913 chore(nid): restore skip nid_no_patch 2026-09-06 15:06:59 +03:00
boykopovar 6123893998 feat(libs): throw not impl ex in every stub 2026-09-06 15:05:04 +03:00
boykopovar 64ed717e77 fix(nid): no skip symbols without nid_postfix 2026-09-06 14:27:22 +03:00
boykopovar ec8faf3ed7 feat(libs): add general not implemented helper 2026-09-06 14:11:05 +03:00
boykopovar 58aef08fe1 feat(nid): add nid_no_patch rule 2026-09-06 13:49:24 +03:00
boykopovar e9f03cbf07 refactor(cli): cli simplification + remove auto output dir 2026-09-06 13:41:02 +03:00
boykopovar 228d95be52 feat(nid): check exported symbols dup 2026-09-06 13:30:17 +03:00
boykopovar ba6d7afc22 refactor(libc): __attribute__ replacing and removing 2026-09-06 13:02:22 +03:00
boykopovar c8391bfb67 refactor(libc): remove non-std link.h 2026-09-06 12:51:24 +03:00
boykopovar 4fd128a40d refactor(libc): remove strings.h linux specific 2026-09-06 12:45:37 +03:00
boykopovar 1752e1d78e refactor(libc): separate platform and compiler specifics in libc 2026-09-06 12:41:33 +03:00
boykopovar 7e61d94b30 feat(libc): print unhandled ex type and what() on terminate 2026-09-06 11:45:06 +03:00
boykopovar 12fb2e928b fix(entry): replace jmpt start with call start + ud2 in relinker 2026-09-06 07:47:22 +03:00
boykopovar baa8a8d9d3 feat(libc): add ex tests + remove bad_alloc dup 2026-09-06 07:30:59 +03:00
boykopovar 57aedfcff0 chore(libs): include exceptions to libc export 2026-09-05 22:32:29 +03:00
boykopovar f449ebb636 fix(libc): fix exception matching + foreign exception handling 2026-09-05 20:13:14 +03:00
boykopovar 36c874e296 feat(libc): implement exception unwinding + array cleanup 2026-09-05 19:54:11 +03:00
boykopovar 6fcbf1f829 feat(libc): init c++ exception runtime for x8664 linux (wip) 2026-09-05 19:34:15 +03:00
boykopovar 9ac0798c09 feat(libc): add new std functions 2026-09-05 19:13:39 +03:00
boykopovar 4945be96ef feat(libs): runtime std dynamic linking for libc 2026-09-05 18:57:58 +03:00
boykopovar 4f760dd6ff feat(libc): add new exception symbols 2026-08-30 14:24:43 +03:00
boykopovar 271a850022 fix(libs): link std lib only to libc prx 2026-08-24 20:47:53 +03:00
boykopovar e82abc96c4 fix(nid): remove jump_slot records filtering 2026-08-22 19:35:34 +03:00
boykopovar a5e09e7e16 feat(libs): add new sceAgcDriver and sceUserServiceTerminate stubs 2026-08-22 17:02:29 +03:00
boykopovar 24f78f57cc feat(libs): implement missing locale and mbstate stubs for libc 2026-08-22 16:50:55 +03:00
boykopovar c27c547810 feat(libs): add locale support funcs to libc 2026-08-22 16:34:48 +03:00
boykopovar 85e3047c04 feat(libs): add atexit and atomic functions to libc 2026-08-22 16:22:19 +03:00
boykopovar a89b9228f1 fix(libs): fix libc building on win 2026-08-22 16:16:11 +03:00
boykopovar 5a1d7525f9 feat(libs): libc impl (wip) 2026-08-22 16:00:29 +03:00
boykopovar efd845fcfd fix(patcher): skip broken needed-library recomputation causing empty dt_needed 2026-08-22 15:21:26 +03:00
boykopovar b1f51a3e4b feat(nid): remap dynamic needed offsets 2026-08-22 14:11:42 +03:00
boykopovar e838a2d9df fix(nid): rebuild ghu hash for patched nid 2026-08-22 11:47:41 +03:00
boykopovar 8672a5cc3d fix(libs): libc export flag name fix 2026-08-22 11:18:42 +03:00
boykopovar b49279e832 fix(nid): update nid computing algorithm 2026-08-22 10:39:19 +03:00
boykopovar 54e66624ec fix(libs): fix nid compute algorithm - no lib name 2026-08-21 17:19:22 +03:00
boykopovar f23cc495f4 fix(nid): rebuild dynstr instead of in-place patch to avoid suffix-merge corruption 2026-08-21 16:24:16 +03:00
boykopovar e2646635d0 feat(libs): add lib ime backend stub 2026-08-21 16:08:10 +03:00
boykopovar 39ebe6a054 feat(libs): add libc shared lib stub 2026-08-21 15:56:03 +03:00
boykopovar 6dfd5a9296 refactor(nid): rename spec cpp + move utils 2026-08-21 15:16:25 +03:00
boykopovar c6550929e9 refactor(nid): windows and linux pathing separating via interface 2026-08-21 15:00:55 +03:00
boykopovar 55a120e318 fix(nid): detect linker suffix-merged symbol names postfixes 2026-08-21 14:45:07 +03:00
boykopovar ca37e667f9 fix(nid): patch linux nid in place + detailed overflow msg 2026-08-21 14:13:58 +03:00
boykopovar 486bb51167 fix(nid): exclude undefined dynamic symbols from elf nid patching 2026-08-21 00:32:00 +03:00
boykopovar 8627076df5 fix(libs): drop std name collisions via nid postfix + remove custom entry point 2026-08-21 00:26:40 +03:00
boykopovar ca38455917 fix(nid): grow export names in place within existing section padding for pe and elf 2026-08-21 00:15:21 +03:00
boykopovar 47099897ac fix(libs): fix libscelibcinternal crt symbol conflict, stray macro in pthread_once, missing typedefs, unnamed params 2026-08-20 23:58:06 +03:00
boykopovar 59bee8d187 feat(libs): add libs function signatures 2026-08-20 23:18:16 +03:00
boykopovar aba18915ba fix(libs): fix nid patching after libs build 2026-08-20 17:32:00 +03:00
boykopovar 9e21a054e0 feat(libs): add rpx library build as libs target 2026-08-20 17:06:41 +03:00
boykopovar dd2481951d feat(elfpatcher): add dt_runpath libs/ support with configurable --rpath flag 2026-08-20 11:01:34 +03:00
boykopovar f786ea6576 fix(elfpatcher): use original dt pltgot vaddr 2026-08-20 09:41:34 +03:00
boykopovar 8236d4e1a2 fix(patcher): keep zero-vaddr code segment and fix stub entry vaddr 2026-08-19 15:40:57 +03:00
boykopovar f84e67f2b1 docs(readme): add current status block to md readme 2026-08-18 20:11:07 +03:00
boykopovar 4147ca1f4c fix(patcher): preserve offset alignment for extra block vaddr 2026-08-18 19:04:48 +03:00
boykopovar 201c4f1d44 fix(patcher): compute virtual addresses for extra block 2026-08-18 18:59:27 +03:00
boykopovar 948017d734 fix(relinker): add dt pltgot to .dynamic + append elf sym write 24 bytes 2026-08-12 13:46:47 +03:00
boykopovar b62ffe327d feat(code): show count of repalced instructions 2026-08-05 13:57:10 +03:00
boykopovar 8c44cf4a52 feat(cli): cli flag for amd to intel convertion 2026-08-05 13:30:03 +03:00
boykopovar c4e4b6112a feat(code): add spec amd instructions to intel convert infrastructure 2026-08-05 13:18:09 +03:00
boykopovar fca8b8d7eb fix(code): add extrq decoding 2026-08-05 12:41:18 +03:00
boykopovar 1cc102f593 fix(code): fix branch offset recalculation after code removal 2026-08-05 11:09:00 +03:00
boykopovar c3e7b4c14a fix(code): decode setcc, evex, x87, of38/3a, shld/shrd + fix c1/of a4 immediate size bugs 2026-08-05 10:49:02 +03:00
boykopovar ab78ae90e2 fix(code): support vex prefix and imul decoding 2026-08-04 23:16:33 +03:00
boykopovar aeb9adfb33 refactor(code): move decoder opcodes to constexpr in header 2026-08-04 22:32:04 +03:00
boykopovar c14c1467c0 feat(code): throw exception for invalid instruction 2026-08-04 22:27:12 +03:00
boykopovar 2ac8a96d70 feat(code): add instruction rewriter implementation 2026-08-04 22:16:55 +03:00
boykopovar 88fca26a28 refactor(scanner): move scanner from relinker to separated module 2026-08-04 15:28:10 +03:00
boykopovar 9c7570176f refactor(patcher): move magic numbers to headers constexpr 2026-08-04 14:51:08 +03:00
boykopovar 0a44083bbf refactor(patcher): separate linux and windows elf patchers 2026-08-04 14:29:32 +03:00
boykopovar 007ba188bb feat(relinker): simplify got address resolution + validate entry sizes 2026-08-04 13:54:16 +03:00
boykopovar be508d9647 fix(relinker): validate dt_os/dt dynamic tags 2026-08-04 13:35:52 +03:00
boykopovar 39ae562b51 feat(core): relocation tables from pt dynamic instead of hardcoded offset 2026-08-04 13:32:22 +03:00
boykopovar 7689e85d8f refactor(patcher): folders structure for elfpatcher + byte writing di 2026-08-04 10:26:33 +03:00
boykopovar 516f13c327 fix(patcher): verify header block fits before first pt load 2026-08-04 09:49:09 +03:00
boykopovar 49f855cd4b refactor(core): describe original program headers with pt phdr 2026-08-04 09:45:09 +03:00
boykopovar 4f9316d7d7 fix(core): add pt phdr for relocated program headers 2026-08-04 09:36:52 +03:00
boykopovar 0193d5f655 fix(patcher): fix segments for success gdb recognizing 2026-08-04 02:02:03 +03:00
boykopovar 0fe6ad11f4 refactor(core): remove extra targets and cmake lists 2026-08-04 01:24:23 +03:00
boykopovar 850eae37eb refactor(core): separate io from domain logic + di 2026-08-04 00:28:58 +03:00
boykopovar e451fde738 fix(patcher): skip pt note and null-page pt load headers 2026-08-03 23:28:43 +03:00
boykopovar b05f877e15 feat(patcher): gen pt interp + executable entry stub 2026-08-03 23:04:11 +03:00
boykopovar 5718f6931a fix(patcher): create pt load segment for dynamic block 2026-08-03 22:53:39 +03:00
boykopovar 6b6004d974 refactor(relinker): clean arch + remove pipelines from main.cpp 2026-08-03 22:36:29 +03:00
boykopovar a4e7d3028e feat(relink): save output linux elf after checking (wip) 2026-08-03 22:13:15 +03:00
boykopovar 6b3deed7e4 fix(scanner): fix false positive fail from naive byte scan for syscall(wip) 2026-08-03 21:38:06 +03:00
boykopovar fe600cb641 fix(header): support pt dynamic import resolution 2026-08-03 21:32:01 +03:00
boykopovar 340a321cbe fix(header): fix read section headers 2026-08-03 21:22:07 +03:00
boykopovar 4d8fc76ff7 refactor(core): add some nodiscard and const 2026-08-03 21:05:36 +03:00
boykopovar 2654c8eb4b fix(types): update type names to fix bug with gcc 2026-08-03 20:40:27 +03:00
boykopovar 8a7c7c4e0d feat(log): add call reg writer 2026-08-03 20:27:55 +03:00
boykopovar 657ada06b3 initial commit 2026-08-03 20:02:52 +03:00
1053 changed files with 150477 additions and 8536 deletions

No files matched your search

-49
View File
@@ -1,49 +0,0 @@
# .forker.yaml — per-fork configuration for Repo Forker.
#
# The upstream URL and its token are NOT set here. They are set in the Gitea UI:
# Settings -> Actions -> Variables & Secrets
# UPSTREAM_URL = https://github.com/owner/repo.git (any provider)
# UPSTREAM_TOKEN = <token that can read the upstream>
# This keeps secrets out of the repo. Everything below is non-secret.
#
# All values are optional; sensible defaults apply when a key is absent.
# (unused — Bearer auth needs no username; retained for compatibility)
token_user: oauth2
# Mirror all tags (true/false). Default: true
mirror_tags: true
# Prune branches that were deleted upstream (true/false). Default: true
mirror_prune: true
# Which upstream branches to mirror. "*" = all (default).
# Comma-separated list to restrict, e.g. "main,develop" (stray spaces
# tolerated). NOTE: pruning is always checked against the FULL upstream
# branch set, so a branch outside this filter but still upstream is never
# deleted.
mirror_branches: "*"
# When a new upstream tag is mirrored, automatically build + publish a release
# on this Gitea (true/false). Default: true
on_new_tag: true
# Also mirror the upstream's existing releases (metadata + assets) via the
# provider API (true/false). Default: false
mirror_upstream_releases: true
# Build commands run inside the tag's working tree to produce release assets.
# Multiple commands are ';'-separated. Leave empty to skip the local build and
# only mirror upstream release assets.
# build_cmd: "make && go build -o dist/app ."
build_cmd: ""
# Optional: point to a custom build script (path relative to the forker branch)
# instead of build_cmd. If set, build_cmd is ignored.
# build_script: "forker/build-custom.sh"
build_script: ""
# Artifacts to attach to the locally-built release. Space-separated globs,
# relative to the tag's working tree.
# artifacts: "dist/*"
artifacts: ""
-38
View File
@@ -1,38 +0,0 @@
name: Repo Forker — Release (build + publish)
# Produces a release on this Gitea fork. Two modes (see .forker.yaml):
# BUILD — checkout the tag's working tree, run the configured build command,
# publish the release (tag + assets) on this Gitea.
# MIRROR — mirror the upstream's existing release (metadata + assets).
#
# NOTE: this workflow is triggered MANUALLY from the UI (workflow_dispatch).
# Automatic releases on new tags are handled INLINE by sync.sh, because a
# mirrored tag points at an upstream commit whose tree has no .gitea/workflows,
# so a "push: tags" trigger would never find this file. See sync.sh.
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to release'
required: true
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run release
run: |
export GITEA_REPO="${GITEA_OWNER_REPO##*/}"
bash forker/release.sh "$TAG"
env:
GITEA_SERVER_URL: ${{ gitea.server_url }}
GITEA_OWNER: ${{ gitea.repository_owner }}
GITEA_OWNER_REPO: ${{ gitea.repository }}
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
UPSTREAM_URL: ${{ vars.UPSTREAM_URL }}
UPSTREAM_TOKEN: ${{ secrets.UPSTREAM_TOKEN }}
TAG: ${{ inputs.tag }}
-35
View File
@@ -1,35 +0,0 @@
name: Repo Forker — Runner check
# Verifies a runner is available for this repo before relying on the cron sync
# and local builds. Run it once after forking (or when a sync run is "pending"
# for a long time — that usually means no runner is registered for this repo).
#
# In this Gitea build, runners are repo-scoped: a runner registered on one repo
# does NOT serve another. Register a runner for this repo (see README, "Runner").
on:
workflow_dispatch: {}
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Confirm a runner picked this job up
run: |
echo "A runner is online and serving this job."
echo "OS=$RUNNER_OS Arch=$RUNNER_ARCH"
- name: Which runner(s) serve this repo
env:
GITEA_SERVER_URL: ${{ gitea.server_url }}
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
# The repo-level API does NOT list shared runners, so check the
# shared (instance) list too and report which serves the repo.
# (The Gitea Actions token has admin scope in this setup; with a
# plain repo token the admin call 403s and we say so, not hide it.)
curl -sS --max-time 20 -H "Authorization: Bearer $GITEA_TOKEN" \
"$GITEA_SERVER_URL/api/v1/repos/${GITEA_OWNER}/${GITEA_REPO}/actions/runners" > /tmp/repo_runners.json
curl -sS --max-time 20 -H "Authorization: Bearer $GITEA_TOKEN" \
"$GITEA_SERVER_URL/api/v1/admin/actions/runners?limit=50" > /tmp/shared_runners.json
python3 -c 'import json; R=json.load(open("/tmp/repo_runners.json")).get("runners",[]); S=[r for r in json.load(open("/tmp/shared_runners.json")).get("runners",[]) if r.get("shared")]; print("Repo-scoped runners: "+(", ".join("%s (%s)"%(r["name"],r["status"]) for r in R) or "(none)")); print("Shared runners: "+(", ".join("%s (%s)"%(r["name"],r["status"]) for r in S) or "(none)")); print("OK: a runner serves this repo." if (R or S) else "WARNING: no runner (repo-scoped or shared) registered - cron runs will stay queued.")'
-82
View File
@@ -1,82 +0,0 @@
name: Repo Forker — Sync (mirror upstream)
# Periodically mirrors the upstream repo (all branches, tags, full history) into
# this Gitea fork. This is the "worker" job.
#
# One-time setup (Gitea UI):
# Settings -> Actions -> Variables & Secrets
# UPSTREAM_URL = https://github.com/owner/repo.git (any provider)
# UPSTREAM_TOKEN = <secret: token that can read the upstream>
# GITEA_* values below are injected automatically by Gitea Actions.
on:
schedule:
# "very periodically" — every 10 minutes. Tune to taste (5-field cron).
- cron: '*/10 * * * *'
workflow_dispatch: {} # manual trigger from the UI
push:
branches: [forker] # re-sync when the forker config changes
jobs:
sync:
runs-on: ubuntu-latest
# A cold full-history fetch can exceed the 10-min cron interval (or a
# push/dispatch can land mid-run); without this, two overlapping runs
# both see the same tag as "missing release" and both build/publish —
# duplicate releases + double builds. Serialize per repo (do NOT
# cancel-in-progress: an in-flight sync must finish).
concurrency:
group: sync-${{ gitea.repository }}
steps:
# A repo without UPSTREAM_URL (e.g. the template itself) is not a mirror:
# skip the whole job with a notice instead of failing.
- name: Upstream configured?
id: check
env:
UPSTREAM_URL: ${{ vars.UPSTREAM_URL }}
run: |
if [ -z "$UPSTREAM_URL" ]; then
echo "::notice::UPSTREAM_URL is not set — this repo is not configured as a mirror (e.g. the template). No-op."
echo "configured=false" >> "$GITHUB_OUTPUT"
else
echo "configured=true" >> "$GITHUB_OUTPUT"
fi
- name: Checkout
if: steps.check.outputs.configured == 'true'
uses: actions/checkout@v4
- name: Restore mirror cache
if: steps.check.outputs.configured == 'true'
uses: actions/cache@v4
continue-on-error: true # no cache service configured? continue cold — still correct
with:
path: .mirror
# Unique per run so saves never conflict; restore-keys pulls the most
# recent saved mirror (incremental fetch). No cache → full fetch, still
# correct.
key: forker-mirror-${{ github.run_id }}
restore-keys: |
forker-mirror-
- name: Show config
if: steps.check.outputs.configured == 'true'
run: |
echo "UPSTREAM_URL=${UPSTREAM_URL:?set in Gitea UI (Variables & Secrets)}"
echo "Gitea repo: ${{ gitea.repository }}"
env:
UPSTREAM_URL: ${{ vars.UPSTREAM_URL }}
- name: Run sync
if: steps.check.outputs.configured == 'true'
run: |
# gitea.repository is "owner/repo"; extract just the repo name.
export GITEA_REPO="${GITEA_OWNER_REPO##*/}"
bash forker/sync.sh
env:
GITEA_SERVER_URL: ${{ gitea.server_url }}
GITEA_OWNER: ${{ gitea.repository_owner }}
GITEA_OWNER_REPO: ${{ gitea.repository }}
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
UPSTREAM_URL: ${{ vars.UPSTREAM_URL }}
UPSTREAM_TOKEN: ${{ secrets.UPSTREAM_TOKEN }}
+45
View File
@@ -0,0 +1,45 @@
relinker:
- changed-files:
- any-glob-to-any-file: 'core/relinker/**'
shader:
- changed-files:
- any-glob-to-any-file: 'core/shader/**'
agc:
- changed-files:
- any-glob-to-any-file: 'core/libs/prx/libSceAgc*/**'
libc:
- changed-files:
- any-glob-to-any-file: 'core/libs/prx/libc/**'
libkernel:
- changed-files:
- any-glob-to-any-file: 'core/libs/prx/libkernel/**'
prx:
- changed-files:
- all-globs-to-any-file:
- 'core/libs/prx/**'
- '!core/libs/prx/libSceAgc*/**'
- '!core/libs/prx/libc/**'
- '!core/libs/prx/libkernel/**'
build:
- changed-files:
- any-glob-to-any-file:
- '**/CMakeLists.txt'
- '**/*.cmake'
- '.gitmodules'
- '3rdparty/**'
docs:
- changed-files:
- any-glob-to-any-file:
- '**/*.md'
- 'docs/**'
ci:
- changed-files:
- any-glob-to-any-file: '.github/**'
+16
View File
@@ -0,0 +1,16 @@
### What
### Tested
<!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. -->
### Checklist
<!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/docs/CONTRIBUTING.md -->
- [ ] 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/CONVENTIONS.md)
- [ ] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/TechnicalDebt.md#silent-stubs)
- [ ] 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: <!-- #PR, or none -->
- [ ] AI-assisted: <!-- yes / no -->
+29
View File
@@ -0,0 +1,29 @@
name: Area labels
on:
schedule:
- cron: '30 * * * *'
workflow_dispatch:
permissions: {}
jobs:
label:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- id: prs
env:
GH_TOKEN: ${{ github.token }}
run: |
{
echo 'numbers<<EOF'
gh pr list -R "$GITHUB_REPOSITORY" --base "${{ github.event.repository.default_branch }}" -L 200 --json number --jq '.[].number'
echo EOF
} >> "$GITHUB_OUTPUT"
- if: steps.prs.outputs.numbers != ''
uses: actions/labeler@v7
with:
pr-number: ${{ steps.prs.outputs.numbers }}
+75
View File
@@ -0,0 +1,75 @@
name: Build
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
env:
CONFIGURE: >-
-G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON
-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
jobs:
linux:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v7
with:
submodules: true
- uses: hendrikmuhs/ccache-action@v1.2.24
with:
key: linux
save: ${{ github.event_name == 'push' }}
evict-old-files: job
- run: cmake -S . -B build $CONFIGURE
- run: cmake --build build
- run: cmake --build build --target libs
- run: ctest --test-dir build --output-on-failure --timeout 120
windows:
runs-on: windows-latest
timeout-minutes: 45
env:
WINLIBS_RELEASE: 15.2.0posix-14.0.0-ucrt-r7
WINLIBS_ZIP: winlibs-x86_64-posix-seh-gcc-15.2.0-mingw-w64ucrt-14.0.0-r7.zip
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v7
with:
submodules: true
- id: toolchain
uses: actions/cache@v6
with:
path: C:\winlibs
key: ${{ env.WINLIBS_ZIP }}
- if: steps.toolchain.outputs.cache-hit != 'true'
run: |
curl -sSfL -o "$RUNNER_TEMP/winlibs.zip" "https://github.com/brechtsanders/winlibs_mingw/releases/download/$WINLIBS_RELEASE/$WINLIBS_ZIP"
7z x "$RUNNER_TEMP/winlibs.zip" -oC:/winlibs > /dev/null
- run: echo 'C:\winlibs\mingw64\bin' >> "$GITHUB_PATH"
- uses: hendrikmuhs/ccache-action@v1.2.24
with:
key: windows
save: ${{ github.event_name == 'push' }}
evict-old-files: job
- shell: cmd
run: cmake -S . -B build %CONFIGURE%
- shell: cmd
run: cmake --build build
- shell: cmd
run: cmake --build build --target libs
- shell: cmd
run: ctest --test-dir build --output-on-failure --timeout 120
+21
View File
@@ -0,0 +1,21 @@
name: Conflict label
on:
push:
branches: [main]
schedule:
- cron: '0 * * * *'
workflow_dispatch:
permissions: {}
jobs:
label:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: eps1lon/actions-label-merge-conflict@v3
with:
dirtyLabel: needs rebase
repoToken: ${{ secrets.GITHUB_TOKEN }}
+42
View File
@@ -0,0 +1,42 @@
name: Progress comment
on:
workflow_run:
workflows: [Progress report]
types: [completed]
permissions:
actions: read
pull-requests: write
jobs:
comment:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v8
with:
name: progress-report
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
- env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RUN_SHA: ${{ github.event.workflow_run.head_sha }}
run: |
pr=$(cat pr)
[[ $pr =~ ^[0-9]+$ ]] || exit 1
[ "$(gh pr view "$pr" --json headRefOid --jq .headRefOid)" = "$RUN_SHA" ] || exit 0
marker='<!-- progress-report -->'
id=$(gh api "repos/$GH_REPO/issues/$pr/comments" --paginate \
--jq ".[] | select(.user.login == \"github-actions[bot]\" and (.body | startswith(\"$marker\"))) | .id" | head -n1)
if [ -f report.md ]; then
printf '%s\n%s' "$marker" "$(cat report.md)" > body.md
if [ -n "$id" ]; then
gh api -X PATCH "repos/$GH_REPO/issues/comments/$id" -F body=@body.md > /dev/null
else
gh pr comment "$pr" --body-file body.md
fi
elif [ -n "$id" ]; then
gh api -X DELETE "repos/$GH_REPO/issues/comments/$id"
fi
+34
View File
@@ -0,0 +1,34 @@
name: Progress report
on:
pull_request:
permissions:
contents: read
jobs:
report:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 2
- env:
PR: ${{ github.event.pull_request.number }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
out=$RUNNER_TEMP/out report=$RUNNER_TEMP/report
git worktree add --detach "$RUNNER_TEMP/base" HEAD^1
python3 tools/progress.py --root "$RUNNER_TEMP/base" "$out/base"
python3 tools/progress.py "$out/head"
mkdir "$report"
echo "$PR" > "$report/pr"
body=$(python3 tools/progress.py --compare "$out/base/progress.json" "$out/head/progress.json")
if [ -n "$body" ]; then
printf '### Progress report (%s → %s)\n\n%s\n' "$(git rev-parse --short HEAD^1)" "${HEAD_SHA::7}" "$body" > "$report/report.md"
cat "$report/report.md" >> "$GITHUB_STEP_SUMMARY"
fi
- uses: actions/upload-artifact@v7
with:
name: progress-report
path: ${{ runner.temp }}/report
+30
View File
@@ -0,0 +1,30 @@
name: Progress
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
progress:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v7
- run: python3 tools/progress.py out
- uses: actions/upload-pages-artifact@v5
with:
path: out
- id: deployment
uses: actions/deploy-pages@v5
+126
View File
@@ -0,0 +1,126 @@
name: Release
on:
push:
tags: ['v*']
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
env:
RELEASE_TAG: ${{ github.ref_name }}
CONFIGURE: >-
-G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON
-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
WINLIBS_RELEASE: 15.2.0posix-14.0.0-ucrt-r7
WINLIBS_ZIP: winlibs-x86_64-posix-seh-gcc-15.2.0-mingw-w64ucrt-14.0.0-r7.zip
jobs:
build:
name: Build and test (${{ matrix.platform }})
strategy:
fail-fast: true
matrix:
include:
- platform: linux
runner: ubuntu-latest
timeout: 30
- platform: windows
runner: windows-latest
timeout: 45
runs-on: ${{ matrix.runner }}
timeout-minutes: ${{ matrix.timeout }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v7
with:
submodules: true
- id: toolchain
if: matrix.platform == 'windows'
uses: actions/cache@v6
with:
path: C:\winlibs
key: ${{ env.WINLIBS_ZIP }}
- if: matrix.platform == 'windows' && steps.toolchain.outputs.cache-hit != 'true'
run: |
curl -sSfL -o "$RUNNER_TEMP/winlibs.zip" "https://github.com/brechtsanders/winlibs_mingw/releases/download/$WINLIBS_RELEASE/$WINLIBS_ZIP"
7z x "$RUNNER_TEMP/winlibs.zip" -oC:/winlibs
- if: matrix.platform == 'windows'
run: echo 'C:\winlibs\mingw64\bin' >> "$GITHUB_PATH"
- uses: hendrikmuhs/ccache-action@v1.2.24
with:
key: ${{ matrix.platform }}
save: false
- name: Configure Linux
if: matrix.platform == 'linux'
run: cmake -S . -B build $CONFIGURE
- name: Configure Windows
if: matrix.platform == 'windows'
shell: cmd
run: cmake -S . -B build %CONFIGURE%
- name: Build project and tests (Linux)
if: matrix.platform == 'linux'
run: cmake --build build
- name: Build project and tests (Windows)
if: matrix.platform == 'windows'
shell: cmd
run: cmake --build build
- name: Run tests (Linux)
if: matrix.platform == 'linux'
run: ctest --test-dir build --output-on-failure --timeout 120 --stop-on-failure --no-tests=error
- name: Run tests (Windows)
if: matrix.platform == 'windows'
shell: cmd
run: ctest --test-dir build --output-on-failure --timeout 120 --stop-on-failure --no-tests=error
- name: Build patched libraries (Linux)
if: matrix.platform == 'linux'
run: cmake --build build --target libs
- name: Build patched libraries (Windows)
if: matrix.platform == 'windows'
shell: cmd
run: cmake --build build --target libs
- name: Package release files
run: python tools/package_release.py --platform "${{ matrix.platform }}" --build build --output dist --version "$RELEASE_TAG"
- uses: actions/upload-artifact@v7
with:
name: release-${{ matrix.platform }}
path: dist/*
if-no-files-found: error
compression-level: 0
publish:
name: Publish release
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
pattern: release-*
merge-multiple: true
path: dist
- name: Check release files and collect documentation
shell: bash
run: |
for file in "prx-windows-$RELEASE_TAG.zip" "prx-windows-$RELEASE_TAG.tar.gz" "prx-linux-$RELEASE_TAG.zip" "prx-linux-$RELEASE_TAG.tar.gz" "relinker-$RELEASE_TAG.exe" "relinker-$RELEASE_TAG"; do
test -s "dist/$file"
done
python tools/package_release.py --docs docs/user --output dist
chmod +x "dist/relinker-$RELEASE_TAG"
- name: Create draft and upload files
run: gh release create "$RELEASE_TAG" dist/* --verify-tag --draft --title "$RELEASE_TAG" --generate-notes
- name: Publish complete release
run: gh release edit "$RELEASE_TAG" --draft=false
+106 -18
View File
@@ -1,23 +1,111 @@
# The bare mirror holds upstream objects; never commit it.
.mirror/
*.d
# Local runner config (contains tokens) — but KEEP runner/docker-compose.yml
# tracked, otherwise a fresh fork has no documented runner setup at all.
# (The runner/_svc_*.go files are untracked Gitea-source scratch snippets.)
runner/config/
runner/_svc_*.go
*.runner.conf
*.slo
*.lo
*.o
*.obj
*.gch
*.pch
*.ilk
*.pdb
*.so
*.so.*
*.dylib
*.dll
*.mod
*.smod
*.lai
*.la
*.a
*.lib
*.exe
*.out
*.app
_SaveData/
_sd/
build/
build_tools/
b/
Build/
build-*/
cmake-build-debug/
cmake-build-release/
cmake-build-*/
CMakeFiles/
CMakeCache.txt
cmake_install.cmake
Makefile
install_manifest.txt
compile_commands.json
vcpkg_installed/
Testing/
tests/sdf/
.cache/
sqlce_wasm.js
sqlce_wasm.wasm
emsdk/
build-wasm/
# OS / editor noise
.DS_Store
*.swp
.idea/
.vscode/
# stray binaries that are never part of this template
*.AppImage
*.appimage
.superdesign/
ui/node_modules/
ui/dist/
ui/*.log
.venv/
venv/
env/
ENV/
__pycache__/
*.pyo
*.pyd
*.egg
*.egg-info/
dist/
*.dwo
.pytest_cache/
coverage.xml
.coverage
htmlcov/
*.tmp
*.log
*.bak
*.swp
raw/
images/
sessions/
downloads/
*.tar.gz
*.zip
*.whl
*.env
*.sdf
*.bat
*.jpg
*.png
*.json
!demo/web/i18n/*.json
!/assets/*.jpg
!/assets/*.png
.DS_Store
Thumbs.db
cookies.txt
.env
.env.local
+24
View File
@@ -0,0 +1,24 @@
[submodule "3rdparty/SDL2"]
path = 3rdparty/SDL2
url = https://github.com/libsdl-org/SDL.git
[submodule "3rdparty/Vulkan-Headers"]
path = 3rdparty/Vulkan-Headers
url = https://github.com/KhronosGroup/Vulkan-Headers.git
[submodule "3rdparty/SPIRV-Headers"]
path = 3rdparty/SPIRV-Headers
url = https://github.com/KhronosGroup/SPIRV-Headers.git
[submodule "3rdparty/SPIRV-Tools"]
path = 3rdparty/SPIRV-Tools
url = https://github.com/KhronosGroup/SPIRV-Tools.git
[submodule "3rdparty/glslang"]
path = 3rdparty/glslang
url = https://github.com/KhronosGroup/glslang.git
[submodule "3rdparty/VulkanMemoryAllocator"]
path = 3rdparty/VulkanMemoryAllocator
url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
[submodule "3rdparty/LibAtrac9"]
path = 3rdparty/LibAtrac9
url = https://github.com/shadps4-emu/ext-LibAtrac9.git
[submodule "3rdparty/freetype"]
path = 3rdparty/freetype
url = https://github.com/freetype/freetype.git
Vendored Submodule
+1
Submodule 3rdparty/LibAtrac9 added at ec8899dadf.
Vendored Submodule
+1
Submodule 3rdparty/SDL2 added at 4b69833bc5.
Vendored Submodule
+1
Submodule 3rdparty/SPIRV-Headers added at 01e0577914.
Vendored Submodule
+1
Submodule 3rdparty/SPIRV-Tools added at 7f2d9ee926.
Vendored Submodule
+1
Submodule 3rdparty/Vulkan-Headers added at 2fa203425e.
Vendored Submodule
+1
Submodule 3rdparty/freetype added at 42608f77f2.
Vendored Submodule
+1
Submodule 3rdparty/glslang added at ba1640446f.
-151
View File
@@ -1,151 +0,0 @@
# AGENTS.md — how to operate Repo Forker
Instructions for AI agents (and humans) working on or with this repository.
## What this is
A **template**. Each fork/generation of it is a *live mirror* of one upstream
git repo on this Gitea: all branches, all tags, full history, plus releases
produced on the runner. The working tree (the `forker` branch) holds only the
machinery — the upstream's content never enters it.
```
This repo (template) → fork/generate per upstream (Lago/<upstream>)
├── forker branch ← scripts, config, workflows
├── .mirror/ ← bare mirror (gitignored)
└── refs ← upstream branches + tags
```
## Golden rules (non-negotiable)
1. **Never authenticate to upstreams with the operator's personal accounts or
stored credentials.** Public upstreams are fetched **anonymously**:
`sync.sh`/`release.sh` cut `GIT_CONFIG_GLOBAL`/`GIT_CONFIG_SYSTEM` and the
credential helper before any upstream git call, and add a Bearer header
**only** when `UPSTREAM_TOKEN` is explicitly set. Do not "simplify" this
away — a `credential.helper=store` entry must never be offered to
`git fetch`. Do not pass tokens from `~/.git-credentials` into the tool.
2. **An empty token must mean "no auth header", not "Bearer <empty>".**
GitHub rejects empty Bearer headers (401). All code paths (git
`extraHeader`, `provider.sh` curl calls) must branch on token presence.
3. **Secrets live in Gitea Actions Variables/Secrets, never in the repo.**
`UPSTREAM_URL` (variable) and `UPSTREAM_TOKEN` (secret, optional). The
`GITEA_*` values are injected by Gitea Actions automatically.
4. **Keep `.forker.yaml` flat** (`key: value`, no nesting) — `config.sh` is a
simple grep parser.
## How it runs
- **Cron** (`sync.yml`, every 10 min) → `forker/sync.sh`:
1. fetch all branches + tags + history into the bare `.mirror/` (incremental
when `actions/cache` restores it),
2. push refs onto this repo + prune what upstream deleted (fork state is
read via the Gitea **API**, not git state — works on cold mirrors),
3. for each **tag that has no release yet**, run `forker/release.sh <tag>`
inline (a tag-push can't trigger a workflow: the tag points at an upstream
commit whose tree has no `.gitea/workflows`). The "missing release" check
(not "new tag") makes a failed release retry on the next cron tick.
`release.sh` publishes only when there is actual content (build assets or
an existing upstream release) and fails loudly on a bad asset
download/upload — a partial release never masquerades as success.
4. `forker/check-unit.sh` — verifies the **Releases unit** is enabled
(self-heals via the units API when the build exposes it; otherwise
detects the 404 and prints the one-time UI fix).
- `release.sh` = local build (if `build_cmd`/`build_script` set) + optional
upstream-release mirror (metadata + assets via `forker/lib/provider.sh`).
Idempotent: an existing release is skipped, not duplicated.
- `runner-check.yml` — run once per repo to confirm a runner serves it.
**Runners are repo-scoped on this Gitea build**: a runner registered on one
repo does not serve another. Use a **shared** runner (or PATCH the runner
to `"shared":true` — the units/runners APIs are missing here, so UI/DB).
## Known Gitea-build quirks (verified on git.lago.dev, Gitea 28.1.0)
- **Forks are created without the Releases unit**
(`DefaultForkRepoUnits = [Code, PullRequests]`) → release assets 404 on the
web download route (`context.RequireUnitReader`), the source tarball 404s
too, while the API by-id works. Fix: enable the Releases unit
(Settings → Repository, or DB `INSERT INTO repo_unit (repo_id, type) ... 4` —
there is no units API on this build). `check-unit.sh` detects/fixes.
**Prefer generating from this template over forking**: generated repos are
not forks and get the full unit set (and Gitea only allows 1 fork of a
repo per user).
- **GitHub asset gotcha**: for a release addressed by *tag*, the asset
`download_url` is **null** — the API `url` returns JSON metadata unless
`Accept: application/octet-stream` is sent. `provider.sh` instead resolves
to the **web download URL** (`github.com/.../releases/download/<tag>/<file>`),
which is also unthrottled (the REST asset endpoint is 60 req/h
unauthenticated — not enough to mirror ~200 assets).
- Runner registration: the `gitea/act_runner` CLI (old and new) fails on this
build ("instance address is empty"); runner creation via API is 405.
Existing runners can be made shared via `PATCH /api/v1/admin/actions/runners/<id>`.
- `actions/cache` timeouts on this build are handled with
`continue-on-error: true` (cold fetch is still correct). The artifact cache
service itself is NOT configured on this Gitea — every sync is a cold fetch
(correct, slower; the cache steps are kept in case a backend is added).
- **Per-job DNS flapping:** the ephemeral per-job container intermittently
fails to resolve `git.lago.dev` on the fork push (the runner daemon's own
network resolves fine). `sync.sh` therefore wraps every fork push in
`push_once` — retry with backoff on transient network errors (resolve /
connect / timeout), abort immediately on non-network failures.
## Editing the template vs. a mirror repo
- **Template** (this repo): edit on `forker` and `git push`. Mirror repos do
**not** auto-track the template — sync them manually after a template
change:
- **Forked repos** (e.g. `Lago/photocraft`): the `forker` branch *is* a
descendant of the template's, so a normal merge works:
```
git remote add template <template-url>
git fetch template forker
git checkout forker && git merge template/forker
git push origin forker
```
- **Generated repos** (e.g. `Lago/pdfcraft`): the `forker` branch is an
**unrelated snapshot** (no common ancestor — `git merge` fails with
add/add conflicts). Reset it to the template and re-apply the single
per-repo setting, then force-push:
```
git checkout forker
git fetch template forker
git reset --hard template/forker
# re-apply this repo's .forker.yaml setting(s), e.g.:
sed -i 's/^mirror_upstream_releases: false/mirror_upstream_releases: true/' .forker.yaml
git commit -am "Adopt template; enable mirror_upstream_releases"
git push --force origin forker
```
This is safe: `forker` holds only the machinery + config (the upstream
content lives on the mirrored branches), so the snapshot's extra content
is discarded by design.
- **Per-repo config**: edit `.forker.yaml` in the UI on the `forker` branch.
Pushing to `forker` triggers a re-sync.
## Local testing (without the runner)
```
export UPSTREAM_URL=... UPSTREAM_TOKEN= # empty for public upstreams
export GITEA_TOKEN=... GITEA_SERVER_URL=... GITEA_OWNER=... GITEA_REPO=...
bash forker/sync.sh # full mirror (use a scratch repo!)
bash forker/release.sh <tag>
make check-unit
```
Test against a **scratch repo** you delete afterwards; never point the scripts
at a real mirror while experimenting. `GITEA_TOKEN` from Actions is an API
token (Bearer works for API + git); a *password* only works for basic auth —
expect the Bearer API calls to fail when testing with a password.
## File map
- `forker/sync.sh` — mirror worker (fetch/push/prune + inline releases + unit check)
- `forker/release.sh` — local build + upstream-release mirror, idempotent
- `forker/check-unit.sh` — Releases unit detection/self-heal (exit 10 = missing)
- `forker/lib/config.sh` — flat `.forker.yaml` parser
- `forker/lib/provider.sh` — provider-agnostic releases API (github/gitea/codeberg)
- `forker/runner-register.sh` — runner registration (see quirks above)
- `.gitea/workflows/` — sync.yml (cron), release.yml (manual), runner-check.yml
- `runner/docker-compose.yml` — gitea-act-runner in Docker (tracked; the local
`runner/config/` token dir is gitignored)
- `Makefile` — local targets (sync / release / mirror-releases / runner-check /
runner-register / check-unit); `runner-check` queries the Gitea runner APIs
- `docs/index.html` — architecture webpage (static)
+49
View File
@@ -0,0 +1,49 @@
cmake_minimum_required(VERSION 3.20)
project(Relinker CXX)
option(BUILD_TESTING "Build and register relinker tests" OFF)
if(BUILD_TESTING)
enable_testing()
endif()
option(ANYPS5_ENABLE_SPIRV_TOOLS "Enable SPIRV-Tools validation and optimization" OFF)
option(APS5_ENABLE_TIMING_LOG "Enable frame timing logging" OFF)
add_compile_definitions(APS5_ENABLE_TIMING_LOG=$<BOOL:${APS5_ENABLE_TIMING_LOG}>)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -static-libgcc -static-libstdc++")
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
set(SDL_STATIC ON CACHE BOOL "" FORCE)
set(SDL_TEST OFF CACHE BOOL "" FORCE)
set(SDL_VIDEO ON CACHE BOOL "" FORCE)
set(SDL_RENDER OFF CACHE BOOL "" FORCE)
set(SDL_X11 ON CACHE BOOL "" FORCE)
set(SDL_WAYLAND OFF CACHE BOOL "" FORCE)
set(SDL_OPENGL OFF CACHE BOOL "" FORCE)
set(SDL_OPENGLES OFF CACHE BOOL "" FORCE)
set(SDL_VULKAN ON CACHE BOOL "" FORCE)
set(SDL_JOYSTICK ON CACHE BOOL "" FORCE)
set(SDL_HAPTIC OFF CACHE BOOL "" FORCE)
set(SDL_HIDAPI OFF CACHE BOOL "" FORCE)
set(SDL_SENSOR OFF CACHE BOOL "" FORCE)
set(SDL_STATIC_PIC ON CACHE BOOL "" FORCE)
set(ANYPS5_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "")
add_subdirectory(3rdparty/SDL2)
set(CMAKE_EXE_LINKER_FLAGS "${ANYPS5_EXE_LINKER_FLAGS}")
set(FT_DISABLE_ZLIB ON CACHE BOOL "" FORCE)
set(FT_DISABLE_BZIP2 ON CACHE BOOL "" FORCE)
set(FT_DISABLE_PNG ON CACHE BOOL "" FORCE)
set(FT_DISABLE_HARFBUZZ ON CACHE BOOL "" FORCE)
set(FT_DISABLE_BROTLI ON CACHE BOOL "" FORCE)
set(SKIP_INSTALL_ALL ON CACHE BOOL "" FORCE)
add_subdirectory(3rdparty/freetype EXCLUDE_FROM_ALL)
set_target_properties(freetype PROPERTIES POSITION_INDEPENDENT_CODE ON)
add_subdirectory(core/shader/recompiler)
add_subdirectory(core/libs)
add_subdirectory(core/relinker)
+338
View File
@@ -0,0 +1,338 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
<https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Moe Ghoul>, 1 April 1989
Moe Ghoul, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
-43
View File
@@ -1,43 +0,0 @@
# Repo Forker — convenience targets.
# Most work happens in the Gitea Actions workflows; these targets are for local
# use (dry-runs, runner setup) and for debugging on the runner.
CONFIG_FILE ?= .forker.yaml
.PHONY: help sync release mirror-releases runner-check runner-register check-unit
help:
@echo "Repo Forker targets:"
@echo " sync Run a manual sync (needs UPSTREAM_* + GITEA_* env)"
@echo " release TAG=x Run a release for tag x"
@echo " mirror-releases Mirror upstream releases for a tag (release.sh MIRROR)"
@echo " runner-check Run the runner-check workflow logic locally"
@echo " runner-register Register a shared gitea-act-runner (see README)"
@echo " check-unit Verify the Releases unit is enabled (fork quirk)"
sync:
bash forker/sync.sh
release:
@test -n "$(TAG)" || (echo "make release TAG=<tag>"; exit 1)
bash forker/release.sh "$(TAG)"
mirror-releases:
@test -n "$(TAG)" || (echo "make mirror-releases TAG=<tag>"; exit 1)
bash forker/release.sh "$(TAG)"
runner-check:
@test -n "$(GITEA_SERVER_URL)" -a -n "$(GITEA_TOKEN)" -a -n "$(GITEA_OWNER)" -a -n "$(GITEA_REPO)" \
|| { echo "needs GITEA_SERVER_URL/GITEA_TOKEN/GITEA_OWNER/GITEA_REPO (or run the workflow instead)"; exit 1; }
@curl -sS --max-time 20 -H "Authorization: Bearer $(GITEA_TOKEN)" \
"$(GITEA_SERVER_URL)/api/v1/repos/$(GITEA_OWNER)/$(GITEA_REPO)/actions/runners" > /tmp/rc_repo.json
@curl -sS --max-time 20 -H "Authorization: Bearer $(GITEA_TOKEN)" \
"$(GITEA_SERVER_URL)/api/v1/admin/actions/runners?limit=50" > /tmp/rc_shared.json || true
@python3 -c 'import json; R=json.load(open("/tmp/rc_repo.json")).get("runners",[]); S=[r for r in json.load(open("/tmp/rc_shared.json")).get("runners",[]) if r.get("shared")]; print("Repo-scoped runners: "+(", ".join("%s (%s)"%(r["name"],r["status"]) for r in R) or "(none)")); print("Shared runners: "+(", ".join("%s (%s)"%(r["name"],r["status"]) for r in S) or "(none)")); print("OK: a runner serves this repo." if (R or S) else "WARNING: no runner (repo-scoped or shared) registered - cron runs will stay queued.")'
@rm -f /tmp/rc_repo.json /tmp/rc_shared.json
runner-register:
bash forker/runner-register.sh
check-unit:
bash forker/check-unit.sh
+24 -196
View File
@@ -1,221 +1,49 @@
# Repo Forker
# About
> 📖 **Documentación y arquitectura interactiva:** [docs/index.html](docs/index.html) — qué es, cómo funciona, cómo crear un fork paso a paso, runner, config y limitaciones.
Tool for automatic executables porting to Linux and Windows.
> 🖥️ **UI de gestión local (mirrors):** [ui/README.md](ui/README.md) — `cd ui && npm install && npm run build && node bin/repo-forker-ui.js` → http://127.0.0.1:8731. Crea/elimina/monitorea mirrors, paridad vs upstream, logs en vivo, cola del runner.
Includes a [relinker](core/relinker) that converts executable to the target system's native format and implementations of [system prx libraries](core/libs/prx) suitable for dynamic linking. No emulation or separate runtime process.
Turn **any** git repo (GitHub, Gitea, Codeberg, …) into a **live mirror on your
Gitea** — all branches, all tags, full commit history — synced very
periodically by a Gitea Actions runner (your "gitea worker"), with releases
produced **locally on the runner** (and optionally mirrored from the upstream).
This repo is a **template**. You **fork** it once per upstream; the fork *is*
the mirror. The upstream's content never touches the working tree: upstream
objects live in a bare mirror (`.mirror/`, gitignored) and are pushed as refs
so they show up in the Gitea UI.
```
Fork of this template (Lago/<upstream>)
├── working tree (forker branch) ← the machinery: scripts, config, workflows
├── .mirror/ ← bare mirror of the upstream (gitignored)
└── refs: <upstream branches> + <tags> ← visible in the Gitea UI
```
## Status
## How it works
[![libraries](https://boykopovar.github.io/AnyPS5/badge-libraries.svg)](https://boykopovar.github.io/AnyPS5/) [![shaders](https://boykopovar.github.io/AnyPS5/badge-shaders.svg)](https://boykopovar.github.io/AnyPS5/)
1. **Sync (the worker).** A cron workflow runs every N minutes. `sync.sh` fetches
all branches + tags + full history from the upstream into a true bare mirror
(`.mirror/`), then pushes them onto this fork and **prunes** what the upstream
deleted. The fork's current state is read via the Gitea API (not git state),
so prune + change-detection work even when the workspace is wiped between
runs. `actions/cache` restores `.mirror/` when possible → incremental fetches.
2. **Release (local build).** When sync detects a **new tag**, it invokes
`release.sh` inline: checkout the tag's tree, run your build command **on the
runner**, publish the release (tag + assets) on this Gitea. (A tag-push can't
trigger a workflow on its own — the tag points at an upstream commit whose
tree has no `.gitea/workflows` — so sync does it.) Re-running is idempotent:
an existing release is skipped, not duplicated.
3. **Release (mirror, optional).** If enabled, the upstream's existing release
(metadata + assets) is copied over via the provider API
(GitHub / Gitea / Codeberg — auto-detected in `forker/lib/provider.sh`).
[![progress map](https://boykopovar.github.io/AnyPS5/progress.svg)](https://boykopovar.github.io/AnyPS5/)
## Quick start (3 steps)
<sub>* System libraries: percentage of the functions known to the project so far (declared in [core/libs/prx](core/libs/prx)), not of every PS5 system function. The total grows as more functions are declared.</sub>
### 1. Fork this template
In the Gitea UI: **this repo → Fork** → name it after the upstream
(e.g. `Lago/some-upstream`).
[List of verified games](docs/user/COMPATIBILITY.md)
### 2. Point it at the upstream (the "remote")
In the fork: **Settings → Actions → Variables & Secrets**
- **Variable** `UPSTREAM_URL` = `https://github.com/owner/repo.git` (any provider)
- **Secret** `UPSTREAM_TOKEN` = *(optional — only for private upstreams.)*
Public upstreams are mirrored **anonymously** and the tool never
authenticates against them: the global/system git config and the
credential helper are cut for all upstream git calls, so a stored
`~/.git-credentials` entry is never used. Only set a token when the
upstream is private (or you need a higher API rate for mirrored
releases).
Dreaming Sarah (2D platformer) runs at a stable 60 fps on a GTX 1050 Ti / i5-7500 3.4GHz.
Everything non-secret (which branches, how often, build command, artifacts) lives
in **`.forker.yaml`** — edit it in the UI on the `forker` branch.
Unsupported or unexpected states strictly throw `std::runtime_error`. `what()` is printed to stderr and the process terminates.
> The `GITEA_*` values (server URL, owner, repo, token) are injected
> automatically by Gitea Actions — you don't set them. (`GITEA_TOKEN` in the
> workflow env block is Gitea's **built-in** Actions secret, not a
> user-created secret — don't create one.)
The [shader recompiler](core/shader/recompiler/Recompiler.cpp) successfully produces SPIR-V (validated via [Spirv-Tools](3rdparty/SPIRV-Tools) when built with `ANYPS5_ENABLE_SPIRV_TOOLS`).
### 3. Make sure a runner serves this repo
In this Gitea build, **runners are repo-scoped**: a runner registered on one
repo does **not** serve another. So either:
[Technical debt of the project](docs/dev/TechnicalDebt.md), [code style conventions](docs/dev/CONVENTIONS.md)
- **Shared runner (recommended, one-time):** register a single runner that serves
**all** repos. See [Runner](#runner).
- **Per-repo runner:** register a runner for this specific repo.
## Build
Then trigger **Settings → Actions → "Repo Forker — Runner check"** and confirm it
completes. If sync runs stay *pending* for a long time, no runner is serving
this repo.
The relinker uses only the C++20 standard library and should build with any conforming compiler.
That's it. The cron sync starts pulling the upstream in, and releases are
produced locally when tags appear. Note: with the template defaults
(`build_cmd` empty, `mirror_upstream_releases: false`) there is nothing to
build, so new tags are mirrored as **refs only** — set a `build_cmd` /
`build_script` (or `mirror_upstream_releases: true`) for releases to appear.
[libc.prx](core/libs/prx/libc) implementations contain compiler-specific code. Linux builds work with GCC; on Windows, MinGW-w64 GCC 15.2.0 (`winlibs-gcc15`, `x86_64-ucrt-posix-seh`) is currently required.
## Configuration (`.forker.yaml`)
The project targets maximum compiler portability. Support for additional compilers will be addressed after the first successful game launch.
| Key | Default | Meaning |
|---|---|---|
| `token_user` | `oauth2` | *(unused — Bearer auth needs no username; retained for compatibility)* |
| `mirror_tags` | `true` | Mirror all tags |
| `mirror_prune` | `true` | Prune branches deleted upstream |
| `mirror_branches` | `*` | `*` = all, or a comma list (`main,develop`) |
| `on_new_tag` | `true` | Build+publish a release when a new tag is mirrored |
| `mirror_upstream_releases` | `false` | Also copy the upstream's release (metadata + assets) |
| `build_cmd` | — | Build command(s), `;`-separated, run in the tag's tree |
| `build_script` | — | Path to a custom build script (overrides `build_cmd`) |
| `artifacts` | — | Space-separated globs of files to attach to the release |
## Compatibility
## Manual triggers
See the [game compatibility list](docs/user/COMPATIBILITY.md) for tested games and known issues.
- **Sync now:** Settings → Actions → *Repo Forker — Sync* → Run workflow.
- **Release a tag:** Settings → Actions → *Repo Forker — Release* → Run workflow
→ enter the tag.
- **Check the runner:** Settings → Actions → *Repo Forker — Runner check*.
## Input mapping
Or from a machine that has the repo + env vars: `make sync`,
`make release TAG=v1.2.3`.
SDL-mapped game controllers are supported, including analog sticks and triggers. Keyboard and mouse controls can be configured with an `anyps5-input.ini` file. See [input mapping](docs/user/INPUT_MAPPING.md) for the supported devices and configuration format.
## Runner
## Disclaimer
The sync (cron) and the local release build both need a **Gitea Actions runner**
serving the repo. In this build, runners are **repo-scoped**, so the clean path
is a **shared runner** registered once:
This project is intended for interoperability, research, preservation, and compatibility purposes. It does not include, distribute, or require copyrighted software, firmware, cryptographic keys, or proprietary libraries. Users are responsible for ensuring that any binaries used with this project are obtained and used in accordance with applicable laws and their respective license terms.
```bash
# install gitea-act-runner (see the Gitea runner docs), then:
GITEA_SERVER_URL=https://git.lago.dev \
GITEA_TOKEN=<admin-token> \
GITEA_OWNER=Lago GITEA_REPO=any \
bash forker/runner-register.sh shared
## License
# then start it (e.g. via docker, see runner/docker-compose.yml)
gitea-act-runner run
```
`forker/runner-register.sh` auto-generates a registration token via
`POST /api/v1/admin/actions/runners/registration-token` (verified working on this
instance) and registers either a **shared** runner or a **per-repo** one.
> The existing online runner on this instance (id 3, `496cfb9f4583`,
> `ubuntu-latest/24.04/22.04`) is registered to `Lago/Tide` only — it will not
> serve your forks. Register a shared runner (or one per repo) as above.
> **This Gitea build quirk (verified):** the `act_runner` CLI fails to
> register ("instance address is empty") on both `gitea/act_runner:0.6.1`
> and `0.2.13`, and the runner-creation API returns 405. The path that
> **does** work: take an existing registered runner and PATCH it to shared:
> ```bash
> curl -X PATCH "$GITEA_SERVER_URL/api/v1/admin/actions/runners/<id>" \
> -H "Authorization: Bearer $GITEA_TOKEN" \
> -d '{"name":"gitea-runner-forker","labels":["ubuntu-latest"],"shared":true,"disabled":false}'
> ```
> then point a `gitea/act_runner:0.6.1` container at its config
> (`runner/docker-compose.yml`).
## Repository layout
```
repo-forker/
├── .gitea/workflows/
│ ├── sync.yml # cron: mirror upstream (the "worker"); restores .mirror cache
│ ├── release.yml # MANUAL only (a tag push can't trigger it); see sync.sh
│ └── runner-check.yml # verify a runner serves this repo
├── forker/
│ ├── sync.sh # true-mirror fetch + push + prune + inline new-tag release + unit check
│ ├── release.sh # local build + publish release (± mirror upstream), idempotent
│ ├── runner-register.sh # register a shared / per-repo runner
│ ├── check-unit.sh # verify/fix the Releases unit (Gitea fork quirk)
│ └── lib/
│ ├── config.sh # load .forker.yaml
│ └── provider.sh # detect provider + releases API (Gitea/GitHub/Codeberg)
├── .mirror/ # bare mirror (gitignored, cached by the workflow)
├── .forker.yaml # per-fork config (non-secret)
├── Makefile
├── runner/docker-compose.yml
└── README.md
```
## Notes & limitations
- **Releases are not git objects.** Git only carries the *tag*; release *assets*
live on the Gitea. "Local release" = build on the runner + upload via the
Gitea API. Mirroring upstream assets works anonymously for public upstreams
(a token is only needed for private ones).
- **Ephemeral workspace.** The Gitea runner wipes the workspace between runs.
`sync.sh` is written to not depend on leftover git state: it re-reads the fork's
current refs via the API every run. `actions/cache` on `.mirror/` makes the
fetch incremental when it hits; a cold cache just means a full-history fetch
(correct, slower).
- **Tags point at upstream commits.** That's intentional — it keeps commit
hashes identical to the upstream. It also means the workflow can't be
triggered *by the tag* (the tag's tree has no workflows), so sync triggers
releases inline.
- **Provider differences** (releases API, token username) are isolated in
`forker/lib/provider.sh`; the rest is provider-agnostic.
- **Secrets stay out of the repo.** Upstream URL/token are Gitea Actions
Variables/Secrets; the Gitea token is the built-in `GITEA_TOKEN`.
- **Runner is the hard dependency.** Without a runner serving the repo, the cron
sync and local builds won't run — run the *Runner check* first.
- **Gitea forks ship without the Releases unit → asset downloads 404.**
Root cause found on this instance (verified in the Gitea source + DB): a fork
is created with `DefaultForkRepoUnits = [Code, PullRequests]` — **no
Releases unit** — while normal repos get it. So release *assets* uploaded to
a fork repo are listed in the API (by-id works) but the web
`browser_download_url` returns 404 at the unit-permission check, and the
release *source tarball* 404s too.
**Detected + fixed:** `sync.sh` runs `check-unit.sh` at the end of every
sync — it self-heals via the units API on builds that expose it, and on
this build (no units API) it detects the 404 (confirming the API by-id
path still works) and prints the exact one-time fix: UI → Settings →
Repository → enable the **Releases** unit. `make check-unit` runs it
standalone.
## Security notes
- **Upstreams are fetched anonymously by default.** `sync.sh` / `release.sh`
cut `GIT_CONFIG_GLOBAL`/`GIT_CONFIG_SYSTEM` and the credential helper before
any upstream git call, and add a Bearer header **only** when `UPSTREAM_TOKEN`
is set. A stored `~/.git-credentials` entry is therefore *never* offered to
`git fetch` — a public upstream is a pure anonymous fetch.
- **`build_cmd` / `build_script` run with the tokens in the environment.**
`release.sh` keeps `GITEA_TOKEN` and `UPSTREAM_TOKEN` set so it can fetch the
tag's tree and publish assets. Any repo member can edit `.forker.yaml`, so a
malicious `build_cmd` could exfiltrate both tokens. Treat `build_cmd` /
`build_script` as **trusted code with credential access** — only put commands
you (or the repo owners) trust there.
- **Tokens briefly persist in the cached `.mirror/` git config.** The per-URL
`http.<url>.extraHeader` Bearer header is written into `.mirror/config`, and
`.mirror/` is the `actions/cache` path. The cache is repo-scoped (not
committed), but a cache-service reader can read it until the next save
overwrites it. The tokens are never written into the repo itself.
This project is licensed under the GNU General Public License version 2 only.
-102
View File
@@ -1,102 +0,0 @@
# TODO — a futuro
## [UI] Gestión local de mirrors (npx)
Una web local (arrancable con `npx`) para gestionar todo el ecosistema de
Repo Forker desde un solo lugar, sin tocar API/curl/DB.
### Idea
```
npx repo-forker-ui # -> http://localhost:8731 (o el puerto libre)
```
El UI habla con la API de Gitea (con un token que el usuario pega una vez,
guardado localmente — nunca en el repo) y ejecuta las mismas operaciones que
los scripts, pero de forma guiada.
### Features (por prioridad)
**P0 — Gestión de mirrors (el corazón):**
- **Crear un mirror**: pega la URL del upstream (GitHub/Gitea/Codeberg/otro)
+ nombre → el UI hace lo que se hace hoy por API/curl:
1. `POST /repos/{owner}/repo-forker/generate` con `git_content: true`
2. crea la variable `UPSTREAM_URL` (`POST .../actions/variables/UPSTREAM_URL`)
3. `PATCH` default branch → la del upstream (o `main`)
4. activa `mirror_upstream_releases` en la rama `forker` (reset + re-apply,
el procedimiento de AGENTS.md para repos generados)
5. dispara el primer `sync.yml` (dispatch) y muestra el progreso
- **Lista de mirrors**: todos los repos generados desde `repo-forker`
(detectables por la rama `forker` + la variable `UPSTREAM_URL`), con:
- estado del último `sync.yml` (green/red, timestamp, duración)
- branches / tags / releases / assets (vs upstream — paridad)
- unidades activas (Code/Issues/PR/Releases/...)
- **Stats y gráficas** (por mirror y agregado):
- timeline de runs (success/failure/queued) — sparkline de los últimos 7 días
- tiempo de sync por run (cold vs incremental — la caché, cuando exista)
- assets por release (barras), crecimiento de branches/tags
- latencia de mirror: commits upstream sin replicar todavía
- **Eliminar un mirror**: delete del repo (con confirmación + advertencia de
lo que se pierde; el template queda intacto)
- **Re-sincronizar / forzar**: dispatch manual de `sync.yml` / `release.yml` /
`runner-check.yml` desde la UI
- **Config per-repo**: editar `.forker.yaml` (los campos conocidos:
`mirror_branches`, `mirror_tags`, `mirror_prune`, `mirror_upstream_releases`,
`build_cmd`, `build_script`, `artifacts`, `on_new_tag`) con validación de
esquema plano (el parser es grep — el UI debe mantenerlo plano)
- **Variables & secrets**: listar/crear/borrar las Variables de Actions
(`UPSTREAM_URL`, `UPSTREAM_TOKEN` opcional) — los secrets solo se crean,
no se leen (la API no los devuelve)
**P1 — Observabilidad:**
- **Cola del runner**: runs `queued`/`in_progress` en vivo (polling), con
tiempo de espera — el runner es serial (maxParallel=1), así que una vista
de "fila" es muy útil
- **Logs en vivo** de un run (stream del log del job, con el
`::group::`/`::notice::` de Gitea Actions renderizado)
- **Diagnóstico de un run fallido**: extraer la línea de error del log y
sugerir la causa (DNS flap, cache timeout, token, unidad Releases)
- **Unidades**: ver/quitar/habilitar la unidad Releases (con fallback a DB
cuando la API no existe — este build)
- **Alerta** de mirror "desactualizado" (última sync > N min con runner idle)
**P2 — Extras:**
- **Generar desde otros templates**: que el UI permita usar cualquier repo
marcado `template: true` (no solo repo-forker)
- **Import de config**: pegar un `.forker.yaml` y aplicarlo
- **Export del estado**: snapshot JSON de todos los mirrors (para backups /
re-crear después de una catástrofe)
- **Comparador de paridad**: side-by-side upstream vs fork (branches/tags/
releases) con diff visual (lo que falta se marca)
### Notas de diseño
- **Stack sugerido**: Vite + React (o SvelteKit) + Tailwind; el backend
"npx" puede ser un thin server Node que solo hace proxy + auth al Gitea
(el UI puede ser 100% client-side si el token se guarda en `localStorage`;
el proxy solo evita CORS y esconde el token de los logs del navegador).
- **Auth**: el usuario pega su token Gitea (o basic) una vez; se guarda en
`~/.repo-forker/credentials` (chmod 600) o `localStorage` según el modo.
NUNCA se sube al repo.
- **Idempotencia**: todas las acciones de creación deben ser idempotentes
(re-crear el mirror con el mismo nombre → "ya existe" + enlazar).
- **No duplicar lógica**: las operaciones (generate, variable, default branch,
forker reset+re-apply, dispatch) ya están probadas en esta sesión — el UI
las reproduce tal cual, no inventa variantes.
- **Modo offline**: la UI debe funcionar aunque el Gitea esté caído (los
últimos datos cacheados + estado "offline").
### Criterio de "hecho" (P0)
1. `npx repo-forker-ui` arranca y se conecta a un Gitea (URL + token).
2. Desde la UI: crear un mirror de un repo GitHub público → aparece en la
lista con su primer sync en verde y paridad correcta.
3. Eliminar un mirror desde la UI (con confirmación).
4. Ver en la UI: últimos 20 runs de cada mirror, paridad de
branches/tags/releases, y el log del último run.
5. Re-sincronizar (dispatch) desde la UI.
### Estado: **A FUTURO — no empezar sin revisar esta spec**
La infraestructura ya soporta todo lo que el UI necesita (APIs de generate,
variables, dispatch, runners, releases; scripts de sync con retry; `check-unit`;
cron de limpieza en tizona). Faltan decisiones: stack, nombre del paquete,
y si el modo "solo client-side con token en localStorage" es suficiente.
+505
View File
@@ -0,0 +1,505 @@
if(NOT WIN32)
string(REPLACE "-static " "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ")
string(STRIP "${CMAKE_EXE_LINKER_FLAGS}" CMAKE_EXE_LINKER_FLAGS)
endif()
add_executable(nid_patcher
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/Sha1.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/NidCompute.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/NidResolver.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/ExportExclusions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/ElfNidPatcher.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/PeNidPatcher.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/BinaryPatcherFactory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/main.cpp
)
target_include_directories(nid_patcher PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/nid/include)
target_compile_features(nid_patcher PRIVATE cxx_std_20)
if(MINGW)
target_link_options(nid_patcher PRIVATE -static -static-libgcc -static-libstdc++)
add_compile_options(-fno-asynchronous-unwind-tables)
endif()
function(configure_windows_unwind target)
if(MINGW)
if(NOT EXISTS "${CMAKE_OBJCOPY}")
message(FATAL_ERROR "Windows DWARF unwinding requires objcopy")
endif()
add_custom_command(TARGET ${target} POST_BUILD
COMMAND "${CMAKE_OBJCOPY}" --rename-section .eh_frame=.ehfram "$<TARGET_FILE:${target}>"
VERBATIM
)
endif()
endfunction()
set(LIBC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/prx/libc)
add_library(libc SHARED EXCLUDE_FROM_ALL)
set(LIBS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(${LIBC_DIR} ${CMAKE_CURRENT_BINARY_DIR}/prx/libc)
target_include_directories(libc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
configure_windows_unwind(libc)
set(UNPATCHED_DIR ${CMAKE_CURRENT_BINARY_DIR}/libs/unpatched)
set(PATCHED_DIR ${CMAKE_CURRENT_BINARY_DIR}/libs)
set_target_properties(libc PROPERTIES
PREFIX ""
SUFFIX .prx
RUNTIME_OUTPUT_DIRECTORY ${UNPATCHED_DIR}
LIBRARY_OUTPUT_DIRECTORY ${UNPATCHED_DIR}
)
set(LIBC_UNPATCHED ${UNPATCHED_DIR}/libc.prx)
set(LIBC_PATCHED ${PATCHED_DIR}/libc.prx)
add_custom_command(
OUTPUT ${LIBC_PATCHED}
COMMAND ${CMAKE_COMMAND} -E copy ${LIBC_UNPATCHED} ${LIBC_PATCHED}
COMMAND $<TARGET_FILE:nid_patcher> libc ${LIBC_PATCHED}
DEPENDS nid_patcher libc ${LIBC_UNPATCHED}
COMMENT "Patching NIDs for libc"
)
file(GLOB LIBS_DIRS LIST_DIRECTORIES true ${CMAKE_CURRENT_SOURCE_DIR}/prx/*)
list(REMOVE_ITEM LIBS_DIRS ${LIBC_DIR})
set(PATCHED_OUTPUTS ${LIBC_PATCHED})
foreach(LIB_DIR ${LIBS_DIRS})
if(IS_DIRECTORY ${LIB_DIR})
get_filename_component(LIB_NAME ${LIB_DIR} NAME)
if(EXISTS ${LIB_DIR}/CMakeLists.txt)
set(LIBS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(${LIB_DIR} ${CMAKE_CURRENT_BINARY_DIR}/prx/${LIB_NAME})
else()
add_library(${LIB_NAME} SHARED EXCLUDE_FROM_ALL ${LIB_DIR}/Export.cpp)
target_include_directories(${LIB_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
configure_windows_unwind(${LIB_NAME})
endif()
if(LIB_NAME STREQUAL "libkernel")
target_link_libraries(${LIB_NAME} PRIVATE libc)
else()
target_link_libraries(${LIB_NAME} PRIVATE libkernel libc)
endif()
set_target_properties(${LIB_NAME} PROPERTIES
PREFIX ""
SUFFIX .prx
RUNTIME_OUTPUT_DIRECTORY ${UNPATCHED_DIR}
LIBRARY_OUTPUT_DIRECTORY ${UNPATCHED_DIR}
)
set(UNPATCHED_FILE ${UNPATCHED_DIR}/${LIB_NAME}.prx)
set(PATCHED_FILE ${PATCHED_DIR}/${LIB_NAME}.prx)
add_custom_command(
OUTPUT ${PATCHED_FILE}
COMMAND ${CMAKE_COMMAND} -E copy ${UNPATCHED_FILE} ${PATCHED_FILE}
COMMAND $<TARGET_FILE:nid_patcher> ${LIB_NAME} --preserve-exports "${LIBC_UNPATCHED}" "${PATCHED_FILE}"
DEPENDS nid_patcher ${LIB_NAME} ${UNPATCHED_FILE} ${LIBC_UNPATCHED}
COMMENT "Patching NIDs for ${LIB_NAME}"
)
list(APPEND PATCHED_OUTPUTS ${PATCHED_FILE})
endif()
endforeach()
set(LIBCOHTML_PATCHED ${PATCHED_DIR}/libcohtml.prx)
set(LIBCOHTML_PROSPERO_PATCHED ${PATCHED_DIR}/libcohtml.Prospero.prx)
add_custom_command(
OUTPUT ${LIBCOHTML_PROSPERO_PATCHED}
COMMAND ${CMAKE_COMMAND} -E copy "${LIBCOHTML_PATCHED}" "${LIBCOHTML_PROSPERO_PATCHED}"
DEPENDS ${LIBCOHTML_PATCHED}
VERBATIM
)
add_custom_target(libcohtml_prospero DEPENDS ${LIBCOHTML_PROSPERO_PATCHED})
list(APPEND PATCHED_OUTPUTS ${LIBCOHTML_PROSPERO_PATCHED})
add_custom_target(libs DEPENDS ${PATCHED_OUTPUTS})
if(BUILD_TESTING)
add_library(host_thread_local_test_library SHARED tests/HostThreadLocalLibrary.cpp)
target_include_directories(host_thread_local_test_library PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(host_thread_local_tests tests/HostThreadLocal.cpp)
target_link_libraries(host_thread_local_tests PRIVATE host_thread_local_test_library)
if(MINGW)
target_compile_options(host_thread_local_test_library PRIVATE -fasynchronous-unwind-tables)
target_compile_options(host_thread_local_tests PRIVATE -fasynchronous-unwind-tables)
endif()
add_test(NAME host_thread_local COMMAND host_thread_local_tests)
set_tests_properties(host_thread_local PROPERTIES TIMEOUT 15)
add_executable(texture_format_lookup_tests tests/TextureFormatLookup.cpp)
target_include_directories(texture_format_lookup_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/3rdparty/Vulkan-Headers/include)
target_link_libraries(texture_format_lookup_tests PRIVATE libSceAgcDriver libc)
configure_windows_unwind(texture_format_lookup_tests)
add_test(NAME texture_format_lookup COMMAND texture_format_lookup_tests)
if(WIN32)
set_tests_properties(texture_format_lookup PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_executable(linear_display_buffer_tests tests/LinearDisplayBuffer.cpp)
target_include_directories(linear_display_buffer_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(linear_display_buffer_tests PRIVATE libSceAgcDriver libc)
configure_windows_unwind(linear_display_buffer_tests)
add_test(NAME linear_display_buffer COMMAND linear_display_buffer_tests)
if(WIN32)
set_tests_properties(linear_display_buffer PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_executable(guest_rendering_wait_tests tests/GuestRenderingWait.cpp)
target_include_directories(guest_rendering_wait_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_rendering_wait_tests PRIVATE libSceAgcDriver libc)
configure_windows_unwind(guest_rendering_wait_tests)
add_test(NAME guest_rendering_wait COMMAND guest_rendering_wait_tests)
if(WIN32)
set_tests_properties(guest_rendering_wait PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_executable(guest_buffer_reuse_tests tests/GuestBufferReuse.cpp)
target_include_directories(guest_buffer_reuse_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_buffer_reuse_tests PRIVATE libc)
configure_windows_unwind(guest_buffer_reuse_tests)
add_test(NAME guest_buffer_reuse COMMAND guest_buffer_reuse_tests)
if(WIN32)
set_tests_properties(guest_buffer_reuse PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_executable(guest_indexed_draw_tests tests/GuestIndexedDraw.cpp)
add_executable(shader_buffer_address_tests tests/ShaderBufferAddress.cpp)
target_link_libraries(shader_buffer_address_tests PRIVATE shader_recompiler_agc_driver libc)
configure_windows_unwind(shader_buffer_address_tests)
add_test(NAME shader_buffer_address COMMAND shader_buffer_address_tests)
if(WIN32)
set_tests_properties(shader_buffer_address PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
target_include_directories(guest_indexed_draw_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_indexed_draw_tests PRIVATE libSceAgc libSceAgcDriver libc)
configure_windows_unwind(guest_indexed_draw_tests)
add_test(NAME guest_indexed_draw COMMAND guest_indexed_draw_tests)
if(WIN32)
set_tests_properties(guest_indexed_draw PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_executable(guest_shader_link_tests tests/GuestShaderLink.cpp)
target_include_directories(guest_shader_link_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_shader_link_tests PRIVATE libSceAgc libc)
configure_windows_unwind(guest_shader_link_tests)
add_test(NAME guest_shader_link COMMAND guest_shader_link_tests)
if(WIN32)
set_tests_properties(guest_shader_link PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_executable(guest_system_exit_tests tests/GuestSystemExit.cpp)
target_include_directories(guest_system_exit_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_system_exit_tests PRIVATE libSceSystemService libc)
configure_windows_unwind(guest_system_exit_tests)
add_test(NAME guest_system_exit_parameters COMMAND guest_system_exit_tests)
add_test(NAME guest_system_exit COMMAND guest_system_exit_tests --exit)
add_test(NAME guest_immediate_exit COMMAND guest_system_exit_tests --immediate)
set_tests_properties(guest_system_exit PROPERTIES
PASS_REGULAR_EXPRESSION "Guest shutdown and atexit completed")
if(WIN32)
set_tests_properties(guest_system_exit guest_system_exit_parameters guest_immediate_exit PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_executable(guest_character_tests tests/GuestCharacter.cpp)
target_include_directories(guest_character_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_character_tests PRIVATE libc)
configure_windows_unwind(guest_character_tests)
add_test(NAME guest_character COMMAND guest_character_tests)
if(WIN32)
set_tests_properties(guest_character PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_executable(guest_math_tests tests/GuestMath.cpp)
target_include_directories(guest_math_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_math_tests PRIVATE libc)
configure_windows_unwind(guest_math_tests)
add_test(NAME guest_math COMMAND guest_math_tests)
if(WIN32)
set_tests_properties(guest_math PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_executable(guest_working_directory_tests tests/GuestWorkingDirectory.cpp)
target_include_directories(guest_working_directory_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_working_directory_tests PRIVATE libc)
configure_windows_unwind(guest_working_directory_tests)
add_test(NAME guest_working_directory COMMAND guest_working_directory_tests)
if(WIN32)
set_tests_properties(guest_working_directory PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_library(guest_module_fixture SHARED tests/GuestModuleFixture.cpp)
target_include_directories(guest_module_fixture PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_command(TARGET guest_module_fixture POST_BUILD
COMMAND $<TARGET_FILE:nid_patcher> guest_module_fixture $<TARGET_FILE:guest_module_fixture>
VERBATIM)
add_dependencies(guest_module_fixture nid_patcher)
add_executable(guest_dynamic_loader_tests tests/GuestDynamicLoader.cpp)
target_include_directories(guest_dynamic_loader_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_dynamic_loader_tests PRIVATE libkernel libc)
configure_windows_unwind(guest_dynamic_loader_tests)
add_dependencies(guest_dynamic_loader_tests guest_module_fixture)
add_test(NAME guest_dynamic_loader COMMAND guest_dynamic_loader_tests $<TARGET_FILE_NAME:guest_module_fixture>)
set_tests_properties(guest_dynamic_loader PROPERTIES
WORKING_DIRECTORY "$<TARGET_FILE_DIR:guest_module_fixture>")
if(WIN32)
set_tests_properties(guest_dynamic_loader PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
endif()
add_executable(guest_filesystem_tests tests/GuestFilesystem.cpp)
target_include_directories(guest_filesystem_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_filesystem_tests PRIVATE libc)
configure_windows_unwind(guest_filesystem_tests)
add_test(NAME guest_filesystem COMMAND guest_filesystem_tests)
if(WIN32)
set_tests_properties(guest_filesystem PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_executable(guest_directory_tests tests/GuestDirectory.cpp)
target_include_directories(guest_directory_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_directory_tests PRIVATE libc)
configure_windows_unwind(guest_directory_tests)
add_test(NAME guest_directory COMMAND guest_directory_tests)
if(WIN32)
set_tests_properties(guest_directory PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_executable(guest_environment_tests tests/GuestEnvironment.cpp)
target_include_directories(guest_environment_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_environment_tests PRIVATE libc)
configure_windows_unwind(guest_environment_tests)
add_test(NAME guest_environment COMMAND guest_environment_tests)
if(WIN32)
set_tests_properties(guest_environment PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_executable(guest_standard_stream_tests tests/GuestStandardStreams.cpp)
target_include_directories(guest_standard_stream_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_standard_stream_tests PRIVATE libc)
configure_windows_unwind(guest_standard_stream_tests)
add_test(NAME guest_standard_streams COMMAND guest_standard_stream_tests)
if(WIN32)
set_tests_properties(guest_standard_streams PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_executable(guest_once_tests tests/GuestOnce.cpp)
target_include_directories(guest_once_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_once_tests PRIVATE libkernel libc)
configure_windows_unwind(guest_once_tests)
add_test(NAME guest_once COMMAND guest_once_tests)
set_tests_properties(guest_once PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_once PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
endif()
add_executable(guest_thread_self_tests tests/GuestThreadSelf.cpp)
target_include_directories(guest_thread_self_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_thread_self_tests PRIVATE libkernel libc)
configure_windows_unwind(guest_thread_self_tests)
add_test(NAME guest_thread_self COMMAND guest_thread_self_tests)
set_tests_properties(guest_thread_self PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_thread_self PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
endif()
add_executable(guest_cond_timedwait_tests tests/GuestCondTimedwait.cpp)
target_include_directories(guest_cond_timedwait_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_cond_timedwait_tests PRIVATE libkernel libc)
configure_windows_unwind(guest_cond_timedwait_tests)
add_test(NAME guest_cond_timedwait COMMAND guest_cond_timedwait_tests)
set_tests_properties(guest_cond_timedwait PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_cond_timedwait PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
endif()
add_executable(guest_signal_tests tests/GuestSignals.cpp)
target_include_directories(guest_signal_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_signal_tests PRIVATE libkernel libc)
configure_windows_unwind(guest_signal_tests)
add_test(NAME guest_signals COMMAND guest_signal_tests)
if(WIN32)
set_tests_properties(guest_signals PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
endif()
add_executable(guest_kernel_error_tests tests/GuestKernelErrors.cpp)
target_include_directories(guest_kernel_error_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_kernel_error_tests PRIVATE libkernel libc)
configure_windows_unwind(guest_kernel_error_tests)
add_test(NAME guest_kernel_errors COMMAND guest_kernel_error_tests)
set_tests_properties(guest_kernel_errors PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_kernel_errors PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
endif()
add_executable(guest_system_configuration_tests tests/GuestSystemConfiguration.cpp)
target_include_directories(guest_system_configuration_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_system_configuration_tests PRIVATE libkernel libc)
configure_windows_unwind(guest_system_configuration_tests)
add_test(NAME guest_system_configuration COMMAND guest_system_configuration_tests)
if(WIN32)
set_tests_properties(guest_system_configuration PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
endif()
add_executable(guest_udp_tests tests/GuestUdp.cpp)
target_include_directories(guest_udp_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_udp_tests PRIVATE libkernel libc)
configure_windows_unwind(guest_udp_tests)
add_test(NAME guest_udp COMMAND guest_udp_tests)
set_tests_properties(guest_udp PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_udp PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
endif()
add_executable(guest_address_tests tests/GuestAddressConversion.cpp)
target_include_directories(guest_address_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_address_tests PRIVATE libkernel libc)
configure_windows_unwind(guest_address_tests)
add_test(NAME guest_addresses COMMAND guest_address_tests)
if(WIN32)
set_tests_properties(guest_addresses PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
endif()
add_executable(guest_error_tests tests/GuestErrors.cpp)
target_include_directories(guest_error_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_error_tests PRIVATE libc)
configure_windows_unwind(guest_error_tests)
add_test(NAME guest_errors COMMAND guest_error_tests)
if(WIN32)
set_tests_properties(guest_errors PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_executable(guest_random_tests tests/GuestRandom.cpp)
target_include_directories(guest_random_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_random_tests PRIVATE libSceRandom)
add_test(NAME guest_random COMMAND guest_random_tests)
if(WIN32)
set_tests_properties(guest_random PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceRandom>")
endif()
add_executable(guest_resolver_tests tests/GuestResolver.cpp)
target_include_directories(guest_resolver_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_resolver_tests PRIVATE libScePosixForWebKit)
add_test(NAME guest_resolver COMMAND guest_resolver_tests)
if(WIN32)
set_tests_properties(guest_resolver PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libScePosixForWebKit>")
endif()
add_executable(guest_rtc_tests tests/GuestRtc.cpp)
target_include_directories(guest_rtc_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_rtc_tests PRIVATE libSceRtc)
add_test(NAME guest_rtc COMMAND guest_rtc_tests)
if(WIN32)
set_tests_properties(guest_rtc PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceRtc>")
endif()
add_executable(guest_font_tests tests/GuestFont.cpp)
target_include_directories(guest_font_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_font_tests PRIVATE libSceFont libSceFontFt libc)
add_test(NAME guest_font COMMAND guest_font_tests)
if(WIN32)
set_tests_properties(guest_font PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceFont>")
endif()
add_executable(guest_json_tests tests/GuestJson.cpp)
target_include_directories(guest_json_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_json_tests PRIVATE libSceJson2 libc)
add_test(NAME guest_json COMMAND guest_json_tests)
if(WIN32)
set_tests_properties(guest_json PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceJson2>")
endif()
add_executable(fiber_tests tests/Fiber.cpp)
target_include_directories(fiber_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(fiber_tests PRIVATE libSceFiber libc)
add_test(NAME fiber COMMAND fiber_tests)
if(WIN32)
set_tests_properties(fiber PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceFiber>")
endif()
add_executable(mspace_tests tests/Mspace.cpp)
target_include_directories(mspace_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(mspace_tests PRIVATE libc)
configure_windows_unwind(mspace_tests)
add_test(NAME mspace COMMAND mspace_tests)
if(WIN32)
set_tests_properties(mspace PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_executable(guest_memory_tests tests/GuestMemory.cpp)
target_include_directories(guest_memory_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_memory_tests PRIVATE libkernel libc)
configure_windows_unwind(guest_memory_tests)
add_test(NAME guest_memory COMMAND guest_memory_tests)
if(WIN32)
set_tests_properties(guest_memory PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
endif()
if(NOT WIN32)
add_executable(guest_directory_entry_tests tests/GuestDirectoryEntries.cpp)
target_include_directories(guest_directory_entry_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_directory_entry_tests PRIVATE libkernel libc)
add_test(NAME guest_directory_entries COMMAND guest_directory_entry_tests)
endif()
add_executable(guest_search_tests tests/GuestSearch.cpp)
target_include_directories(guest_search_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_search_tests PRIVATE libc)
configure_windows_unwind(guest_search_tests)
add_test(NAME guest_search COMMAND guest_search_tests)
if(WIN32)
set_tests_properties(guest_search PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_executable(guest_string_tests tests/GuestStrings.cpp)
target_include_directories(guest_string_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_string_tests PRIVATE libc libScePosixForWebKit)
configure_windows_unwind(guest_string_tests)
add_test(NAME guest_strings COMMAND guest_string_tests)
if(WIN32)
set_tests_properties(guest_strings PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
if(UNIX)
add_executable(exception_runtime_tests tests/ExceptionRuntime.cpp)
target_include_directories(exception_runtime_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(exception_runtime_tests PRIVATE libc)
add_test(NAME exception_runtime COMMAND exception_runtime_tests)
endif()
endif()
add_executable(application_heap_tests EXCLUDE_FROM_ALL tests/ApplicationHeap.cpp)
target_include_directories(application_heap_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(application_heap_tests PRIVATE libc)
configure_windows_unwind(application_heap_tests)
set_target_properties(application_heap_tests PROPERTIES CXX_EXTENSIONS OFF)
if(BUILD_TESTING)
set_target_properties(application_heap_tests PROPERTIES EXCLUDE_FROM_ALL FALSE)
add_test(NAME application_heap_replacement COMMAND application_heap_tests)
add_test(NAME application_heap_invalid_metadata COMMAND application_heap_tests invalid)
add_test(NAME application_heap_default COMMAND application_heap_tests default)
if(WIN32)
set_tests_properties(application_heap_replacement application_heap_invalid_metadata application_heap_default
PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
endif()
add_executable(guest_locale_tests EXCLUDE_FROM_ALL tests/GuestLocale.cpp)
target_include_directories(guest_locale_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(guest_locale_tests PROPERTIES CXX_EXTENSIONS OFF)
target_link_libraries(guest_locale_tests PRIVATE libc)
configure_windows_unwind(guest_locale_tests)
if(MINGW)
foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static)
string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
endforeach()
add_executable(windows_exception_tests EXCLUDE_FROM_ALL tests/WindowsExceptions.cpp)
set_target_properties(windows_exception_tests PROPERTIES CXX_EXTENSIONS OFF)
target_link_libraries(windows_exception_tests PRIVATE libc)
configure_windows_unwind(windows_exception_tests)
endif()
+18
View File
@@ -0,0 +1,18 @@
#ifndef CORE_LIBS_HITLOG_HPP
#define CORE_LIBS_HITLOG_HPP
#include <atomic>
#include <cstdio>
// Logs the first three calls of the surrounding call site, then stays silent (keeps guest logs usable).
#define APS5_HIT(tag, ...) \
do { \
static std::atomic<int> aps5HitCount{0}; \
if (aps5HitCount.fetch_add(1, std::memory_order_relaxed) < 3) { \
std::fprintf(stderr, "[" tag "] " __VA_ARGS__); \
std::fputc('\n', stderr); \
std::fflush(stderr); \
} \
} while (0)
#endif
+91
View File
@@ -0,0 +1,91 @@
#ifndef CORE_LIBS_SCE_SHADERS_HPP
#define CORE_LIBS_SCE_SHADERS_HPP
#include <cstdint>
struct ShaderSharp {
std::uint16_t offset_dw : 15;
std::uint16_t size : 1;
};
struct ShaderRegister {
std::uint32_t offset;
std::uint32_t value;
};
struct ShaderUserData {
std::uint16_t* direct_resource_offset;
ShaderSharp* sharp_resource_offset[4];
std::uint16_t eud_size_dw;
std::uint16_t srt_size_dw;
std::uint16_t direct_resource_count;
std::uint16_t sharp_resource_count[4];
};
struct ShaderRegisterRange {
std::uint16_t start;
std::uint16_t end;
};
struct ShaderDrawModifier {
std::uint32_t enbl_start_vertex_offset : 1;
std::uint32_t enbl_start_index_offset : 1;
std::uint32_t enbl_start_instance_offset : 1;
std::uint32_t enbl_draw_index : 1;
std::uint32_t enbl_user_vgprs : 1;
std::uint32_t render_target_slice_offset : 3;
std::uint32_t fuse_draws : 1;
std::uint32_t compiler_flags : 23;
std::uint32_t is_default : 1;
std::uint32_t reserved : 31;
};
struct ShaderSpecialRegs {
ShaderRegister ge_cntl;
ShaderRegister vgt_shader_stages_en;
std::uint32_t dispatch_modifier;
ShaderRegisterRange user_data_range;
ShaderDrawModifier draw_modifier;
ShaderRegister vgt_gs_out_prim_type;
ShaderRegister ge_user_vgpr_en;
};
struct ShaderSemantic {
std::uint32_t semantic : 8;
std::uint32_t hardware_mapping : 8;
std::uint32_t size_in_elements : 4;
std::uint32_t is_f16 : 2;
std::uint32_t is_flat_shaded : 1;
std::uint32_t is_linear : 1;
std::uint32_t is_custom : 1;
std::uint32_t static_vb_index : 1;
std::uint32_t static_attribute : 1;
std::uint32_t reserved : 1;
std::uint32_t default_value : 2;
std::uint32_t default_value_hi : 2;
};
struct Shader {
std::uint32_t file_header;
std::uint32_t version;
ShaderUserData* user_data;
const volatile void* code;
ShaderRegister* cx_registers;
ShaderRegister* sh_registers;
ShaderSpecialRegs* specials;
ShaderSemantic* input_semantics;
ShaderSemantic* output_semantics;
std::uint32_t header_size;
std::uint32_t shader_size;
std::uint32_t embedded_constant_buffer_size_dqw;
std::uint32_t target;
std::uint32_t num_input_semantics;
std::uint16_t scratch_size_dw_per_thread;
std::uint16_t num_output_semantics;
std::uint16_t special_sizes_bytes;
std::uint8_t type;
std::uint8_t num_cx_registers;
std::uint8_t num_sh_registers;
};
#endif
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,15 @@
#ifndef NID_BINARYPATCHERFACTORY_HPP
#define NID_BINARYPATCHERFACTORY_HPP
#include <nid/IBinaryPatcher.hpp>
#include <cstdint>
#include <memory>
#include <vector>
namespace Nid {
std::unique_ptr<IBinaryPatcher> MakePatcher(const std::vector<std::uint8_t>& binary);
}
#endif
+103
View File
@@ -0,0 +1,103 @@
#ifndef NID_ELFPATCHER_HPP
#define NID_ELFPATCHER_HPP
#include <nid/IBinaryPatcher.hpp>
namespace Nid {
struct Elf64_Ehdr {
std::uint8_t e_ident[16];
std::uint16_t e_type;
std::uint16_t e_machine;
std::uint32_t e_version;
std::uint64_t e_entry;
std::uint64_t e_phoff;
std::uint64_t e_shoff;
std::uint32_t e_flags;
std::uint16_t e_ehsize;
std::uint16_t e_phentsize;
std::uint16_t e_phnum;
std::uint16_t e_shentsize;
std::uint16_t e_shnum;
std::uint16_t e_shstrndx;
};
struct Elf64_Shdr {
std::uint32_t sh_name;
std::uint32_t sh_type;
std::uint64_t sh_flags;
std::uint64_t sh_addr;
std::uint64_t sh_offset;
std::uint64_t sh_size;
std::uint32_t sh_link;
std::uint32_t sh_info;
std::uint64_t sh_addralign;
std::uint64_t sh_entsize;
};
struct Elf64_Sym {
std::uint32_t st_name;
std::uint8_t st_info;
std::uint8_t st_other;
std::uint16_t st_shndx;
std::uint64_t st_value;
std::uint64_t st_size;
};
struct Elf64_Rela {
std::uint64_t r_offset;
std::uint64_t r_info;
std::int64_t r_addend;
};
struct Elf64_Dyn {
std::int64_t d_tag;
std::uint64_t d_val;
};
struct Elf64_Verneed {
std::uint16_t vn_version;
std::uint16_t vn_cnt;
std::uint32_t vn_file;
std::uint32_t vn_aux;
std::uint32_t vn_next;
};
struct Elf64_Vernaux {
std::uint32_t vna_hash;
std::uint16_t vna_flags;
std::uint16_t vna_other;
std::uint32_t vna_name;
std::uint32_t vna_next;
};
struct GnuHashLayout {
std::uint32_t NBuckets;
std::uint32_t SymOffset;
std::uint32_t BloomSize;
std::uint32_t BloomShift;
std::size_t BloomOffset;
std::size_t BucketsOffset;
std::size_t ChainOffset;
};
constexpr std::int64_t kDtNeeded = 1;
constexpr std::int64_t kDtSoname = 14;
constexpr std::int64_t kDtNull = 0;
constexpr std::uint32_t kShtDynamic = 6u;
constexpr std::uint32_t kShtGnuVerneed = 0x6ffffffeu;
constexpr std::uint32_t kShtDynsym = 11u;
constexpr std::uint32_t kShtGnuHash = 0x6ffffff6u;
constexpr std::uint32_t kShtRela = 4u;
constexpr std::uint32_t kShtGnuVersym = 0x6fffffffu;
constexpr std::uint8_t kStbLocal = 0u;
constexpr std::uint16_t kShnUndef = 0u;
class ElfNidPatcher final : public IBinaryPatcher {
public:
void PatchNids(std::vector<std::uint8_t>& binary, const std::string& libraryName, const std::unordered_set<std::string>& excludedExports) const override;
};
}
#endif
@@ -0,0 +1,14 @@
#ifndef NID_EXPORTEXCLUSIONS_HPP
#define NID_EXPORTEXCLUSIONS_HPP
#include <string>
#include <unordered_set>
namespace Nid {
std::string NormalizeExportName(const std::string& name);
std::unordered_set<std::string> ReadExportExclusions(const std::string& path);
}
#endif
@@ -0,0 +1,20 @@
#ifndef NID_IBINARYPATCHER_HPP
#define NID_IBINARYPATCHER_HPP
#include <cstdint>
#include <string>
#include <unordered_set>
#include <vector>
namespace Nid {
class IBinaryPatcher {
public:
virtual ~IBinaryPatcher() = default;
virtual void PatchNids(std::vector<std::uint8_t>& binary, const std::string& libraryName, const std::unordered_set<std::string>& excludedExports) const = 0;
};
}
#endif
+12
View File
@@ -0,0 +1,12 @@
#ifndef NID_NIDCOMPUTE_HPP
#define NID_NIDCOMPUTE_HPP
#include <string>
namespace Nid {
std::string ComputeNid(const std::string& symbolName, const std::string& libraryName);
}
#endif
@@ -0,0 +1,87 @@
#ifndef NID_NIDPATCHERUTILS_HPP
#define NID_NIDPATCHERUTILS_HPP
#include <algorithm>
#include <cctype>
#include <cstdint>
#include <cstring>
#include <stdexcept>
#include <string>
#include <vector>
namespace Nid {
namespace Internal {
constexpr char kNidPostfix[] = "_nid_postfix";
constexpr std::size_t kNidPostfixLen = sizeof(kNidPostfix) - 1u;
constexpr char kNidNoPatch[] = "_nid_no_patch";
constexpr std::size_t kNidNoPatchLen = sizeof(kNidNoPatch) - 1u;
constexpr char kNidNoPatchCut[] = "_nid_no_patch_cut";
constexpr std::size_t kNidNoPatchCutLen = sizeof(kNidNoPatchCut) - 1u;
constexpr char kNidDisambigMarker[] = "_nid_disambig";
constexpr std::size_t kNidDisambigMarkerLen = sizeof(kNidDisambigMarker) - 1u;
constexpr char kSDLPrefix[] = "SDL_";
constexpr std::size_t kSDLPrefixLen = sizeof(kSDLPrefix) - 1u;
inline bool IsNidNoPatch(const std::string& name) {
return (
name.size() >= kNidNoPatchLen &&
name.compare(name.size() - kNidNoPatchLen, kNidNoPatchLen, kNidNoPatch) == 0
) || name.compare(0, kSDLPrefixLen, kSDLPrefix) == 0;
}
inline bool IsNidNoPatchCut(const std::string& name) {
return name.size() >= kNidNoPatchCutLen &&
name.compare(name.size() - kNidNoPatchCutLen, kNidNoPatchCutLen, kNidNoPatchCut) == 0;
}
inline std::string StripNidNoPatchCut(const std::string& name) {
return name.substr(0u, name.size() - kNidNoPatchCutLen);
}
inline std::string StripNidPostfix(const std::string& name) {
std::string result = name;
if (result.size() >= kNidPostfixLen &&
result.compare(result.size() - kNidPostfixLen, kNidPostfixLen, kNidPostfix) == 0) {
result.resize(result.size() - kNidPostfixLen);
}
const auto disambigPos = result.rfind(kNidDisambigMarker);
if (disambigPos != std::string::npos) {
const auto suffixStart = disambigPos + kNidDisambigMarkerLen;
const bool allDigits = std::all_of(
result.begin() + static_cast<std::ptrdiff_t>(suffixStart), result.end(),
[](unsigned char c) { return std::isdigit(c) != 0; }
);
if (allDigits && suffixStart < result.size())
result.resize(disambigPos);
}
return result;
}
template<typename T>
T Read(const std::vector<std::uint8_t>& buf, std::size_t offset) {
if (offset + sizeof(T) > buf.size()) throw std::runtime_error("read out of bounds");
T v;
std::memcpy(&v, buf.data() + offset, sizeof(T));
return v;
}
template<typename T>
void Write(std::vector<std::uint8_t>& buf, std::size_t offset, const T& v) {
if (offset + sizeof(T) > buf.size()) throw std::runtime_error("write out of bounds");
std::memcpy(buf.data() + offset, &v, sizeof(T));
}
inline std::string ReadCStr(const std::vector<std::uint8_t>& buf, std::size_t offset) {
if (offset >= buf.size()) throw std::runtime_error("cstr offset out of bounds");
std::string s;
while (offset < buf.size() && buf[offset] != 0u)
s.push_back(static_cast<char>(buf[offset++]));
return s;
}
}
}
#endif
+17
View File
@@ -0,0 +1,17 @@
#ifndef NID_NIDRESOLVER_HPP
#define NID_NIDRESOLVER_HPP
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
namespace Nid {
std::string ResolveOneName(const std::string& funcName);
std::unordered_map<std::string, std::string> ResolveNids(const std::vector<std::string>& exportedNames, const std::string& libraryName, const std::unordered_set<std::string>& excludedExports);
}
#endif
@@ -0,0 +1,47 @@
#ifndef CORE_LIBS_NID_PENIDPATCHER_HPP
#define CORE_LIBS_NID_PENIDPATCHER_HPP
#include <nid/IBinaryPatcher.hpp>
namespace Nid {
struct PeDataDirectory {
std::uint32_t VirtualAddress;
std::uint32_t Size;
};
struct PeExportDirectory {
std::uint32_t Characteristics;
std::uint32_t TimeDateStamp;
std::uint16_t MajorVersion;
std::uint16_t MinorVersion;
std::uint32_t Name;
std::uint32_t Base;
std::uint32_t NumberOfFunctions;
std::uint32_t NumberOfNames;
std::uint32_t AddressOfFunctions;
std::uint32_t AddressOfNames;
std::uint32_t AddressOfNameOrdinals;
};
struct PeSectionHeader {
std::uint8_t Name[8];
std::uint32_t VirtualSize;
std::uint32_t VirtualAddress;
std::uint32_t SizeOfRawData;
std::uint32_t PointerToRawData;
std::uint32_t PointerToRelocations;
std::uint32_t PointerToLinenumbers;
std::uint16_t NumberOfRelocations;
std::uint16_t NumberOfLinenumbers;
std::uint32_t Characteristics;
};
class PeNidPatcher final : public IBinaryPatcher {
public:
void PatchNids(std::vector<std::uint8_t>& binary, const std::string& libraryName, const std::unordered_set<std::string>& excludedExports) const override;
};
}
#endif
+14
View File
@@ -0,0 +1,14 @@
#ifndef NID_SHA1_HPP
#define NID_SHA1_HPP
#include <cstdint>
#include <array>
#include <vector>
namespace Nid {
std::array<std::uint8_t, 20> Sha1(const std::vector<std::uint8_t>& data);
}
#endif
@@ -0,0 +1,16 @@
#include <nid/BinaryPatcherFactory.hpp>
#include <nid/ElfPatcher.hpp>
#include <nid/PeNidPatcher.hpp>
#include <stdexcept>
namespace Nid {
std::unique_ptr<IBinaryPatcher> MakePatcher(const std::vector<std::uint8_t>& binary) {
if (binary.size() >= 4 && binary[0] == 0x7f && binary[1] == 'E' && binary[2] == 'L' && binary[3] == 'F')
return std::make_unique<ElfNidPatcher>();
if (binary.size() >= 2 && binary[0] == 'M' && binary[1] == 'Z')
return std::make_unique<PeNidPatcher>();
throw std::runtime_error("unrecognized binary format");
}
}
+497
View File
@@ -0,0 +1,497 @@
#include <nid/ElfPatcher.hpp>
#include <nid/NidResolver.hpp>
#include <nid/NidPatcherUtils.hpp>
#include <nid/NidCompute.hpp>
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <stdexcept>
#include <string>
#include <vector>
namespace Nid {
namespace {
std::uint32_t GnuHash(const std::string& name) {
std::uint32_t h = 5381u;
for (const unsigned char c : name)
h = h * 33u + c;
return h;
}
GnuHashLayout ReadGnuHashLayout(const std::vector<std::uint8_t>& elf, std::size_t sectionOffset) {
using namespace Internal;
GnuHashLayout layout{};
layout.NBuckets = Read<std::uint32_t>(elf, sectionOffset + 0u);
layout.SymOffset = Read<std::uint32_t>(elf, sectionOffset + 4u);
layout.BloomSize = Read<std::uint32_t>(elf, sectionOffset + 8u);
layout.BloomShift = Read<std::uint32_t>(elf, sectionOffset + 12u);
layout.BloomOffset = sectionOffset + 16u;
layout.BucketsOffset = layout.BloomOffset + static_cast<std::size_t>(layout.BloomSize) * 8u;
layout.ChainOffset = layout.BucketsOffset + static_cast<std::size_t>(layout.NBuckets) * 4u;
return layout;
}
void ReorderDynSymForGnuHash(
std::vector<std::uint8_t>& elf,
std::size_t dynSymOffset,
std::size_t symCount,
std::uint32_t symOffset,
std::uint32_t bucketCount,
std::vector<std::string>& symbolNames,
std::vector<std::uint32_t>& oldToNewIndex
) {
using namespace Internal;
std::vector<std::uint32_t> movableIndices;
for (std::uint32_t i = symOffset; i < symCount; ++i)
movableIndices.push_back(i);
std::stable_sort(
movableIndices.begin(), movableIndices.end(),
[&](const std::uint32_t lhs, const std::uint32_t rhs) {
return GnuHash(symbolNames[lhs]) % bucketCount < GnuHash(symbolNames[rhs]) % bucketCount;
}
);
std::vector<Elf64_Sym> reorderedSyms(symCount);
std::vector<std::string> reorderedNames(symCount);
for (std::uint32_t i = 0u; i < symOffset; ++i) {
reorderedSyms[i] = Read<Elf64_Sym>(elf, dynSymOffset + i * sizeof(Elf64_Sym));
reorderedNames[i] = symbolNames[i];
oldToNewIndex[i] = i;
}
for (std::size_t position = 0u; position < movableIndices.size(); ++position) {
const std::uint32_t oldIndex = movableIndices[position];
const std::uint32_t newIndex = symOffset + static_cast<std::uint32_t>(position);
reorderedSyms[newIndex] = Read<Elf64_Sym>(elf, dynSymOffset + oldIndex * sizeof(Elf64_Sym));
reorderedNames[newIndex] = symbolNames[oldIndex];
oldToNewIndex[oldIndex] = newIndex;
}
for (std::size_t i = 0u; i < symCount; ++i)
Write(elf, dynSymOffset + i * sizeof(Elf64_Sym), reorderedSyms[i]);
symbolNames = std::move(reorderedNames);
}
void FixupRelocationSymbolIndices(
std::vector<std::uint8_t>& elf,
const Elf64_Ehdr& ehdr,
std::uint32_t dynSymSectionIndex,
const std::vector<std::uint32_t>& oldToNewIndex
) {
using namespace Internal;
for (std::uint16_t i = 0u; i < ehdr.e_shnum; ++i) {
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + i * sizeof(Elf64_Shdr);
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
if (shdr.sh_type != kShtRela) continue;
if (shdr.sh_link != dynSymSectionIndex) continue;
const std::size_t relaOffset = static_cast<std::size_t>(shdr.sh_offset);
const std::size_t relaCount = static_cast<std::size_t>(shdr.sh_size) / sizeof(Elf64_Rela);
for (std::size_t r = 0u; r < relaCount; ++r) {
const std::size_t entryOffset = relaOffset + r * sizeof(Elf64_Rela);
const auto rela = Read<Elf64_Rela>(elf, entryOffset);
const auto oldSymIndex = static_cast<std::uint32_t>(rela.r_info >> 32u);
if (oldSymIndex >= oldToNewIndex.size()) continue;
const std::uint32_t newSymIndex = oldToNewIndex[oldSymIndex];
const auto relType = static_cast<std::uint32_t>(rela.r_info & 0xffffffffu);
const std::uint64_t newInfo = (static_cast<std::uint64_t>(newSymIndex) << 32u) | relType;
Write(elf, entryOffset + offsetof(Elf64_Rela, r_info), newInfo);
}
}
}
void RebuildGnuHash(
std::vector<std::uint8_t>& elf,
std::size_t sectionOffset,
std::size_t sectionSize,
std::size_t symCount,
const std::vector<std::string>& symbolNames
) {
using namespace Internal;
const GnuHashLayout layout = ReadGnuHashLayout(elf, sectionOffset);
const std::size_t chainCount = symCount - layout.SymOffset;
const std::size_t requiredSize = layout.ChainOffset - sectionOffset + chainCount * 4u;
if (requiredSize > sectionSize)
throw std::runtime_error("gnu.hash section too small to rebuild in place");
std::vector<std::uint32_t> hashes(symCount, 0u);
for (std::size_t i = layout.SymOffset; i < symCount; ++i)
hashes[i] = GnuHash(symbolNames[i]);
std::vector<std::uint64_t> bloom(layout.BloomSize, 0u);
for (std::size_t i = layout.SymOffset; i < symCount; ++i) {
const std::uint32_t h = hashes[i];
const std::uint32_t wordIndex = (h / 64u) % layout.BloomSize;
const std::uint32_t bit1 = h % 64u;
const std::uint32_t bit2 = (h >> layout.BloomShift) % 64u;
bloom[wordIndex] |= (std::uint64_t{1} << bit1);
bloom[wordIndex] |= (std::uint64_t{1} << bit2);
}
std::vector<std::uint32_t> buckets(layout.NBuckets, 0u);
std::vector<std::uint32_t> chain(chainCount, 0u);
for (std::size_t i = layout.SymOffset; i < symCount; ++i) {
const std::uint32_t bucketIndex = hashes[i] % layout.NBuckets;
if (buckets[bucketIndex] == 0u)
buckets[bucketIndex] = static_cast<std::uint32_t>(i);
}
for (std::size_t i = layout.SymOffset; i < symCount; ++i) {
const std::uint32_t bucketIndex = hashes[i] % layout.NBuckets;
const bool isLastInBucket = (i + 1u == symCount) || (hashes[i + 1u] % layout.NBuckets != bucketIndex);
chain[i - layout.SymOffset] = isLastInBucket ? (hashes[i] | 1u) : (hashes[i] & ~std::uint32_t{1});
}
for (std::uint32_t bloomIndex = 0u; bloomIndex < layout.BloomSize; ++bloomIndex)
Write(elf, layout.BloomOffset + bloomIndex * 8u, bloom[bloomIndex]);
for (std::uint32_t bucketIndex = 0u; bucketIndex < layout.NBuckets; ++bucketIndex)
Write(elf, layout.BucketsOffset + bucketIndex * 4u, buckets[bucketIndex]);
for (std::size_t i = 0u; i < chainCount; ++i)
Write(elf, layout.ChainOffset + i * 4u, chain[i]);
if (requiredSize < sectionSize)
std::memset(elf.data() + sectionOffset + requiredSize, 0, sectionSize - requiredSize);
}
void RemapDynamicNeededOffsets(
std::vector<std::uint8_t>& elf,
const Elf64_Ehdr& ehdr,
const std::vector<std::pair<std::uint32_t, std::uint32_t>>& oldToNewOffset
) {
using namespace Internal;
for (std::uint16_t i = 0u; i < ehdr.e_shnum; ++i) {
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + i * sizeof(Elf64_Shdr);
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
if (shdr.sh_type != kShtDynamic) continue;
const std::size_t dynOffset = static_cast<std::size_t>(shdr.sh_offset);
const std::size_t dynCount = static_cast<std::size_t>(shdr.sh_size) / sizeof(Elf64_Dyn);
for (std::size_t d = 0u; d < dynCount; ++d) {
const std::size_t entryOffset = dynOffset + d * sizeof(Elf64_Dyn);
const auto dyn = Read<Elf64_Dyn>(elf, entryOffset);
if (dyn.d_tag != kDtNeeded && dyn.d_tag != kDtSoname) continue;
const auto oldNameOffset = static_cast<std::uint32_t>(dyn.d_val);
const auto mapped = std::find_if(
oldToNewOffset.begin(), oldToNewOffset.end(),
[&](const auto& entry) { return entry.first == oldNameOffset; }
);
if (mapped == oldToNewOffset.end()) continue;
Write(elf, entryOffset + offsetof(Elf64_Dyn, d_val), static_cast<std::uint64_t>(mapped->second));
}
}
}
void RemapVerneedOffsets(
std::vector<std::uint8_t>& elf,
const Elf64_Ehdr& ehdr,
const std::vector<std::pair<std::uint32_t, std::uint32_t>>& oldToNewOffset
) {
using namespace Internal;
for (std::uint16_t i = 0u; i < ehdr.e_shnum; ++i) {
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + i * sizeof(Elf64_Shdr);
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
if (shdr.sh_type != kShtGnuVerneed) continue;
const std::size_t verneedOffset = static_cast<std::size_t>(shdr.sh_offset);
std::size_t entryOffset = verneedOffset;
while (true) {
const auto verneed = Read<Elf64_Verneed>(elf, entryOffset);
const auto mappedFile = std::find_if(
oldToNewOffset.begin(), oldToNewOffset.end(),
[&](const auto& entry) { return entry.first == verneed.vn_file; }
);
if (mappedFile != oldToNewOffset.end())
Write(elf, entryOffset + offsetof(Elf64_Verneed, vn_file), mappedFile->second);
std::size_t auxOffset = entryOffset + verneed.vn_aux;
for (std::uint16_t a = 0u; a < verneed.vn_cnt; ++a) {
const auto vernaux = Read<Elf64_Vernaux>(elf, auxOffset);
const auto mappedName = std::find_if(
oldToNewOffset.begin(), oldToNewOffset.end(),
[&](const auto& entry) { return entry.first == vernaux.vna_name; }
);
if (mappedName != oldToNewOffset.end())
Write(elf, auxOffset + offsetof(Elf64_Vernaux, vna_name), mappedName->second);
if (vernaux.vna_next == 0u) break;
auxOffset += vernaux.vna_next;
}
if (verneed.vn_next == 0u) break;
entryOffset += verneed.vn_next;
}
}
}
std::vector<std::uint32_t> CollectDynamicNameOffsets(const std::vector<std::uint8_t>& elf, const Elf64_Ehdr& ehdr) {
using namespace Internal;
std::vector<std::uint32_t> offsets;
for (std::uint16_t i = 0u; i < ehdr.e_shnum; ++i) {
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + i * sizeof(Elf64_Shdr);
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
if (shdr.sh_type != kShtDynamic) continue;
const std::size_t dynOffset = static_cast<std::size_t>(shdr.sh_offset);
const std::size_t dynCount = static_cast<std::size_t>(shdr.sh_size) / sizeof(Elf64_Dyn);
for (std::size_t d = 0u; d < dynCount; ++d) {
const auto dyn = Read<Elf64_Dyn>(elf, dynOffset + d * sizeof(Elf64_Dyn));
if (dyn.d_tag == kDtNull) break;
if (dyn.d_tag != kDtNeeded && dyn.d_tag != kDtSoname) continue;
offsets.push_back(static_cast<std::uint32_t>(dyn.d_val));
}
}
return offsets;
}
std::vector<std::uint32_t> CollectVerneedNameOffsets(const std::vector<std::uint8_t>& elf, const Elf64_Ehdr& ehdr) {
using namespace Internal;
std::vector<std::uint32_t> offsets;
for (std::uint16_t i = 0u; i < ehdr.e_shnum; ++i) {
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + i * sizeof(Elf64_Shdr);
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
if (shdr.sh_type != kShtGnuVerneed) continue;
std::size_t entryOffset = static_cast<std::size_t>(shdr.sh_offset);
while (true) {
const auto verneed = Read<Elf64_Verneed>(elf, entryOffset);
offsets.push_back(verneed.vn_file);
std::size_t auxOffset = entryOffset + verneed.vn_aux;
for (std::uint16_t a = 0u; a < verneed.vn_cnt; ++a) {
const auto vernaux = Read<Elf64_Vernaux>(elf, auxOffset);
offsets.push_back(vernaux.vna_name);
if (vernaux.vna_next == 0u) break;
auxOffset += vernaux.vna_next;
}
if (verneed.vn_next == 0u) break;
entryOffset += verneed.vn_next;
}
}
return offsets;
}
}
void ElfNidPatcher::PatchNids(std::vector<std::uint8_t>& elf, const std::string& libraryName, const std::unordered_set<std::string>& excludedExports) const {
using namespace Internal;
if (elf.size() < sizeof(Elf64_Ehdr)) throw std::runtime_error("file too small");
if (elf[4] != 2) throw std::runtime_error("not ELF64");
const auto ehdr = Read<Elf64_Ehdr>(elf, 0u);
std::size_t dynSymOffset = 0u, dynSymSize = 0u;
std::size_t gnuHashOffset = 0u, gnuHashSize = 0u;
std::size_t versymOffset = 0u;
std::uint32_t dynSymSectionIndex = 0u;
std::uint32_t gnuHashSymOffset = 0u;
for (std::uint16_t i = 0u; i < ehdr.e_shnum; ++i) {
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + i * sizeof(Elf64_Shdr);
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
if (shdr.sh_type == kShtDynsym) {
dynSymOffset = static_cast<std::size_t>(shdr.sh_offset);
dynSymSize = static_cast<std::size_t>(shdr.sh_size);
dynSymSectionIndex = i;
}
if (shdr.sh_type == kShtGnuHash) {
gnuHashOffset = static_cast<std::size_t>(shdr.sh_offset);
gnuHashSize = static_cast<std::size_t>(shdr.sh_size);
gnuHashSymOffset = Read<std::uint32_t>(elf, gnuHashOffset + 4u);
}
if (shdr.sh_type == kShtGnuVersym)
versymOffset = static_cast<std::size_t>(shdr.sh_offset);
}
if (dynSymOffset == 0u) throw std::runtime_error("no .dynsym section");
const std::size_t symCount = dynSymSize / sizeof(Elf64_Sym);
if (symCount == 0u) throw std::runtime_error(".dynsym is empty");
const std::size_t dynStrSectionLink = [&]() -> std::size_t {
for (std::uint16_t i = 0u; i < ehdr.e_shnum; ++i) {
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + i * sizeof(Elf64_Shdr);
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
if (shdr.sh_type == kShtDynsym) return static_cast<std::size_t>(shdr.sh_link);
}
throw std::runtime_error("cannot find dynsym sh_link");
}();
std::size_t dynStrOffset = 0u, dynStrSize = 0u;
{
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + dynStrSectionLink * sizeof(Elf64_Shdr);
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
dynStrOffset = static_cast<std::size_t>(shdr.sh_offset);
dynStrSize = static_cast<std::size_t>(shdr.sh_size);
}
if (dynStrOffset == 0u) throw std::runtime_error("no .dynstr section");
const std::vector<std::uint8_t> origDynStr(
elf.begin() + static_cast<std::ptrdiff_t>(dynStrOffset),
elf.begin() + static_cast<std::ptrdiff_t>(dynStrOffset + dynStrSize)
);
std::vector<std::string> exportedNames;
for (std::size_t i = 1u; i < symCount; ++i) {
const std::size_t symOffset = dynSymOffset + i * sizeof(Elf64_Sym);
const auto sym = Read<Elf64_Sym>(elf, symOffset);
if (sym.st_name == 0u) continue;
const std::uint8_t binding = sym.st_info >> 4u;
if (binding == kStbLocal || sym.st_shndx == kShnUndef) continue;
const std::string symName = ReadCStr(origDynStr, sym.st_name);
if (symName.empty()) continue;
exportedNames.push_back(symName);
}
const auto nidMap = ResolveNids(exportedNames, libraryName, excludedExports);
struct SymbolNameUse {
std::size_t symIndex;
std::uint32_t oldNameOffset;
std::string newValue;
};
std::vector<SymbolNameUse> uses;
for (std::size_t i = 1u; i < symCount; ++i) {
const std::size_t symOffset = dynSymOffset + i * sizeof(Elf64_Sym);
const auto sym = Read<Elf64_Sym>(elf, symOffset);
if (sym.st_name == 0u) continue;
const std::uint8_t binding = sym.st_info >> 4u;
const bool isPatchable = binding != kStbLocal && sym.st_shndx != kShnUndef;
const std::string symName = ReadCStr(origDynStr, sym.st_name);
if (symName.empty()) continue;
std::string newValue = symName;
if (isPatchable) {
const auto it = nidMap.find(symName);
if (it != nidMap.end())
newValue = it->second;
} else if (binding != kStbLocal && sym.st_shndx == kShnUndef) {
const bool isUnversioned = versymOffset == 0u ||
(Read<std::uint16_t>(elf, versymOffset + i * sizeof(std::uint16_t)) <= 1u);
const bool hasNidPostfix = symName.size() >= kNidPostfixLen &&
symName.compare(symName.size() - kNidPostfixLen, kNidPostfixLen, kNidPostfix) == 0;
const bool hasScePrefix = symName.size() >= 3u &&
std::tolower(static_cast<unsigned char>(symName[0])) == 's' &&
std::tolower(static_cast<unsigned char>(symName[1])) == 'c' &&
std::tolower(static_cast<unsigned char>(symName[2])) == 'e';
if (isUnversioned && (hasNidPostfix || hasScePrefix))
newValue = ResolveOneName(symName);
}
uses.push_back(SymbolNameUse{i, sym.st_name, newValue});
}
std::vector<std::uint8_t> newDynStr;
newDynStr.push_back(0u);
std::vector<std::pair<std::uint32_t, std::uint32_t>> oldToNewOffset;
for (const auto& use : uses) {
const auto existing = std::find_if(
oldToNewOffset.begin(), oldToNewOffset.end(),
[&](const auto& entry) { return entry.first == use.oldNameOffset; }
);
if (existing != oldToNewOffset.end()) continue;
const auto newOffset = static_cast<std::uint32_t>(newDynStr.size());
newDynStr.insert(newDynStr.end(), use.newValue.begin(), use.newValue.end());
newDynStr.push_back(0u);
oldToNewOffset.emplace_back(use.oldNameOffset, newOffset);
}
std::vector<std::uint32_t> preservedOffsets = CollectDynamicNameOffsets(elf, ehdr);
const std::vector<std::uint32_t> verneedOffsets = CollectVerneedNameOffsets(elf, ehdr);
preservedOffsets.insert(preservedOffsets.end(), verneedOffsets.begin(), verneedOffsets.end());
for (const auto oldOffset : preservedOffsets) {
const auto existing = std::find_if(
oldToNewOffset.begin(), oldToNewOffset.end(),
[&](const auto& entry) { return entry.first == oldOffset; }
);
if (existing != oldToNewOffset.end()) continue;
const std::string preservedValue = ReadCStr(origDynStr, oldOffset);
const auto newOffset = static_cast<std::uint32_t>(newDynStr.size());
newDynStr.insert(newDynStr.end(), preservedValue.begin(), preservedValue.end());
newDynStr.push_back(0u);
oldToNewOffset.emplace_back(oldOffset, newOffset);
}
if (newDynStr.size() > dynStrSize) {
throw std::runtime_error(
"rebuilt .dynstr (" + std::to_string(newDynStr.size()) + " bytes) exceeds original section size (" +
std::to_string(dynStrSize) + " bytes) - relinking with a larger section is required"
);
}
newDynStr.resize(dynStrSize, 0u);
std::vector<std::string> newSymbolNames(symCount);
for (std::size_t i = 1u; i < symCount; ++i) {
const std::size_t symOffset = dynSymOffset + i * sizeof(Elf64_Sym);
const auto sym = Read<Elf64_Sym>(elf, symOffset);
if (sym.st_name == 0u) continue;
const auto mapped = std::find_if(
oldToNewOffset.begin(), oldToNewOffset.end(),
[&](const auto& entry) { return entry.first == sym.st_name; }
);
if (mapped == oldToNewOffset.end()) continue;
newSymbolNames[i] = ReadCStr(newDynStr, mapped->second);
Write(elf, symOffset + offsetof(Elf64_Sym, st_name), mapped->second);
}
std::memcpy(elf.data() + dynStrOffset, newDynStr.data(), newDynStr.size());
RemapDynamicNeededOffsets(elf, ehdr, oldToNewOffset);
RemapVerneedOffsets(elf, ehdr, oldToNewOffset);
if (gnuHashOffset != 0u) {
const auto bucketCount = Read<std::uint32_t>(elf, gnuHashOffset);
std::vector<std::uint32_t> oldToNewIndex(symCount);
ReorderDynSymForGnuHash(elf, dynSymOffset, symCount, gnuHashSymOffset, bucketCount, newSymbolNames, oldToNewIndex);
FixupRelocationSymbolIndices(elf, ehdr, dynSymSectionIndex, oldToNewIndex);
RebuildGnuHash(elf, gnuHashOffset, gnuHashSize, symCount, newSymbolNames);
}
}
}
+137
View File
@@ -0,0 +1,137 @@
#include <nid/ExportExclusions.hpp>
#include <nid/ElfPatcher.hpp>
#include <nid/PeNidPatcher.hpp>
#include <nid/NidPatcherUtils.hpp>
#include <bit>
#include <cstring>
#include <fstream>
#include <stdexcept>
namespace Nid {
namespace {
void RequireRange(const std::vector<std::uint8_t>& binary, std::uint64_t offset, std::uint64_t size) {
if (offset > binary.size() || size > binary.size() - offset) throw std::runtime_error("export reference range out of bounds");
}
template<typename TValue>
TValue ReadValue(const std::vector<std::uint8_t>& binary, std::uint64_t offset) {
RequireRange(binary, offset, sizeof(TValue));
TValue value;
std::memcpy(&value, binary.data() + offset, sizeof(value));
return value;
}
std::string ReadName(const std::vector<std::uint8_t>& binary, std::uint64_t offset, std::uint64_t size) {
RequireRange(binary, offset, size);
if (size == 0) throw std::runtime_error("empty export reference name range");
const auto start = reinterpret_cast<const char*>(binary.data() + offset);
const auto end = static_cast<const char*>(std::memchr(start, 0, size));
if (!end || end == start) throw std::runtime_error("invalid export reference name");
return {start, end};
}
std::unordered_set<std::string> ReadPeExports(const std::vector<std::uint8_t>& binary) {
const std::uint64_t header = ReadValue<std::uint32_t>(binary, 0x3c);
if (ReadValue<std::uint32_t>(binary, header) != 0x4550) throw std::runtime_error("invalid reference PE signature");
const auto sectionCount = ReadValue<std::uint16_t>(binary, header + 6);
const auto optionalSize = ReadValue<std::uint16_t>(binary, header + 20);
const auto optional = header + 24;
RequireRange(binary, optional, optionalSize);
const auto magic = ReadValue<std::uint16_t>(binary, optional);
if (magic != 0x20b && magic != 0x10b) throw std::runtime_error("unsupported reference PE optional header");
const std::uint64_t directoryOffset = magic == 0x20b ? 112 : 96;
if (optionalSize < directoryOffset + sizeof(PeDataDirectory)) throw std::runtime_error("missing reference PE export directory");
if (ReadValue<std::uint32_t>(binary, optional + directoryOffset - 4) == 0) throw std::runtime_error("missing reference PE data directories");
const auto directory = ReadValue<PeDataDirectory>(binary, optional + directoryOffset);
if (!directory.VirtualAddress || directory.Size < sizeof(PeExportDirectory)) throw std::runtime_error("missing reference PE exports");
const auto sections = optional + optionalSize;
RequireRange(binary, sections, std::uint64_t{sectionCount} * sizeof(PeSectionHeader));
const auto mapRva = [&](std::uint32_t rva, std::uint64_t size) -> std::uint64_t {
for (std::uint16_t index = 0; index < sectionCount; ++index) {
const auto section = ReadValue<PeSectionHeader>(binary, sections + std::uint64_t{index} * sizeof(PeSectionHeader));
if (rva < section.VirtualAddress) continue;
const std::uint64_t relative = rva - section.VirtualAddress;
if (relative >= section.SizeOfRawData || size > section.SizeOfRawData - relative) continue;
const auto offset = std::uint64_t{section.PointerToRawData} + relative;
RequireRange(binary, offset, size);
return offset;
}
throw std::runtime_error("unmapped reference PE export RVA");
};
const auto table = ReadValue<PeExportDirectory>(binary, mapRva(directory.VirtualAddress, sizeof(PeExportDirectory)));
if (!table.NumberOfNames) throw std::runtime_error("reference PE has no named exports");
const auto names = mapRva(table.AddressOfNames, std::uint64_t{table.NumberOfNames} * 4);
std::unordered_set<std::string> result;
for (std::uint32_t index = 0; index < table.NumberOfNames; ++index) {
const auto rva = ReadValue<std::uint32_t>(binary, names + std::uint64_t{index} * 4);
const auto offset = mapRva(rva, 1);
auto name = ReadName(binary, offset, binary.size() - offset);
mapRva(rva, name.size() + 1);
if (!result.insert(name).second) throw std::runtime_error("duplicate reference export: " + name);
}
return result;
}
std::unordered_set<std::string> ReadElfExports(const std::vector<std::uint8_t>& binary) {
const auto header = ReadValue<Elf64_Ehdr>(binary, 0);
if (header.e_ident[4] != 2 || header.e_ident[5] != 1 || header.e_shentsize != sizeof(Elf64_Shdr)) throw std::runtime_error("unsupported reference ELF layout");
RequireRange(binary, header.e_shoff, std::uint64_t{header.e_shnum} * sizeof(Elf64_Shdr));
std::unordered_set<std::string> result;
for (std::uint16_t index = 0; index < header.e_shnum; ++index) {
const auto section = ReadValue<Elf64_Shdr>(binary, header.e_shoff + std::uint64_t{index} * sizeof(Elf64_Shdr));
if (section.sh_type != kShtDynsym) continue;
if (section.sh_entsize != sizeof(Elf64_Sym) || section.sh_size % sizeof(Elf64_Sym) || section.sh_link >= header.e_shnum) throw std::runtime_error("invalid reference ELF symbol table");
RequireRange(binary, section.sh_offset, section.sh_size);
const auto strings = ReadValue<Elf64_Shdr>(binary, header.e_shoff + std::uint64_t{section.sh_link} * sizeof(Elf64_Shdr));
if (strings.sh_type != 3) throw std::runtime_error("invalid reference ELF string table");
RequireRange(binary, strings.sh_offset, strings.sh_size);
for (std::uint64_t offset = 0; offset < section.sh_size; offset += sizeof(Elf64_Sym)) {
const auto symbol = ReadValue<Elf64_Sym>(binary, section.sh_offset + offset);
const auto binding = symbol.st_info >> 4;
const auto visibility = symbol.st_other & 3;
if (symbol.st_shndx == kShnUndef || (binding != 1 && binding != 2 && binding != 10) || (visibility != 0 && visibility != 3)) continue;
if (symbol.st_name >= strings.sh_size) throw std::runtime_error("invalid reference ELF export name");
result.insert(ReadName(binary, strings.sh_offset + symbol.st_name, strings.sh_size - symbol.st_name));
}
}
if (result.empty()) throw std::runtime_error("reference ELF has no exports");
return result;
}
}
std::string NormalizeExportName(const std::string& name) {
if (name.ends_with(Internal::kNidPostfix)) return name.substr(0, name.size() - Internal::kNidPostfixLen);
return name;
}
std::unordered_set<std::string> ReadExportExclusions(const std::string& path) {
if constexpr (std::endian::native != std::endian::little) throw std::runtime_error("export references require a little-endian host");
std::ifstream input(path, std::ios::binary | std::ios::ate);
if (!input) throw std::runtime_error("cannot open export reference: " + path);
const auto size = input.tellg();
if (size <= 0) throw std::runtime_error("empty or unreadable export reference: " + path);
std::vector<std::uint8_t> binary(static_cast<std::size_t>(size));
input.seekg(0);
if (!input.read(reinterpret_cast<char*>(binary.data()), static_cast<std::streamsize>(binary.size()))) throw std::runtime_error("cannot read export reference: " + path);
std::unordered_set<std::string> exports;
if (binary.size() >= 2 && binary[0] == 'M' && binary[1] == 'Z') {
exports = ReadPeExports(binary);
} else if (binary.size() >= 4 && binary[0] == 0x7f && binary[1] == 'E' && binary[2] == 'L' && binary[3] == 'F') {
exports = ReadElfExports(binary);
} else {
throw std::runtime_error("unrecognized export reference format: " + path);
}
std::unordered_set<std::string> result;
result.reserve(exports.size());
for (const auto& name : exports) {
auto normalized = NormalizeExportName(name);
if (normalized.empty()) throw std::runtime_error("empty normalized export reference name");
result.insert(std::move(normalized));
}
return result;
}
}
+54
View File
@@ -0,0 +1,54 @@
#include <nid/NidCompute.hpp>
#include <nid/Sha1.hpp>
#include <stdexcept>
#include <cstdint>
namespace Nid {
constexpr uint8_t kNidSuffix[16] = {
0x51, 0x8D, 0x64, 0xA6, 0x35, 0xDE, 0xD8, 0xC1,
0xE6, 0xB0, 0x39, 0xB1, 0xC3, 0xE5, 0x52, 0x30
};
constexpr char kBase64S[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-";
std::string ComputeNid(const std::string& symbolName, const std::string& libraryName) {
if (symbolName.empty())
throw std::invalid_argument("symbolName is empty");
std::vector<uint8_t> input;
input.reserve(symbolName.size() + 16u);
for (char c : symbolName)
input.push_back(static_cast<uint8_t>(c));
for (uint8_t b : kNidSuffix)
input.push_back(b);
const auto digest = Sha1(input);
uint8_t reversed[8];
for (int i = 0; i < 8; i++)
reversed[i] = digest[7 - i];
char nid[12];
int nidIndex = 0;
for (int i = 0; i < 6; i += 3) {
const uint32_t triple = (static_cast<uint32_t>(reversed[i]) << 16) |
(static_cast<uint32_t>(reversed[i + 1]) << 8) |
static_cast<uint32_t>(reversed[i + 2]);
nid[nidIndex++] = kBase64S[(triple >> 18) & 0x3F];
nid[nidIndex++] = kBase64S[(triple >> 12) & 0x3F];
nid[nidIndex++] = kBase64S[(triple >> 6) & 0x3F];
nid[nidIndex++] = kBase64S[triple & 0x3F];
}
const uint32_t tail = (static_cast<uint32_t>(reversed[6]) << 16) |
(static_cast<uint32_t>(reversed[7]) << 8);
nid[nidIndex++] = kBase64S[(tail >> 18) & 0x3F];
nid[nidIndex++] = kBase64S[(tail >> 12) & 0x3F];
nid[nidIndex++] = kBase64S[(tail >> 6) & 0x3F];
nid[11] = '\0';
return std::string(nid, 11);
}
}
+68
View File
@@ -0,0 +1,68 @@
#include <nid/NidResolver.hpp>
#include <nid/ExportExclusions.hpp>
#include <nid/NidCompute.hpp>
#include <nid/NidPatcherUtils.hpp>
#include <cstdint>
#include <stdexcept>
#include <unordered_set>
#include <vector>
namespace Nid {
std::string ResolveOneName(const std::string& funcName) {
using namespace Internal;
if (IsNidNoPatchCut(funcName))
return StripNidNoPatchCut(funcName);
if (IsNidNoPatch(funcName))
return funcName;
return ComputeNid(StripNidPostfix(funcName), "");
}
std::unordered_map<std::string, std::string> ResolveNids(const std::vector<std::string>& exportedNames, const std::string& libraryName, const std::unordered_set<std::string>& excludedExports) {
using namespace Internal;
std::unordered_set<std::string> nameSet(exportedNames.begin(), exportedNames.end());
if (nameSet.size() != exportedNames.size()) {
for (std::size_t i = 0u; i < exportedNames.size(); ++i) {
for (std::size_t j = i + 1u; j < exportedNames.size(); ++j) {
if (exportedNames[i] == exportedNames[j])
throw std::runtime_error("duplicate exported symbol \"" + exportedNames[i] + "\" in library \"" + libraryName + "\"");
}
}
}
std::unordered_map<std::string, std::string> result;
result.reserve(exportedNames.size());
for (const std::string& name : exportedNames) {
if (excludedExports.contains(NormalizeExportName(name))) {
result[name] = name;
continue;
}
if (IsNidNoPatchCut(name)) {
result[name] = StripNidNoPatchCut(name);
continue;
}
if (IsNidNoPatch(name)) {
result[name] = name;
continue;
}
const std::string stripped = StripNidPostfix(name);
const bool hasPostfix = stripped != name;
if (!hasPostfix && nameSet.count(name + kNidPostfix)) {
result[name] = name;
continue;
}
result[name] = ComputeNid(stripped, libraryName);
}
return result;
}
}
+253
View File
@@ -0,0 +1,253 @@
#include <nid/PeNidPatcher.hpp>
#include <nid/NidResolver.hpp>
#include <nid/NidPatcherUtils.hpp>
#include <nid/NidCompute.hpp>
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <limits>
#include <stdexcept>
#include <string>
#include <vector>
namespace Nid {
namespace {
std::size_t FindSectionOffsetByRva(const std::vector<std::uint8_t>& pe, std::uint32_t rva, std::uint32_t peHeaderOffset, std::uint16_t numberOfSections, std::uint32_t sizeOfOptionalHeader) {
const std::size_t sectionTableOffset = static_cast<std::size_t>(peHeaderOffset) + 4u + 20u + sizeOfOptionalHeader;
for (std::uint16_t i = 0u; i < numberOfSections; ++i) {
const std::size_t sectionOffset = sectionTableOffset + i * sizeof(PeSectionHeader);
if (sectionOffset + sizeof(PeSectionHeader) > pe.size()) throw std::runtime_error("section header out of bounds");
const auto section = Internal::Read<PeSectionHeader>(pe, sectionOffset);
const std::uint32_t effectiveSize = section.VirtualSize != 0u ? section.VirtualSize : section.SizeOfRawData;
if (rva >= section.VirtualAddress && rva < section.VirtualAddress + effectiveSize)
return sectionOffset;
}
throw std::runtime_error("rva not mapped to any section");
}
std::size_t RvaToOffset(const std::vector<std::uint8_t>& pe, std::uint32_t rva, std::uint32_t peHeaderOffset, std::uint16_t numberOfSections, std::uint32_t sizeOfOptionalHeader) {
const std::size_t sectionOffset = FindSectionOffsetByRva(pe, rva, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
const auto section = Internal::Read<PeSectionHeader>(pe, sectionOffset);
return static_cast<std::size_t>(section.PointerToRawData) + (rva - section.VirtualAddress);
}
}
void PeNidPatcher::PatchNids(std::vector<std::uint8_t>& pe, const std::string& libraryName, const std::unordered_set<std::string>& excludedExports) const {
using namespace Internal;
if (pe.size() < 0x40) throw std::runtime_error("file too small");
const auto peHeaderOffset = Read<std::uint32_t>(pe, 0x3cu);
if (static_cast<std::size_t>(peHeaderOffset) + 4u > pe.size()) throw std::runtime_error("invalid pe header offset");
if (pe[peHeaderOffset] != 'P' || pe[peHeaderOffset + 1u] != 'E' || pe[peHeaderOffset + 2u] != 0u || pe[peHeaderOffset + 3u] != 0u)
throw std::runtime_error("not a PE file");
const std::size_t coffHeaderOffset = static_cast<std::size_t>(peHeaderOffset) + 4u;
const auto numberOfSections = Read<std::uint16_t>(pe, coffHeaderOffset + 2u);
const auto sizeOfOptionalHeader = Read<std::uint16_t>(pe, coffHeaderOffset + 16u);
if (sizeOfOptionalHeader == 0u) throw std::runtime_error("no optional header");
const std::size_t sectionTableOffset = coffHeaderOffset + 20u + sizeOfOptionalHeader;
const auto symbolTable = Read<std::uint32_t>(pe, coffHeaderOffset + 8u);
const auto symbolCount = Read<std::uint32_t>(pe, coffHeaderOffset + 12u);
for (std::uint16_t i = 0; i < numberOfSections; ++i) {
const auto offset = sectionTableOffset + i * sizeof(PeSectionHeader);
auto section = Read<PeSectionHeader>(pe, offset);
if (pe[offset] != '/' || !symbolTable) continue;
const std::string reference(reinterpret_cast<const char*>(pe.data() + offset), 8);
const auto stringOffset = std::stoul(reference.substr(1));
const auto name = ReadCStr(pe, static_cast<std::size_t>(symbolTable) + static_cast<std::size_t>(symbolCount) * 18 + stringOffset);
if (name == ".eh_frame") {
const char shortName[8] = ".ehfram";
std::memcpy(pe.data() + offset, shortName, 8);
}
}
const std::size_t optionalHeaderOffset = coffHeaderOffset + 20u;
const auto magic = Read<std::uint16_t>(pe, optionalHeaderOffset);
std::size_t dataDirectoryOffset;
if (magic == 0x20bu) {
dataDirectoryOffset = optionalHeaderOffset + 112u;
} else if (magic == 0x10bu) {
dataDirectoryOffset = optionalHeaderOffset + 96u;
} else {
throw std::runtime_error("unsupported optional header magic");
}
const auto exportDir = Read<PeDataDirectory>(pe, dataDirectoryOffset);
if (exportDir.VirtualAddress == 0u) throw std::runtime_error("no export directory");
const std::size_t exportDirOffset = RvaToOffset(pe, exportDir.VirtualAddress, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
const auto exportTable = Read<PeExportDirectory>(pe, exportDirOffset);
if (exportTable.NumberOfNames == 0u) throw std::runtime_error("no exported names");
const std::size_t namesArrayOffset = RvaToOffset(pe, exportTable.AddressOfNames, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
const std::size_t ordinalsArrayOffset = RvaToOffset(pe, exportTable.AddressOfNameOrdinals, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
std::vector<std::uint32_t> nameRvas(exportTable.NumberOfNames);
std::vector<std::string> names(exportTable.NumberOfNames);
for (std::uint32_t i = 0u; i < exportTable.NumberOfNames; ++i) {
const auto nameRva = Read<std::uint32_t>(pe, namesArrayOffset + i * 4u);
const std::size_t nameOffset = RvaToOffset(pe, nameRva, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
const std::string name = ReadCStr(pe, nameOffset);
if (name.empty()) throw std::runtime_error("empty exported name");
nameRvas[i] = nameRva;
names[i] = name;
}
const auto nidMap = ResolveNids(names, libraryName, excludedExports);
const std::size_t edataSectionOffset = FindSectionOffsetByRva(pe, exportDir.VirtualAddress, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
const auto edataSection = Read<PeSectionHeader>(pe, edataSectionOffset);
const auto fileAlignment = Read<std::uint32_t>(pe, optionalHeaderOffset + 36u);
if (fileAlignment == 0u) throw std::runtime_error("invalid file alignment");
std::uint32_t stringsRegionStart = std::numeric_limits<std::uint32_t>::max();
for (std::uint32_t i = 0u; i < exportTable.NumberOfNames; ++i) {
const std::uint32_t rvaFromSection = nameRvas[i] - edataSection.VirtualAddress;
if (rvaFromSection < stringsRegionStart) stringsRegionStart = rvaFromSection;
}
if (stringsRegionStart == std::numeric_limits<std::uint32_t>::max())
throw std::runtime_error("could not determine strings region start");
const std::uint32_t rawLimit = ((edataSection.SizeOfRawData + fileAlignment - 1u) / fileAlignment) * fileAlignment;
std::vector<std::string> finalNames(exportTable.NumberOfNames);
for (std::uint32_t i = 0u; i < exportTable.NumberOfNames; ++i) {
const auto it = nidMap.find(names[i]);
if (it == nidMap.end()) throw std::runtime_error("symbol not in nid map: " + names[i]);
finalNames[i] = it->second;
}
std::uint32_t requiredSize = stringsRegionStart;
for (std::uint32_t i = 0u; i < exportTable.NumberOfNames; ++i)
requiredSize += static_cast<std::uint32_t>(finalNames[i].size()) + 1u;
if (requiredSize > rawLimit)
throw std::runtime_error("not enough raw space in edata section to repack export names");
std::uint32_t writeOffset = stringsRegionStart;
for (std::uint32_t i = 0u; i < exportTable.NumberOfNames; ++i) {
const std::uint32_t newNameRva = edataSection.VirtualAddress + writeOffset;
const std::size_t newNameFileOffset = static_cast<std::size_t>(edataSection.PointerToRawData) + writeOffset;
if (newNameFileOffset + finalNames[i].size() + 1u > pe.size())
throw std::runtime_error("repack write out of file bounds");
std::memcpy(pe.data() + newNameFileOffset, finalNames[i].data(), finalNames[i].size());
pe[newNameFileOffset + finalNames[i].size()] = 0u;
Write(pe, namesArrayOffset + i * 4u, newNameRva);
writeOffset += static_cast<std::uint32_t>(finalNames[i].size()) + 1u;
}
const std::uint32_t newVirtualSize = std::max(edataSection.VirtualSize, writeOffset);
auto patchedSection = edataSection;
patchedSection.VirtualSize = newVirtualSize;
Write(pe, edataSectionOffset, patchedSection);
struct ExportName {
std::string Name;
std::uint32_t Rva;
std::uint16_t Ordinal;
};
std::vector<ExportName> exportNames;
exportNames.reserve(exportTable.NumberOfNames);
for (std::size_t i = 0; i < exportTable.NumberOfNames; ++i) {
const auto nameRva = Read<std::uint32_t>(pe, namesArrayOffset + i * sizeof(std::uint32_t));
const auto ordinal = Read<std::uint16_t>(pe, ordinalsArrayOffset + i * sizeof(std::uint16_t));
if (ordinal >= exportTable.NumberOfFunctions)
throw std::runtime_error("export name ordinal out of bounds");
const auto nameOffset = RvaToOffset(pe, nameRva, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
exportNames.push_back({ReadCStr(pe, nameOffset), nameRva, ordinal});
}
std::sort(exportNames.begin(), exportNames.end(), [](const ExportName& left, const ExportName& right) { return left.Name < right.Name; });
for (std::size_t i = 0; i < exportNames.size(); ++i) {
if (i != 0 && exportNames[i - 1].Name == exportNames[i].Name)
throw std::runtime_error("duplicate patched export name: " + exportNames[i].Name);
Write(pe, namesArrayOffset + i * sizeof(std::uint32_t), exportNames[i].Rva);
Write(pe, ordinalsArrayOffset + i * sizeof(std::uint16_t), exportNames[i].Ordinal);
}
constexpr std::size_t kImportDirIndex = 1u;
if (dataDirectoryOffset + (kImportDirIndex + 1u) * sizeof(PeDataDirectory) > pe.size())
return;
const auto importDir = Read<PeDataDirectory>(pe, dataDirectoryOffset + kImportDirIndex * sizeof(PeDataDirectory));
if (importDir.VirtualAddress == 0u || importDir.Size == 0u)
return;
struct PeImportDescriptor {
std::uint32_t OriginalFirstThunk;
std::uint32_t TimeDateStamp;
std::uint32_t ForwarderChain;
std::uint32_t Name;
std::uint32_t FirstThunk;
};
std::size_t importDescOffset = RvaToOffset(pe, importDir.VirtualAddress, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
while (true) {
if (importDescOffset + sizeof(PeImportDescriptor) > pe.size())
throw std::runtime_error("import descriptor out of bounds");
const auto desc = Read<PeImportDescriptor>(pe, importDescOffset);
if (desc.OriginalFirstThunk == 0u && desc.FirstThunk == 0u)
break;
const std::uint32_t thunkRva = desc.OriginalFirstThunk != 0u ? desc.OriginalFirstThunk : desc.FirstThunk;
std::size_t thunkOffset = RvaToOffset(pe, thunkRva, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
const bool is64 = magic == 0x20bu;
const std::size_t thunkEntrySize = is64 ? 8u : 4u;
const std::uint64_t ordinalFlag = is64 ? (std::uint64_t{1} << 63u) : (std::uint64_t{1} << 31u);
while (true) {
if (thunkOffset + thunkEntrySize > pe.size())
throw std::runtime_error("thunk entry out of bounds");
const std::uint64_t thunk = is64
? Read<std::uint64_t>(pe, thunkOffset)
: static_cast<std::uint64_t>(Read<std::uint32_t>(pe, thunkOffset));
if (thunk == 0u)
break;
if (!(thunk & ordinalFlag)) {
const auto hintNameRva = static_cast<std::uint32_t>(thunk & 0x7fffffffffffffffu);
const std::size_t hintNameOffset = RvaToOffset(pe, hintNameRva, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
if (hintNameOffset + 2u >= pe.size())
throw std::runtime_error("import by name out of bounds");
const std::string funcName = ReadCStr(pe, hintNameOffset + 2u);
if (!funcName.empty()) {
const bool hasNidPostfix = funcName.size() >= kNidPostfixLen &&
funcName.compare(funcName.size() - kNidPostfixLen, kNidPostfixLen, kNidPostfix) == 0;
const bool hasScePrefix = funcName.size() >= 3u &&
std::tolower(static_cast<unsigned char>(funcName[0])) == 's' &&
std::tolower(static_cast<unsigned char>(funcName[1])) == 'c' &&
std::tolower(static_cast<unsigned char>(funcName[2])) == 'e';
if (hasNidPostfix || hasScePrefix) {
const std::string nid = ResolveOneName(funcName);
if (nid.size() > funcName.size())
throw std::runtime_error("import NID longer than original name: " + funcName);
std::memcpy(pe.data() + hintNameOffset + 2u, nid.data(), nid.size());
pe[hintNameOffset + 2u + nid.size()] = 0u;
}
}
}
thunkOffset += thunkEntrySize;
}
importDescOffset += sizeof(PeImportDescriptor);
}
}
}
+80
View File
@@ -0,0 +1,80 @@
#include <nid/Sha1.hpp>
#include <cstdint>
#include <array>
#include <vector>
namespace Nid {
namespace {
constexpr std::uint32_t _rotl32(std::uint32_t x, unsigned n) {
return (x << n) | (x >> (32u - n));
}
}
std::array<std::uint8_t, 20> Sha1(const std::vector<std::uint8_t>& data) {
std::uint32_t h0 = 0x67452301u;
std::uint32_t h1 = 0xEFCDAB89u;
std::uint32_t h2 = 0x98BADCFEu;
std::uint32_t h3 = 0x10325476u;
std::uint32_t h4 = 0xC3D2E1F0u;
std::vector<std::uint8_t> msg(data);
const std::uint64_t bitLen = static_cast<std::uint64_t>(data.size()) * 8u;
msg.push_back(0x80u);
while ((msg.size() % 64u) != 56u)
msg.push_back(0x00u);
for (int i = 7; i >= 0; --i)
msg.push_back(static_cast<std::uint8_t>((bitLen >> (i * 8u)) & 0xffu));
for (std::size_t offset = 0; offset < msg.size(); offset += 64u) {
std::uint32_t w[80];
for (int i = 0; i < 16; ++i) {
w[i] = (static_cast<std::uint32_t>(msg[offset + i * 4u + 0u]) << 24u)
| (static_cast<std::uint32_t>(msg[offset + i * 4u + 1u]) << 16u)
| (static_cast<std::uint32_t>(msg[offset + i * 4u + 2u]) << 8u)
| (static_cast<std::uint32_t>(msg[offset + i * 4u + 3u]));
}
for (int i = 16; i < 80; ++i)
w[i] = _rotl32(w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16], 1u);
std::uint32_t a = h0, b = h1, c = h2, d = h3, e = h4;
for (int i = 0; i < 80; ++i) {
std::uint32_t f, k;
if (i < 20) {
f = (b & c) | ((~b) & d);
k = 0x5A827999u;
} else if (i < 40) {
f = b ^ c ^ d;
k = 0x6ED9EBA1u;
} else if (i < 60) {
f = (b & c) | (b & d) | (c & d);
k = 0x8F1BBCDCu;
} else {
f = b ^ c ^ d;
k = 0xCA62C1D6u;
}
std::uint32_t temp = _rotl32(a, 5u) + f + e + k + w[i];
e = d; d = c; c = _rotl32(b, 30u); b = a; a = temp;
}
h0 += a; h1 += b; h2 += c; h3 += d; h4 += e;
}
std::array<std::uint8_t, 20> digest;
auto _put = [&](int base, std::uint32_t v) {
digest[base+0] = static_cast<std::uint8_t>(v >> 24u);
digest[base+1] = static_cast<std::uint8_t>(v >> 16u);
digest[base+2] = static_cast<std::uint8_t>(v >> 8u);
digest[base+3] = static_cast<std::uint8_t>(v);
};
_put(0, h0); _put(4, h1); _put(8, h2); _put(12, h3); _put(16, h4);
return digest;
}
}
+67
View File
@@ -0,0 +1,67 @@
#include <nid/BinaryPatcherFactory.hpp>
#include <nid/ExportExclusions.hpp>
#include <fstream>
#include <iostream>
#include <stdexcept>
#include <string>
#include <vector>
namespace {
std::vector<std::uint8_t> _readFile(const std::string& path) {
std::ifstream f(path, std::ios::binary);
if (!f) throw std::runtime_error("cannot open: " + path);
return {std::istreambuf_iterator<char>(f), {}};
}
void _writeFile(const std::string& path, const std::vector<std::uint8_t>& data) {
std::ofstream f(path, std::ios::binary);
if (!f) throw std::runtime_error("cannot write: " + path);
f.write(reinterpret_cast<const char*>(data.data()), static_cast<std::streamsize>(data.size()));
}
}
int main(int argc, char* argv[]) {
if (argc < 3) {
std::cerr << "Usage: nid_patcher <library_name> [--preserve-exports <unpatched-library>] <file> [file2 ...]\n";
return 1;
}
const std::string libraryName = argv[1];
std::unordered_set<std::string> excludedExports;
std::vector<std::string> paths;
try {
bool hasReference = false;
for (int i = 2; i < argc; ++i) {
const std::string argument = argv[i];
if (argument == "--preserve-exports") {
if (hasReference || i + 1 == argc) throw std::runtime_error("--preserve-exports requires exactly one reference library");
hasReference = true;
excludedExports = Nid::ReadExportExclusions(argv[++i]);
} else {
if (argument.starts_with("--")) throw std::runtime_error("unknown option: " + argument);
paths.push_back(argument);
}
}
if (paths.empty()) throw std::runtime_error("no files to patch");
} catch (const std::exception& e) {
std::cerr << "FAIL: " << e.what() << '\n';
return 2;
}
for (const std::string& path : paths) {
try {
auto binary = _readFile(path);
const auto patcher = Nid::MakePatcher(binary);
patcher->PatchNids(binary, libraryName, excludedExports);
_writeFile(path, binary);
std::cout << "OK: " << path << "\n";
} catch (const std::exception& e) {
std::cerr << "FAIL: " << path << ": " << e.what() << "\n";
return 2;
}
}
return 0;
}
@@ -0,0 +1,54 @@
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
int APS5_VABI ErrorDialogClose(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI ErrorDialogOpen(const void* param) {
(void)param;
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI ShareGetCurrentStatus(uint32_t feature_flag, ShareCurrentStatus* status) {
(void)feature_flag;
(void)status;
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI ShareInitialize(size_t heap_size, int thread_priority, uint64_t affinity_mask) {
(void)heap_size;
(void)thread_priority;
(void)affinity_mask;
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI ShareTerminate(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI SystemServiceParamGetInt(int param_id, int* value) {
(void)param_id;
(void)value;
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI SystemServiceParamGetString(int param_id, char* buf, size_t buf_size) {
(void)param_id;
(void)buf;
(void)buf_size;
NotImplemented_nid_no_patch(__func__);
return 0;
}
}
@@ -0,0 +1,35 @@
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
int APS5_VABI RemotePlayGetConnectionStatus(int user_id, int* status) {
(void)user_id;
(void)status;
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI ShareGetCurrentStatus(uint32_t feature_flag, ShareCurrentStatus* status) {
(void)feature_flag;
(void)status;
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI ShareInitialize(size_t heap_size, int thread_priority, uint64_t affinity_mask) {
(void)heap_size;
(void)thread_priority;
(void)affinity_mask;
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI ShareTerminate(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
}
+145
View File
@@ -0,0 +1,145 @@
#include <cstdint>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
APS5_EXPORT("0DsDTr534gc", renoirStub00);
uint64_t APS5_VABI renoirStub00(void) {
NotImplemented_nid_no_patch("0DsDTr534gc");
return 0;
}
APS5_EXPORT("2T56HgbPW08", renoirStub01);
uint64_t APS5_VABI renoirStub01(void) {
NotImplemented_nid_no_patch("2T56HgbPW08");
return 0;
}
APS5_EXPORT("3HnCozh8Az8", renoirStub02);
uint64_t APS5_VABI renoirStub02(void) {
NotImplemented_nid_no_patch("3HnCozh8Az8");
return 0;
}
APS5_EXPORT("5Ysce+s-CWU", renoirStub03);
uint64_t APS5_VABI renoirStub03(void) {
NotImplemented_nid_no_patch("5Ysce+s-CWU");
return 0;
}
APS5_EXPORT("AdlSqA4lGS8", renoirStub04);
uint64_t APS5_VABI renoirStub04(void) {
NotImplemented_nid_no_patch("AdlSqA4lGS8");
return 0;
}
APS5_EXPORT("bC37hk7rHqs", renoirStub05);
uint64_t APS5_VABI renoirStub05(void) {
NotImplemented_nid_no_patch("bC37hk7rHqs");
return 0;
}
APS5_EXPORT("dfPK9R6M0qM", renoirStub06);
uint64_t APS5_VABI renoirStub06(void) {
NotImplemented_nid_no_patch("dfPK9R6M0qM");
return 0;
}
APS5_EXPORT("fZiBbVa2ZDU", renoirStub07);
uint64_t APS5_VABI renoirStub07(void) {
NotImplemented_nid_no_patch("fZiBbVa2ZDU");
return 0;
}
APS5_EXPORT("hkWBH8-WfW4", renoirStub08);
uint64_t APS5_VABI renoirStub08(void) {
NotImplemented_nid_no_patch("hkWBH8-WfW4");
return 0;
}
APS5_EXPORT("hUxvGdi64Io", renoirStub09);
uint64_t APS5_VABI renoirStub09(void) {
NotImplemented_nid_no_patch("hUxvGdi64Io");
return 0;
}
APS5_EXPORT("NxqsZxGisrA", renoirStub10);
uint64_t APS5_VABI renoirStub10(void) {
NotImplemented_nid_no_patch("NxqsZxGisrA");
return 0;
}
APS5_EXPORT("OgZVIkaNmb0", renoirStub11);
uint64_t APS5_VABI renoirStub11(void) {
NotImplemented_nid_no_patch("OgZVIkaNmb0");
return 0;
}
APS5_EXPORT("ojLQdRUnVgA", renoirStub12);
uint64_t APS5_VABI renoirStub12(void) {
NotImplemented_nid_no_patch("ojLQdRUnVgA");
return 0;
}
APS5_EXPORT("s0qDfgsAgVg", renoirStub13);
uint64_t APS5_VABI renoirStub13(void) {
NotImplemented_nid_no_patch("s0qDfgsAgVg");
return 0;
}
APS5_EXPORT("sgrd-r1Nw60", renoirStub14);
uint64_t APS5_VABI renoirStub14(void) {
NotImplemented_nid_no_patch("sgrd-r1Nw60");
return 0;
}
APS5_EXPORT("sjTRb8YD7dQ", renoirStub15);
uint64_t APS5_VABI renoirStub15(void) {
NotImplemented_nid_no_patch("sjTRb8YD7dQ");
return 0;
}
APS5_EXPORT("tG86XGc2VtE", renoirStub16);
uint64_t APS5_VABI renoirStub16(void) {
NotImplemented_nid_no_patch("tG86XGc2VtE");
return 0;
}
APS5_EXPORT("umlGxOcNzgc", renoirStub17);
uint64_t APS5_VABI renoirStub17(void) {
NotImplemented_nid_no_patch("umlGxOcNzgc");
return 0;
}
APS5_EXPORT("vPxA9OFW0os", renoirStub18);
uint64_t APS5_VABI renoirStub18(void) {
NotImplemented_nid_no_patch("vPxA9OFW0os");
return 0;
}
APS5_EXPORT("X2qEBlOLkNo", renoirStub19);
uint64_t APS5_VABI renoirStub19(void) {
NotImplemented_nid_no_patch("X2qEBlOLkNo");
return 0;
}
APS5_EXPORT("ynh4E+BIaqY", renoirStub20);
uint64_t APS5_VABI renoirStub20(void) {
NotImplemented_nid_no_patch("ynh4E+BIaqY");
return 0;
}
APS5_EXPORT("YXe6ABbHZPs", renoirStub21);
uint64_t APS5_VABI renoirStub21(void) {
NotImplemented_nid_no_patch("YXe6ABbHZPs");
return 0;
}
APS5_EXPORT("z0jsXZVz75I", renoirStub22);
uint64_t APS5_VABI renoirStub22(void) {
NotImplemented_nid_no_patch("z0jsXZVz75I");
return 0;
}
}
+56
View File
@@ -0,0 +1,56 @@
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
#include <atomic>
// Audio co-processor batches complete immediately without producing output; audio is silent.
static constexpr int SCE_ACM_ERROR_INVALID_PARAMETER = static_cast<int>(0x80E30002);
static std::atomic<uint32_t> g_nextId{1};
extern "C" {
int APS5_VABI sceAcmBatchStartBuffer(AcmContextId context, const void* batch_commands, size_t batch_size, AcmBatchError* batch_error, AcmBatchId* batch) {
(void)context;
(void)batch_commands;
(void)batch_size;
(void)batch_error;
if (!batch) return SCE_ACM_ERROR_INVALID_PARAMETER;
*batch = g_nextId.fetch_add(1, std::memory_order_relaxed);
return 0;
}
int APS5_VABI sceAcmBatchStartBuffers(AcmContextId context, uint32_t batch_info_count, const AcmBatchInfo* const batch_info[], AcmBatchError* batch_error, AcmBatchId* batch) {
(void)context;
(void)batch_info_count;
(void)batch_info;
(void)batch_error;
if (!batch) return SCE_ACM_ERROR_INVALID_PARAMETER;
*batch = g_nextId.fetch_add(1, std::memory_order_relaxed);
return 0;
}
int APS5_VABI sceAcmBatchWait(AcmContextId context, AcmBatchId batch, uint32_t timeout) {
(void)context;
(void)batch;
(void)timeout;
return 0;
}
int APS5_VABI sceAcmContextCreate(AcmContextId* context) {
if (!context) return SCE_ACM_ERROR_INVALID_PARAMETER;
*context = g_nextId.fetch_add(1, std::memory_order_relaxed);
return 0;
}
int APS5_VABI sceAcmContextDestroy(AcmContextId context) {
(void)context;
return 0;
}
// Builds a convolution-reverb command into a batch; batches execute as no-ops, so nothing is encoded.
int APS5_VABI sceAcm_ConvReverb_SharedInput(void) {
return 0;
}
}
@@ -0,0 +1,4 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_ACB_INCLUDE_CONTROL_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_ACB_INCLUDE_CONTROL_HPP
#endif
@@ -0,0 +1,4 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_ACB_INCLUDE_DISPATCH_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_ACB_INCLUDE_DISPATCH_HPP
#endif
@@ -0,0 +1,4 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_ACB_INCLUDE_MEMORY_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_ACB_INCLUDE_MEMORY_HPP
#endif
@@ -0,0 +1,4 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_ACB_INCLUDE_SYNC_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_ACB_INCLUDE_SYNC_HPP
#endif
@@ -0,0 +1,92 @@
#include "prx/libSceAgc/Acb/include/Control.hpp"
#include "prx/libSceAgc/Command/include/Memory.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include "prx/libSceAgc/DcbState/include/Marker.hpp"
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
// unknown signature
APS5_EXPORT("gQkqkLttcpw", sceAgcAcb_gQkqkLttcpw);
void* APS5_VABI sceAgcAcb_gQkqkLttcpw (void) {
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
std::uint32_t* APS5_VABI sceAgcAcbJump(CommandBuffer* buf, std::uint8_t cachePolicy, const std::uint32_t* target, std::uint32_t sizeInDwords) {
(void)buf;
(void)cachePolicy;
(void)target;
(void)sizeInDwords;
NotImplemented_nid_no_patch(__func__);
return 0;
}
uint32_t APS5_VABI sceAgcAcbJumpGetSize(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
// Encoded as the custom DISPATCH_RESET NOP packet the driver consumes on compute queues.
uint32_t* APS5_VABI sceAgcAcbResetQueue(CommandBuffer* buf, uint32_t op, uint32_t value) {
(void)value;
Agc::Command::Require(buf != nullptr, __func__, "null command buffer");
constexpr std::uint32_t OpcodeNop = 0x10;
constexpr std::uint32_t CustomDispatchReset = 0x09;
auto* packet = Agc::Command::Allocate(buf, 2, __func__);
packet[0] = Agc::Command::Header(OpcodeNop, 2, CustomDispatchReset << 2);
packet[1] = op;
return packet;
}
std::uint32_t* APS5_VABI sceAgcAcbRewind(CommandBuffer* buf, std::uint32_t initialState) {
(void)buf;
(void)initialState;
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
std::uint32_t APS5_VABI sceAgcAcbRewindGetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcAcbWaitUntilSafeForRendering(CommandBuffer* buf, std::uint32_t videoOutHandle, std::uint32_t displayBufferIndex) {
(void)buf;
(void)videoOutHandle;
(void)displayBufferIndex;
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
std::uint32_t* APS5_VABI sceAgcAcbSetFlip(CommandBuffer* buf, std::uint32_t videoOutHandle, std::int32_t displayBufferIndex, std::uint32_t flipMode, std::int64_t flipArg) {
(void)buf;
(void)videoOutHandle;
(void)displayBufferIndex;
(void)flipMode;
(void)flipArg;
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
uint32_t* APS5_VABI sceAgcAcbPushMarker(CommandBuffer* buf, const char* str, uint32_t color) {
(void)color;
return Agc::Marker::Push(buf, str, __func__);
}
uint32_t* APS5_VABI sceAgcAcbPopMarker(CommandBuffer* buf) {
return Agc::Marker::Pop(buf, __func__);
}
uint32_t* APS5_VABI sceAgcAcbSetMarker(CommandBuffer* buf, const char* str, uint32_t color) {
(void)color;
auto* packet = Agc::Marker::Push(buf, str, __func__);
Agc::Marker::Pop(buf, __func__);
return packet;
}
}
@@ -0,0 +1,25 @@
#include "prx/libSceAgc/Acb/include/Dispatch.hpp"
#include "prx/libSceAgc/Command/include/Memory.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
uint32_t* APS5_VABI sceAgcAcbDispatchIndirect(CommandBuffer* buf, const volatile void* indirect_args, uint32_t modifier) {
// Compute queues take the argument address directly (DISPATCH_INDIRECT with a 64-bit address).
const auto address = reinterpret_cast<std::uintptr_t>(indirect_args);
Agc::Command::CheckAddress(address, 4, __func__);
Agc::Command::CheckBits(modifier, 0xa038u | 0x41u, __func__);
return Agc::Command::Emit(buf, 0x16u, {static_cast<std::uint32_t>(address), static_cast<std::uint32_t>(address >> 32u), modifier | 0x41u}, __func__);
}
std::uint32_t APS5_VABI sceAgcAcbDispatchIndirectGetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
}
@@ -0,0 +1,90 @@
#include "prx/libSceAgc/Acb/include/Memory.hpp"
#include "prx/libSceAgc/DcbFlow/include/Memory.hpp"
#include "prx/libSceAgc/Command/include/Memory.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
std::uint32_t* APS5_VABI sceAgcAcbAcquireMem(CommandBuffer* buf, std::uint32_t gcrControl, const volatile void* base, std::uint64_t sizeBytes, std::uint32_t pollCycles) {
return sceAgcDcbAcquireMem(buf, 1, 0, gcrControl, base, sizeBytes, pollCycles);
}
uint32_t APS5_VABI sceAgcAcbAcquireMemGetSize(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
uint32_t* APS5_VABI sceAgcAcbCopyData(CommandBuffer* buf, uint8_t dst, uint8_t dst_cache_policy, uint64_t dst_address, uint8_t src, uint8_t src_cache_policy, uint64_t src_address_or_immediate, uint8_t item_size, uint8_t write_confirm) {
(void)buf;
(void)dst;
(void)dst_cache_policy;
(void)dst_address;
(void)src;
(void)src_cache_policy;
(void)src_address_or_immediate;
(void)item_size;
(void)write_confirm;
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
std::uint64_t APS5_VABI sceAgcAcbCopyDataGetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcAcbDmaData(CommandBuffer* buf, std::uint8_t dst, std::uint8_t dstCachePolicy, std::uint64_t dstAddress, std::uint8_t src, std::uint8_t srcCachePolicy, std::uint64_t srcAddress, std::uint32_t numBytes, std::uint8_t waitForPrevious, std::uint8_t writeConfirm) {
return Agc::Command::WriteDma(buf, true, 0, dst, dstCachePolicy, dstAddress, src, srcCachePolicy, srcAddress, numBytes, waitForPrevious, writeConfirm, 0, __func__);
}
std::uint32_t APS5_VABI sceAgcAcbDmaDataGetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcAcbAtomicMem(CommandBuffer* buf, std::uint8_t atomicOp, std::uint8_t command, std::uint8_t cachePolicy, const volatile void* address, std::uint64_t srcData, std::uint64_t compareData, std::uint16_t loopInterval) {
(void)buf;
(void)atomicOp;
(void)command;
(void)cachePolicy;
(void)address;
(void)srcData;
(void)compareData;
(void)loopInterval;
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
std::uint32_t APS5_VABI sceAgcAcbAtomicMemGetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t APS5_VABI sceAgcAcbAtomicGdsGetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcAcbPrimeUtcl2(CommandBuffer* buf, const volatile void* address, std::uint32_t sizeInBytes) {
(void)buf;
(void)address;
(void)sizeInBytes;
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
std::uint32_t APS5_VABI sceAgcAcbPrimeUtcl2GetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcAcbWriteData(CommandBuffer* buf, std::uint8_t dst, std::uint8_t cachePolicy, std::uint64_t address, const void* data, std::uint32_t numDwords, std::uint8_t increment, std::uint8_t writeConfirm) {
return Agc::Command::WriteData(buf, true, dst, cachePolicy, address, data, numDwords, increment, writeConfirm, __func__);
}
}
+61
View File
@@ -0,0 +1,61 @@
#include "prx/libSceAgc/Acb/include/Sync.hpp"
#include "prx/libSceAgc/Command/include/Memory.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
uint32_t* APS5_VABI sceAgcAcbCondExec(CommandBuffer* buf, const volatile uint32_t* address, uint32_t num_dwords) {
(void)buf;
(void)address;
(void)num_dwords;
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
uint32_t APS5_VABI sceAgcAcbCondExecGetSize(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcAcbWaitRegMem(CommandBuffer* buf, std::uint8_t size, std::uint8_t compareFunction, std::uint8_t cachePolicy, const volatile void* address, std::uint64_t reference, std::uint64_t mask, std::uint32_t pollCycles) {
return Agc::Command::WriteWait(buf, size, compareFunction, 0, cachePolicy, address, reference, mask, pollCycles, __func__);
}
std::uint64_t APS5_VABI sceAgcAcbWaitOnAddressGetSize(std::uint8_t size) {
(void)size;
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcAcbEventWrite(CommandBuffer* buf, std::uint8_t eventType, const volatile void* address) {
Agc::Command::CheckBits(eventType, 0x3fu, __func__);
Agc::Command::Require(address == nullptr, __func__, "ACB event address is not supported");
return Agc::Command::Emit(buf, 0x46u, {eventType | (eventType == 7 ? 0x400u : 0u)}, __func__);
}
std::uint64_t APS5_VABI sceAgcAcbEventWriteGetSize(std::uint8_t eventType) {
(void)eventType;
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t APS5_VABI sceAgcAcbQueueEndOfShaderActionGetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcAcbMemSemaphore(CommandBuffer* buf, std::uint8_t action, std::uint8_t clientCode, const volatile void* address) {
(void)buf;
(void)action;
(void)clientCode;
(void)address;
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
}
+69
View File
@@ -0,0 +1,69 @@
add_library(libSceAgc SHARED EXCLUDE_FROM_ALL
${CMAKE_CURRENT_SOURCE_DIR}/Unimplemented.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Acb/src/Control.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Acb/src/Dispatch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Acb/src/Memory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Acb/src/Sync.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Cb/src/Branch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Cb/src/Dispatch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Cb/src/Registers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Cb/src/Sync.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Command/src/Memory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Command/src/Draw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Command/src/RegisterDefaults.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Command/src/Packet.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DcbDraw/src/DrawIndexed.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DcbDraw/src/DrawNonIndexed.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DcbDraw/src/IndexBuffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DcbDraw/src/Instancing.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DcbDraw/src/Stats.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DcbFlow/src/Control.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DcbFlow/src/Dispatch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DcbFlow/src/Memory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DcbFlow/src/Sync.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DcbState/src/ContextState.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DcbState/src/Display.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DcbState/src/Init.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DcbState/src/Marker.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DcbState/src/Predication.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DcbState/src/Registers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DcbState/src/Workload.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Misc/src/PacketInfo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Misc/src/RegisterDefaults.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Misc/src/ShaderFusion.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Misc/src/Suspend.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Patch/src/CondExec.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Patch/src/Dma.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Patch/src/IndirectRegisters.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Patch/src/Jump.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Patch/src/Nop.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Patch/src/QueueEndOfPipeAction.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Patch/src/Rewind.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Patch/src/WaitRegMem.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Patch/src/Branch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Predication/src/Predication.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Shader/src/CreateShader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Shader/src/InterpolantMapping.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Shader/src/LinkShaders.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Shader/src/PrimState.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Shader/src/ShaderUtils.cpp
)
target_include_directories(libSceAgc PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(libSceAgc PRIVATE libSceAgcDriver libc)
option(APS5_AGC_CREATE_LOG "Logging sceAgcCreateShader Ok status" ON)
target_compile_definitions(libSceAgc PRIVATE
APS5_AGC_CREATE_LOG=$<BOOL:${APS5_AGC_CREATE_LOG}>
)
foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static)
string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
endforeach()
add_executable(agc_command_tests EXCLUDE_FROM_ALL tests/Commands.cpp)
target_include_directories(agc_command_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(agc_command_tests PRIVATE libSceAgc libc)
configure_windows_unwind(agc_command_tests)
configure_windows_unwind(libSceAgc)
@@ -0,0 +1,4 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_CB_INCLUDE_BRANCH_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_CB_INCLUDE_BRANCH_HPP
#endif
@@ -0,0 +1,4 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_CB_INCLUDE_DISPATCH_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_CB_INCLUDE_DISPATCH_HPP
#endif
@@ -0,0 +1,4 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_CB_INCLUDE_REGISTERS_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_CB_INCLUDE_REGISTERS_HPP
#endif
@@ -0,0 +1,4 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_CB_INCLUDE_SYNC_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_CB_INCLUDE_SYNC_HPP
#endif
+46
View File
@@ -0,0 +1,46 @@
#include "prx/libSceAgc/Cb/include/Branch.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
std::uint32_t* APS5_VABI sceAgcCbBranch(CommandBuffer* buf, std::uint8_t mode, std::uint8_t compareFunction, const volatile std::uint64_t* compareAddress, std::uint64_t mask, std::uint64_t reference, std::uint8_t cachePolicy1, const volatile std::uint32_t* buffer1, std::uint32_t sizeInDwords1, std::uint8_t cachePolicy2, const volatile std::uint32_t* buffer2, std::uint32_t sizeInDwords2) {
Agc::Command::CheckBits(mode, 3, __func__);
Agc::Command::CheckBits(compareFunction, 7, __func__);
Agc::Command::CheckBits(cachePolicy1, 3, __func__);
Agc::Command::CheckBits(cachePolicy2, 3, __func__);
Agc::Command::CheckBits(sizeInDwords1, 0xfffffu, __func__);
Agc::Command::CheckBits(sizeInDwords2, 0xfffffu, __func__);
const auto address = reinterpret_cast<std::uintptr_t>(compareAddress);
const auto first = reinterpret_cast<std::uintptr_t>(buffer1);
const auto second = reinterpret_cast<std::uintptr_t>(buffer2);
Agc::Command::CheckAddress(address, 8, __func__);
Agc::Command::CheckAddress(first, 4, __func__);
Agc::Command::CheckAddress(second, 4, __func__);
return Agc::Command::Emit(buf, 0x3fu, {mode | (static_cast<std::uint32_t>(compareFunction) << 8u), static_cast<std::uint32_t>(address), static_cast<std::uint32_t>(address >> 32u), static_cast<std::uint32_t>(mask), static_cast<std::uint32_t>(mask >> 32u), static_cast<std::uint32_t>(reference), static_cast<std::uint32_t>(reference >> 32u), static_cast<std::uint32_t>(first), static_cast<std::uint32_t>(first >> 32u), sizeInDwords1 | (static_cast<std::uint32_t>(cachePolicy1) << 28u), static_cast<std::uint32_t>(second), static_cast<std::uint32_t>(second >> 32u), sizeInDwords2 | (static_cast<std::uint32_t>(cachePolicy2) << 28u)}, __func__);
}
std::uint32_t APS5_VABI sceAgcCbBranchGetSize() {
return 56;
}
uint32_t* APS5_VABI sceAgcCbCondWrite(CommandBuffer* buf, uint32_t cond, uint32_t a, uint32_t b, uint32_t c) {
(void)buf;
(void)cond;
(void)a;
(void)b;
(void)c;
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
std::uint32_t APS5_VABI sceAgcCbCondWriteGetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
}
@@ -0,0 +1,21 @@
#include "prx/libSceAgc/Cb/include/Dispatch.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
std::uint32_t* APS5_VABI sceAgcCbDispatch(CommandBuffer* buf, std::uint32_t threadGroupX, std::uint32_t threadGroupY, std::uint32_t threadGroupZ, std::uint32_t modifier) {
Agc::Command::CheckBits(modifier, 0xa038u | 0x41u, __func__);
return Agc::Command::Emit(buf, 0x15u, {threadGroupX, threadGroupY, threadGroupZ, modifier | 0x41u}, __func__);
}
uint32_t APS5_VABI sceAgcCbDispatchGetSize(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
}
@@ -0,0 +1,51 @@
#include "prx/libSceAgc/Cb/include/Registers.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
std::uint32_t* APS5_VABI sceAgcCbSetUcRegisterRangeDirect(CommandBuffer* buf, std::uint32_t offset, const std::uint32_t* values, std::uint32_t numValues) {
return Agc::Command::WriteRegisterRange(buf, 0x79u, offset, values, numValues, __func__);
}
std::uint32_t* APS5_VABI sceAgcCbSetShRegisterRangeDirect(CommandBuffer* buf, std::uint32_t offset, const std::uint32_t* values, std::uint32_t numValues) {
return Agc::Command::WriteRegisterRange(buf, 0x76u, offset, values, numValues, __func__);
}
uint32_t APS5_VABI sceAgcCbSetShRegisterRangeDirectGetSize(uint32_t num_values) {
(void)num_values;
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t APS5_VABI sceAgcCbSetUcRegisterRangeDirectGetSize(std::uint32_t numValues) {
(void)numValues;
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcCbSetShRegistersDirect(CommandBuffer* buf, const volatile ShaderRegister* regs, std::uint32_t numRegs) {
return Agc::Command::WriteRegisters(buf, 0x76u, regs, numRegs, true, __func__);
}
std::uint32_t APS5_VABI sceAgcCbSetShRegistersDirectGetSize(std::uint32_t numRegs) {
(void)numRegs;
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcCbSetUcRegistersDirect(CommandBuffer* buf, const volatile ShaderRegister* regs, std::uint32_t numRegs) {
return Agc::Command::WriteRegisters(buf, 0x79u, regs, numRegs, false, __func__);
}
std::uint32_t APS5_VABI sceAgcCbSetUcRegistersDirectGetSize(std::uint32_t numRegs) {
(void)numRegs;
NotImplemented_nid_no_patch(__func__);
return 0;
}
}
+63
View File
@@ -0,0 +1,63 @@
#include "prx/libSceAgc/Cb/include/Sync.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
std::uint32_t* APS5_VABI sceAgcCbNop_nid_postfix(CommandBuffer* buf, std::uint32_t sizeInDwords) {
return Agc::Command::WriteNop(buf, sizeInDwords, __func__);
}
uint32_t APS5_VABI sceAgcCbNopGetSize(uint32_t size_in_dwords) {
(void)size_in_dwords;
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t APS5_VABI sceAgcCbQueueEndOfPipeActionGetSize() {
return 32;
}
std::uint32_t* APS5_VABI sceAgcCbReleaseMem(CommandBuffer* buf, std::uint8_t action, std::uint16_t gcrControl, std::uint8_t dst, std::uint8_t cachePolicy, const volatile Label* address, std::uint8_t dataSelect, std::uint64_t data, std::uint16_t gdsOffset, std::uint16_t gdsSize, std::uint8_t interrupt, std::uint32_t interruptContextId) {
Agc::Command::CheckBits(action, 0x3fu, __func__);
Agc::Command::CheckBits(gcrControl, 0xfffu, __func__);
Agc::Command::CheckBits(dst, 1, __func__);
Agc::Command::CheckBits(cachePolicy, 3, __func__);
Agc::Command::Require(dataSelect <= 3 || dataSelect == 5, __func__, "invalid release data selector");
Agc::Command::Require(interrupt <= 4, __func__, "invalid release interrupt selector");
Agc::Command::CheckBits(interruptContextId, 0x7ffffffu, __func__);
auto guestAddress = reinterpret_cast<std::uintptr_t>(address);
auto value = data;
if (interrupt == 4) {
Agc::Command::Require(guestAddress == 0 && value == 0, __func__, "interrupt-only release cannot write data");
} else if (dataSelect == 5) {
Agc::Command::Require(data == 0, __func__, "GDS release cannot use immediate data");
value = gdsOffset | (static_cast<std::uint64_t>(gdsSize) << 16u);
} else {
Agc::Command::Require(gdsOffset == 0 && gdsSize <= 1, __func__, "GDS parameters supplied for a non-GDS release");
}
// A null label is accepted: games emit releases whose destination is never read.
if (dataSelect != 0 && interrupt != 4 && guestAddress != 0) {
Agc::Command::CheckAddress(guestAddress, dataSelect == 2 || dataSelect == 3 ? 8 : 4, __func__);
}
if (dataSelect == 1) {
Agc::Command::CheckBits(data, 0xffffffffu, __func__);
}
std::uint32_t control = gcrControl;
if ((control & 0x300u) == 0x100u) {
control |= 0x200u;
}
const auto eventIndex = action >= 0x2fu ? 6u : 5u;
auto* packet = Agc::Command::Emit(buf, 0x49u, {action | (eventIndex << 8u) | (control << 12u) | (static_cast<std::uint32_t>(cachePolicy) << 25u), (static_cast<std::uint32_t>(dst) << 16u) | (static_cast<std::uint32_t>(interrupt) << 24u) | (static_cast<std::uint32_t>(dataSelect) << 29u), static_cast<std::uint32_t>(guestAddress), static_cast<std::uint32_t>(guestAddress >> 32u), static_cast<std::uint32_t>(value), static_cast<std::uint32_t>(value >> 32u), interruptContextId}, __func__);
static const std::uint64_t traced = [] { const char* value = std::getenv("APS5_TRACE_LABEL"); return value ? std::strtoull(value, nullptr, 16) : 0ull; }();
if (traced != 0 && guestAddress == traced) std::fprintf(stderr, "[agc] RELEASE_MEM for 0x%llx recorded at %p" "\n", static_cast<unsigned long long>(guestAddress), static_cast<void*>(packet));
return packet;
}
}
@@ -0,0 +1,14 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_COMMAND_INCLUDE_DRAW_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_COMMAND_INCLUDE_DRAW_HPP
#include "prx/libSceAgc/Command/include/Packet.hpp"
namespace Agc::Command {
std::uint32_t DrawInitiator(std::uint64_t modifier, bool indexed, const char* function);
std::uint64_t DrawPatchOffsets(std::uint64_t modifier, const char* function);
std::uint32_t DrawIndexLocation(std::uint64_t modifier);
}
#endif
@@ -0,0 +1,15 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_COMMAND_INCLUDE_MEMORY_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_COMMAND_INCLUDE_MEMORY_HPP
#include "prx/libSceAgc/Command/include/Packet.hpp"
namespace Agc::Command {
std::uint32_t* WriteDma(CommandBuffer* buffer, bool compute, std::uint8_t engine, std::uint8_t dst, std::uint8_t dstCachePolicy, std::uint64_t dstAddress, std::uint8_t src, std::uint8_t srcCachePolicy, std::uint64_t srcAddress, std::uint32_t numBytes, std::uint8_t waitForPrevious, std::uint8_t writeConfirm, std::uint8_t blockEngine, const char* function);
std::uint32_t* WriteData(CommandBuffer* buffer, bool compute, std::uint8_t dst, std::uint8_t cachePolicy, std::uint64_t address, const void* data, std::uint32_t count, std::uint8_t increment, std::uint8_t writeConfirm, const char* function);
std::uint32_t* WriteWait(CommandBuffer* buffer, std::uint8_t size, std::uint8_t compareFunction, std::uint8_t operation, std::uint8_t cachePolicy, const volatile void* address, std::uint64_t reference, std::uint64_t mask, std::uint32_t pollCycles, const char* function);
std::uint32_t* ValidateWait(std::uint32_t* packet, const char* function);
}
#endif
@@ -0,0 +1,27 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_COMMAND_INCLUDE_PACKET_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_COMMAND_INCLUDE_PACKET_HPP
#include <cstdint>
#include <initializer_list>
#include "SceTypes.hpp"
namespace Agc::Command {
void Require(bool condition, const char* function, const char* reason);
void CheckBits(std::uint64_t value, std::uint64_t mask, const char* function);
void CheckAddress(std::uint64_t address, std::uint32_t alignment, const char* function);
std::uint32_t Header(std::uint32_t opcode, std::uint32_t count, std::uint32_t flags = 0);
void Reserve(CommandBuffer* buffer, std::uint32_t count, const char* function);
std::uint32_t* Allocate(CommandBuffer* buffer, std::uint32_t count, const char* function);
std::uint32_t* Emit(CommandBuffer* buffer, std::uint32_t opcode, std::initializer_list<std::uint32_t> payload, const char* function);
void ValidatePacket(const std::uint32_t* packet, std::uint32_t opcode, std::uint32_t count, const char* function);
std::uint32_t* WriteNop(CommandBuffer* buffer, std::uint32_t count, const char* function);
std::uint32_t* WriteRegisterRange(CommandBuffer* buffer, std::uint32_t opcode, std::uint32_t offset, const std::uint32_t* values, std::uint32_t count, const char* function);
std::uint32_t* WriteRegisters(CommandBuffer* buffer, std::uint32_t opcode, const volatile ShaderRegister* registers, std::uint32_t count, bool snapshotAll, const char* function);
std::uint32_t* WriteIndirectRegisters(CommandBuffer* buffer, std::uint32_t opcode, const volatile ShaderRegister* registers, std::uint32_t count, const char* function);
void PatchIndirectAddress(std::uint32_t* packet, std::uint32_t opcode, const volatile ShaderRegister* registers, const char* function);
void PatchIndirectCount(std::uint32_t* packet, std::uint32_t opcode, std::uint32_t count, const char* function);
}
#endif
@@ -0,0 +1,12 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_COMMAND_INCLUDE_REGISTERDEFAULTS_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_COMMAND_INCLUDE_REGISTERDEFAULTS_HPP
#include <cstdint>
namespace Agc::Command {
void* GetRegisterDefaults(std::uint32_t version, bool internal, const char* function);
}
#endif
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,32 @@
#include "prx/libSceAgc/Command/include/Draw.hpp"
namespace Agc::Command {
namespace {
std::uint32_t sgprBase(std::uint64_t modifier) {
const auto stage = static_cast<std::uint32_t>(modifier) >> 29u;
return stage == 3 || stage == 5 ? 0x10cu : 0x8cu;
}
}
std::uint32_t DrawInitiator(std::uint64_t modifier, bool indexed, const char* function) {
CheckBits(modifier, 0x1ffffffffull, function);
const auto flags = (modifier & 0x100000000ull) != 0 ? 0u : static_cast<std::uint32_t>((modifier >> 3u) & 0x20u);
return flags | (indexed ? 0u : 2u);
}
std::uint64_t DrawPatchOffsets(std::uint64_t modifier, const char* function) {
CheckBits(modifier, 0x1ffffffffull, function);
const auto base = sgprBase(modifier);
const auto vertex = (modifier & 1u) != 0 ? base + static_cast<std::uint32_t>((modifier >> 9u) & 0x1fu) : 0x280u;
const auto instance = (modifier & 4u) != 0 ? base + static_cast<std::uint32_t>((modifier >> 19u) & 0x1fu) : 0x280u;
return vertex | (static_cast<std::uint64_t>(instance) << 32u);
}
std::uint32_t DrawIndexLocation(std::uint64_t modifier) {
return (modifier & 8u) != 0 ? sgprBase(modifier) + static_cast<std::uint32_t>((modifier >> 24u) & 0x1fu) : 0x280u;
}
}
@@ -0,0 +1,103 @@
#include "prx/libSceAgc/Command/include/Memory.hpp"
#include <algorithm>
#include <cstring>
#include <vector>
namespace Agc::Command {
std::uint32_t* WriteDma(CommandBuffer* buffer, bool compute, std::uint8_t engine, std::uint8_t dst, std::uint8_t dstCachePolicy, std::uint64_t dstAddress, std::uint8_t src, std::uint8_t srcCachePolicy, std::uint64_t srcAddress, std::uint32_t numBytes, std::uint8_t waitForPrevious, std::uint8_t writeConfirm, std::uint8_t blockEngine, const char* function) {
CheckBits(engine, 1, function);
CheckBits(dst, 0xfu, function);
CheckBits(dstCachePolicy, 3, function);
CheckBits(srcCachePolicy, 3, function);
CheckBits(waitForPrevious, 1, function);
CheckBits(writeConfirm, 1, function);
CheckBits(blockEngine, 1, function);
CheckBits(numBytes, 0x3ffffffu, function);
if (src == 0x14u || src == 0x24u || (!compute && src == 0x64u) || (compute && src == 0x25u)) {
const auto slot = src == 0x14u ? 0u : src == 0x24u ? 1u : 2u;
srcAddress = (engine == 1 ? 0x30148u : 0x30174u) + slot * 8u;
} else {
CheckBits(src, 0xfu, function);
}
const auto control = engine | (static_cast<std::uint32_t>(srcCachePolicy) << 13u) | ((dst & 3u) << 20u) | (static_cast<std::uint32_t>(dstCachePolicy) << 25u) | ((src & 3u) << 29u) | (static_cast<std::uint32_t>(blockEngine) << 31u);
const auto command = numBytes | ((src & 4u) << 24u) | ((dst & 4u) << 25u) | ((src & 8u) << 25u) | ((dst & 8u) << 26u) | (static_cast<std::uint32_t>(waitForPrevious) << 30u) | (static_cast<std::uint32_t>(writeConfirm) << 31u);
return Emit(buffer, 0x50u, {control, static_cast<std::uint32_t>(srcAddress), static_cast<std::uint32_t>(srcAddress >> 32u), static_cast<std::uint32_t>(dstAddress), static_cast<std::uint32_t>(dstAddress >> 32u), command}, function);
}
std::uint32_t* WriteData(CommandBuffer* buffer, bool compute, std::uint8_t dst, std::uint8_t cachePolicy, std::uint64_t address, const void* data, std::uint32_t count, std::uint8_t increment, std::uint8_t writeConfirm, const char* function) {
Require(data != nullptr && count != 0 && count <= 0x3ffdu, function, "invalid write data payload");
CheckBits(dst, compute ? 0xfu : 0x1fu, function);
CheckBits(cachePolicy, 3, function);
CheckBits(increment, 1, function);
CheckBits(writeConfirm, 1, function);
Require(compute || (address & 3u) == 0, function, "misaligned write address");
Require(dst != 0 || writeConfirm == 0, function, "register writes do not support write confirmation");
std::vector<std::uint32_t> snapshot(count);
std::memcpy(snapshot.data(), data, count * sizeof(std::uint32_t));
const auto destination = compute ? static_cast<std::uint32_t>(dst) << 8u : ((dst & 1u) << 30u) | ((dst & 0x1eu) << 7u);
auto* packet = Allocate(buffer, count + 4u, function);
packet[0] = Header(0x37u, count + 4u);
packet[1] = destination | (static_cast<std::uint32_t>(increment) << 16u) | (static_cast<std::uint32_t>(writeConfirm) << 20u) | (static_cast<std::uint32_t>(cachePolicy) << 25u);
packet[2] = static_cast<std::uint32_t>(address);
packet[3] = static_cast<std::uint32_t>(address >> 32u);
std::copy(snapshot.begin(), snapshot.end(), packet + 4);
return packet;
}
std::uint32_t* WriteWait(CommandBuffer* buffer, std::uint8_t size, std::uint8_t compareFunction, std::uint8_t operation, std::uint8_t cachePolicy, const volatile void* address, std::uint64_t reference, std::uint64_t mask, std::uint32_t pollCycles, const char* function) {
CheckBits(size, 1, function);
Require(compareFunction <= 6, function, "invalid wait comparison");
CheckBits(operation, size == 0 ? 0xfu : 7u, function);
CheckBits(cachePolicy, 3, function);
Require((pollCycles >> 4u) <= 0xffffu, function, "wait poll interval overflow");
if (size == 0) {
// 32-bit waits only use the low halves; guests commonly pass a full 64-bit mask.
reference &= 0xffffffffu;
mask &= 0xffffffffu;
}
const auto guestAddress = reinterpret_cast<std::uintptr_t>(address);
// The address may be left null and filled in later with sceAgcWaitRegMemPatchAddress.
if (guestAddress != 0) CheckAddress(guestAddress, size == 0 ? 4 : 8, function);
CheckBits(guestAddress, 0xffffffffffffull, function);
const auto waitSize = size == 0 ? 7u : 9u;
auto* packet = Allocate(buffer, waitSize + 7u, function);
packet[0] = Header(0x79u, 4, 1);
packet[1] = 0x342u;
packet[2] = (size == 0 ? 0xc8010000u : 0xc8020000u) | static_cast<std::uint32_t>(guestAddress >> 32u);
packet[3] = static_cast<std::uint32_t>(guestAddress);
auto* wait = packet + 4;
wait[0] = Header(size == 0 ? 0x3cu : 0x93u, waitSize);
const auto opBits = size == 0 ? ((operation & 3u) << 8u) | ((operation & 0xcu) << 4u) : ((operation & 1u) << 8u) | ((operation & 6u) << 5u);
wait[1] = 0x10u | compareFunction | opBits | (static_cast<std::uint32_t>(cachePolicy) << 25u);
wait[2] = static_cast<std::uint32_t>(guestAddress);
wait[3] = static_cast<std::uint32_t>(guestAddress >> 32u);
wait[4] = static_cast<std::uint32_t>(reference);
if (size == 0) {
wait[5] = static_cast<std::uint32_t>(mask);
} else {
wait[5] = static_cast<std::uint32_t>(reference >> 32u);
wait[6] = static_cast<std::uint32_t>(mask);
wait[7] = static_cast<std::uint32_t>(mask >> 32u);
}
wait[waitSize - 1u] = pollCycles >> 4u;
wait[waitSize] = Header(0x79u, 3, 1);
wait[waitSize + 1u] = 0x342u;
wait[waitSize + 2u] = 0xc8000000u;
return packet;
}
std::uint32_t* ValidateWait(std::uint32_t* packet, const char* function) {
CheckAddress(reinterpret_cast<std::uintptr_t>(packet), 4, function);
Require(packet[0] == Header(0x79u, 4, 1) && packet[1] == 0x342u, function, "invalid wait wrapper");
const auto tag = packet[2] & 0xffff0000u;
Require(tag == 0xc8010000u || tag == 0xc8020000u, function, "invalid wait tag");
const auto size = tag == 0xc8010000u ? 7u : 9u;
auto* wait = packet + 4;
ValidatePacket(wait, size == 7 ? 0x3cu : 0x93u, size, function);
Require(wait[size] == Header(0x79u, 3, 1) && wait[size + 1u] == 0x342u && wait[size + 2u] == 0xc8000000u, function, "invalid wait end tag");
return wait;
}
}
@@ -0,0 +1,162 @@
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <algorithm>
#include <cstdio>
#include <limits>
#include <stdexcept>
#include <string>
#include <vector>
namespace Agc::Command {
void Require(bool condition, const char* function, const char* reason) {
if (!condition) {
throw std::runtime_error(std::string(function) + ": " + reason);
}
}
void CheckBits(std::uint64_t value, std::uint64_t mask, const char* function) {
if ((value & ~mask) == 0) return;
char reason[96];
std::snprintf(reason, sizeof(reason), "reserved bits are set (value 0x%llx, allowed 0x%llx)", static_cast<unsigned long long>(value), static_cast<unsigned long long>(mask));
Require(false, function, reason);
}
void CheckAddress(std::uint64_t address, std::uint32_t alignment, const char* function) {
if (address != 0 && (address & (alignment - 1u)) == 0) return;
char message[64];
std::snprintf(message, sizeof(message), "null or misaligned address 0x%llx", static_cast<unsigned long long>(address));
Require(false, function, message);
}
std::uint32_t Header(std::uint32_t opcode, std::uint32_t count, std::uint32_t flags) {
Require(count >= 2 && count <= 0x4001u && opcode <= 0xffu && flags <= 0xffu, __func__, "invalid packet header");
return 0xc0000000u | ((count - 2u) << 16u) | (opcode << 8u) | flags;
}
namespace {
std::uint32_t available(const CommandBuffer& buffer, const char* function) {
const auto bottom = reinterpret_cast<std::uintptr_t>(buffer.bottom);
const auto top = reinterpret_cast<std::uintptr_t>(buffer.top);
const auto up = reinterpret_cast<std::uintptr_t>(buffer.cursor_up);
const auto down = reinterpret_cast<std::uintptr_t>(buffer.cursor_down);
Require(((bottom | top | up | down) & 3u) == 0, function, "misaligned command buffer");
Require(bottom <= up && up <= down && down <= top, function, "invalid command buffer cursors");
Require(bottom != 0 || top == 0, function, "null command buffer storage");
const auto count = (down - up) / sizeof(std::uint32_t);
Require(count >= buffer.reserved_dw, function, "reserved space exceeds command buffer capacity");
Require(count - buffer.reserved_dw <= std::numeric_limits<std::uint32_t>::max(), function, "command buffer capacity overflow");
return static_cast<std::uint32_t>(count - buffer.reserved_dw);
}
}
void Reserve(CommandBuffer* buffer, std::uint32_t count, const char* function) {
Require(buffer != nullptr && count != 0, function, "null command buffer or empty allocation");
if (available(*buffer, function) < count) {
Require(buffer->callback != nullptr, function, "command buffer exhausted");
Require(count <= std::numeric_limits<std::uint32_t>::max() - buffer->reserved_dw, function, "command buffer allocation overflow");
Require(buffer->callback(buffer, count + buffer->reserved_dw, buffer->user_data), function, "command buffer allocation callback failed");
Require(available(*buffer, function) >= count, function, "command buffer allocation callback returned insufficient space");
}
}
std::uint32_t* Allocate(CommandBuffer* buffer, std::uint32_t count, const char* function) {
Reserve(buffer, count, function);
auto* result = buffer->cursor_up;
buffer->cursor_up += count;
return result;
}
std::uint32_t* Emit(CommandBuffer* buffer, std::uint32_t opcode, std::initializer_list<std::uint32_t> payload, const char* function) {
Require(payload.size() <= 0x4000u, function, "packet payload exceeds maximum size");
const auto count = static_cast<std::uint32_t>(payload.size()) + 1u;
const auto header = Header(opcode, count);
auto* packet = Allocate(buffer, count, function);
packet[0] = header;
std::copy(payload.begin(), payload.end(), packet + 1);
return packet;
}
void ValidatePacket(const std::uint32_t* packet, std::uint32_t opcode, std::uint32_t count, const char* function) {
CheckAddress(reinterpret_cast<std::uintptr_t>(packet), 4, function);
Require(packet[0] == Header(opcode, count), function, "unexpected packet type, size or flags");
}
std::uint32_t* WriteNop(CommandBuffer* buffer, std::uint32_t count, const char* function) {
const auto header = Header(0x10u, count);
auto* packet = Allocate(buffer, count, function);
packet[0] = header;
std::fill_n(packet + 1, count - 1u, 0u);
return packet;
}
std::uint32_t* WriteRegisterRange(CommandBuffer* buffer, std::uint32_t opcode, std::uint32_t offset, const std::uint32_t* values, std::uint32_t count, const char* function) {
Require(count != 0 && count <= 0x3fffu && offset <= 0xffffu && count <= 0x10000u - offset, function, "invalid register range");
std::vector<std::uint32_t> snapshot;
if (values != nullptr) {
CheckAddress(reinterpret_cast<std::uintptr_t>(values), 4, function);
snapshot.assign(values, values + count);
}
auto* packet = Allocate(buffer, count + 2u, function);
packet[0] = Header(opcode, count + 2u);
packet[1] = offset;
std::copy(snapshot.begin(), snapshot.end(), packet + 2);
return packet;
}
std::uint32_t* WriteRegisters(CommandBuffer* buffer, std::uint32_t opcode, const volatile ShaderRegister* registers, std::uint32_t count, bool snapshotAll, const char* function) {
Require(count != 0, function, "empty register list");
CheckAddress(reinterpret_cast<std::uintptr_t>(registers), 4, function);
std::vector<ShaderRegister> snapshot;
if (snapshotAll) {
snapshot.reserve(count);
for (std::uint32_t i = 0; i < count; ++i) {
snapshot.push_back({registers[i].offset, registers[i].value});
CheckBits(snapshot.back().offset, 0xffffu, function);
}
}
const auto offsetAt = [&](std::uint32_t index) { return snapshotAll ? snapshot[index].offset : registers[index].offset; };
const auto valueAt = [&](std::uint32_t index) { return snapshotAll ? snapshot[index].value : registers[index].value; };
std::uint32_t* first = nullptr;
std::uint32_t index = 0;
while (index < count) {
const auto offset = offsetAt(index);
CheckBits(offset, 0xffffu, function);
std::vector<std::uint32_t> values{valueAt(index++)};
while (index < count && offsetAt(index) == offset + values.size() && values.size() < 0x3fffu) {
CheckBits(offsetAt(index), 0xffffu, function);
values.push_back(valueAt(index++));
}
auto* packet = WriteRegisterRange(buffer, opcode, offset, values.data(), static_cast<std::uint32_t>(values.size()), function);
if (first == nullptr) {
first = packet;
}
}
return first;
}
std::uint32_t* WriteIndirectRegisters(CommandBuffer* buffer, std::uint32_t opcode, const volatile ShaderRegister* registers, std::uint32_t count, const char* function) {
const auto address = reinterpret_cast<std::uintptr_t>(registers);
CheckAddress(address, 4, function);
CheckBits(count, 0x3fffu, function);
return Emit(buffer, opcode, {static_cast<std::uint32_t>(address), static_cast<std::uint32_t>(address >> 32u), 0x80000000u, count}, function);
}
void PatchIndirectAddress(std::uint32_t* packet, std::uint32_t opcode, const volatile ShaderRegister* registers, const char* function) {
ValidatePacket(packet, opcode, 5, function);
Require(packet[3] == 0x80000000u && (packet[4] & ~0x3fffu) == 0, function, "invalid indirect register packet");
const auto address = reinterpret_cast<std::uintptr_t>(registers);
CheckAddress(address, 4, function);
packet[1] = static_cast<std::uint32_t>(address);
packet[2] = static_cast<std::uint32_t>(address >> 32u);
}
void PatchIndirectCount(std::uint32_t* packet, std::uint32_t opcode, std::uint32_t count, const char* function) {
ValidatePacket(packet, opcode, 5, function);
Require(packet[3] == 0x80000000u && packet[4] <= 0x3fffu && count <= 0x3fffu - packet[4], function, "indirect register count overflow or invalid packet");
packet[4] += count;
}
}
@@ -0,0 +1,79 @@
#include "prx/libSceAgc/Command/include/RegisterDefaults.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <algorithm>
#include <array>
#include <cstddef>
#include <mutex>
#include <vector>
namespace Agc::Command {
namespace {
struct RegisterDefaults {
ShaderRegister** tables[4];
std::uint32_t registerCounts[4];
std::uint32_t* types;
std::uint32_t count;
};
static_assert(offsetof(RegisterDefaults, count) == 0x38);
struct CompactBank {
ShaderRegister* registers;
std::uint32_t registerCount;
const std::uint16_t* offsets;
std::uint32_t pointerCount;
};
struct CompactRegisterDefaults {
CompactBank banks[4];
std::uint32_t* types;
std::uint32_t count;
};
#include "prx/libSceAgc/Command/include/RegisterDefaultsData.hpp"
struct Storage {
RegisterDefaults defaults{};
std::array<std::vector<ShaderRegister*>, 4> pointers;
bool initialized = false;
};
std::mutex defaultsMutex;
std::array<std::array<Storage, 14>, 2> storage;
}
void* GetRegisterDefaults(std::uint32_t version, bool internal, const char* function) {
Require(version < 14, function, "unsupported register defaults version");
const auto* source = internal ? agcInternalRegDefaultsByVersion[version] : agcPublicRegDefaultsByVersion[version];
std::lock_guard lock(defaultsMutex);
auto& destination = storage[internal ? 1 : 0][version];
if (!destination.initialized) {
std::array<std::vector<ShaderRegister*>, 4> pointers;
RegisterDefaults defaults{};
for (std::size_t bank = 0; bank < pointers.size(); ++bank) {
const auto& input = source->banks[bank];
Require(input.pointerCount == 0 || (input.registers != nullptr && input.offsets != nullptr), function, "invalid register defaults bank");
auto& table = pointers[bank];
table.reserve(input.pointerCount);
for (std::uint32_t index = 0; index < input.pointerCount; ++index) {
Require(input.offsets[index] < input.registerCount, function, "register defaults pointer exceeds bank");
table.push_back(input.registers + input.offsets[index]);
}
defaults.tables[bank] = table.empty() ? nullptr : table.data();
defaults.registerCounts[bank] = input.registerCount;
}
Require(source->count == 0 || source->types != nullptr, function, "missing register defaults types");
defaults.types = source->types;
defaults.count = source->count;
destination.pointers = std::move(pointers);
destination.defaults = defaults;
destination.initialized = true;
}
return &destination.defaults;
}
}
@@ -0,0 +1,4 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_DRAWINDEXED_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_DRAWINDEXED_HPP
#endif
@@ -0,0 +1,4 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_DRAWNONINDEXED_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_DRAWNONINDEXED_HPP
#endif
@@ -0,0 +1,4 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_INDEXBUFFER_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_INDEXBUFFER_HPP
#endif
@@ -0,0 +1,4 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_INSTANCING_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_INSTANCING_HPP
#endif
@@ -0,0 +1,4 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_STATS_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_DCBDRAW_INCLUDE_STATS_HPP
#endif
@@ -0,0 +1,84 @@
#include "prx/libSceAgc/Command/include/Draw.hpp"
#include "prx/libSceAgc/DcbDraw/include/DrawIndexed.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
std::uint32_t* APS5_VABI sceAgcDcbDrawIndex(CommandBuffer* buf, std::uint32_t indexCount, const volatile void* indexAddress, std::uint64_t modifier) {
const auto address = reinterpret_cast<std::uintptr_t>(indexAddress);
Agc::Command::CheckAddress(address, 1, __func__);
return Agc::Command::Emit(buf, 0x27u, {indexCount, static_cast<std::uint32_t>(address), static_cast<std::uint32_t>(address >> 32u), indexCount, Agc::Command::DrawInitiator(modifier, true, __func__)}, __func__);
}
std::uint32_t APS5_VABI sceAgcDcbDrawIndexGetSize() {
return 24;
}
std::uint32_t* APS5_VABI sceAgcDcbDrawIndexAuto(CommandBuffer* buf, std::uint32_t indexCount, std::uint64_t modifier) {
return Agc::Command::Emit(buf, 0x2du, {indexCount, Agc::Command::DrawInitiator(modifier, false, __func__)}, __func__);
}
std::uint32_t APS5_VABI sceAgcDcbDrawIndexAutoGetSize() {
return 12;
}
std::uint32_t* APS5_VABI sceAgcDcbDrawIndexOffset(CommandBuffer* buf, std::uint32_t indexOffset, std::uint32_t indexCount, std::uint64_t modifier) {
return Agc::Command::Emit(buf, 0x35u, {indexCount == 0 ? 1u : indexCount, indexOffset, indexCount, Agc::Command::DrawInitiator(modifier, true, __func__)}, __func__);
}
uint32_t APS5_VABI sceAgcDcbDrawIndexOffsetGetSize(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
uint32_t* APS5_VABI sceAgcDcbDrawIndexIndirect(CommandBuffer* buf, uint32_t data_offset_in_bytes, uint64_t modifier) {
Agc::Command::Require((data_offset_in_bytes & 3u) == 0, __func__, "misaligned indirect argument offset");
const auto offsets = Agc::Command::DrawPatchOffsets(modifier, __func__);
return Agc::Command::Emit(buf, 0x25u, {data_offset_in_bytes, static_cast<std::uint32_t>(offsets), static_cast<std::uint32_t>(offsets >> 32u), Agc::Command::DrawInitiator(modifier, true, __func__)}, __func__);
}
std::uint32_t APS5_VABI sceAgcDcbDrawIndexIndirectGetSize() {
return 20;
}
uint32_t* APS5_VABI sceAgcDcbDrawIndexIndirectMulti(CommandBuffer* buf, uint32_t data_offset_in_bytes, uint32_t count_indirect, uint32_t max_count_or_count, const volatile void* count_addr, uint32_t stride_in_bytes, uint64_t modifier) {
Agc::Command::CheckBits(count_indirect, 1, __func__);
Agc::Command::Require((data_offset_in_bytes & 3u) == 0 && (stride_in_bytes & 3u) == 0 && stride_in_bytes >= 20, __func__, "invalid indirect draw offset or stride");
const auto address = reinterpret_cast<std::uintptr_t>(count_addr);
if (count_indirect != 0) {
Agc::Command::CheckAddress(address, 4, __func__);
} else {
Agc::Command::Require(address == 0, __func__, "count address supplied for a direct draw count");
}
const auto offsets = Agc::Command::DrawPatchOffsets(modifier, __func__);
const auto low = static_cast<std::uint32_t>(modifier);
const auto control = Agc::Command::DrawIndexLocation(modifier) | ((low & 0x10u) << 23u) | (count_indirect << 30u) | ((low & 8u) << 28u);
return Agc::Command::Emit(buf, 0x38u, {data_offset_in_bytes, static_cast<std::uint32_t>(offsets), static_cast<std::uint32_t>(offsets >> 32u), control, max_count_or_count, static_cast<std::uint32_t>(address), static_cast<std::uint32_t>(address >> 32u), stride_in_bytes, Agc::Command::DrawInitiator(modifier, true, __func__)}, __func__);
}
std::uint32_t APS5_VABI sceAgcDcbDrawIndexIndirectMultiGetSize() {
return 40;
}
uint32_t* APS5_VABI sceAgcDcbDrawIndexMultiInstanced(CommandBuffer* buf, uint32_t index_count, const volatile void* index_addr, const volatile void* object_ids, uint32_t instance_count, uint64_t modifier) {
(void)buf;
(void)index_count;
(void)index_addr;
(void)object_ids;
(void)instance_count;
(void)modifier;
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
uint32_t APS5_VABI sceAgcDcbDrawIndexMultiInstancedGetSize(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
}
@@ -0,0 +1,59 @@
#include "prx/libSceAgc/Command/include/Draw.hpp"
#include "prx/libSceAgc/DcbDraw/include/DrawNonIndexed.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
std::uint32_t* APS5_VABI sceAgcDcbDrawIndirect(CommandBuffer* buf, std::uint32_t dataOffsetInBytes, std::uint64_t modifier) {
Agc::Command::Require((dataOffsetInBytes & 3u) == 0, __func__, "misaligned indirect argument offset");
const auto offsets = Agc::Command::DrawPatchOffsets(modifier, __func__);
return Agc::Command::Emit(buf, 0x24u, {dataOffsetInBytes, static_cast<std::uint32_t>(offsets), static_cast<std::uint32_t>(offsets >> 32u), Agc::Command::DrawInitiator(modifier, false, __func__)}, __func__);
}
std::uint32_t APS5_VABI sceAgcDcbDrawIndirectGetSize() {
return 20;
}
std::uint32_t* APS5_VABI sceAgcDcbDrawIndirectMulti(CommandBuffer* buf, std::uint32_t dataOffsetInBytes, std::uint32_t countIndirect, std::uint32_t maxCountOrCount, const volatile void* countAddress, std::uint32_t strideInBytes, std::uint64_t modifier) {
Agc::Command::CheckBits(countIndirect, 1, __func__);
Agc::Command::Require((dataOffsetInBytes & 3u) == 0 && (strideInBytes & 3u) == 0 && strideInBytes >= 16, __func__, "invalid indirect draw offset or stride");
const auto address = reinterpret_cast<std::uintptr_t>(countAddress);
if (countIndirect != 0) {
Agc::Command::CheckAddress(address, 4, __func__);
} else {
Agc::Command::Require(address == 0, __func__, "count address supplied for a direct draw count");
}
const auto offsets = Agc::Command::DrawPatchOffsets(modifier, __func__);
const auto initiator = Agc::Command::DrawInitiator(modifier, false, __func__);
const auto low = static_cast<std::uint32_t>(modifier);
const auto control = Agc::Command::DrawIndexLocation(modifier) | ((low & 0x10u) << 23u) | (countIndirect << 30u) | ((low & 8u) << 28u);
auto* packet = Agc::Command::Allocate(buf, 16, __func__);
packet[0] = Agc::Command::Header(0x79u, 3, 1);
packet[1] = 0x342u;
packet[2] = 0xc6000008u;
packet[3] = Agc::Command::Header(0x2cu, 10);
packet[4] = dataOffsetInBytes;
packet[5] = static_cast<std::uint32_t>(offsets);
packet[6] = static_cast<std::uint32_t>(offsets >> 32u);
packet[7] = control;
packet[8] = maxCountOrCount;
packet[9] = static_cast<std::uint32_t>(address);
packet[10] = static_cast<std::uint32_t>(address >> 32u);
packet[11] = strideInBytes;
packet[12] = initiator;
packet[13] = Agc::Command::Header(0x79u, 3, 1);
packet[14] = 0x342u;
packet[15] = 0xc6000000u;
return packet;
}
std::uint32_t APS5_VABI sceAgcDcbDrawIndirectMultiGetSize() {
return 64;
}
}
@@ -0,0 +1,52 @@
#include "prx/libSceAgc/DcbDraw/include/IndexBuffer.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
std::uint32_t* APS5_VABI sceAgcDcbSetIndexBuffer(CommandBuffer* buf, std::uint64_t indexAddress) {
if (indexAddress != 0) Agc::Command::CheckAddress(indexAddress, 2, __func__);
return Agc::Command::Emit(buf, 0x26u, {static_cast<std::uint32_t>(indexAddress), static_cast<std::uint32_t>(indexAddress >> 32u)}, __func__);
}
std::uint32_t APS5_VABI sceAgcDcbSetIndexBufferGetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcDcbSetIndexCount(CommandBuffer* buf, std::uint32_t indexCount) {
return Agc::Command::Emit(buf, 0x13u, {indexCount}, __func__);
}
std::uint32_t APS5_VABI sceAgcDcbSetIndexCountGetSize() {
return 8;
}
std::uint32_t* APS5_VABI sceAgcDcbSetIndexSize(CommandBuffer* buf, std::uint8_t indexSize, std::uint8_t cachePolicy) {
Agc::Command::Require(indexSize <= 2, __func__, "invalid index element size");
Agc::Command::CheckBits(cachePolicy, 3, __func__);
return Agc::Command::Emit(buf, 0x7au, {0x20000243u, 0x400u | indexSize | (static_cast<std::uint32_t>(cachePolicy) << 6u)}, __func__);
}
std::uint32_t APS5_VABI sceAgcDcbSetIndexSizeGetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcDcbSetIndexIndirectArgs(CommandBuffer* buf, std::uint32_t dataOffsetInBytes) {
(void)buf;
(void)dataOffsetInBytes;
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
std::uint32_t APS5_VABI sceAgcDcbSetIndexIndirectArgsGetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
}
@@ -0,0 +1,33 @@
#include "prx/libSceAgc/DcbDraw/include/Instancing.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
std::uint32_t* APS5_VABI sceAgcDcbSetNumInstances(CommandBuffer* buf, std::uint32_t numInstances) {
return Agc::Command::Emit(buf, 0x2fu, {numInstances}, __func__);
}
std::uint32_t APS5_VABI sceAgcDcbSetNumInstancesGetSize() {
return 8;
}
uint32_t* APS5_VABI sceAgcDcbSetBaseIndirectArgs(CommandBuffer* buf, uint32_t shader_type, const volatile void* indirect_base_addr) {
// SET_BASE with base index 1; header bit 1 selects the dispatch (compute) base over the draw base.
Agc::Command::CheckBits(shader_type, 1, __func__);
const auto address = reinterpret_cast<std::uintptr_t>(indirect_base_addr);
Agc::Command::CheckAddress(address, 8, __func__);
Agc::Command::CheckBits(address, 0xffffffffffffull, __func__);
auto* packet = Agc::Command::Allocate(buf, 4, __func__);
packet[0] = Agc::Command::Header(0x11u, 4, shader_type != 0 ? 2u : 0u);
packet[1] = 1;
packet[2] = static_cast<std::uint32_t>(address);
packet[3] = static_cast<std::uint32_t>(address >> 32u);
return packet;
}
}
@@ -0,0 +1,34 @@
#include "prx/libSceAgc/DcbDraw/include/Stats.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
std::uint32_t* APS5_VABI sceAgcDcbGetLodStats(CommandBuffer* buf, std::uint8_t cachePolicy, const volatile void* buffer, std::uint32_t bufferSizeInBytes, std::uint32_t resetCount, std::uint8_t forceReset, std::uint8_t reportAndReset, std::uint32_t reportingIntervalIn100kClocks) {
Agc::Command::CheckBits(cachePolicy, 3, __func__);
Agc::Command::CheckBits(resetCount, 0xffu, __func__);
Agc::Command::CheckBits(forceReset, 1, __func__);
Agc::Command::CheckBits(reportAndReset, 1, __func__);
Agc::Command::CheckBits(reportingIntervalIn100kClocks, 0xffu, __func__);
const auto address = reinterpret_cast<std::uintptr_t>(buffer);
if (address != 0) Agc::Command::CheckAddress(address, 64, __func__);
const auto control = (static_cast<std::uint32_t>(cachePolicy) << 28u) | (static_cast<std::uint32_t>(reportAndReset) << 19u) | (static_cast<std::uint32_t>(forceReset) << 18u) | (resetCount << 10u) | (reportingIntervalIn100kClocks << 2u);
// LOD statistics are not collected; a same-sized NOP keeps the packet layout without producing data.
return Agc::Command::Emit(buf, 0x10u, {bufferSizeInBytes, static_cast<std::uint32_t>(address), static_cast<std::uint32_t>(address >> 32u), control}, __func__);
}
std::uint32_t APS5_VABI sceAgcDcbBeginOcclusionQueryGetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t APS5_VABI sceAgcDcbEndOcclusionQueryGetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
}
@@ -0,0 +1,4 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBFLOW_INCLUDE_CONTROL_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_DCBFLOW_INCLUDE_CONTROL_HPP
#endif
@@ -0,0 +1,4 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBFLOW_INCLUDE_DISPATCH_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_DCBFLOW_INCLUDE_DISPATCH_HPP
#endif
@@ -0,0 +1,8 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBFLOW_INCLUDE_MEMORY_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_DCBFLOW_INCLUDE_MEMORY_HPP
#include "SceTypes.hpp"
extern "C" std::uint32_t* APS5_VABI sceAgcDcbAcquireMem(CommandBuffer* buf, std::uint8_t engine, std::uint32_t cbDbOp, std::uint32_t gcrControl, const volatile void* base, std::uint64_t sizeBytes, std::uint32_t pollCycles);
#endif
@@ -0,0 +1,5 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBFLOW_INCLUDE_SYNC_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_DCBFLOW_INCLUDE_SYNC_HPP
#endif
@@ -0,0 +1,59 @@
#include "prx/libSceAgc/DcbFlow/include/Control.hpp"
#include "prx/libSceAgc/Command/include/Memory.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
// unknown signature
APS5_EXPORT("zARR5aCmkoY", sceAgcDcbA_zARR5aCmkoY);
void* APS5_VABI sceAgcDcbA_zARR5aCmkoY(void) {
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
uint32_t* APS5_VABI sceAgcDcbJump(CommandBuffer* buf, uint8_t mode, uint8_t cache_policy, const uint32_t* target, uint32_t size_in_dwords) {
(void)buf;
(void)mode;
(void)cache_policy;
(void)target;
(void)size_in_dwords;
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
std::uint32_t APS5_VABI sceAgcDcbJumpGetSize() {
return 16;
}
std::uint32_t* APS5_VABI sceAgcDcbResetQueue(CommandBuffer* buf, std::uint32_t op, std::uint32_t state) {
Agc::Command::CheckBits(op, 0xfffu, __func__);
Agc::Command::CheckBits(state, 0xfu, __func__);
return Agc::Command::Emit(buf, 0x12u, {state}, __func__);
}
uint32_t* APS5_VABI sceAgcDcbRewind(CommandBuffer* buf, uint32_t initial_state) {
(void)buf;
(void)initial_state;
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
uint32_t APS5_VABI sceAgcDcbRewindGetSize(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
uint32_t* APS5_VABI sceAgcDcbWaitUntilSafeForRendering(CommandBuffer* buf, uint32_t video_out_handle, uint32_t display_buffer_index) {
// Presentation copies the display buffer when the flip executes, so the buffer is always safe to
// render into; keep the arguments in a NOP for command-buffer dumps.
return Agc::Command::Emit(buf, 0x10u, {video_out_handle, display_buffer_index}, __func__);
}
}
@@ -0,0 +1,22 @@
#include "prx/libSceAgc/DcbFlow/include/Dispatch.hpp"
#include "prx/libSceAgc/Command/include/Memory.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
uint32_t* APS5_VABI sceAgcDcbDispatchIndirect(CommandBuffer* buf, uint32_t data_offset_in_bytes, uint32_t flags) {
// Graphics queues read the arguments at an offset from the base set by SetBaseDispatchIndirectArgs.
Agc::Command::CheckBits(flags, 0xa038u | 0x41u, __func__);
return Agc::Command::Emit(buf, 0x16u, {data_offset_in_bytes, flags | 0x41u}, __func__);
}
std::uint32_t APS5_VABI sceAgcDcbDispatchIndirectGetSize() {
return 12;
}
}
@@ -0,0 +1,93 @@
#include "prx/libSceAgc/DcbFlow/include/Memory.hpp"
#include "prx/libSceAgc/Command/include/Memory.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
std::uint32_t* APS5_VABI sceAgcDcbAcquireMem(CommandBuffer* buf, std::uint8_t engine, std::uint32_t cbDbOp, std::uint32_t gcrControl, const volatile void* base, std::uint64_t sizeBytes, std::uint32_t pollCycles) {
Agc::Command::CheckBits(engine, 1, __func__);
Agc::Command::CheckBits(cbDbOp, 0x7fffffffu, __func__);
Agc::Command::CheckBits(gcrControl, 0x7ffffu, __func__);
// The range only scopes cache maintenance, so round it outward to the 256-byte granularity the
// packet encodes instead of rejecting unaligned ranges.
const auto requested = reinterpret_cast<std::uintptr_t>(base);
auto address = requested & ~static_cast<std::uintptr_t>(0xffu);
const auto wholeAddressSpace = sizeBytes == 0xffffffffffffffffull || (address >> 40u) != 0 || sizeBytes > (1ull << 40u);
if (wholeAddressSpace) address = 0;
else sizeBytes = (sizeBytes + (requested - address) + 0xffu) & ~0xffull;
Agc::Command::Require(pollCycles / 40u <= 0xffffu, __func__, "acquire poll interval overflow");
return Agc::Command::Emit(buf, 0x58u, {(static_cast<std::uint32_t>(engine) << 31u) | cbDbOp, wholeAddressSpace ? 0u : static_cast<std::uint32_t>(sizeBytes >> 8u), 0, static_cast<std::uint32_t>(address >> 8u), 0, pollCycles / 40u, gcrControl}, __func__);
}
uint32_t APS5_VABI sceAgcDcbAcquireMemGetSize(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
uint32_t* APS5_VABI sceAgcDcbCopyData(CommandBuffer* buf, uint8_t dst, uint8_t dst_cache_policy, uint64_t dst_address, uint8_t src, uint8_t src_cache_policy, uint64_t src_address_or_immediate, uint8_t item_size, uint8_t write_confirm) {
(void)buf;
(void)dst;
(void)dst_cache_policy;
(void)dst_address;
(void)src;
(void)src_cache_policy;
(void)src_address_or_immediate;
(void)item_size;
(void)write_confirm;
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
std::uint64_t APS5_VABI sceAgcDcbCopyDataGetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcDcbDmaData(CommandBuffer* buf, std::uint8_t engine, std::uint8_t dst, std::uint8_t dstCachePolicy, std::uint64_t dstAddress, std::uint8_t src, std::uint8_t srcCachePolicy, std::uint64_t srcAddress, std::uint32_t numBytes, std::uint8_t waitForPrevious, std::uint8_t writeConfirm, std::uint8_t blockEngine) {
return Agc::Command::WriteDma(buf, false, engine, dst, dstCachePolicy, dstAddress, src, srcCachePolicy, srcAddress, numBytes, waitForPrevious, writeConfirm, blockEngine, __func__);
}
std::uint32_t APS5_VABI sceAgcDcbDmaDataGetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcDcbAtomicMem(CommandBuffer* buf, std::uint8_t atomicOp, std::uint8_t command, std::uint8_t cachePolicy, const volatile void* address, std::uint64_t srcData, std::uint64_t compareData, std::uint16_t loopInterval) {
(void)buf;
(void)atomicOp;
(void)command;
(void)cachePolicy;
(void)address;
(void)srcData;
(void)compareData;
(void)loopInterval;
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
std::uint32_t APS5_VABI sceAgcDcbAtomicMemGetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t APS5_VABI sceAgcDcbAtomicGdsGetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcDcbWriteData(CommandBuffer* buf, std::uint8_t dst, std::uint8_t cachePolicy, std::uint64_t address, const void* data, std::uint32_t numDwords, std::uint8_t increment, std::uint8_t writeConfirm) {
return Agc::Command::WriteData(buf, false, dst, cachePolicy, address, data, numDwords, increment, writeConfirm, __func__);
}
uint32_t APS5_VABI sceAgcDcbWriteDataGetSize(uint32_t num_dwords) {
(void)num_dwords;
NotImplemented_nid_no_patch(__func__);
return 0;
}
}
@@ -0,0 +1,71 @@
#include "prx/libSceAgc/DcbFlow/include/Sync.hpp"
#include "prx/libSceAgc/Command/include/Memory.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
extern "C" {
uint32_t* APS5_VABI sceAgcDcbCondExec(CommandBuffer* buf, const volatile uint32_t* address, uint32_t num_dwords) {
(void)buf;
(void)address;
(void)num_dwords;
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
uint32_t APS5_VABI sceAgcDcbCondExecGetSize(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcDcbWaitRegMem(CommandBuffer* buf, std::uint8_t size, std::uint8_t compareFunction, std::uint8_t operation, std::uint8_t cachePolicy, const volatile void* address, std::uint64_t reference, std::uint64_t mask, std::uint32_t pollCycles) {
return Agc::Command::WriteWait(buf, size, compareFunction, operation, cachePolicy, address, reference, mask, pollCycles, __func__);
}
uint32_t APS5_VABI sceAgcDcbWaitOnAddressGetSize(uint32_t size) {
(void)size;
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcDcbEventWrite(CommandBuffer* buf, std::uint8_t eventType, const volatile void* address) {
Agc::Command::CheckBits(eventType, 0x3fu, __func__);
if ((eventType & 0xfeu) == 0x38u) {
const auto guestAddress = reinterpret_cast<std::uintptr_t>(address);
Agc::Command::CheckAddress(guestAddress, 8, __func__);
return Agc::Command::Emit(buf, 0x46u, {0x100u | eventType, static_cast<std::uint32_t>(guestAddress), static_cast<std::uint32_t>(guestAddress >> 32u)}, __func__);
}
Agc::Command::Require(address == nullptr, __func__, "this event does not use an address");
const auto eventIndex = eventType == 7 || eventType == 15 || eventType == 16 ? 0x400u : 0u;
return Agc::Command::Emit(buf, 0x46u, {eventIndex | eventType}, __func__);
}
std::uint64_t APS5_VABI sceAgcDcbEventWriteGetSize(std::uint8_t eventType) {
(void)eventType;
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcDcbStallCommandBufferParser(CommandBuffer* buf) {
return Agc::Command::Emit(buf, 0x42u, {0}, __func__);
}
std::uint32_t APS5_VABI sceAgcDcbStallCommandBufferParserGetSize() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
std::uint32_t* APS5_VABI sceAgcDcbMemSemaphore(CommandBuffer* buf, std::uint8_t action, std::uint8_t clientCode, const volatile void* address) {
(void)buf;
(void)action;
(void)clientCode;
(void)address;
NotImplemented_nid_no_patch(__func__);
return nullptr;
}
}
@@ -0,0 +1,4 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBSTATE_INCLUDE_CONTEXTSTATE_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_DCBSTATE_INCLUDE_CONTEXTSTATE_HPP
#endif
@@ -0,0 +1,4 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGC_DCBSTATE_INCLUDE_DISPLAY_HPP
#define CORE_LIBS_PRX_LIBSCEAGC_DCBSTATE_INCLUDE_DISPLAY_HPP
#endif
Loaded 100 of 1053 files, more files were not shown because too many files have changed in this diff. Show more