Commit Graph

498 Commits

Author SHA1 Message Date
PixelyIon a74eb8dbd6 Fix Scheduler Core Migration Deadlock
Encountered in 不如帰大乱 when `HOS-3` is awoken at the same time as `HOS-0` called `SvcSetThreadCoreMask` resulting in a deadlock where `HOS-0` owns `HOS-3`'s `coreMigrationMutex` while `HOS-3` owns the core mutex with the both of them attempting to lock the other mutex
2021-07-12 20:57:05 +05:30
PixelyIon b43541c1a4 Implement `IApplicationDisplayService::ConvertScalingMode`
Utilized by アイリス魔法学園
2021-07-12 20:27:46 +05:30
PixelyIon 3f54b83f2d Move Mbed TLS to submodule + Update Java Libraries
We've moved from using an AAR for Mbed TLS to a submodule as the AAR was packaged manually and used from a local repository which ended up being very hacky and resulted in Linter errors, it could also not be updated with ease as it would need to be repackaged. All of these issues have been solved by moving to a git submodule tied to the official Mbed TLS GitHub repository.
2021-07-12 00:18:34 +05:30
PixelyIon 50945deac8 Address CR Comments + Increase `minSdkVersion` to 29 (Android 10) 2021-07-10 20:05:49 +05:30
PixelyIon e7aa439029 Support Sticky Transforms + Minor Formatting Fixes
Sticky transforms have been stubbed, as they are on HOS/Android. Certain titles like Xenoblade Chronicles end up setting the sticky transform even if it doesn't do anything, as a result of this we cannot throw an exception for it and stub it without an exception (Aside from the cases where the value isn't recognized).
2021-07-06 00:19:53 +05:30
PixelyIon 0e02f1900f Implement additional IGraphicBufferProducer transactions
The following GraphicBufferProducer transactions were implemented:
* `SetBufferCount`
* `DetachBuffer`
* `DetachNextBuffer`
* `AttachBuffer`
It should be noted that `preallocatedBufferCount` (previously `hasBufferCount`) and `activeSlotCount` were adapted accordingly with how they were effectively the same value as all active buffers were preallocated prior but now there can be a non-preallocated active slot. 
Additionally, a bug has been fixed where `SetPreallocatedBuffer` has the graphic buffer as an optional argument whereas it was treated as a mandatory argument prior and could lead to a SEGFAULT if an application were to not pass in a buffer.
2021-07-04 09:39:53 +05:30
PixelyIon d595b9fe4f Implement SvcUnmapSharedMemory + Remove Redundant [[unlikely]] 2021-07-04 05:58:55 +05:30
PixelyIon a9de99357b Rework VI + IHOSBinder
VI/IHOSBinder suffered from major inaccuracies in their function due to being quickly thrown together initially with little concern for accuracy, this has now been fixed with them being substantially more accurate now.
2021-07-04 05:21:19 +05:30
PixelyIon 879d01f78d Improve `ENUM_STRING` + Fix Host1X Syncpoints
`ENUM_STRING` now has a unified implementation in <common/macros.h> with a documented format and can be used throughout the codebase. 

A major performance regression was added in the Host1X Syncpoint revamp as it did a syscall if there were any waiters during `Increment` even if they would just be woken up and go back to sleep as the threshold wasn't hit. It has now been optimized to only do a wake if any waiting thread needs to be awoken. 

There was also a bug concerning increment where it would perform actions corresponding to the previous increment rather than the current one which has also been fixed.
2021-06-30 18:36:28 +05:30
PixelyIon 375ce58008 Rework Performance Statistics
We used instantaneous values for FPS previously which led to a lot of variation in it and the inability to determine a proper FPS value due to constant fluctuations. All FPS values are now averaged to allow reading out a stable value and a deviation statistic has been added for the frame-time to judge judder and frame-pacing which allows for a significantly better measure of overall performance. The formatting for all the floating-point numbers is now fixed-point to prevent shifting of position due to decimal digits becoming 0.
2021-06-30 18:36:28 +05:30
PixelyIon 05bd7faeb6 Support Swap Interval + Cropping + Transforms and more for QueueBuffer
Support for the following parameters was added to `QueueBuffer`:
* Earliest Present Timestamp
* Swap Interval
* Crop
* Scaling Mode
* Transform
* Frame ID (Not returned to guest yet)
We utilize ANativeWindow APIs directly to achieve all of this in an efficient manner since HWC will be used directly for it, we do plan to introduce Vulkan equivalents for all of these operations later down the line for a port to non-Android platforms.
2021-06-30 18:36:28 +05:30
PixelyIon 8d4a8564f5 Update C++ Libraries 2021-06-30 18:36:28 +05:30
PixelyIon 33aa676b0d Replace LogActivity with "Share Logs" + Add Timestamp to Logger 2021-06-30 18:34:01 +05:30
PixelyIon a1598dcae2 Implement Display Settings + Attach Texture to FenceCycle 2021-06-30 18:34:01 +05:30
PixelyIon 16f875bab6 Revamp Host1X Syncpoint + Address Review Comments 2021-06-30 18:34:01 +05:30
PixelyIon b9af701bbe Separate Guest and Host Presentation + AChoreographer V-Sync Event
We had issues when combining host and guest presentation since certain configurations in guest presentation such as double buffering were very unoptimal for the host and would significantly affect the FPS. As a result of this, we've now made host presentation have its own presentation textures which are copied into from the guest at presentation time, allowing us to change parameters of the host presentation independently of the guest.

