From 923089a29825cad8159a63616d14dcbd7161cb3c Mon Sep 17 00:00:00 2001 From: gdkchan Date: Thu, 25 Aug 2022 23:16:41 -0300 Subject: Fast path for Inline-to-Memory texture data transfers (#3610) * Fast path for Inline-to-Memory texture data transfers * Only do it for block linear textures to be on the safe side --- Ryujinx.Graphics.Gpu/Image/Texture.cs | 18 ++++++++++++++++++ Ryujinx.Graphics.Gpu/Image/TextureCache.cs | 10 ++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Image') diff --git a/Ryujinx.Graphics.Gpu/Image/Texture.cs b/Ryujinx.Graphics.Gpu/Image/Texture.cs index a598f212..320bc014 100644 --- a/Ryujinx.Graphics.Gpu/Image/Texture.cs +++ b/Ryujinx.Graphics.Gpu/Image/Texture.cs @@ -761,6 +761,24 @@ namespace Ryujinx.Graphics.Gpu.Image _hasData = true; } + /// + /// Uploads new texture data to the host GPU for a specific layer/level and 2D sub-region. + /// + /// New data + /// Target layer + /// Target level + /// Target sub-region of the texture to update + public void SetData(ReadOnlySpan data, int layer, int level, Rectangle region) + { + BlacklistScale(); + + HostTexture.SetData(data, layer, level, region); + + _currentData = null; + + _hasData = true; + } + /// /// Converts texture data to a format and layout that is supported by the host GPU. /// diff --git a/Ryujinx.Graphics.Gpu/Image/TextureCache.cs b/Ryujinx.Graphics.Gpu/Image/TextureCache.cs index dcac9f64..d76879eb 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureCache.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureCache.cs @@ -905,7 +905,8 @@ namespace Ryujinx.Graphics.Gpu.Image /// Number of pixels to be copied per line /// Number of lines to be copied /// True if the texture has a linear layout, false otherwise - /// If is false, should have the memory layout, otherwise ignored + /// If is false, the amount of GOB blocks in the Y axis + /// If is false, the amount of GOB blocks in the Z axis /// A matching texture, or null if there is no match public Texture FindTexture( MemoryManager memoryManager, @@ -916,7 +917,8 @@ namespace Ryujinx.Graphics.Gpu.Image int xCount, int yCount, bool linear, - MemoryLayout memoryLayout) + int gobBlocksInY, + int gobBlocksInZ) { ulong address = memoryManager.Translate(gpuVa); @@ -955,8 +957,8 @@ namespace Ryujinx.Graphics.Gpu.Image bool sizeMatch = xCount * bpp == texture.Info.Width * format.BytesPerPixel && height == texture.Info.Height; bool formatMatch = !texture.Info.IsLinear && - texture.Info.GobBlocksInY == memoryLayout.UnpackGobBlocksInY() && - texture.Info.GobBlocksInZ == memoryLayout.UnpackGobBlocksInZ(); + texture.Info.GobBlocksInY == gobBlocksInY && + texture.Info.GobBlocksInZ == gobBlocksInZ; match = sizeMatch && formatMatch; } -- cgit v1.2.3