Commit Graph

652 Commits

Author SHA1 Message Date
lynxnb
6913a90361 Use the new log file name & ext for every logger context 2021-11-11 16:32:19 +01:00
lynxnb
5cd1f01690 Refactor all logger calls 2021-11-11 16:13:24 +01:00
lynxnb
769e6c933d Make Logger class static and introduce LoggerContext
A thread local LoggerContext is now used to hold the output file stream instead of the `Logger` class. Before doing any logging operations, a LoggerContext must be initialized.
This commit will not build successfully on purpose.
2021-11-11 16:13:24 +01:00
PixelyIon
69ef93bfa8 Add Dividers to ControllerActivity's RecyclerView
Dividers after titles were missing in `ControllerActivity` which made it look inconsistent with `SettingsActivity` which did have them. They have now been added by extending `DividerItemDecoration` to be drawn before any `ControllerHeaderItem`.
2021-11-11 20:20:19 +05:30
PixelyIon
b230afcd35 Fix FAB Icon color in OnScreenEditActivity
The icons in these FABs had the same color as the FAB prior which led them to being invisible. This has been fixed by setting a white tint on them which makes the icons clearly visible.
2021-11-11 18:59:09 +05:30
PixelyIon
e4fbee1626 Style Improvements to LicenseDialog
Additional padding has been added to the text alongside making it be left-aligned rather than center-aligned and justified. A newline has also been added to the copyright notice for Skyline to make it look nicer.
2021-11-11 16:35:30 +05:30
PixelyIon
36a1f2a2ec Make all Dialogs use @color/backgroundColor as the background color
We wanted the color of the modals used by the dialogs to be the same as our regular background color rather than a lighter grey. This has now been enforced with style attributes in the case of `AlertDialog` and `setBackground` in the case of `BottomSheetDialog`.
2021-11-11 16:34:38 +05:30
PixelyIon
3f3891839e Make all AlertDialogs use MaterialComponents theme
We inconsistently used `AppCompat`'s `AlertDialog` theme in Settings while using `MaterialComponents`'s theme in Controller Configuration. This has now been fixed by universally using the `MaterialComponents` theme.
2021-11-11 16:28:57 +05:30
PixelyIon
ff5887975b Remove Logo from MainActivity
The Skyline logo was added to the title area but it ended up being too distracting with a light theme as the logo was designed purely for a white background. Ultimately, even though it looked good with the dark theme we had to remove it.
2021-11-11 13:58:25 +05:30
PixelyIon
43b9d95dbc Rework App Dialog Buttons
Aligning the buttons to the bottom of the game image was determined to look odd due to the amount of padding between the title and buttons. They are now back to being below the title but the buttons have been resized with "Play" being a wide button while "Pin" has been replaced with Google Material Icons's "Add To Home Screen" icon and sized down to an icon-only button.
2021-11-11 13:47:20 +05:30
lynxnb
6a0ad25c27 Update BottomSheetDialog appearance
* Fix incorrect dialog surface color
* Adjust buttons' position
2021-11-10 17:41:07 +01:00
lynxnb
df120ab76d Fix unicode characters being turned into emojis for some vendors 2021-11-10 17:41:07 +01:00
lynxnb
b7b0f07ba8 Update application branding
- Logo is now displayed next to the app name
- Remove search bar animation
- New color accent
- Improve visibility of controller binding setting's glyphs
2021-11-10 17:41:07 +01:00
lynxnb
827439d2d1 Use the new font for the application name in main activity 2021-11-10 17:41:07 +01:00
lynxnb
07f899e904 Update application icon 2021-11-10 17:41:07 +01:00
Billy Laws
d88b08d986 Address PR feedback 2021-11-10 21:35:36 +05:30
Billy Laws
1b453c04ca Remove completed nvmap TODO
Pins have been implemented so the to-do is no longer needed.
2021-11-10 21:35:36 +05:30
Billy Laws
d2d181725f Remove unused virtEnd variable in FlatMemoryManager::{Read, Write} 2021-11-10 21:35:36 +05:30
Billy Laws
60fbfad4bc Add virtual dtors to time service code 2021-11-10 21:35:36 +05:30
Billy Laws
ef10d3d394 Use semantic wrapping where appropriate for class initialiser lists 2021-11-10 21:35:36 +05:30
Billy Laws
6b33268d85 Remove unused gm20b EngineID enum 2021-11-10 21:35:36 +05:30
Billy Laws
73896c2e6b Fixup nvdrv channel types to follow naming conventions 2021-11-10 21:35:36 +05:30
Billy Laws
ad900aba7a s/Host1X/Host1x/ as per Nvidia naming 2021-11-10 21:35:36 +05:30
Billy Laws
dbfb1cfe20 Fully implement the nvdrv Host1xChannel::Submit operation
This pushes a set of command buffers into the Host1x command FIFO allocated for the channel, returning fence thresholds that can be waited on for completion,
2021-11-10 21:35:36 +05:30
Billy Laws
baefb0fe93 Implement the Host1x command FIFO together with barebones Host1x classes
The Host1x block of the TX1 supports 14 separate channels to which commands can be issued, these all run asynchronously so are emulated the same way as GPU channels with one FIFO emulation thread each. The command FIFO itself is very similar to the GPFIFO found in the GPU however there are some differences, mainly the introduction of classes (similar to engines) and the Mask opcode (which allows writing to a specific set of offsets much more efficiently).