We've implemented the infrastructure for this which includes being able to create images from host GPU memory using VMA, an optimized linear texture sync and a method to do on-GPU texture-to-texture copies.

We've also moved to driving the V-Sync event using AChoreographer on its on thread in this PR, which more accurately encapsulates HOS behavior and allows games such as ARMS to boot as they depend on the V-Sync event being signalled even when the game isn't presenting.
2021-06-30 18:34:01 +05:30
PixelyIon b4799f612c Redesign Texture Class + Improve Presentation Engine
This commit reworks the `Texture` class to include a Vulkan Image backing that can be optionally owning or non-owning and swapped in with consideration for Vulkan image layout, it also adds CPU-sided synchronization for the texture objects with FenceCycle. It also makes the appropriate changes to `PresentationEngine` and `GraphicBufferProducer` to work with the new `Texture` class while setting the groundwork for supporting swapchain recreation. It also fixes a log in `IpcResponse` and improves the display mode selection algorithm by further weighing refresh rate.
2021-06-30 18:34:01 +05:30
PixelyIon 0bfddc1b0d Implement Fence Cycle, Memory Manager and Command Scheduler
Implements a wrapper over fences to track a single cycle of activation, implement a Vulkan memory manager that wraps the Vulkan-Memory-Allocator library and a command scheduler for scheduling Vulkan command buffers
2021-06-30 18:34:01 +05:30
PixelyIon 9b145b5e26 Rework GraphicBufferProducer
This commit makes GraphicBufferProducer significantly more accurate by matching the behavior of AOSP alongside mirroring the tweaks made by Nintendo. 

It eliminates a lot of the magic structures and enumerations used prior and replaces them with the correct values from AOSP or HOS. 

There was a lot of functional inaccuracy as well which was fixed, we emulate the exact subset of HOS behavior that we need to. A lot of the intermediate layers such as GraphicBufferConsumer or Gralloc/Sync are not emulated as they're pointless abstractions here.
2021-06-30 18:34:01 +05:30
PixelyIon aa4df1b1f0 Update NDK to 21.4.7075529 2021-06-30 18:34:01 +05:30
PixelyIon 25b60f2572 Presentation Engine Vulkan Surface + Swapchain Initialization
This commit adds in VkSurface/VkSwapchain initialization and recreation. It also adapts GraphicsBuffferProducer and Texture to fit in with those changes but it doesn't yet implement presenting those buffers nor uploading guest buffers onto the host.
2021-06-30 18:34:01 +05:30
PixelyIon 305b7a6fa5 Extend VkQueue Allocation Code
The VkQueue allocation code is rewritten to iterate through all queue families to look for an appropriate queue now
2021-06-30 18:34:01 +05:30
PixelyIon 0a38bebb2e Vulkan PhysicalDevice + Device Initialization + Report Accurate Version
Vulkan Device initialization is handled now, it supports required extensions but support for optional extensions/features/properties will come in later when we require those. In addition, we now correctly report the version of Skyline to Vulkan which can be accessed from debugging tools. 

There's also a minor change regarding the search pattern for `SkylineLibraries` which now only searches in headers of libraries and it also explicitly excludes the redundant `vulkan.hpp` from the `Vulkan-Headers` repository.
2021-06-30 18:34:01 +05:30
PixelyIon 8b0d056c54 Vulkan Instance + Validation Layer + Debug Report Initialization
The GPU class has been extended in this for Vulkan initialization, this is done to the point of initializing the instance alongside loading in `VK_LAYER_KHRONOS_validation` which is also now packed into all Debug APKs for Skyline. In addition, `VK_EXT_debug_report` is also initialized and it's output is piped directly into the Logger. 

