[PR #638] [MERGED] Add patches for F16C instructions under Rosetta 2. #1685

Closed
opened 2026-02-27 21:13:33 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/638
Author: @squidbus
Created: 8/29/2024
Status: Merged
Merged: 8/30/2024
Merged by: @georgemoralis

Base: mainHead: f16c


📝 Commits (1)

  • a171509 Add patches for F16C instructions under Rosetta 2.

📊 Changes

8 files changed (+291 additions, -36 deletions)

View changed files

📝 .gitmodules (+4 -1)
📝 CMakeLists.txt (+3 -0)
📝 externals/CMakeLists.txt (+11 -5)
externals/half (+1 -0)
📝 src/core/cpu_patches.cpp (+259 -30)
📝 src/core/cpu_patches.h (+6 -0)
📝 src/core/libraries/kernel/thread_management.cpp (+3 -0)
📝 src/core/linker.cpp (+4 -0)

📄 Description

Adds patches for F16C instructions which are currently missing under Rosetta 2 on macOS.

This also enhances the stack saving capabilities in the patcher to allow saving entire contexts with fewer TLS slots. Before the patcher would allocate a TLS slot for each register it needed to save. Now, it only needs two slots for an arbitrary amount of context: one slot for a thread-specific patch stack and the other for the original function stack. When a patch needs to save context it can switch out the stacks and save registers, then do the reverse when done.

Additionally some code is added for using vector and immediate operands in patches.

I tested this with CUSA16429 which is the only game I have that uses these instructions. From basic debugging examining the inputs and outputs it seems to work as expected although the game still does not progress past a black screen on launch so I can't validate it in-depth. It gets a lot further a long though until it hits a missing primitive type.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/shadps4-emu/shadPS4/pull/638 **Author:** [@squidbus](https://github.com/squidbus) **Created:** 8/29/2024 **Status:** ✅ Merged **Merged:** 8/30/2024 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `f16c` --- ### 📝 Commits (1) - [`a171509`](https://github.com/shadps4-emu/shadPS4/commit/a17150960f01b728d17522791c714d2d5ff10c79) Add patches for F16C instructions under Rosetta 2. ### 📊 Changes **8 files changed** (+291 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `.gitmodules` (+4 -1) 📝 `CMakeLists.txt` (+3 -0) 📝 `externals/CMakeLists.txt` (+11 -5) ➕ `externals/half` (+1 -0) 📝 `src/core/cpu_patches.cpp` (+259 -30) 📝 `src/core/cpu_patches.h` (+6 -0) 📝 `src/core/libraries/kernel/thread_management.cpp` (+3 -0) 📝 `src/core/linker.cpp` (+4 -0) </details> ### 📄 Description Adds patches for F16C instructions which are currently missing under Rosetta 2 on macOS. This also enhances the stack saving capabilities in the patcher to allow saving entire contexts with fewer TLS slots. Before the patcher would allocate a TLS slot for each register it needed to save. Now, it only needs two slots for an arbitrary amount of context: one slot for a thread-specific patch stack and the other for the original function stack. When a patch needs to save context it can switch out the stacks and save registers, then do the reverse when done. Additionally some code is added for using vector and immediate operands in patches. I tested this with CUSA16429 which is the only game I have that uses these instructions. From basic debugging examining the inputs and outputs it seems to work as expected although the game still does not progress past a black screen on launch so I can't validate it in-depth. It gets a lot further a long though until it hits a missing primitive type. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 21:13:33 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shadPS4#1685
No description provided.