0
0
Fork 0
mirror of https://github.com/GreemDev/Ryujinx.git synced 2024-12-23 03:25:46 +00:00
Ryujinx/Ryujinx.Graphics.OpenGL
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
..
Helper Miria: The Death of OpenTK 3 (#2194) 2021-04-14 12:28:43 +02:00
Image GPU: Pass SpanOrArray for Texture SetData to avoid copy (#3745) 2022-10-08 12:04:47 -03:00
Queries Vulkan backend (#2518) 2022-07-31 18:26:06 -03:00
BackgroundContextWorker.cs Vulkan backend (#2518) 2022-07-31 18:26:06 -03:00
Buffer.cs Vulkan backend (#2518) 2022-07-31 18:26:06 -03:00
Constants.cs Fix transform feedback errors caused by host pause/resume and multiple uses (#1634) 2020-10-25 17:23:42 -03:00
Debugger.cs Rename DebugLevel Performance to Slowdowns (#1450) 2020-08-07 15:30:06 +02:00
DrawTextureEmulation.cs Implement DrawTexture functionality (#2747) 2021-11-10 15:37:49 -03:00
EnumConversion.cs Add alternative "GL" enum values for StencilOp (#3321) 2022-05-05 21:16:58 +02:00
FormatInfo.cs Add basic error logging to the GPU 2020-01-09 02:13:00 +01:00
FormatTable.cs Vulkan: Add ETC2 texture formats (#3576) 2022-08-16 15:42:42 +02:00
Framebuffer.cs OpenGL: Fix clears of unbound color targets (#3564) 2022-08-08 17:39:22 +00:00
Handle.cs Spanify Graphics Abstraction Layer (#1226) 2020-05-23 11:46:09 +02:00
HwCapabilities.cs Vulkan backend (#2518) 2022-07-31 18:26:06 -03:00
IOpenGLContext.cs Miria: The Death of OpenTK 3 (#2194) 2021-04-14 12:28:43 +02:00
OpenGLRenderer.cs OpenGL: Fix blit from non-multisample to multisample texture (#3596) 2022-09-19 16:12:56 -03:00
PersistentBuffers.cs Texture Sync, incompatible overlap handling, data flush improvements. (#2971) 2022-01-09 13:28:48 -03:00
Pipeline.cs OpenGL: Fix blit from non-multisample to multisample texture (#3596) 2022-09-19 16:12:56 -03:00
Program.cs New shader cache implementation (#3194) 2022-04-10 10:49:44 -03:00
ResourcePool.cs Texture/Buffer Memory Management Improvements (#1408) 2020-09-10 16:44:04 -03:00
Ryujinx.Graphics.OpenGL.csproj misc: Clean up of CS project after Avalonia merge (#3340) 2022-05-15 16:02:15 +02:00
Sync.cs Only flush commands when creating sync on Intel/AMD (windows) (#2165) 2021-04-03 11:10:37 +11:00
VertexArray.cs OpenGL: Limit vertex buffer range for non-indexed draws (#3542) 2022-08-11 20:21:56 -03:00
Window.cs Avalonia - Use embedded window for avalonia (#3674) 2022-09-19 15:05:26 -03:00