A minor change regarding the type of the `Fps` and `Frametime` globals was changed to `skyline::i32`s which is a more suitable type due to those having a smaller chance of overflowing while being signed as Java doesn't have unsigned integral types.
2021-06-30 18:34:01 +05:30
Billy Laws 5be7860cf7 Fixup validity check in mmnv IRequest::Get
Fixes a random crash in SMO when launching the game for the first time.
2021-06-27 14:47:52 +01:00
Billy Laws 100cff7692 Address feedback 2021-06-20 14:18:40 +01:00
Billy Laws b87f451746 Handle empty core queues in Scheduler::UpdatePriority
If the queue is empty then begin() == end() leading to
ArmPreemptionTimer being called on an unscheduled thread.
2021-06-20 14:18:40 +01:00
Billy Laws d57883705d Avoid aligning BSS and .data individually and instead align as one
As both of these are in the same memory segment they have no individual
alignment requirements, this created a bug in
にゃんらぶ~私の恋の見つけ方~ where the data segment would be larger
than the game expected and invalid command line arguments would be read.
2021-06-20 14:18:40 +01:00
Billy Laws e1ca24d35f Stub IParentalControlService::Initialize
This is used in newer SDKs in favour of initialising on creation with
IParentalControlServiceFactory::CreateServiceOld.
2021-06-20 14:18:40 +01:00
Billy Laws af5ee96b9a Ensure that threads are ready before their preemption timer can be
armed.

It was discovered during testing of 'Hatsune Miku Project DIVA: Mega Mix'
that if a thread was starting while preemption was being enabled a NULL
pointer dereference could occur in the timer_settime call as
timer_create may not have been called yet.
2021-06-20 14:18:40 +01:00
Billy Laws a7dc69223b Implement mmnv::IRequest for media module clock control
This is used by games before calling into nvdec in order to clock up the
HW module, it can also be used to request a RAM frequency. Since we
obviously don't emulate the hardware down to this level a basic stub
that provides the correct reponses is enough.

Fixes a crash on first level of Super Mario Odyssey.
2021-06-20 14:18:40 +01:00
Billy Laws 54d39fbaa7 Fix backtrace format string so it properly handles SVC names
This was missed when we moved over to printing SVC names rather than
numbers.
2021-06-20 14:18:40 +01:00
Billy Laws 99a839d669 Check the mutex tag in MutexLock if the given handle isn't found
Makes sure the correct error is reported as HOS only reports
InvalidHandle if the tag matches.
2021-06-20 14:18:40 +01:00
Billy Laws 476bb65f37 Stub GetAccumulatedSuspendedTickValue and fix call misnumbering
This is used by some more recent games like Hatsune Miku: Project DIVA
MegaMix!
2021-06-20 14:18:40 +01:00
Billy Laws 22c83006a3 Stub application copyright image AM calls
These are used on HOS to control the screenshot overlay image for
developer copyrights.
2021-06-20 14:18:40 +01:00
Billy Laws 6f9189e8f9 Reimplement GetPseudoDeviceId to be more accurate
Now returns a valid V5 UUID and uses the game's seed from control.nacp
for generation.
2021-06-20 14:18:40 +01:00
Billy Laws d4b13c34ee Fixup broken SetTimeslice nvdrv ioctl that was missed in conversion 2021-06-20 14:18:40 +01:00
Willi Ye bf2e20565f Check if fragment is attached when doing animations 2021-06-17 20:30:22 +05:30
Willi Ye ce60101989 Filter on screen buttons by controller type 2021-06-17 20:30:22 +05:30
Willi Ye 2ff06d5421 Apply changed layout to all items
* Fix memory leaks
2021-06-17 20:30:22 +05:30
PixelyIon 686d61b893 Update NDK to 21.4.7075529 2021-06-17 20:30:22 +05:30
PixelyIon 0c29f982d5 Replace skyline-emu/VkHpp with KhronosGroup/Vulkan-Hpp
We used a custom version of Vulkan-Hpp which split the files a lot prior to avoid any developers needing to manually set IDE settings for IntelliJ to work but this wasn't practical due to how it required modifications to Vulkan-Hpp's generator which would make maintenance extremely difficult. It was determined that we should just add the requirement for changing the IDE settings and use Vulkan-Hpp directly.
2021-06-17 20:30:22 +05:30
Willi Ye 7a5684e57f Rework focus for controller 2021-06-17 20:30:22 +05:30
Willi Ye 3c23302b82 Make rom extensions case insensitive
* Use standard margins
* Some clean up
2021-06-17 20:30:22 +05:30
Willi Ye f410b20d58 Remove non existant activities from manifest 2021-06-17 20:30:22 +05:30
Willi Ye 61c489dc68 Increase trigger distance of swipe to refresh 2021-06-17 20:30:22 +05:30
Willi Ye 88b05f45d5 Update library version 2021-06-17 20:30:22 +05:30
Willi Ye 1e27aef9e7 Properly constraint width in linear layout 2021-06-17 20:30:22 +05:30
Willi Ye e50f5a5d72 Make controller layout more preferences like 2021-06-17 20:30:22 +05:30
Willi Ye 4b7cb176f6 Add mime type to key picker 2021-06-17 20:30:22 +05:30