There is an internal Host1x class which functions similar to the GPFIFO class in the GPU, handling general operations such as syncpoint waits, this is accessed via the simple method interface. Other channels such as NVDEC and VIC are behind the 'Tegra Host Interface' (THI) in HW, this abstracts out the classes internal details and provides a uniform method interface ontop of the Host1x method one. We emulate the THI as a templated wrapper for the underlying class.

Syncpoint increments in Host1x are different to GPU, the THI allows submitting increment requests that will be queued up and only be applied after a specific condition in the associated engine is met; however the option to for immediate increments is also available.
2021-11-10 21:35:36 +05:30
Billy Laws
2494cafee8 Cleanup GPFIFO comments and make Run() private 2021-11-10 21:35:36 +05:30
Billy Laws
2577658fc7 Avoid GetPointer on nvmap handles where they would be accessed via SMMU
GetPointer sets the sharedMemMapped flag, which should only be set if
other userspace processes have the handle mapped.
2021-11-10 21:35:36 +05:30
Billy Laws
fd0420443c Add template utils for constructing all elements in an std::array
This avoids the excessive repetition needed for the case where array
members have no default constructor.

eg:
```c++
std::array<Type, 10> channels{util::MakeFilledArray<Type, 10>(typeConstructorArg, <...>)};
```
2021-11-10 21:35:36 +05:30
Billy Laws
34bf413661 Fix bitmask check for event IDs > 32 in Ctrl::SyncpointFreeEventBatch
Doing 1 << 32 would result in an integer overflow rather than the desired behaviour of checking a bit, make 1 64 bit to present that.
2021-11-10 21:34:30 +05:30
Billy Laws
debab7c9c7 Implement nvmap handle pinning/unpinning
nvmap allows mapping handles into the SMMU address space through 'pins'. These are refcounted mappings that are lazily freed when required due to AS space running out. Nvidia implements this by using several MRU lists of handles in order to choose which ones to free and which ones to keep, however as we are unlikely to even run into the case of not having enough address space a naive queue approach works fine. This pin infrastructure is used by nvdrv's host1x channel implementation in order to handle mapping of both command and data buffers for submit.
2021-11-10 21:34:30 +05:30
Billy Laws
a0c57256cc Hookup FlatMemoryManager for SMMU into SoC
The SMMU is used to control the mappings of peripherals such as the VIC
and NVDEC.
2021-11-10 21:34:30 +05:30
Billy Laws
97dc053ffd Move FlatAllocator allocation error handling to the caller
This is a prerequisite for nvmap SMMU memory management, which only frees the memory handles refer to if an allocation fails.
2021-11-10 21:34:30 +05:30
Billy Laws
04e5237ec1 Stub host1x channel devices and IOCTLs
host1x channels are generally similar to GPU channels however there is only one channel for each specific class (like a GPU engine) and an address space is shared between them all.

