Commit Graph

2976 Commits

Author SHA1 Message Date
Lander Gallastegi
c82c165b29
Merge branch 'shadps4-emu:main' into hybrid 2025-05-09 22:46:45 +02:00
Stephen Miller
6477dc4f1e
Core: Memory Fixes (#2872)
* Fix VirtualQuery behavior on low addresses.

* Fix VirtualQuery struct

Somewhere in our BitField and array use, the size of our VirtualQuery struct became larger than the struct used on real hardware.
Fixing this fixes some data corruption visible in the name parameter during my tests.

* Default name to anon

On real hardware, nameless mappings are given the name "anon:address" where address appears to be the address that made the memory call.
For simplicity sake, I'll stick to the name "anon" for now.

* Place an upper bound on returns from SearchFree

Right now, this upper bound is set based on the limitations of our GPU buffer cache and page table.
Someone with more experience in that area of code should probably fix that at some point.

* More anons

* Clang

* Fix name in sceKernelMapNamedDirectMemory

* strncpy instead of strcpy

Hardcoded the constant size for now, I need to review how real hardware behaves here to determine if anything else is necessary for this to be accurate.

* Fix name behavior

All memory naming functions restrict the name size to a 31 character limit, and return `ORBIS_KERNEL_ERROR_ENAMETOOLONG` if that limit is exceeded.
Since this value is constant for all functions involving names, I've defined it as a constant in kernel's memory.h, and used that in place of any hardcoded 32 character limits.

* Error logging

Hopefully this helps in catching the UFC regression?

* Increase address space upper bound

Probably needs heavy testing, especially on Mac/Windows.
This increases the address space, as needed to accommodate strange memory behaviors seen in UFC.

* VirtualQuery fix

Due to limitations of certain platforms, we initialize our vma_map with 3 separate free mappings.
As such, we need to use a while loop here to accurately query mappings with high addresses

* Fix mappings to high addresses

The PS4's GPU can only handle 40bit addresses. Our texture cache and buffer cache were designed around these limits, and mapping to higher addresses would cause segmentation faults and access violations.
To fix these crashes, only map to the GPU if the mapping is fully contained within the address space the GPU should access.
I'm open to suggestions on how to make this cleaner

* Revert "Increase address space upper bound"

This reverts commit 3d50eeeebb.

* Revert VirtualQuery while loop

Windows wasn't happy with this, again.
Will try to debug and properly fix this when I have a good chance.

* Fix asserts

FindVMA, due to the way it's programmed, never actually returns vma_map.end(), the furthest it ever returns is the last valid memory area. All those asserts we involving vma_map.end() never actually trigger due to this.
This commit removes redundant asserts, adds messages to asserts that were lacking them, and fixes all asserts designed to detect out of bounds memory accesses so they actually trigger.
I've also fixed some potential memory safety issues.

* Proper error behavior in QueryProtection

Might as well handle this properly while I'm here.

* Clang

* More information about ReserveVirtualRange results

Should help debug issues like the one in The Order: 1886 (CUSA00076)

* Fix assert message

* Update assert message

Extra space

* Fix my bug

Oh hey, finally something that's my fault.

* Fix rasterizer unmaps

Should use adjusted_size here, otherwise we could unmap too much.
Thanks to diegolix29 for spotting this.

* Fix edge case in MapMemory

Code comments explain everything.
This should fix some memory asserts.

* Fix fix

Avoid running the code path if it's unnecessary, since there are many additional edge cases to handle when the VMA map is small.

* Fix fix fix

Should prevent infinite loops, haven't tested properly yet though.

* Split logging for inputs and out_addr in ReserveVirtualRange

Addresses review comments.
2025-05-09 12:33:04 -07:00
squidbus
a1439b15cf
gnm: Implement sceGnmDrawIndexIndirectMulti (#2889) 2025-05-09 10:04:37 -07:00
Missake212
8d7cbf9943
Adding opcode IMAGE_SAMPLE_B_O (#2894)
* Adding opcode IMAGE_SAMPLE_B_O:

* fix clang (my first time !)
2025-05-09 09:01:34 -07:00
squidbus
b130fe6ed5
vulkan: Handle incompatible depth format using null binding. (#2892)
Co-authored-by: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com>
2025-05-09 08:43:20 -07:00
kalaposfos13
8e7c5a4d99
Remove deprecated include (#2893) 2025-05-09 08:33:32 -07:00
mailwl
46b88bd10f
[Libs] Stubs sceSigninDialog (#2890)
* [Libs] Stubs SigninDialog

* clang-format

* clang-format again

* remove magic constant

* log dialog finished status
2025-05-09 11:08:22 +03:00
Lander Gallastegi
3d674c109b
Merge branch 'shadps4-emu:main' into hybrid 2025-05-08 20:16:00 +02:00
Lander Gallastegi
ab1c3c8b89 Iterators 2025-05-08 20:13:52 +02:00
Paris Oplopoios
58df609ba0
Optimize games that hit unpatchable EXTRQ/INSERTQ (#2888)
* Make signal handler faster

* I love clang-format

* Use faster decoding

* MacOS CI
2025-05-08 19:59:12 +03:00
Vinicius Rangel
3b7c36e1ba
Clear stack before executing guest code (#2877)
* Clear stack before executing guest code

* clang, don't optimize me 🚨

avoid ClearStack function being optimized in release builds
2025-05-07 15:20:55 -07:00
Fire Cube
1aa7eb8a42
add scePthreadSetaffinity and emulate affinity (#2885)
* add implementation

* fix preprocessor

* fixes squidbus's comments

* fix clang

* comment became fucked up?

* fix removed return
2025-05-07 14:50:16 -07:00
MajorP93
c7fb3ebd93
shader_recompiler: Widen num_conversion bitfield (#2886)
We do this in order to be able to actually fit in all possible values from AmdGpu::NumberConversion.

Fixes gcc compiler warnings:
warning: ‘Shader::PsColorBuffer::num_conversion’ is too small to hold all values of ‘enum class AmdGpu::NumberConversion’
2025-05-06 17:11:32 -07:00
Lander Gallastegi
a6c8dc2252 Implement recursive shared/scoped locks 2025-05-06 23:25:37 +02:00
Lander Gallastegi
01a0e00dbb Sync the whole buffer insteed of only the range 2025-05-05 22:23:29 +02:00
Stephen Miller
fed064931a
Core: Fix module load addresses (#2879)
* Fix module map addresses

Most modules are mapped starting at 0x800000000, with no gaps between mappings.

* Hardcode hardware accurate base address

Looking at our address space, all platforms will have this base address mapped, so there shouldn't be any problem in using it.

* Clang

* Swap module mapping to NoFlags, remove offset code

Since real hardware has no gap between module mappings, the Fixed flag is just an annoyance to work around, and has no impact on the actual mappings.
Swapping the module mappings to use flags NoFlags instead simplifies our code slightly.

* Fix module mapping names

On real hardware, the file extension is part of the mapping name. Easiest way to manage this is to swap the name to be `file.filename().string()` instead of `file.stem().string()`

* Fix patches

Completely missed this, whoops.
2025-05-05 03:24:08 -07:00
Lander Gallastegi
c6757763e4 Bring back applying pending operations in wait 2025-05-04 17:56:32 +02:00
Lander Gallastegi
95af4451ec Correctly checkout moltenvk 2025-05-04 15:39:17 +02:00
Lander Gallastegi
9d45536ab4 Less waiting and barriers 2025-05-04 15:27:14 +02:00
oltolm
9a22185ab7
vulkan: do not use VK_EXT_extended_dynamic_state (#2880)
fixes Bloodborne crashing on RX 580
2025-05-04 03:11:02 -07:00
squidbus
17b6343f18
emulator: Fix log initialization order. (#2878) 2025-05-03 13:47:03 -07:00
Vinicius Rangel
d542d952f4
Savefixes VIII (#2851)
* savedata dialog: fix SaveDialogUi move semantics

fix possible dangling points

* savedata dialog: removed unnecessary firmware version checks
2025-05-03 12:51:10 -03:00
Stephen Miller
0ba9ea6a3b
Only perform early read-write open when truncating is needed (#2874)
Should stop some fs error spam when games open files from /app0, as this open call would fail from reduced permissions.
2025-05-02 11:22:05 -07:00
squidbus
eb09c4ccce
vk_presenter: Use correct format for output frame image and view. (#2871) 2025-05-01 20:10:42 -07:00
Lander Gallastegi
9d2d39e70c Point sirit to upstream 2025-05-01 17:16:19 +02:00
Lander Gallastegi
66e57a40e3 Remove memory coveragte logic 2025-05-01 16:56:36 +02:00
Lander Gallastegi
ef51446b36 Better sync 2025-05-01 16:56:36 +02:00
Lander Gallastegi
b6001e47d6 Fixes for better sync 2025-05-01 16:56:36 +02:00
Lander Gallastegi
19473b2672 Better sync (WIP, breaks PR now) 2025-05-01 16:56:36 +02:00
Lander Gallastegi
5947526a4d Fix store_index 2025-05-01 16:56:36 +02:00
Lander Gallastegi
59ea5f8cfe 32 bit counter 2025-05-01 16:56:36 +02:00
Lander Gallastegi
0bf4e75da8 Use spec const and 32 bit atomic 2025-05-01 16:56:36 +02:00
Lander Gallastegi
f260a61d26 Only sync in the first time we see a readconst
Thsi is partialy wrong. We need to save the state into the submission context itself, not the rasterizer since we can yield and process another sumission (if im not understanding wrong).
2025-05-01 16:56:36 +02:00
Lander Gallastegi
c642e4f1be Process faults on submit 2025-05-01 16:56:36 +02:00
Lander Gallastegi
69a39a3afe Use compute to parse fault buffer 2025-05-01 16:56:36 +02:00
Lander Gallastegi
629dc6132e Some fixes (and async testing (doesn't work)) 2025-05-01 16:56:36 +02:00
Lander Gallastegi
ce17f57954 Fix size truncated when syncing range
And memory barrier
2025-05-01 16:56:36 +02:00
Lander Gallastegi
cbed00e09c Revert "Attempt to range sync error"
This reverts commit dd287b48682b50f215680bb0956e39c2809bf3fe.
2025-05-01 16:56:36 +02:00
Lander Gallastegi
8e0905b136 Attempt to range sync error 2025-05-01 16:56:36 +02:00
Lander Gallastegi
bee2ad3721 Use 2 mutexes insteed of copy 2025-05-01 16:56:36 +02:00
Lander Gallastegi
442a7ee509 Copy to avoid deadlock 2025-05-01 16:56:36 +02:00
Lander Gallastegi
e2f56feb8b Possible fix for NieR deadlock 2025-05-01 16:55:04 +02:00
Lander Gallastegi
359856d770 Fix incorrect assert 2025-05-01 16:55:04 +02:00
Lander Gallastegi
7c26fb3fbd Correct size insteed of end 2025-05-01 16:55:04 +02:00
Lander Gallastegi
e012c6c51e clang-format 2025-05-01 16:55:04 +02:00
Lander Gallastegi
0d9337b1f9 Add IR dumping from my read-const branch 2025-05-01 16:55:04 +02:00
Lander Gallastegi
87b3771285 Removed host buffers (may do it in another PR)
Also some random barrier fixes
2025-05-01 16:55:04 +02:00
Lander Gallastegi
e97c3e9653 Offset in bytes 2025-05-01 16:52:44 +02:00
Lander Gallastegi
4c38a1d429 Clang format once more 2025-05-01 16:52:44 +02:00
Lander Gallastegi
8f997f8d0b No need to check if it is a deleted buffer 2025-05-01 16:52:44 +02:00