* SearchFree adjustments
* Robust address validation
I've adjusted IsValidAddress to take in a size, and check whether the whole range is contained in vma map.
If no size is provided, the function reverts to the old form of address validation instead.
* Map around gaps
As is, this should work mostly.
Only remaining issue is adding logic to pass the "mapped regions" to the guest vma map (and make such logic cross-platform).
* Initialize vma_map using gaps
This should allow memory code to catch any issues from address space gaps, and prevent non-fixed mappings from jumping to a location that isn't actually available.
* Clang
* Fix compile
* Clang
* Fix compile again
* Set system_managed_base and system_managed_size based on
Many places in our code use system_managed_base as the minimum mappable address, ensure this fact remains the same on Windows to prevent potential bugs.
* Reduce address validation in SearchFree
Allows SearchFree to function when a certain Windows GPU driver goes and reserves the whole system managed area.
Since SearchFree is only called on flexible addresses, allowing this particular case, where addresses are in bounds, but there's not enough space to map, should be safe enough.
* Bump address space size further
To handle Madden NFL 16 (and any games like it)
* More thorough logging of available memory regions
Should help with spotting weirdness.
* Formatting fixes
* Clang
* Slight reduction of user space
Still large enough to handle EA's shenanigans, but small enough that Linux doesn't break.
* Assert on VirtualQuery failure
* Extra debugging information
* Further reduce user space
This will unfix most of EA's titles, but UFC will still work.
Older windows versions support the high addresses, but trying to actually use them causes significant performance issues.
* Extra debugging info
Just in case other testers still run into issues.
* Remove debug logging
* Revert user space increases
Technically this constant is still higher than before, but weird side effects of our old logic resulted in a max address somewhere around this in main.
* address_space: Support expanded virtual memory space on macOS.
Co-Authored-By: squidbus <175574877+squidbus@users.noreply.github.com>
* Move address space constants to address_space.cpp
This ensures that all code must use the calculated address space memory values instead of the constants, since the calculated values can differ based on the platform.
This does require slight modification to thread state and gnmdriver code, since both were already using these constants directly.
* Workaround Windows 10 limitations
If a Windows 10 device is detected, use a lower value for USER_MAX to prevent system-wide hangs in VirtualAlloc2 calls.
* Fix compile for Windows-Qt
* Move tessellation_factors_ring_addr initialization to sceGnmGetTheTessellationFactorRingBufferBaseAddress
* Set image base address on Windows
This seems to work fine on Windows 11, needs testing from Windows 10 due to the previously discussed bugs.
* Set Linux executable base to 0x700000000000
This allows Linux to map the full user space without any workarounds.
Co-Authored-By: Marcin Mikołajczyk <2052578+mikusp@users.noreply.github.com>
* Basic formatting changes
* Reduce USER_MAX on Linux
Seems like finding a reliable way to move shadPS4's position in memory is difficult, for now limit the user size so we aren't trying to overwrite ourselves.
* Move memory and address_space variables.
---------
Co-authored-by: squidbus <175574877+squidbus@users.noreply.github.com>
Co-authored-by: Marcin Mikołajczyk <2052578+mikusp@users.noreply.github.com>
* Add RNG device
* rng device implementation
Tailored around libSceSsl2's usage, and based on fpPS4's implementation.
* Device file function types and log fixups
* Updated creates
Updates device file create functions to be the same as the directory file create functions.
* Fix compile
* Includes cleanup
Generally preferred to have full paths. Also removed some unused imports too.
* Fix buffer size
* Bring back cstdlib imports
Needed for Mac OS.
* Add support for restarting the emulator with new configurations
- Implement `Restart` function in `Emulator` to enable process relaunch with updated parameters.
- Modify `sceSystemServiceLoadExec` to use the restart functionality.
* Add logging for emulator restart and system service load execution
* Add IPC emulator PID output command
Impl `PID` output command to return the emulator process ID
- required for launches supporting emulator restart
* Add log file append mode support (used after restarting to keep the same log file)
* Keep game root between restarts
* add --wait-for-debugger option flag
* add --wait-for-pid flag
used for sync between parent & child process during restart
* impl restart via ipc
* fix override game root
* add qt flags to allow restart
* Np library cleanup
Moved all Np libraries to a Np folder, created files for Np error codes and structs shared between the libraries, removed empty auto-generated stubs from NpCommon and NpManager, and more things of that nature.
Also implemented sceNpGetAccountCountry, since we already had sceNpGetAccountCountryA anyway.
* Cleanup NpManager signed_out checks
The PR that introduced the PSN signed in status reverted some of the changes I'd previously made to improve accuracy.
Also they missed sceNpHasSignedUp, which just uses an internal variant of sceNpGetState for it's own check.
* Copyright dates
* Move signin check to NpManager RegisterLib
Hardcoding it the way I did caused it to read signin status before config was read.
* Fix RegisterLib names
Not sure why these weren't adjusted yet, so I've adjusted them myself.
* Fix NpCommon exports
* Basic parameter validation in sceNpDeleteRequest and sceNpCreateRequest
* More thorough request logic
Created an enum to capture the current state of each request, using a vector to store them.
I've made 3 states, none represents deleted requests, active represents requests that were made, but haven't been used yet, and complete represents used requests (a request cannot be used for multiple functions).
* Functions
sceNpCheckAvailability, sceNpCheckAvailabilityA, sceNpCheckNpReachability, sceNpGetAccountDateOfBirth, sceNpGetAccountDateOfBirthA added.
* sceNpGetAccountLanguage, sceNpGetAccountLanguageA
* sceNpGetGamePresenceStatus, sceNpGetGamePresenceStatusA
Also reduced debug logging for functions with early signed out returns, since those should behave identically to real hardware so long as you keep PSN emulation disabled.
* Fix sceNpGetAccountLanguage parameters
Oops
* sceNpGetNpReachabilityState
* sceNpGetParentalControlInfo, sceNpGetParentalControlInfoA
* Move OrbisNpState back to np_manager.h
Until this sees use elsewhere, this doesn't need to be with np-wide things.
* Clang
* AF_UNIX preliminary support
* fixed windows
* added windows implemenation for socketpair
* More gotos
* added sys_socketpair for libkernel_ps2emu
---------
Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
* Log presets feature
- Add “Load Presets…” button in Logger → Log Filter (settings_dialog.ui)
- Implement LogPresetsDialog (table: Comment, Filter)
- Support add (+), multi-remove (−), load via button or double-click
- Persist presets via QSettings at logger_presets/entries (qt_ui.ini)
- Wire button to open dialog and set logFilterLineEdit
- Update CMakeLists.txt to include new dialog sources
* CLang fix
* CLang fix again
* Log Presets: checkbox selection + tri-state header
- Added first column with per-row checkboxes
- Implemented header checkbox with tri-state; click toggles select-all/none
- Synced checkboxes and row selection in both directions
- Header toggle also updates row selection to match
- Remove operates on checked rows; falls back to selected rows if none checked
- Load uses first checked row; falls back to first selected row
- Double-click row triggers the same action as Load
- Load button visible only when exactly one row is selected
- Remove button visible only when at least one row is selected
- Dialog opens with no selected rows and no focused buttons; focus set to table
- New rows start editing in the Comment column
- Serialization updated for new column indices; checkbox state not persisted
- Cleanups: removed unused include and empty helper; pruned temporary comments
* Clang
* Fix: tri‑state header checkbox visible and aligned
- Overlay real QCheckBox in header section 0 (tri‑state)
- Align with row checkboxes using SE_ItemViewItemCheckIndicator
- Reposition on header resize and geometry changes
- Header click + checkbox click toggle select‑all/none
- Tri‑state reflects per‑row checkbox states
* CLang
---------
Co-authored-by: w1naenator <valdis.bogdans@hotmail.com>
* Allow vector and scalar offset in buffer address arg to
LoadBuffer/StoreBuffer
* remove is_ring check
* fix atomics and update pattern matching for tess factor stores
* remove old asserts about soffset
* small fixes
* copyright
* Handle sgpr initialization for 2 special hull shader values, including tess factor buffer offset
* libSceVrTracker stubs, structs, enums, and errors
* sceVrTrackerQueryMemory
* Clang and slight struct cleanup
* Implement sceVrTrackerInit
* Store memory pointers and sizes
Mainly for future developers, since I doubt these memory areas will be particularly useful for these stubs.
* sceVrTrackerRegisterDevice
I haven't really identified the difference between the two register device functions, but I do know that they both internally call the internal function with slightly different parameters.
* sceVrTrackerUnregisterDevice
Also changes Hmd and Move handles to be values closer to what real hardware returns, since this function seemingly relies on handles being different for all these device types.
* sceVrTrackerTerm
* Additional error checks in sceVrTrackerRegisterDeviceInternal
* sceVrTrackerGetTime
* sceVrTrackerRecalibrate
Recalibration succeeds on real hardware (at least for some device types), so I've left the stub log intact.
* Update vr_tracker.cpp
* sceVrTrackerSetDurationUntilStatusNotTracking stub
Only handled the error checks, so I left the stub log intact.
* sceVrTrackerGpu* functions
Most of these can't succeed without a camera attached.
* Rename SceKernelIovec to OrbisKernelIovec
Fixes the naming scheme to match the rest of the project.
* Type fixups
Noticed this while working on the actual thing this PR is about.
* More type fixups
* Update file_system.cpp
* Abstract directory handling
* Clang
* Directory fstat
* Fix dirent loading logic
* PfsDirectory size
Seemed to be hardcoded when I ran tests, so I've hardcoded it here.
Also fixed up the reclen-aligning logic based on hardware observations.
* GetDents cleanup
Bring back the bytes < 512 error return from before, as that's still something that can be checked for out here.
I've also swapped the file type stuff to run from a switch case, so that the check for invalid file type can be used as the default case
* Support reading directories
* getdents
For PfsDirectory, getdents behaves like read does on normal directories. Since dirents are stored internally with a different struct, this means getdents has to convert the dirents before returning data.
For NormalDirectory, getdents is identical to read, so it can just call read and set the basep output.
* Directory readv
* Directory preadv
Since the file mutex is locked before these calls, messing with dirents_index like this shouldn't cause any weird side effects.
* return ORBIS_OK instead of 0
to better align with our coding standards.
* Directory lseek
* Un-modify CMakePresets.json
I keep this modified locally for Linux, but accidentally pushed it.
* Clang
* Fix mac compile
* Potential windows compile fix?
* Filename fix
* Fix normal directory d_reclen
* Comment cleanup
* Remove unnecessary dirent conversion logic
On real hardware, the records are still returned with the same reclen, despite the change in structure.
* PfsDirectory dirents_index fixes
Some weird stuff happens once you reach eof on directories.
Thankfully, PfsDirectories are rather tame in this regard.
* Change comment
* Rewrite normal directory reads
The logic for these seems to behave like a normal file, so instead of tracking a dirents_index, keep an internal buffer representing the file contents, and copy that to output buffers as needed.
* Update pfs_directory.cpp
* Clang
* Fix normal dirents
When rewriting the code, I forgot to account for the increased reclen value for the last dirent in the buffer.
* PfsDirectory::lseek fixes
Based on some additional tests, it seems like lseek unconditionally returns dirents_index, not the actual file position.
Also fixed some bugs with the logic for calculating the proper offset when games do wonky things, and fixed a potential area where games could crash.
* Downgrade stat and fstat log to debug
These functions can get pretty spammy.
* PfsDirectory: Properly track if end of file is reached
Using the metric `dirents_index < directory_content_size` fails when `directory_content_size` is larger than the actual directory size we report.
Since, from what I can tell, PfsDirectories shouldn't ever report more than 0x10000 bytes for size, this change is necessary.
* Revert "PfsDirectory: Properly track if end of file is reached"
I need to do some hardware tests to see if all this excess logic is actually necessary.
* Fix PfsDirectory directory_size
Turns out, if your game has over 1000 files in a folder, it will actually cause the size to increase.
* Update copyright date
* Move devices and directories into file_sys
I've also updated the copyright dates on all these files.
* C++ style type casts
* Remove unnecessary memset
* Use a vector for the data buffer
Simplifies logic for freeing the buffer, based on review suggestions.
* Fix potential oob array access
* Change type casts in Create function
* Clang
* std::memcpy instead of memcpy
* NormalDirectory::lseek cleanup
* Create constants for directory alignment values.
* Use const wherever possible
* Includes cleanup
* vk_pipeline_cache: Cleanup graphics key refresh
* position: Don't assert on None mapping
Also check outputs in runtime info so shader is recompiled if they change
* Initial work
* More work
* More stuff
* Update hmd.cpp
* Separate Reprojection and Distortion functions
Mainly doing this to clean up the code, since these sub-libraries are fairly self-contained.
* Fix weird Git issue
* Improve error documentation
After thorough decompilation, it seems clear that Sony didn't really put much thought into how libSceHmd behaves with no headset connected.
* Fix sceHmdGet2DEyeOffset
* Update hmd.cpp
* Add sceHmdInternalGetDeviceInformation and sceHmdInternalGetDeviceInformationByHandle
Based entirely off decompilation, these two functions are internally the cause of much of my trouble with this library.
They're also called by libSceVrTracker, but I don't think we'll be LLE'ing that anytime soon.
* Cleanup
* sceHmdGetAssyError
Struct isn't fully decompiled, but since it goes entirely unused when PSVR is disconnected, it doesn't matter too much.
I'm pretty certain it's 4 floats though, based on what I've decompiled of this function.
* More organization and fixes
* sceHmdGetInertialSensorData
Behavior should be fully accurate, but I've left the stub log since I haven't decompiled the parameters properly.
Also gave NID aTg7K0466r8 a proper name, based on what I've seen while decompiling. It behaves identically to sceHmdGetInertialSensorData, but with a slight difference in the params used for an internal function call.
* Update hmd.cpp
* Revert name change
* Organizational changes
These two functions modify internal variables used exclusively by reprojection functions.
* Remove internal device information calls
* Log PSVR-related attributes from param.sfo
Would mainly be helpful for compatibility list moderation, since these notices will be much more reliable for games that crash instantly.
* Remove unnecessary includes
* Improved libSceMove stubs
These should more accurately represent how an actual PS4 behaves when a game calls libSceMove functions while no move controllers are connected.
* Clang
* Change sceMoveGetExtensionPortInfo stub
Not entirely sure the ExtensionPortData struct is for this one, but the struct itself isn't exactly important for now anyway.
* Fix sceMoveTerm
* Update move.cpp
* cpu info
Update cpu_info.h
Revert "Update cpu_info.h"
This reverts commit 6db3814e7f8162ca546c33479942d7204524b281.
Revert "cpu info"
This reverts commit cfecdf694fd7bee0fdf025c3933ff7b9498a1c3f.
hardware info
* log OS
* Round RAM, add space
* switch temporarily to local fork
* Update CMakeLists.txt
* set shallow = true for submodule
* Log logical cores as well
* point submodule to shadps4 fork
From what I can tell, this is valid behavior since a user could choose not to enter a party.
This fixes a potential crash on boot in Grand Theft Auto V.
* video_core: Rework detiling
* video_core: Support tiling and macrotile detiling
* clang format
* image_info: Cleanups
* resource: Revert some changes
* texture_cache: Fix small error
* image_info: Set depth flag on depth promote
* buffer_cache: Remove level check
* tile_manager: Handle case of staging buffer causing flush
* image_info: Add 2D thick array mode
* image_info: Add slices to mip size
* tile_manager: Set bank swizzle
* buffer_cache: Support image copies from DmaData
* vk_rasterizer: Accelerate trivial render target copies with compute
Before tiling PR compute image copies were done with the following sequence
vkCmdCopyImageToBuffer (in SynchronizeBufferFromImage) -> vkCmdDispatch (copy) -> vkCmdCopyBufferToImage (in RefreshImage)
With the tiling PR it added extra tiling/detiling steps
vkCmdCopyImageToBuffer -> vkCmdDispatch (tiling) -> vkCmdDispatch (copy) -> vkCmdDispatch (detiling) -> vkCmdCopyBufferToImage
This is quite a bit of overhead for a simple image copy. This commit tries to detect trivial image copies i.e cs shaders that copy the full source image to all of the destination.
So now all this sequence is just a vkCmdCopyImage. How much it triggers depends on the guest
* texture_cache: Fix build
* image: Copy all subresources with buffer too
* shader_recompiler: Remove remnants of old discard
Also constant propagate conditional discard if condition is constant
* resource_tracking_pass: Rework sharp tracking for robustness
* resource_tracking_pass: Add source dominance analysis
When reachability is not enough to prune source list, check if a source dominates all other sources
* resource_tracking_pass: Fix immediate check
How did this work before
* resource_tracking_pass: Remove unused template type
* readlane_elimination_pass: Don't add phi when all args are the same
New sharp tracking exposed some bad sources coming on sampler sharps with aniso disable pattern that also were part of readlane pattern, fix tracking by removing the unnecessary phis inbetween
* resource_tracking_pass: Allow phi in disable aniso pattern
* resource_tracking_pass: Handle not valid buffer sharp and more phi in aniso pattern