This PR implements the simple IOCTLs with the larger ones that will depend on changes outside of nvdrv being left for future commits. This is enough to partly run oss-nvjpeg.
2021-11-10 21:34:30 +05:30
Billy Laws
5087d3dc2a Reserve host1x channel syncpoints 2021-11-10 21:34:30 +05:30
Billy Laws
b0a5dab0f7 Support passing additional constructor arguments to nvdrv devices
Needed for host1x channels which use the same class for multiple types.
2021-11-10 21:34:30 +05:30
Billy Laws
eb6f052873 Fixup GpuChannel::SetNvmapFd to take an FD rather than an nvmap handle 2021-11-10 21:34:30 +05:30
Billy Laws
386a3447a8 Introduce variable sized span support to nvdrv deserialisation
The element containing the size first needs to be saved to a save slot with Save<T, slotId>, it can then be read back later as the size of a span with SlotSizeSpan<T, slotId>. This is needed to support the Host1XChannel Submit IOCTL.
2021-11-10 21:34:30 +05:30
Billy Laws
6eeaa343f8 Avoid crash when passing unallocated syncpoint IDs to EventWait 2021-11-10 21:34:30 +05:30
PixelyIon
fbfad21f03 Migrate Maxwell3D::Registers to OffsetMember
Maxwell3D registers were primarily written with absolute offsets and ended up being fairly messy due to attempting to emulate this using struct relative positioning resulting in a lot of pointless padding members. This has now been improved by utilizing `OffsetMember` to directly use offsets resulting in much neater code.
2021-11-10 21:31:45 +05:30
PixelyIon
69761389ff Extend OffsetMember with direct operator=/operator[]
It was found to be semantically advantageous to directly pass-through certain operators such as the assignment (`=`) and array index (`[]`) operators. These would require a dereference prior to their usage otherwise but now can be directly used.
2021-11-10 21:30:02 +05:30
Billy Laws
cc7b2a0ab8 Introduce OffsetMember for offset-based union members
The offset of a member in a structure was determined by its relative position and compiler alignment. This is unoptimal for larger structures such as those found in GPU Engines that are primarily named by offset rather than relative positioning and end up requiring a massive amount of padding to function as is. A solution to this problem was simply to supply member offsets directly which can be done by using `OffsetMember` alongside a `union`.
2021-11-10 21:17:31 +05:30
PixelyIon
fb476567ff Introduce JniString as C++ wrapper over jstring
We used to manually call JNI UTF-8 string allocation and deallocation functions when utilizing a `jstring` but this could be erroneous and is just inconvenient. All of this has now been consolidated into an class `JniString` which is a wrapper around `std::string` and creates a copy of the contents of the `jstring` in its constructor and passes them into the `std::string` constructor.
2021-11-09 21:18:47 +05:30
PixelyIon
79ceb2cf23 Improve Vulkan Texture Synchronization
The Vulkan Pipeline Barriers were unoptimal and incorrect to some degree prior as we purely synchronized images and not staging buffers. This has now been fixed and improved in general with more relevant synchronization.
2021-11-09 21:08:03 +05:30
PixelyIon
bed9fbf5e7 Fix EmulationActivity.vibrateDevice assert due to null Vibrator
`EmulationActivity.vibrateDevice` would assert when a `null` Vibrator is provided due to one not being set in the controller configuration. This has now been fixed by the code not playing a vibration when a vibration device isn't selected.
2021-11-01 00:28:11 +05:30
PixelyIon
414c0104c3 Rework Joy-Con Vibration Conversion
The guest -> host vibration conversion code was entirely broken as it didn't set the vibration `start`/`end` timestamps correctly for a cycle nor did it subtract from the `totalAmplitude` (`currentAmplitude` now) when it a cycle ended due to an incorrect `if` statement and contents. It would just end up saturating the amplitude as much as possible by adding more and more to `totalAmplitude` on every cycle while never subtracting which is entirely wrong and led to a very noticeable drop in amplitude when a vibration was repeated.

