Commit Graph

858 Commits

Author SHA1 Message Date
Billy Laws
a476bbaf4d Add 11_11_10 vertex buffer format 2022-06-04 17:41:10 +01:00
Billy Laws
71c37dd6c4 Add D24X8Unorm depth RT format support 2022-06-04 17:40:49 +01:00
Billy Laws
d3af629b83 Support R32G32B32A32 int RT formats 2022-06-04 17:38:57 +01:00
Billy Laws
0f5f04ade3 Set default surfaceflinger parameters based off of preallocated buffers
Required by resident evil 4 as otherwise Dequeue would fail due to it using BGRA buffers but the default being RGBA.
2022-06-04 16:55:08 +01:00
Billy Laws
106ad597db Support BGRA8888 surfaceflinger format
A swizzle is applied to R8G8B8A8 to transform it to BGRA since BGRA isn't a commonly supported swapchain format on Android.
2022-06-04 16:49:26 +01:00
Billy Laws
2bbeb6b08f Fix OsFileSystem initial directory creation
By passing basePath as an argument the CreateDirectory function did mkdir(basePath+basePath) which is obviously not the intended behaviour, fix this.
2022-06-03 19:33:31 +01:00
Billy Laws
84dec7561c Dont cache rendertarget mappings
Some games remap rendertargets or map them late which would lead to weird graphical bugs or crashes. Drop the caching since VMM lookup is fairly cheap anyway.
2022-06-03 19:31:52 +01:00
Billy Laws
581a016991 Add GuestTexture::GetSize helper function
This code was getting duplicated a bit so commonise into a helper function.
2022-06-03 19:30:54 +01:00
Billy Laws
31d418ad54 Fix 3D semaphore counter type 0 handling
Counter type 0 actually releases the semaphore payload rather than a constant zero as was previously thought. This is required by Skyrim.
2022-06-02 22:03:19 +01:00
Billy Laws
0202bf5531 Add semaphore release debug logs 2022-06-02 22:02:59 +01:00
Billy Laws
3736d36b75 Fix KPrivateMemory remap permissions 2022-06-02 18:10:35 +01:00
Billy Laws
389ab0fb50 Add {Map,Unmap}Physical memory debug logs 2022-06-02 18:10:10 +01:00
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
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
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