* 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
Layer must be output from the final pre-rasterization stage, so when tessellation is
being used the vertex shader cannot set it. We could pass it through to the tessellation
shaders in some way, but unless it becomes an issue that's more effort than it's worth.
* 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
* video_core: support for RT layer outputs
- support for RT layer outputs
- refactor for handling of export attributes
- move output->attribute mapping to a separate header
* export: Rework render target exports
- Centralize all code related to MRT exports into a single function to make it easier to follow
- Apply swizzle to output RGBA colors instead of the render target channel.
This fixes swizzles on formats with < 4 channels
For example with render target format R8_UNORM and COMP_SWAP ALT_REV the previous code would output
frag_color.a = color.r;
instead of
frag_color.r = color.a;
which would result in incorrect output in some cases
* vk_pipeline_cache: Apply swizzle to write masks
---------
Co-authored-by: polyproxy <47796739+polybiusproxy@users.noreply.github.com>
* 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
* make shadps4 default repo for patches
* if present, put shadPS4 patches on top of listview
* Update cheats_patches.cpp
---------
Co-authored-by: rainmakerv2 <30595646+rainmakerv3@users.noreply.github.com>
* Initial work on improved stubs
Simulates library behaviors for when a camera is not connected.
* Get* functions complete
I ended up leaving some stubs behind, but most of what I didn't do seem to be internal functions called by other libraries we'd be running HLE anyway.
* Finished stubs
Everything I can reasonably confirm the behavior of should behave as expected, emulating the behavior of a PS4 with no camera attached.
* sceCameraStart firmware check
This check only applies to higher eboot firmwares, since my previous test eboots used firmware 1.00 I completely missed this.
* sceCameraGetAutoExposureGain fix
When option is provided and valid, size is also set to 0.
* Track opened handles
Extremely basic for now, if the library was ever properly implemented this could be swapped for a map of some kind instead.
* Fix errors for sceCameraStart
The firmware-related parameter checks come after the library opened check.
* Promote sceCameraIsAttached log to info
Since you don't need to initialize the library to call this function, some games will call sceCameraIsAttached before anything else.
* 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
* ir: Perform degamma in shader when sampler sets force_degamma
* specialization: Add srgb if image is sampled
Might fix cases where sampler force_degamma is used with srgb image
Previously a buffer load in a vertex shader could be treated like a ring access, dropping offen vgpr and possibly asserting during resource tracking because of mismatch between types (u32x2 vs U32), caused by inconsistencies in flags (index_enable and offset_enable)
* Properly align address and size in munmap
Based on observations of FreeBSD source code, fixes a Windows-related memory issue in War Thunder (CUSA00224)
* Format len and phys_addr in mmap
This should make logs slightly easier to understand, since we format these parameters in other memory calls.
* Update memory.cpp