It's been entirely reworked to fix all the issues listed above and remove a lot of code that had no understandable purpose. More comments have also been added to the code to make it more readable with better variable and function naming alongside it.
2021-11-01 00:28:11 +05:30
PixelyIon
96027f0f09 Build libraries with -Ofast for debug builds
To offset some of the performance overhead of using debug builds, we now optimize all libraries using `-Ofast` while building Skyline itself with `-O0`.
2021-10-31 16:05:08 +05:30
PixelyIon
4b80e1f91c Use libcxx from LLVM Project submodule
The version of libcxx shipped with Android NDK is fairly outdated and doesn't contain several features we desire such as C++ 20 ranges. This has been fixed by using libcxx directly from the LLVM Project which has been added as a submodule and can be updated independently of NDK.
2021-10-31 16:04:44 +05:30
PixelyIon
82154f3ef6 Upgrade AGP to 7.1.0-beta01 & NDK to 24.0.7856742
We've moved to using a beta AGP as `7.0.2` is breaks `clangd` and other C++ features on Beta/Canary Android Studio. NDK was additionally updated with `mbedtls` to fix warnings caused by it alongside some other minor fixes to code for newer versions of libcxx.

The new AGP has a bug where it does not look for executables specified in `android_gradle_build.json` in `PATH` that includes `ninja` which is provided by the `ninja-build` package on the system rather than Android SDK's CMake on GitHub Actions (Ubuntu 20.04). This has been fixed by symlinking `/usr/bin/ninja` to the project root which is searched in for the `ninja` executable.
2021-10-31 15:50:15 +05:30
PixelyIon
962d8dc4c8 Return immediately for non-joining KProcess::Kills when already killed
Locking `KProcess::threadMutex` when a process is being killed by another thread with `join` can lead to the non-joining killer effectively joining as it's waiting on the joining killer to relinquish the mutex. This has been fixed by having an atomic boolean tracking if the process has already been killed and if it has, immediately returning prior to locking the mutex for any non-joining killers.
2021-10-31 15:45:10 +05:30
Billy Laws
6f59cba68d Adds bounds checks to resampler to avoid OOB reads
Resampling would sometimes perform an OOB read into `inputBuffer` due it not containing enough data to calculate corresponding the output sample, this has been fixed by introducing bounds checking to ensure that the buffer has enough data.
2021-10-29 21:46:51 +05:30
PixelyIon
9e3b7a75b2 Use finishAffinity instead of finishAndRemoveTask
The method used to finish (`finishAndRemoveTask`) an activity prior to going back to `MainActivity` or restarting the process led to the process prematurely exiting entirely and would result in it not being restarted or another activity not being launched. This has now been fixed by utilizing `finishAffinity` in its place which correctly only ends the activities with the same affinity as the caller.
2021-10-29 21:20:04 +05:30
PixelyIon
9f5ab13858 Implement R16G16{Unorm/Sint/Uint} RT Formats
Utilized in "The Touryst"
2021-10-29 20:21:58 +05:30
PixelyIon
afebf77544 Zero-Initialize GuestTexture Members
Members of `GuestTexture` were apparently not being initialized and this led to UB since they would be read as random values. Titles such as Super Mario Odyssey avoided setting `baseArrayLayer` which led to it being left at the default value which was completely random and this would lead to crashes. This commit fixes this by initializing said values correctly.
2021-10-27 22:49:45 +05:30
PixelyIon
a0921f8261 Implement R16G16B16A16Snorm/R16G16B16A16Sint RT Formats
Utilized in "The Touryst"
2021-10-27 22:49:45 +05:30
PixelyIon
df64ff5d14 Zero-Fill IAudioRenderer::RequestUpdate Output Buffer
Some titles don't clear the output buffer prior to submission, as the service is expected to fill all of it in, our audren implementation is incomplete and doesn't end up doing this leaving the contents of the buffer to be undefined leading to UB in the form of SEGFAULTs or the application throwing a fatal error. This has been patched over by 0-filling the buffer which is a sane default value for the fields that aren't filled in albeit not a replacement for a proper audren implementation.
2021-10-27 16:18:20 +05:30
PixelyIon
1f3519e6e3 Fix Logger Message OOB Access
Certain titles can submit logs where the last field is one off by the buffer end, the logger loop now considers this and terminates if there isn't enough data left to read the field type and length.
2021-10-26 21:59:47 +05:30
PixelyIon
645183c903 Fix OOB Vibration Array Access in VibrateDevice
Access to the `vibrations` field in `vibrations[3].period` could lead to UB, this has been replaced with a proper check which adds up the period over all vibrations instead. A minor cleanup with variable names and explicit types for integer arithmetic has also been done.
2021-10-26 21:57:28 +05:30
PixelyIon
cfdb2abf9e Fix Non-builtin Uncached Vibrator Getter
If a non-builtin vibrator was attempted to be fetched, it'd insert it in the vibrator cache and return directly as opposed to playing the vibration on it prior to returning. This has now been fixed, the value is both put into the cache and the vibration is played on it.
2021-10-26 21:54:33 +05:30
PixelyIon
dc3f7f1ab4 Fix Incorrect Scissor Extent
The decomposition from `texture::Dimension` to `vk::Rect2D` was somehow implicit and completely incorrect resulting in wrong conversion with undefined values. It's now been fixed by explicitly setting `vk::Rect2D::extent` to `scissor` specifically.
2021-10-26 20:08:53 +05:30
PixelyIon
a60f238479 Fix GPU::DebugCallback Type String Extraction
The second parameter of `std::string_view::substr` was assumed to be an end position (similar to `std::span`) rather than `count` which it is. As a result of this, it was entirely broken but only held together by a constant factor being subtracted from it which was derived by trial and error. It's now been fixed by returning a count rather than the absolute position.
2021-10-26 20:08:35 +05:30
PixelyIon
10ed5bf418 Silence errors from libraries
Library headers would produce errors that are out of our control and as a result of that, we just want to ignore this. This is possible by including the offending headers as system headers, compilers don't emit any warnings arising from them. This was extended to all libraries rather than just those which currently emitted warnings for consistency's sake.
2021-10-26 20:08:18 +05:30
Billy Laws
70d1b4994c Enable Wconversion and fix warnings produced 2021-10-26 11:41:24 +01:00
PixelyIon
315d2dc26c Update NDK to 23.1.7779620 2021-10-26 10:46:36 +05:30
PixelyIon
661396fc97 Resume EmulationActivity when launcher icon is used
Fix a bug where attempting to launch Skyline from the launcher while emulation was in progress would result in `MainActivity` launching rather than `EmulationActivity`. We always want `EmulationActivity` to stay on top of the stack and be launched whenever Skyline is resumed, no other activity should be able to run in parallel to `EmulationActivity` in any user-accessible manner.
2021-10-26 10:46:36 +05:30
PixelyIon
39e924aec8 Resume rather than relaunch when same shortcut is used 2021-10-26 10:46:36 +05:30
Billy Laws
1e7347bf72 Use semantic wrapping for nvdrv where appropriate 2021-10-26 10:46:36 +05:30
PixelyIon
830a800d9e Consolidate AddAttachment Loops + Rename Renderpass -> RenderPass 2021-10-26 10:46:36 +05:30
PixelyIon
92a21ea616 Cleanup & Use C++ Concepts in utils.h 2021-10-26 10:46:36 +05:30
PixelyIon
ea2626bcc6 Address CR Comments 2021-10-26 10:46:36 +05:30
PixelyIon
1d532628cb Null-Check Optional NACP before extracting application title
Not doing this can lead to the NACP being filled with invalid data and led to crashes on homebrew titles like SpaceNX.
2021-10-26 10:46:36 +05:30
PixelyIon
c8821c7313 Update nvdrv perms to 11.0.0+ & Implement nvdrv:a service
`nvdrv:a` (For Applets) is used by some older homebrew such as SpaceNX which don't fall back to `nvdrv` (For Applications).
2021-10-26 10:46:36 +05:30
PixelyIon
3b4bbd2b38 Switch to using exceptions for guest exiting
Guest-driven exiting could cause objects left on the heap due to a `std::longjmp` from high up in the host call stack, this has been fixed by introducing `ExitException` which implicitly unrolls the stack with the exception handling mechanism.
2021-10-26 10:46:36 +05:30
PixelyIon
eff5711c49 Split monolithic common.h into smaller chunks
* Resolves dependency cycles in some components
* Allows for easier navigation of certain components like `span` which were especially large
* Some imports have been moved from `common.h` into their own files due to their infrequency
2021-10-26 10:46:36 +05:30
PixelyIon
1d57bab08f Revamp LicenseDialog + Update Licenses + Stop Bintray Usage
* Update licenses for dependent projects
* Add copyright notices (as provided)
* Revamp styling for `LicenseDialog` 
* Fix invisible `PreferenceDialog` buttons in Settings
* Consolidating color variables into `colorPrimary`, `backgroundColor` and `backgroundColorVariant`
* Use `com.google.android.flexbox:flexbox:3.0.0` (Google Maven) rather than `com.google.android:flexbox:2.0.1` (Bintray)
2021-10-26 10:46:36 +05:30
PixelyIon
bbf28d1942 Improve Clean Exit + Audio Pausing + Improve System Language Setting
* Clean Exiting was improved by implementing a robust system for when to abandon clean exiting and simply restart the process alongside moving clean exiting to the background when the application is quit by using the back button
* Audio is now automatically paused whenever the application is moved to the background and automatically resumed when it's brought to the foreground
* The system language setting had several errors and inconsistencies which have now been fixed, it's been brought more in line with HOS language (Albeit not entirely due to no region setting in Skyline)
* Fix a bug with `ThreadLocal` where the atomic `list` pointer was uninitialized resulting in a `SEGFAULT` during the destructor
2021-10-26 10:46:36 +05:30
PixelyIon
a7548c79a0 Android 12 Support + Update Libraries + Include Khronos Validation Layer
* Fix handling `SA_EXPOSE_TAGBITS` bit being set in Android 12 `sigaction`
* Fix CMake bug using `CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE` when not supported causing `-fuse-ld=gold` to be emitted as a linker flag
* Support using `VIBRATOR_MANAGER_SERVICE` rather than `VIBRATOR_SERVICE` on Android 12
* Optimize Imports for Kotlin code
* Move away from deprecated APIs in Kotlin or explicitly mark where it's not possible
* Update SDK, NDK and libraries
* Enable Gradle Configuration Cache
2021-10-26 10:46:36 +05:30
Billy Laws
b7d0f2fafa Implement support for pushbuffer methods split across multiple GpEntries
These are used heavily in OpenGL games, which now, together with the
previous syncpoint changes, work perfectly. The actual implementation is
rather novel as rather than using a per-class state machine for all
methods we only use it for those that are known to be split across
GpEntry boundaries, as a result only a single bounds check is added to
the hot path of contiguous method execution and the performance loss is
negligible.
2021-10-16 12:13:30 +01:00
Billy Laws
fc017e1e95 Implement pre-wait and post-increment syncpoint operations in submit
These are used by both OpenGL and Vulkan games as opposed to including
the operations inside the main commandbuffer.
2021-10-16 12:13:30 +01:00
PixelyIon
9b9bf8d300 Introduce ThreadLocal Class + Fix Several GPU Bugs
* Fix `AddClearColorSubpass` bug where it would not generate a `VkCmdNextSubpass` when an attachment clear was utilized
* Fix `AddSubpass` bug where the Depth Stencil texture would not be synced
* Respect `VkCommandPool` external synchronization requirements by making it thread-local with a custom RAII wrapper
* Fix linear RT width calculation as it's provided in terms of bytes rather than format units
* Fix `AllocateStagingBuffer` bug where it would not supply `eTransferDst` as a usage flag
* Fix `AllocateMappedImage` where `VkMemoryPropertyFlags` were not respected resulting in non-`eHostVisible` memory being utilized
* Change feature requirement in `AndroidManifest.xml` to Vulkan 1.1 from OGL 3.1 as this was incorrect
2021-10-16 12:13:30 +01:00
Billy Laws
eb25f60033 Implement multichannel support for GPU
Allows the execution of multiple channels at the same time, with locking
being performed on the host GPU scheduler layer, address spaces can be
bound to one or more channels.
2021-10-16 12:13:30 +01:00
PixelyIon
b762d1df23 Introduce Texture Always Sync + Wait on GPU Execution + More RT Formats
Infrastructure for always syncing textures has been introduced now, they will be synced prior to and after every execution. This does considerably reduce the performance alongside waiting on GPU execution to finish but it will be partially recouped once conditional syncing is performed.
2021-10-16 12:13:30 +01:00
PixelyIon
f8acc1e131 Improve Shared Fonts + Fix AM PopLaunchParameter & Choreographer Bug
* Move Shared Font TTFs to AAsset storage + Support external shared font loading from `/data/data/skyline.emu/data/fonts`
* Fix bug in `IApplicationFunctions::PopLaunchParameter` caused by ignoring `LaunchParameterKind`
* Fix bug with Choreographer causing it to be awoken and exit prior to the destruction of `PresentationEngine`
* Fix bug with `IDirectory::Read` where it used `inputBuf` for the output buffer rather than `outputBuf`
* Improve `GetFunctionStackTrace` logs when `dli_sname` or `dli_fname` are missing
* Support more RT Formats
2021-10-16 12:13:30 +01:00
PixelyIon
95a08627e5 Subpass Support + More RT Formats + Fix FenceCycle Cyclic Dependencies
Support for subpasses was added by reworking attachment reuse code to account for preserved attachments and subpass dependencies. A lot of RT formats were also added to allow SMO to boot up entirely, it should be noted that it doesn't render anything. 

