1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-30 00:36:01 +00:00
Ryujinx/Ryujinx.Graphics.Gpu/Image
riperiperi bf77d1cab9
GPU: Pass SpanOrArray for Texture SetData to avoid copy (#3745)
* GPU: Pass SpanOrArray for Texture SetData to avoid copy

Texture data is often converted before upload, meaning that an array was allocated to perform the conversion into. However, the backend SetData methods were being passed a Span of that data, and the Multithreaded layer does `ToArray()` on it so that it can be stored for later! This method can't extract the original array, so it creates a copy.

This PR changes the type passed for textures to a new ref struct called SpanOrArray, which is backed by either a ReadOnlySpan or an array. The benefit here is that we can have a ToArray method that doesn't copy if it is originally backed by an array.

This will also avoid a copy when running the ASTC decoder.

On NieR this was taking 38% of texture upload time, which it does a _lot_ of when you move between areas, so there should be a 1.6x performance boost when strictly uploading textures. No doubt this will also improve texture streaming performance in UE4 games, and maybe a small reduction with video playback.

From the numbers, it's probably possible to improve the upload rate by a further 1.6x by performing layout conversion on GPU. I'm not sure if we could improve it further than that - multithreading conversion on CPU would probably result in memory bottleneck.

This doesn't extend to buffers, since we don't convert their data on the GPU emulator side.

* Remove implicit cast to array.
2022-10-08 12:04:47 -03:00
..
AutoDeleteCache.cs Removed unused usings. (#3593) 2022-08-18 18:04:54 +02:00
FormatInfo.cs Allow swizzles to match with "undefined" components (#1538) 2020-09-11 09:48:48 +10:00
FormatTable.cs Replace image format magic numbers with enums (#3631) 2022-08-28 01:56:26 +00:00
ITextureDescriptor.cs shader cache: Fix invalid virtual address clean up (#1717) 2020-11-17 22:20:17 +01:00
Pool.cs Ensure texture ID is valid before getting texture descriptor (#3406) 2022-06-24 02:41:57 +02:00
PoolCache.cs Add a sampler pool cache and improve texture pool cache (#3487) 2022-07-27 21:07:48 -03:00
ReductionFilter.cs Address PR feedback 2020-01-09 02:13:00 +01:00
Sampler.cs Optimize Texture Binding and Shader Specialization Checks (#3399) 2022-06-17 13:09:14 -03:00
SamplerDescriptor.cs Use a descriptor cache for faster pool invalidation. (#1977) 2021-01-29 14:19:06 +11:00
SamplerMinFilter.cs Add XML documentation to Ryujinx.Graphics.Gpu.Image 2020-01-09 02:13:00 +01:00
SamplerMipFilter.cs Add XML documentation to Ryujinx.Graphics.Gpu.Image 2020-01-09 02:13:00 +01:00
SamplerPool.cs Add a sampler pool cache and improve texture pool cache (#3487) 2022-07-27 21:07:48 -03:00
SamplerPoolCache.cs Add a sampler pool cache and improve texture pool cache (#3487) 2022-07-27 21:07:48 -03:00
Texture.cs GPU: Pass SpanOrArray for Texture SetData to avoid copy (#3745) 2022-10-08 12:04:47 -03:00
TextureBindingInfo.cs Simplify logic for bindless texture handling (#1667) 2020-11-09 19:35:04 -03:00
TextureBindingsManager.cs Allow bindless textures with handles from unbound constant buffer (#3706) 2022-09-19 15:35:47 -03:00
TextureCache.cs Fast path for Inline-to-Memory texture data transfers (#3610) 2022-08-26 02:16:41 +00:00
TextureCompatibility.cs Vulkan backend (#2518) 2022-07-31 18:26:06 -03:00
TextureComponent.cs Add XML documentation to Ryujinx.Graphics.Gpu.Image 2020-01-09 02:13:00 +01:00
TextureDependency.cs Texture Cache: "Texture Groups" and "Texture Dependencies" (#2001) 2021-03-02 19:30:54 -03:00
TextureDescriptor.cs Vulkan backend (#2518) 2022-07-31 18:26:06 -03:00
TextureDescriptorType.cs Add XML documentation to Ryujinx.Graphics.Gpu.Image 2020-01-09 02:13:00 +01:00
TextureGroup.cs GPU: Pass SpanOrArray for Texture SetData to avoid copy (#3745) 2022-10-08 12:04:47 -03:00
TextureGroupHandle.cs Fix various issues with texture sync (#3302) 2022-04-29 18:34:11 -03:00
TextureInfo.cs Texture Cache: "Texture Groups" and "Texture Dependencies" (#2001) 2021-03-02 19:30:54 -03:00
TextureManager.cs Add a sampler pool cache and improve texture pool cache (#3487) 2022-07-27 21:07:48 -03:00
TextureMatchQuality.cs Prefer truly perfect texture matches over fomat aliased ones (#1754) 2020-11-27 19:46:23 +01:00
TextureMsaaMode.cs Add XML documentation to Ryujinx.Graphics.Gpu.Image 2020-01-09 02:13:00 +01:00
TexturePool.cs Add a sampler pool cache and improve texture pool cache (#3487) 2022-07-27 21:07:48 -03:00
TexturePoolCache.cs Add a sampler pool cache and improve texture pool cache (#3487) 2022-07-27 21:07:48 -03:00
TextureScaleMode.cs Use "Undesired" scale mode for certain textures rather than blacklisting (#2537) 2021-08-11 22:44:51 +02:00
TextureSearchFlags.cs Perform unscaled 2d engine copy on CPU if source texture isn't in cache. (#3112) 2022-02-22 11:21:29 -03:00
TextureTarget.cs Fix TXQ for 3D textures. (#2613) 2021-09-02 00:17:43 -03:00
TextureViewCompatibility.cs Texture Sync, incompatible overlap handling, data flush improvements. (#2971) 2022-01-09 13:28:48 -03:00