Commit Graph

1312 Commits

Author SHA1 Message Date
PixelyIon
2712b3276b Fix incorrect VkBufferImageCopy offset calculations
The `VkBufferImageCopy` offset calculations were wrong inside `CopyIntoStagingBuffer` as it multiplied the mip level's linear size by `levelCount` rather than `layerCount`. This led to substantial UB in games which called this function as it led to an overflow and resulted in writing to other areas of the buffer which caused major issues such as vertex/index buffer corruption and corresponding graphical glitches alongside likely being the cause of some crashes.
2022-06-02 22:14:22 +05:30
PixelyIon
06901ef22a Fix BC7 output swizzling from BGRA to RGBA
BC7 CPU decoding had the red and blue channels swapped around as it outputted a BGRA image after decoding while we expected an RGBA image to be produced. This should fix the colors of certain textures in titles such as Cuphead or Sonic Forces.
2022-06-02 19:48:55 +05:30
Billy Laws
9cb68c31e1 Stub nfp IUser::AttachAvailabilityChangeEvent 2022-06-02 00:04:01 +01:00
Billy Laws
33c9731eca Implement IFileSystem::CreateDirectory 2022-06-02 00:04:01 +01:00
Billy Laws
a09414424b Fix broken VFS directory creation 2022-06-02 00:04:01 +01:00
Billy Laws
3518e04a18 Correct Directory EntryType to be u8 rather than u32 2022-06-02 00:04:01 +01:00
Billy Laws
0c11d9e294 Implement IDirectory::GetEntryCount 2022-06-02 00:04:01 +01:00
MCredstoner2004
c15b3a8d40
Make Applet accesses to the data queues lock
Avoids potential races when the guest access the same applet from more than one thread.
2022-06-02 03:47:38 +05:30
Billy Laws
91b2c47991 Fix potential nvdrv submission race
The syncpoint maximum value represents the maximum possible syncpt value at a given time, however due to PBs being submitted before max was incremented, for a brief moment of time this is not the case which could lead to crashes or other such behaviour if a game waits on the fence at the right moment.
2022-06-01 17:15:25 +01:00
PixelyIon
37453ed7fa Use DocumentsProvider for log sharing
We used a `FileProvider` for log sharing prior, this is no longer necessary since it comes under the `DocumentsProvider` now which can be utilized to share the log document directly.
2022-06-01 21:41:14 +05:30
PixelyIon
8efa9298f9 Fix name conflict resolution for copyDocument
Any documents with the same name existing in a directory that is copied to would cause an exception due to existing already, this fixes that by handling conflict resolution in those cases and automatically determining a file name that would avoid a conflict.
2022-06-01 21:41:14 +05:30
Billy Laws
c4bd9c47e4 Stub NVGPU_GPU_IOCTL_ZBC_SET_TABLE nvdrv ioctl
This was missed in the original implementation and caused crashes in some games.
2022-06-01 16:59:14 +01:00
Billy Laws
c639fdcf06 Fixup NFP service stub state handling
Previously a broken state value was returned from GetState that caused crashes in games using newer SDKs and NFP, correctly handle state now by updating it after initialisation.
2022-06-01 15:00:26 +01:00
Billy Laws
c745e0e02b Move image type logic to GuestTexture, allowing 2D array views for 3D RTs
We can't render to a 3D texture through a 3D view, we instead have to create a 2D array view into it and render to that. The texture manager previously didn't support having a different view type/layer count between a guest texture view and the underlying storage texture that is required to support this so that was also implemented by reading the view layer count from the dimensions depth instead if the underlying texture is 3D (and the view type is 2D array). Additionally move away from our own view type enum to Vulkan, inline with other guest texture member types.
2022-05-31 22:09:53 +01:00
Billy Laws
22695c4feb Stub nim services used for eShop communication
We obviously don't need to implement these so add a simple set of stubs to satify games using them (mainly demos such as DQXII)
2022-05-31 22:07:01 +01:00
Billy Laws
ff12dc9c10 Add R32_SFLOAT to adreno validation layer format filtering 2022-05-31 22:03:53 +01:00
Billy Laws
6cc925c2d3 Reset RT mappings on dimension and format changes 2022-05-31 17:49:16 +01:00
Billy Laws
8180bf852e Lock textures before attaching in BlitContext 2022-05-31 16:54:13 +01:00
Billy Laws
cb2b36e3ab Allow providing a callback that's called after every CPU access in GMMU
Required for the planned implementation of GPU side memory trapping.
2022-05-31 16:04:27 +01:00
Billy Laws
46ee18c3e3 Require depthBiasClamp Vulkan device feature
Used in some UE4 games and supported by 95% of devices so skip implementing a fallback path.
2022-05-31 14:46:45 +01:00
PixelyIon
e592b11039 Drop samplerAnisotropy as a required GPU feature
Sampler anisotropy was made a required feature in an earlier commit due to its widespread availability but this was determined to be incorrect as certain Mali GPUs that can otherwise run 2D games in Skyline do not have this feature, while they are still not officially supported as this was the only roadblock to support them, it has now been made an optional feature.
2022-05-31 01:37:40 +05:30
PixelyIon
4336134b07 Reintroduce android:hasFragileUserData due to stable signature
`android:hasFragileUserData` was added in an earlier commit but then removed due to it not functioning because of signature checks. Now that signatures are consistent across builds, it has been readded and should now allow carrying data across CI and developer builds.
2022-05-31 01:37:07 +05:30
PixelyIon
da79e2c8e3 Add Robust CI Cache Restoration
The `restore-keys` parameter of `actions/cache@v3` is now utilized to add robust fallbacks for missing cache keys, it should automatically fall back to an older but still valid cache rather than entirely miss now.
2022-05-31 01:25:18 +05:30
PixelyIon
40a7433e97 Extend CI Gradle caching and performance parameters
A lot of default Gradle parameters are unoptimal for the best performance, this enables the configuration and build cache alongside parallel building.
2022-05-31 01:25:18 +05:30
PixelyIon
4a6978a3bb Extend CI C++ build cache
The CI didn't cache the C++ build related directories under `app/build/` which caused a full recompilation of C++ code, this takes a significant amount of time.
2022-05-31 01:25:18 +05:30
PixelyIon
3da67d79a1 Remove Android Linting + R8 Mapping from CI
These steps were determined to be useless in practice as no one checked the lint report for any issues and R8 mappings were never utilized.
2022-05-31 01:25:18 +05:30
PixelyIon
c516819e6e Make CI APK name more verbose
Adds the CI run number to the APK name, they were `app-(debug/release).apk` but are now `skyline-${CI run number}-(debug/release).apk`. This makes it significantly easier to identify what version a specific build is, this alongside signing consolidates Skyline builds.
2022-05-31 01:25:18 +05:30
PixelyIon
b91ce939a2 Introduce CI build signing
We've done no signing of any Skyline APKs to date which causes issues regarding authenticity of any APKs as they could be entirely unofficial builds which have not been vetted by the team. Additionally, the different keys remove the ability to reinstall a different build successively as Android checks for matching signatures before installing an APK.
2022-05-31 01:25:18 +05:30
PixelyIon
e1cc8676cf Add option to view internal directory
With the Skyline document provider, easy access to the internal directory is required which may be hard to navigate to through the system file manager. This adds an option in settings to directly open up the directory in the system file manager.
2022-05-31 01:25:18 +05:30
PixelyIon
ba97985b55 Revise DocumentsProvider URI structure
The URIs (Document ID + Root) of the Skyline `DocumentsProvider` was unoptimal as it wasn't relative to a base directory. This is required for opening a root without knowledge of the full path in advance, it is therefore cleaner to provide a uniform `ROOT_ID` in a companion class.
2022-05-31 01:25:18 +05:30
Mylah Dee
ee7da31fc6 Add DocumentProvider for accessing internal files
On Android 12 and above, files from an application's external storage directory cannot be accessed by the user. The only proper SAF-compliant way to solve this is to create a `DocumentProvider` which proxies access to internal storage accordingly.
2022-05-30 15:09:30 +05:30
Narr the Reg
7aa6a5c4ca
Add HID touch attribute and index reporting
Adds missing parameter TouchAttribute and emulates correctly the touch point index. Both changes are necessary on Voez to keep track of each finger.
2022-05-29 10:28:51 +01:00
PixelyIon
80c8fb8791 Implement CPU BCn Texture Decoding
Certain GPU vendors such as ARM's Mali do not have support for BCn textures whatsoever while other vendors such as AMD only have partial support (BC1-BC3). Most titles on the guest utilize BC textures and to address this on host GPUs without support for BCn, we need to decompress the texture on the CPU. This commit implements a CPU BCn texture decoder based off Swiftshader's BC decoder, it also adds the necessary infrastructure to have different formats for the `GuestTexture` and `Texture` objects.
2022-05-28 21:22:24 +05:30
PixelyIon
fe615b1e03 Clarify texture swizzling inner-loop iteration count
The iterations of the inner loop for sector deswizzling was miscalculated as `SectorWidth * SectorHeight` while the result was correct at `32`, it should be determined by the amount of sector lines within a GOB i.e.: `(GobWidth / SectorWidth) * GobHeight`.
2022-05-28 21:22:24 +05:30
PixelyIon
7d4e0a7844 Implement Mipmapped Texture Support
Support for mipmapped textures was not implemented which is fairly crucial to proper rendering of games as the only level that would load is the first level (highest resolution), that might result in a lot more memory bandwidth being utilized. Mipmapping also has associated benefits regarding aliasing as it has a minor anti-aliasing effect on distant textures. 