`FenceCycle` had a cyclic dependency which broke clean exit, we now utilize `std::weak_ptr<FenceCycle>` inside the `Texture` object. A minor fix for broken stack traces was also made caused by supplying a `nullptr` C-string to libfmt when a symbol was unresolved which caused an `abort` due to invocation of `strlen` with it.
2021-10-16 12:13:30 +01:00
PixelyIon
239d2625e2 Introduce CommandExecutor + Implement ClearBuffers + More RT Formats
This commit introduces the `CommandExecutor` which is responsible for creating and orchestrating a Vulkan command graph comprising of `CommandNode`s that construct all the objects required for rendering. As a result of the infrastructure provided by `CommandExecutor`, `ClearBuffers` could be implemented and be appropriately utilized.

A bug regarding scissors was also determined and fixed in the PR, the extent of them were previously inaccurate and this has now been fixed.

Note: We don't synchronize any textures from the guest for now as this would override the contents on the host, this'll be fixed with the appropriate write tracking but it also results in a black screen for anything that writes to FB
2021-10-05 01:13:22 +05:30
PixelyIon
3879d573d5 Fix Command Buffer Allocation & FenceCycle
This commit fixes a major issue with command buffer allocation which would result in only being able to utilize a command buffer slot on the 2nd attempt to use it after it's freed, this would lead to a significantly larger amount of command buffers being created than necessary. It also fixes an issue with the command buffers not being reset after they were utilized which results in UB eventually.

