Commit graph

1001 commits

Author SHA1 Message Date
Lander Gallastegi
a71bfb30a2
shader_recompiler: Patch SRT walker on segfault (#2991)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* Patch srt walker access violations

* Fix range

* clang-format lolz

* Lower log from warning to debug
2025-06-09 13:04:21 +03:00
TheTurtle
d7051f15f4
texture_cache: Basic handling of partially resident images (#3066)
* texture_cache: Avoid gpu tracking assert on sparse image

At the moment just take the easy way of creating the entire image normally and uploading unmapped subresources are zero

* tile_manager: Downgrade assert to error

* fix macos
2025-06-09 01:26:10 -07:00
Paris Oplopoios
5004e41100
Patch movntss and movntsd (#3049)
* Patch movntss and movntsd

* clang-format

* Deduplication

* Allow rep to be in other places
2025-06-08 22:29:33 +03:00
Fire Cube
5d064dd89f
Dev Tools: Fix Module Viewer HLE detection (#3058)
* fix

* clang
2025-06-08 21:04:55 +03:00
Stephen Miller
2857ef34f0
Don't coalesce dmem pages (#3059)
Looks like this change is what broke P.T.
I'll need to look closer at this when I have a chance, clearly we're doing something wrong here.
2025-06-08 21:04:43 +03:00
Stephen Miller
5edd9ff54b
Improved sceKernelMapNamedFlexibleMemory logging (#3050)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* More descriptive sceKernelMapNamedFlexibleMemory logging

* Misc exports

These functions are used by Overwatch: Origins Edition

* Clang

* Function parameter cleanup

Changes the parameters on our sceKernelMapNamedFlexibleMemory and sceKernelMapFlexibleMemory functions to better align with our current standards.
2025-06-08 00:17:45 +03:00
Stephen Miller
43bf4ed1bc
sceVideoOutGetResolutionStatus error behavior (#3044) 2025-06-05 12:14:34 -07:00
Stephen Miller
0e9420a7b2
Fix request queues in libSceZlib (#3041)
Queues are a FIFO data structure, so pop() removes the front, not the end.
2025-06-05 16:43:39 +03:00
Stephen Miller
23710f397e
Reduce clamp threshold to 2MB (#3034)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
A proposed solution to the non-GPU memory asserts seen in RESIDENT EVIL 2 (CUSA09193)
2025-06-03 22:17:35 -07:00
Marcin Mikołajczyk
5b6fc788b3
Fix passing user data in user-triggered equeue events (#2948) 2025-06-03 11:42:20 -07:00
Stephen Miller
8cdd8dd725
Core: Pthread affinity fixups (#3021)
Some checks are pending
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / clang-format (push) Waiting to run
Build and Release / reuse (push) Waiting to run
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* posix_pthread_attr_getschedparam

* Fixes for scePthreadGetAffinity and scePthreadSetAffinity

Looking at FreeBSD source, and our other pthread functions, we should be using our FindThread function to get the appropriate thread if thread != g_curthread.
2025-06-03 03:43:56 -07:00
Stephen Miller
bb3f8af81a
Core: Protect fixes (#3029)
* Swap do-while to while

If we use a do-while loop, we waste time if `aligned_size = 0`.  This is also still accurate to FreeBSD behavior, where it returns success if `start == end` during mprotect.
This also effectively prevents the memory assert seen in updated versions of RESIDENT EVIL 2 (CUSA09193)

* Move prot validation outside loop

The prot variable shouldn't change during a mprotect call, so we can check the flags before protecting instead.
Also cleans up the code for prot validation.
This should improve performance, and is more accurate to FreeBSD code.

* Add logging for protect calls

This will help in debugging future problems
2025-06-03 09:29:25 +03:00
mailwl
eed99141b3
Network Play: set user signed in (#2944)
* Network Play: set user signed in

* get signedIn status from config

---------

Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
2025-06-03 09:11:18 +03:00
Stephen Miller
2c78272185
Emulate libSceGnmDriver's init behavior (#3024)
This time, perform it after the LoadSharedLibraries call, which places it after the various init memory mappings GFD engine titles perform.
2025-06-03 08:02:51 +03:00
Stephen Miller
6bdd83684b
Libs: libSceVoice stubs (#3022)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* voice lib stubs

Primarily for GTA V

* Clang
2025-06-01 19:30:03 +03:00
WujekFoliarz
b1af1334c9
Fix touchpad handling and change gyro calculation (#3006)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
* Change touchpad handling and orientation calculation

* remove unnecessary includes in pad.cpp

* remove the cmake command arguments

* remove the weird file

* try to fix formatting

* limit new gyro and touchpad logic to controller 1

* remove cout

* fix formatting and add the handle check to scePadRead

* swap y and z back
2025-06-01 19:13:02 +03:00
Stephen Miller
c09e463b8e
Revert new GPU map logic (#3019)
Some checks are pending
Build and Release / pre-release (push) Blocked by required conditions
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Something's wrong somewhere, and there's just too many places that somewhere could be for me to debug it right now.
2025-05-31 17:35:52 +03:00
Stephen Miller
6cdc52cdde
Core: More Memory Cleanup & Fixes (#2997)
* Only perform GPU memory mapping when GPU can access it

This better aligns with hardware observations, and should also speed up unmaps and decommits, since they don't need to be compared with the GPU max address anymore.

* Reserve fixes

ReserveVirtualRange seems to follow the 0x200000000 base address like MemoryPoolReserve does.
Both also need checks in their flags Fixed path to ensure we're mapping in-bounds. If we're not in mapping to our address space, we'll end up reserving and returning the wrong address, which could lead to weird memory issues in games.

I'll need to test on real hardware to verify if such changes are appropriate.

* Better sceKernelMmap

Handles errors where we would previously throw exceptions. Also moves the file logic to MapFile, since that way all the possible errors are in one place.
Also fixes some function parameters to align with our current standards.

* Major refactor

MapDirectMemory, MapFlexibleMemory, ReserveVirtualRange, and MemoryPoolReserve all internally use mmap to perform their mappings. Naturally, this means that all functions have similar behaviors, and a lot of duplicate code.
This add necessary conditional behavior to MapMemory so MemoryPoolReserve and ReserveVirtualRange can use it, without disrupting the behavior of MapDirectMemory or MapFlexibleMemory calls.

* Accurate phys_addr for non-direct mappings

* Properly handle GPU access rights

Since my first commit restricts GPU mappings to memory areas with GPU access permissions, we also need to be updating the GPU mappings appropriately during Protect calls too.

* Update memory.cpp

* Update memory.h

* Update memory.cpp

* Update memory.cpp

* Update memory.cpp

* Revert "Update memory.cpp"

This reverts commit 2c55d014c0.

* Coalesce dmem map

Aligns with hardware observations, hopefully shouldn't break anything since nothing should change hardware-wise when release dmem calls and unmap calls are performed?
Either that or Windows breaks because Windows, will need to test.

* Implement posix_mprotect

Unity calls this
Also fixes the names of sceKernelMprotect and sceKernelMtypeprotect, though that's more of a style change and can be reverted if requested.

* Fix sceKernelSetVirtualRangeName

Partially addresses a "regression" introduced when I fixed up some asserts.
As noted in the code, this implementation is still slightly inaccurate, as handling this properly could cause regressions on Windows.

* Unconditional assert in MapFile

* Remove protect warning

This is expected behavior, shouldn't need any logging.

* Respect alignment

Forgot to properly do this when updating ReserveVirtualRange and MemoryPoolReserve

* Fix Mprotect on free memory

On real hardware, this just does nothing. If something did get protected, there's no way to query that information.
Therefore, it seems pretty safe to just behave like munmap and return size here.

* Minor tidy-up

No functional difference, but looks better.
2025-05-29 18:56:03 +03:00
Fire Cube
eb9f66c349
Libs: CompanionUtil (#2963)
* impl

* more

* move log

* cleanup type definitions

* error code cleanup and clang

* cleanup ugly RE code

* shame

* clang

---------

Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
2025-05-29 12:33:56 +03:00
georgemoralis
7f0503bf8b
Implemented sceNetInetNtop in RE (#3003)
* implemented sceNetInetNtop in RE

* some logging

* added freebsd_inet_ntop4

* freebsd_inet_ntop6

* fixups based on reviews

* review fixes
2025-05-29 11:59:34 +03:00
squidbus
95f04b746d
equeue: Move small timer check to WaitForEvents. (#3000)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
2025-05-28 19:54:47 +03:00
Fire Cube
e0309a4b01
Equeue: fix WaitEqueue assert on nullptr (#2994)
Some checks are pending
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* fix

* fix infinite call of waitforsmalltimer

* fix wrong nullptr check

* add comment back

* fix discrepancy

* remove assert

---------

Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
2025-05-27 14:47:54 -07:00
Fire Cube
149898193f
Devtools: Add Module Viewer (#2976)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* impl

* add User or Sysmodule detection

* fix compiler warning

* clang

* fix string

* add HLE

* prevent crash

* fix mutex

* remove ref in arg

* cleanup

* move gamefolder to elfinfo
2025-05-24 09:15:10 -03:00
georgemoralis
b55c3f4555
Trophy fix (#2975)
* fixed invalid handle destroy

* removed log
2025-05-22 05:35:00 -07:00
squidbus
6935b24440
savedata: Fix missing uses of config based save data dir. (#2971) 2025-05-22 11:28:41 +03:00
kalaposfos13
eb21083078
Lower stack size to clear from 13 to 12 KB (#2967) 2025-05-21 16:22:38 -03:00
Vinicius Rangel
5eb58799fe
SaveData: respect install dir in param.sfo to select the game save folder (#2951)
Some checks failed
Build and Release / reuse (push) Has been cancelled
Build and Release / clang-format (push) Has been cancelled
Build and Release / get-info (push) Has been cancelled
Build and Release / windows-sdl (push) Has been cancelled
Build and Release / windows-qt (push) Has been cancelled
Build and Release / macos-sdl (push) Has been cancelled
Build and Release / macos-qt (push) Has been cancelled
Build and Release / linux-sdl (push) Has been cancelled
Build and Release / linux-qt (push) Has been cancelled
Build and Release / linux-sdl-gcc (push) Has been cancelled
Build and Release / linux-qt-gcc (push) Has been cancelled
Build and Release / pre-release (push) Has been cancelled
2025-05-17 12:00:35 -03:00
Vinicius Rangel
5f447a815e
SaveDataDialog: fix possible null access (#2947) 2025-05-17 10:41:16 -03:00
Stephen Miller
a0acb47185
Only align when flags Fixed is not present (#2945)
Should fix some remaining memory issues.
2025-05-16 14:21:13 -07:00
mailwl
ffd31589cf
Fix reading not existing savedata (#2941)
* Fix reading not existing savedata

* alloc save memory instead return error

* save memory saze to save slot instead of global

* remove unused enum

* remove unneeded memory clean
2025-05-16 13:22:47 -03:00
Stephen Miller
4d769d9c7e
Proper error handling for MapMemory errors (#2938)
* Properly handle ENOMEM error return in MapMemory

Needed for Assassin's Creed Unity to behave properly.

* Change error message

If I left the message as-is, we'd probably see inexperienced people claiming the assert means your device needs more memory, which is completely false.

* Clang

You know you're doing something right when Clang complains.

* Attempt to handle MemoryMapFlags::NoOverwrite

Based on my interpretation of red_prig's descriptions. These changes are untested, as I'm not able to test right now.

* Fix flag description

* Move overwrite check to while condition
2025-05-16 17:41:22 +03:00
georgemoralis
7de6aec337
[Libs] Companion httpd (#2942)
* stubbed companion httpd

* sceCompanionHttpdGetEvent returns disconnected device

* more function definations

* added error codes file
2025-05-16 16:17:37 +03:00
Stephen Miller
18ff65efc8
Implement sceKernelMapDirectMemory2 (#2940)
* Implement sceKernelMapDirectMemory2

Behaves similarly to sceKernelMapDirectMemory, but has a type parameter.

* Simplify

No need to copy all the MapDirectMemory code over, can just call the function, then do the SetDirectMemoryType call

* Clang
2025-05-16 05:38:40 -07:00
squidbus
aeb4536988
externals: Remove winpthreads. (#2932) 2025-05-15 13:59:34 -07:00
Stephen Miller
6d38100a41
Avoid logging nulls in sceKernelIsStack (#2933)
Games would crash if providing nullptr to start or end.
Also don't need the :# part when logging pointers, as they're automatically formatted.
2025-05-14 17:09:23 +03:00
squidbus
26c965cf4a equeue: Fix timer cancel error code check.
Some checks failed
Build and Release / reuse (push) Has been cancelled
Build and Release / clang-format (push) Has been cancelled
Build and Release / get-info (push) Has been cancelled
Build and Release / windows-sdl (push) Has been cancelled
Build and Release / windows-qt (push) Has been cancelled
Build and Release / macos-sdl (push) Has been cancelled
Build and Release / macos-qt (push) Has been cancelled
Build and Release / linux-sdl (push) Has been cancelled
Build and Release / linux-qt (push) Has been cancelled
Build and Release / linux-sdl-gcc (push) Has been cancelled
Build and Release / linux-qt-gcc (push) Has been cancelled
Build and Release / pre-release (push) Has been cancelled
2025-05-13 17:31:23 -07:00
squidbus
1639640902 event_flag: Lower error logs to debug. 2025-05-13 14:46:59 -07:00
squidbus
3ab69e24db fix: Compiling with newer Boost 2025-05-13 14:22:44 -07:00
squidbus
0d127a82dd
equeue: Clean up timers implementation. (#2925) 2025-05-13 14:05:29 -07:00
Marcin Mikołajczyk
e5b675d607
Handle IT_WAIT_REG_MEM with Register argument (#2927) 2025-05-13 13:56:20 -07:00
Marcin Mikołajczyk
1832ec2ac2
Implement sceKernelIsStack (#2917) 2025-05-13 13:54:22 -07:00
Fire Cube
7334fb620b
sceKernelAddTimerEvent implementation (#2906)
* implementation

* add backend (WIP)

* now should be good
- fix implementation based on homebrew tests
- demote log to debug
- make squidbus happy (hopefully)

* fix moved m_name

* fix clang

* replace existing event when its same id and filter

* run timercallback after addEvent and remove useless code

* move KernelSignalRequest to the end

* clang (i hate you)
2025-05-13 12:16:53 -07:00
georgemoralis
f97c0deea9
ngs2: removed possible nullptr value from logging (#2924) 2025-05-13 11:29:47 -07:00
georgemoralis
e6a144ddb0
[Libs] sceNet IV (#2867)
* dummy returns in p2p sockets

* added logging for sceNetSetsockopt

* possible fix for ORBIS_NET_SO_LINGER set

* logging for getsockoption as well

* disable kernel getsockname (seems to create issues with cyberpunk)

* some fixes with SetSocketOptions

* arggg

* posix_getsockname try

* mutex protection

* removed duplicated include (diegolix29)

* posix_getsockname appears to have issues in cyberpunk , comment it for now
2025-05-13 08:54:38 +03:00
squidbus
3a10fda008 kernel: Simplify sceKernelUuidCreate 2025-05-12 22:15:04 -07:00
Roman
2a3a701115
kernel: macos/linux Implement sceKernelUuidCreate (#2923)
* kernel: macos/linux Implement sceKernelUuidCreate

* Fix clang-format

* Fix Linux build

* Fix Linux build (2)

---------

Co-authored-by: squidbus <175574877+squidbus@users.noreply.github.com>
2025-05-12 22:10:33 -07:00
Marcin Mikołajczyk
3a3a6d8e45
Mprotect only over whole pages (#2918)
* Mprotect only over whole pages

* Fix aligned_size error and clang-format.

---------

Co-authored-by: squidbus <175574877+squidbus@users.noreply.github.com>
2025-05-12 16:55:19 -07:00
Vinicius Rangel
5ab5fa7024
hotfix: replace memset declaration by cstring include
fixes the Arch package build (https://aur.archlinux.org/packages/shadps4-git#comment-1023984)
2025-05-12 18:35:04 -03:00
squidbus
f94c7e52b7
kernel: Implement scePthreadGetaffinity (#2916) 2025-05-12 10:46:53 -07:00
squidbus
678f18ddb9
core: Introduce host call wrapper. (#2913)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
2025-05-11 20:27:54 -07:00