This commit entirely implements mipmapping support but it does not extend to full support for views into specific mipmap levels due to the texture manager implemention being incomplete.
2022-05-28 21:22:24 +05:30
PixelyIon
da7e6a7df7 Replace Maxwell DMA GuestTexture usage with new swizzling API
Maxwell DMA requires swizzled copies to/from textures and earlier it had to construct an arbitrary `GuestTexture` to do so but with the introduction of the cleaner API, this has become redundant which this commit cleans up and replaces with direct calls to the API with all the necessary values.
2022-05-28 21:22:24 +05:30
PixelyIon
de300bfdbe Refactor Texture Swizzling
The API for texture swizzling is now more concrete and abstracted out from `GuestTexture`, this allows for neater usage in certain areas such as MaxwellDMA while having a `GuestTexture` wrapper as well allowing for neater usage in those cases. 

The code itself has also been cleaned up slightly with all usage of `u32`s being upgraded to `size_t` as this is simply more efficient due to the compiler not needing to emulate wraparound behavior for integer types smaller than the processor word size.
2022-05-19 17:13:55 +05:30
Billy Laws
72473369b6 Account for OOB copyOffsets in CircularBuffer::Read
Caused crashes in Pokemon
2022-05-14 15:30:59 +01:00
Robin Kertels
0a3cf25823 Implement the Fermi 2D blitting engine
The Fermi 2D engine implements both image blit and resolve operations, supporting subpixel sampling with both linear and point filtering.