Another issue was fixed with `FenceCycle` where all dependencies are only destroyed on destruction of the `FenceCycle` itself rather than the function where the `VkFence` was found to be signalled.
2021-10-05 01:13:22 +05:30
PixelyIon
bee28aaf0d Validation Layer Filter + Fix Texture, GPU & PresentationEngine bugs
This commit implements a filter by type for any validation layer output, this allows filtering out any logs which may be unnecessary and additionally triggering a breakpoint as required. 

An issue concerning the `NDEBUG` flag never being set was fixed, it's now supplied as a release compiler flag. The issue can manifest itself by always relying on a validation layer even though it shouldn't on release, this is why the validation layer was mistakenly disabled entirely previously by using `#ifndef` rather than `#ifdef`.

An issue with the initial layout of a texture being supplied as neither `VK_IMAGE_LAYOUT_UNDEFINED` or `VK_IMAGE_LAYOUT_PREINITIALIZED` was fixed, these cases are now handled by transitioning to those layouts after creating the image rather than supplying it within `initialLayout`.

Another issue was fixed regarding not maintaining a transformation after a surface has been destroyed and recreated existed and manifested itself when the user would go out of the app and come back in, they would see the surface having an identity transformation rather than the desired one.
2021-10-05 01:13:22 +05:30
PixelyIon
54908afc44 Texture GMMU Address Resolution + Refactor Maxwell3D::CallMethod
Fixes bugs with the Texture Manager lookup, fixes `RenderTarget` address extraction (`low`/`high` were flipped prior), refactors `Maxwell3D::CallMethod` to utilize a case for the register being modified + preventing redundant method calls when no new value is being written to the register, and fixes the behavior of shadow RAM which was broken previously and would lead to incorrect arguments being utilized for methods.
2021-10-05 01:13:22 +05:30
PixelyIon
270f2db1d2 Initial Texture Manager Implementation + Maxwell3D Render Target
Implement the groundwork for the texture manager to be able to report basic overlaps and be extended to support more in the future. The Maxwell3D registers `RenderTargetControl`, `RenderTarget` and a stub for `ClearBuffers` were implemented. 

