Commit Graph

1097 Commits

Author SHA1 Message Date
Billy Laws
b1f10865a0 Attach depth RT to command executor before draws
This enforces that the depth RT outlives the draw, without this the depth RT could be freed while in active use by command executor leading to UAFs and crashes.
2022-04-14 14:14:52 +05:30
Billy Laws
0182fabc50 Stub {Set,Get}NpadHandheldActivationMode in HID 2022-04-14 14:14:52 +05:30
Billy Laws
2e197cead5 Support D32S8_Float_Uint_Unorm_Unorm depth/stencil format 2022-04-14 14:14:52 +05:30
Billy Laws
7717a86fb1 Implement VMM region->region copies
Required by the DMA engine, a simple memcpy doesn't work since the buffers could span multiple blocks.
2022-04-14 14:14:52 +05:30
Billy Laws
af90d4f977 Implement audren Surround->Stereo downmixing 2022-04-14 14:14:52 +05:30
PixelyIon
ad0005f398 Remove guard-page from main thread stack
This was erroneously included while migrating from older code where stack creation was entirely handled with host constructs such as `mmap` directly to using `KPrivateMemory` to manage it, we would create a guard page with `mprotect` that the guest was unaware about and would cause a segfault when a guest accessed the extents of the stack as reported to the guest.
2022-04-14 14:14:52 +05:30
PixelyIon
de81d28b1d Implement SVC GetThreadContext3
A partial implementation of the `GetThreadContext3` SVC, we cannot return the whole thread context as the kernel only stores the registers we need according to the ARMv8 ABI convention and so far usages of this SVC do not require the unavailable registers but all future usage must be monitored and potentially require extending the amount of saved registers.
2022-04-14 14:14:52 +05:30
PixelyIon
b706aa3463 Implement SVC SetThreadActivity
This SVC can pause/resume a thread, it is used by engines like Unity to pause a thread during a GC world stop.
2022-04-14 14:14:52 +05:30
PixelyIon
36a7ad06bd Use built-in vibrator by default for controller #0
The vibration device had to be set manually prior which led to it generally not being set at all even though a user might want vibration, this commit fixes that by making controller #0 use the built-in vibrator by default.
2022-04-14 14:14:52 +05:30
lynxnb
924d5f7081 Update CI to use cache@v3 + ignore partial matches of cache key 2022-04-14 14:14:52 +05:30
lynxnb
69ba4f8abb Swap out boostorg/boost for skyline-emu/boost 2022-04-14 14:14:52 +05:30
PixelyIon
b45437b78b Move Skyline internal files to external directory
Any Skyline files that should have been user-accessible were moved from `/data/data/skyline.emu/files` to `/sdcard/Android/data/skyline.emu/files` as the former directory is entirely private and cannot be accessed without either adb or root. This made retrieving certain data such as saves or loading custom driver shared objects extremely hard to do while this can be trivially done now.
2022-04-14 14:14:52 +05:30
Billy Laws
e5e20f39c9 Implement a simple constant buffer cache
In some games such as SMO thousands of constant buffers are bound per frame which was causing an unreasonable number of lookups in both vmm and the buffer manager. Work around this by introducing a simple hashmap based cache, eviction is currently unsupported but not really necessary yet due to the small size of the buffers in the cache.
2022-04-14 14:14:52 +05:30
PixelyIon
cb2614f80e Handle host accesses for NCE Memory Trapping API
We cannot ignore accesses from the host to a region protected by the NCE Memory Trapping API, there's often access to regions which have overlap with a protected region unintentionally and those accesses need to be handled correctly rather than leading to a crash. This is done by implementing an additional signal handler `NCE::HostSignalHandler` to lookup any potential traps on a `SIGSEGV` and handle them correctly or when there isn't a corresponding trap raise a `SIGTRAP` when debugger is connected or delegate to `signal::ExceptionalSignalHandler` when it isn't.
2022-04-14 14:14:52 +05:30
PixelyIon
b04a0c386a Page out RW-trapped memory in NCE Memory Trapping
To cut down memory usage we now page out memory that is RW trapped via the NCE memory trapping API, the callbacks are supposed to page in the memory. This behavior is backed up by Texture/Buffer syncing which would read the host copies of data and write it to the guest, by paging the corresponding data on the guest we're avoiding redundant memory usage.
2022-04-14 14:14:52 +05:30
PixelyIon
344c5f2a62 Implement RAII wrapper over file descriptors
The `FileDescriptor` class is a RAII wrapper over FDs which handles their lifetimes alongside other C++ semantics such as moving and copying. It has been used in `skyline::kernel::MemoryManager` to handle the lifetime of the ashmem FD correctly, it wasn't being destroyed earlier which can result in leaking FDs across runs.
2022-04-14 14:14:52 +05:30
PixelyIon
7ce2a903a1 Update LLVM + Oboe
Initially this commit was only intended to update LLVM but due to a compilation error  on latest LLVM libcxx due to the C++ stdlib header `<algorithm>` being a transitive dependency that is no longer transitively included on the latest LLVM libcxx (as of https://reviews.llvm.org/D119667), this required changes in Skyline and Oboe which were done in https://github.com/google/oboe/pull/1521 and the submodule has been updated to include those changes.
2022-04-14 14:14:52 +05:30
Billy Laws
c549788377 Update shader compiler 2022-04-14 14:14:52 +05:30
Billy Laws
01c027b9f6 Fix GetBlockLinearLayerSize to avoid incorrectly calculating a zero size 2022-04-14 14:14:52 +05:30
PixelyIon
c84badb498 Update NDK (25.0.8221429) + Gradle (7.4.1) + Build Tools (33.0.0) 2022-04-14 14:14:52 +05:30
lynxnb
08e24915d8 Add support for drawing inside the display cutout areas 2022-04-14 14:14:52 +05:30
MK73DS
6e929e6f6a Stub ICommonStateGetter::SetCpuBoostMode
This makes Metroid Dread boot
2022-04-14 14:14:52 +05:30
Billy Laws
d033ff2478 Fix draws when no colour RTs and only depth is bound 2022-04-14 14:14:52 +05:30
Billy Laws
d137051833 Add basic support for 3d/cubemap textures
These are mostly used in 3D games like SMO, support is still quite basic and synchronising block linear 3D texture will crash in most cases due to them being unimplemented.
2022-04-14 14:14:52 +05:30
Billy Laws
bcc00216b7 Fix incorrect Bc2/3 block sizes 2022-04-14 14:14:52 +05:30
PixelyIon
7e9b0fec77 Increase reported audren revision to 11
Some games crash due to requiring an `audren` version greater than 7. The `audren` version can be increased without any issues as `audren` is stubbed and therefore the reported version doesn't matter.
2022-04-14 14:14:52 +05:30
PixelyIon
e294fa8c91 Add subpass limit quirk to fix Adreno driver bug
Older Adreno proprietary drivers (5xx and below) will segfault while destroying the renderpass and associated objects if more than 64 subpasses are within a renderpass due to internal driver implementation details. This commit introduces checks to automatically break up a renderpass when that limit is hit.
2022-04-14 14:14:52 +05:30
PixelyIon
65d5a3bce5 Align all Buffers to page boundary
We have support for overlapping buffers which allows us to merge a lot of smaller buffers located on a single page into a single larger buffer which allows for better performance. It additionally ensures that all host buffers match the alignment guarantees of the guest and adequately fulfill host alignment requirements.
2022-04-14 14:14:52 +05:30
PixelyIon
cb1ec9a7f4 Rework BufferManager, Buffer and BufferView
This commit encapsulates a complex sequence of cascading changes in the process of supporting overlaps for buffers:
* We determined that it is impossible to resolve overlaps with multiple intervals per buffer within the constraints of each overlap being a contiguous view, support for multiple intervals was therefore dropped. The older buffer manager code was entirely reworked to be simpler due to only handling one interval per buffer with code now being based off `IntervalMap` but tailored specifically for buffers.
* During overlap resolution, the problem of how existing views into the buffer being recreated would be updated, it had to be replaced with a larger buffer that could contain all overlaps and all existing views would need to be repointed to it. This was addressed by a buffer owning all views to itself, we could automatically recalculate the offset of all views and update the buffers with it.
* We still needed to update usage of existing views which was done by handling all access (such as inside a recorded draw) to buffer view properties via `BufferView::RegisterUsage` which dispatches a callback with the view and the corresponding backing buffer. This callback can be stored and called during overlap resolution with the new buffer.
* We had issues with lifetime of the buffer with the handle-like semantics of `BufferView` introduced in the last buffer-related commit, if we updated the view to be owned by a new buffer we'd need to extend the lifetime of the new buffer not the older one and the only way to do this was a proxy owner object `BufferDelegate` which holds a shared pointer to the real `Buffer` which in-turn holds a pointer to all `BufferDelegate` objects to update on repointing. A `BufferView` is effectively just a wrapper around `std::shared_ptr<BufferDelegate>` with more favorable semantics but generally just forwarding calls.
It should be additionally noted that to support usage of `RegisterUsage` the code around buffers in `GraphicsContext` was refactored to defer truly binding till the recording phase.
2022-04-14 14:14:52 +05:30
PixelyIon
a6781b38f4 Clear syncBuffers after CommandExecutor execution
Due to an oversight, we weren't clearing the list of buffers that needed to be synced after every execution which led to them building up. Due to the relatively cheap synchronization of buffers and only doing so on faults this wasn't caught until now, it does depress the framerate significantly over time due to the size of the list growing to be in the range of 100k buffer views depending on the title.
2022-04-14 14:14:52 +05:30
kaikecarlos
49c0ba1207 Implement IAccountServiceForApplication::IsUserRegistrationRequestPermitted 2022-04-14 14:14:52 +05:30
kaikecarlos
e8cc760b10 Implement IHidServer Functions
Add GetVibrationDeviceInfo and StartSixAxisSensor
2022-04-14 14:14:52 +05:30
kaikecarlos
9f51664b1d Stub IRS Service 2022-04-14 14:14:52 +05:30
lynxnb
707c0cc0af Stub aocsrv::IAddOnContentManager::ListAddOnContent 2022-04-14 14:14:52 +05:30
lynxnb
873ed641ea Stub nfp::IUser::ListDevices and nfp::IUser::GetState 2022-04-14 14:14:52 +05:30
lynxnb
7d518cba2b Stub am::ICommonStateGetter::IsVrModeEnabled 2022-04-14 14:14:52 +05:30
Billy Laws
c55e1a135e Update adrenotools 2022-04-14 14:14:52 +05:30
Robin Kertels
594f061b21 Implement SSBOs
Co-authored-by: Billy Laws <blaws05@gmail.com>
2022-04-14 14:14:52 +05:30
Billy Laws
82d2a9ab56 Unify engine related macros to avoid excessive code duplication 2022-04-14 14:14:52 +05:30
Billy Laws
ae41ddf4f0 Implement a skeleton compute engine
The Kepler compute engine is used to run compute jobs encapsulated in to QMDs on the GPU, this commit doesn't implement compute itself but adds the register and QMD structs that will be needed for it in the future.
2022-04-14 14:14:52 +05:30
Billy Laws
0298a7b1f6 Implement the actual inline to memory engine on subch 2
Used mostly by OGL games for copying stuff around.
2022-04-14 14:14:52 +05:30
Billy Laws
ba7111d33a Add maxwell3d I2M support 2022-04-14 14:14:52 +05:30
Billy Laws
8c73b62b2c Implement basic inline2memory engine support
Not currently used by anything but will be used by both compute, 3D and its own engine in the future. Block linear copies are currently unsupported.
2022-04-14 14:14:52 +05:30
Billy Laws
5c387f5c5a Fixup depth mode init value to allow ignoring redundant calls 2022-04-14 14:14:52 +05:30
PixelyIon
7a5c771f44 Rework GPU BufferView to have handle-like semantics
We wanted views to extend the lifetime of the underlying buffers and at the same time preserve all views until the destruction of the buffer to prevent recreation which might be costly in the future when we need `VkBufferView`s of the buffer but also require a centralized list of all views for recreation of the buffer. It also removes the inconsistency between `BufferView*` being returned in `GetXView` in `GraphicsContext`.
2022-04-14 14:14:52 +05:30
Billy Laws
fae5332f20 Disable descriptor aliasing on Adreno to workaround shader compiler bug
Alised descriptor sets are incorrectly interpreted by the shader compiler causing it to bugger up LLVM function argument types and crash

Co-authored-by: PixelyIon <pixelyion@protonmail.com>
2022-04-14 14:14:52 +05:30
Billy Laws
fc2c123ae2 Implement GPU depthMode register
This controls the depth range used by the shader, hades already has support for the necessary patching so we only need to pass the current mode over to it and it'll do the necessary work.
2022-04-14 14:14:52 +05:30
Billy Laws
7e088ca465 Fix constbuf updates to actually increment the write offset
Uses the register directly now as when we modify it we want the changes to be visible from macros too.
2022-04-14 14:14:52 +05:30
PixelyIon
d2f3479610 Use eB5G6R5UnormPack16 VkFormat for B5G6R5Unorm and R5G6B5Unorm
Using `eB5G6R5UnormPack16` (with a swizzle for `R5G6B5Unorm`) removes the need for `VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT` when those formats are aliased which happens in Sonic Mania among other titles.
2022-04-14 14:14:52 +05:30
PixelyIon
24d7066d8b Add quirk to avoid VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT on Adreno GPUs
Adreno GPUs have significant performance penalties from usage of `VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT` which require disabling UBWC and on Turnip, forces linear tiling. As a result, it's been made an optional quirk which doesn't supply the flag in `VkImageCreateInfo` and logs a warning if a view with a different Vulkan format from the original image is created.
2022-04-14 14:14:52 +05:30