Resolve operations are performed by sampling from the center of each pixel in order to resolve the final image from the MSAA samples
MSAA images are stored in memory like regular images but each pixels dimensions are scaled: e.g for 2x2 MSAA
```
112233
112233
445566
445566
```
These would be sampled with both duDx and duDy as 2 (integer part), resolving to the following:
```
123
456
```
Blit operations are performed by sampling from the corner of each pixel, scaling the image as one would expect.

This implementation isn't fully complete as Vulkan blit doesn't support some combinations which Fermi does, most notably between colour and depth stencil. These will be implemented properly at a later date, likely after the texture manager rework.
Out of Bounds Blit, used by some OpenGL games is also missing since supporting it requires texture aliasing, this will also be supported after the texture manager rework.

Co-authored-by: Billy Laws <blaws05@gmail.com>
2022-05-13 22:37:37 +01:00
Billy Laws
be2546138d Move IOVA class to GMMU so it can be used for other engines 2022-05-13 22:37:37 +01:00
Billy Laws
3ad640fcbc Fix accidental graphics context member/parameter duplication 2022-05-13 22:37:37 +01:00
PixelyIon
7a6f27a19a Fix texture swizzling OOB writes
Certain writes during swizzling went out of bounds due to incorrect `blockExtentY` calculation, the previous commit to fix this ended up breaking it further. This commit returns to the original commit's calculations with the proper addendum of a check for exact alignment with a GOB which is the case that was broken earlier.
2022-05-13 14:52:41 +05:30
PixelyIon
168e51e7ad Always use GetLayerStride for layer stride in Texture
The `GuestTexture::GetLayerStride` function was not always being utilized to retrieve the layer stride inside `Texture`, it would instead directly access the `guestTexture::layerStride` member. This is problematic as it may not be initialized and return `0` which would lead to a broken image copy.
2022-05-13 14:21:37 +05:30
Billy Laws
b81d5bc865 Implement and cleanup semaphore operations in all engines
Most engines have the capability to release a semaphore payload (or reduce in the case of GPFIFO) when a method is called or action is complete. Semaphores are used by games for both timing how long things take on GPU and waiting on resources so missing them can cause deadlocks or other related issues.
2022-05-12 19:40:24 +01:00
Billy Laws
bca88685bd Stub nvdrv {Get,Dump}Status 2022-05-12 17:38:22 +01:00
Billy Laws
97e740c986 Fix slight locking bug with nvmap handle duplication 2022-05-12 17:38:22 +01:00
Billy Laws
57378457dc Treat symbol file paths without slashes as filenames
Prevents crashes printing backtrace if this occurs
2022-05-12 17:38:22 +01:00
Billy Laws
d08ac63bbf Use TIC maximum index over TSC when tscIndexLinked is set 2022-05-12 17:38:22 +01:00
Billy Laws
8e021a9f1f Load custom drivers from app private data dir
Required since /sdcard doesn't have exec perm support
2022-05-12 17:38:21 +01:00
Billy Laws
dcef597345 Introduce TrivialObject concept and use where appropriate
Simplifies type checking and handles excluding container types that are trivially copyable but contain pointers
2022-05-12 17:38:21 +01:00