A lot of changes were also made to `GuestTexture`/`Texture` for supporting mipmapping and multiple array layers alongside significant architectural changes to `GuestTexture` effectively disconnecting it from `Texture` with it no longer being a parent rather an object that can be used to create a `Texture` object.

Note: Support for fragmented CPU mappings hasn't been added for texture synchronization yet
2021-10-05 01:13:22 +05:30
PixelyIon
8cba1edf6d Introduce Boost as a submodule + Minor Fixes
Utilize Boost Container's `small_vector` for optimizing allocations, fix certain implicit casting issues and make `ILogger` not output an additional newline in the log when the application supplies one at the end of the log
2021-10-05 01:13:22 +05:30
PixelyIon
190fde110f Introduce GraphicContext and Implement Viewport Transform + Scissors 2021-10-05 01:13:22 +05:30
PixelyIon
bc378ad135 Fix GraphicBufferProducer Format Bug
The format provided in `GraphicBuffer` can be misleading and is supplied as `None` by the Deko3D Swapchain, it instead supplies the real format in the `NvGraphicHandle` which we now utilize instead of the one in `GraphicBuffer`.
2021-10-05 01:13:22 +05:30
PixelyIon
18cf0b82d6 Fix KTransferMemory Destruction Behavior + Add Missing SVC Handle Logs
KTransferMemory needs to be reset to RW on destruction unlike KSharedMemory which is simply freed on destruction, not emulating this behavior accurately leads to `deko_examples` from `switch-examples` to lead to a SEGFAULT on selecting an example as it expects the memory to be R/W while it ends up being freed instead
2021-10-05 01:13:22 +05:30
Billy Laws
192459f726 Adjust AS block end predecessors to successors after reuse as end 2021-10-04 20:29:02 +01:00
PixelyIon
d45193874e Fix NvDrv CloseDevice Bug
The unique pointer to a device in the map was simply reset rather than deleting the entry from the map, this resulted in the device not being properly closed and when the device was reopened then the `emplace` was a NOP as the entry already existed. This resulted in a `nullptr` dereference down the line when an application attempted to issue an IOCTL to a device that was previously closed and reopened. This is known to occur in Deko3D as it recreates the context when loading an example which includes closing and reopening devices.
2021-10-03 18:02:32 +05:30
Billy Laws
7a5ca19c0b Fix improper VMM error check in unmap 2021-10-01 20:58:22 +01:00
Billy Laws
4eff515c55 Add support for IOCTL3 CtrlGpu calls missed in refactor 2021-10-01 20:57:59 +01:00
PixelyIon
02bcf98b8c Fix NvDrv Bugs + NACP Parsing Bug
A hotfix for a nvdrv bug where an IOCTL with no input/output buffers would crash and a major `nvmap` bug which broke the `FromId` IOCTL as it didn't write back the handle ID, another minor bug existed in `nvhost` where the `ZCullGetInfo` IOCTL was `INOUT` rather than `OUT`.

A bug with NACPs was also fixed caused by incorrect padding for the `NacpData` structure which resulted in the `saveDataOwnerId` member being read incorrectly and as a result the save data folder being incorrect.

Co-authored-by: artem8086 <artemsvyatoha@gmail.com>
2021-10-02 00:15:53 +05:30
lynxnb
afc3dda1ee Reintroduce LanguageCode alias type 2021-09-30 02:19:19 +05:30
lynxnb
c6d91c552b Address CR 2021-09-30 02:19:19 +05:30
lynxnb
0077833667 Support game icon selection based on language 2021-09-30 02:19:19 +05:30