Commit Graph

1305 Commits

Author SHA1 Message Date
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
lynxnb
01ce09183b Rework common languages
Swapped out the usages of frozen constexpr unordered maps for switch statements, which are very likely to be turned into jump tables given the nature of the enums used, resulting in better performance than a map
2021-09-30 02:19:19 +05:30
sspacelynx
4d20d7a4d0 Address CR + Code formatting 2021-09-30 02:19:19 +05:30
sspacelynx
ca97517d81 Rework GetDesiredLanguage + Remove LanguageCode alias type 2021-09-30 02:19:19 +05:30
sspacelynx
6135f531ae Add refreshRequired xml attribute in IntegerListPreference
This attribute controls whether a rom list refresh will be triggered when the setting value changes.
2021-09-30 02:19:19 +05:30
sspacelynx
221039084e Make languages setting use IntegerListPreference 2021-09-30 02:19:19 +05:30
sspacelynx
c1a3ddcd1c Implement an IntegerListPreference
Unlike `ListPreference`, this preference class uses integers as its values instead of strings, avoiding unnecessary casting. It also doesn't require an array for values: in that case it will be using the clicked entry position as its value.
2021-09-30 02:19:19 +05:30
sspacelynx
fdc7e1238a Implement language support for rom loaders 2021-09-30 02:19:19 +05:30
sspacelynx
3c5509e52a Update available languages to those post 10.1.0
Brazilian Portuguese has been added in firmware version 10.1.0
2021-09-30 02:19:19 +05:30
sspacelynx
3fffde3061 Rework OS to allow passing a language 2021-09-30 02:19:19 +05:30
Billy Laws
a4a6511177 Address feedback 2021-09-30 02:11:19 +05:30
Billy Laws
a18f1aa889 Address feedback 2021-09-30 02:11:19 +05:30
Billy Laws
8db2cf29f2 Implement AsGpu::FreeSpace and clean up locking and debug prints 2021-09-30 02:11:19 +05:30
Billy Laws
d3dc0bddc4 Cleanup IStorageAccessor validation code 2021-09-30 02:11:19 +05:30
Billy Laws
39faa739b9 Optimise GPFIFO command processing for higher throughput
Using a u32 for the loop index prevents masking on all increments,
giving a moderate performance increase.

Passing methods as u32 parameters and stopping subChannel being passed
gives quite a significant increase when combined with the inlining
allowed by subchannel based engine selection.
2021-09-30 02:11:19 +05:30
Billy Laws
3d538a29da Misc code cleanup and more comments in AS map 2021-09-30 02:11:19 +05:30
Billy Laws
30d41252f7 Use IPC raw data size to calculate C Buffer offset
Some games don't have a u16 size array, the code for this is also kinda
pointless when we can use the raw data size too.
2021-09-30 02:11:19 +05:30
Billy Laws
d03b288db6 NEEDS CLEANUP: Reimplement GPU VMM and rewrite nvdrv VM impl 2021-09-30 02:11:19 +05:30
Billy Laws
020aa0e43a Add support for Ioctl2/3 and improve debug logging 2021-09-30 02:11:19 +05:30
Billy Laws
15db64671f Update CMakeLists for nvdrv rework 2021-09-30 02:11:19 +05:30
Billy Laws
9bda574a4e Move nvhost-ctrl-gpu to new device API 2021-09-30 02:11:19 +05:30
Billy Laws
39492d9365 Move nvhost-gpu to new device API
The implementation of GPU channels and Host1X channels will be split up
as it allows a much cleaner implementation and less undefined behaviour
potential.
2021-09-30 02:11:19 +05:30
Billy Laws
3d4f7d9b44 Move nvhost-as-gpu to new device API 2021-09-30 02:11:19 +05:30
Billy Laws
1149158198 Make GraphicBufferProducer use the new nvmap API 2021-09-30 02:11:19 +05:30
Billy Laws
c97f5a9315 Entirely rewrite nvmap to separate global and per device state.
This will be required later for NVDEC/SMMU support and fixes many
significant issues in the previous implementation.
Based off of my 2.0.0/12.0.0 nvdrv REs.
2021-09-30 02:11:19 +05:30
Billy Laws
78356fa789 Migrate syncpoint management over to the new device API
The syncpoint manager has beeen given convinience functions for fences
which remove the need to access the raw id/threshold most of the time
and various accuracy fixes and cleanups to match HOS 12.0.0 have also
been done.
2021-09-30 02:11:19 +05:30
Billy Laws
a19bf973b1 Rework the nvdrv core for accuracy and support new deserialisation
Devices will need to be moved over in order to support this new
interface, IOCTL2/3 support will be added in a later commit.
2021-09-30 02:11:19 +05:30
Billy Laws
db2abe2290 Use concepts for Backing::Read over enable_if 2021-09-30 02:11:19 +05:30
Billy Laws
3340c74332 Implement efficient template based IOCTL deserialisation
This moves IOCTLs from frozen to a template based parser, this allows
IOCTL lookup to be performed much more optimally and some IOCTLs to be
inlined.
2021-09-30 02:11:19 +05:30
Billy Laws
75a67dcfa5 Allow supplying a custom ResultValue result type and optimise span
This allows PosixResultValue to be created easily.
2021-09-30 02:11:19 +05:30