diff --git a/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs b/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs index b1f766b83..133b30750 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs @@ -216,13 +216,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma { var target = memoryManager.Physical.TextureCache.FindTexture( memoryManager, - dst, dstGpuVa, dstBpp, dstStride, + dst.Height, xCount, yCount, - dstLinear); + dstLinear, + dst.MemoryLayout); if (target != null) { diff --git a/Ryujinx.Graphics.Gpu/Image/TextureCache.cs b/Ryujinx.Graphics.Gpu/Image/TextureCache.cs index ef29fe96d..dfa44afec 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureCache.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureCache.cs @@ -900,23 +900,25 @@ namespace Ryujinx.Graphics.Gpu.Image /// Tries to find an existing texture matching the given buffer copy destination. If none is found, returns null. /// /// GPU memory manager where the texture is mapped - /// The texture information /// GPU virtual address of the texture /// Bytes per pixel /// If is true, should have the texture stride, otherwise ignored + /// If is false, should have the texture height, otherwise ignored /// 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 /// A matching texture, or null if there is no match public Texture FindTexture( MemoryManager memoryManager, - DmaTexture tex, ulong gpuVa, int bpp, int stride, + int height, int xCount, int yCount, - bool linear) + bool linear, + MemoryLayout memoryLayout) { ulong address = memoryManager.Translate(gpuVa); @@ -945,7 +947,7 @@ namespace Ryujinx.Graphics.Gpu.Image { // Size is not available for linear textures. Use the stride and end of the copy region instead. - match = texture.Info.IsLinear && texture.Info.Stride == stride && tex.RegionY + yCount <= texture.Info.Height; + match = texture.Info.IsLinear && texture.Info.Stride == stride && yCount == texture.Info.Height; } else { @@ -953,10 +955,10 @@ namespace Ryujinx.Graphics.Gpu.Image // Due to the way linear strided and block layouts work, widths can be multiplied by Bpp for comparison. // Note: tex.Width is the aligned texture size. Prefer param.XCount, as the destination should be a texture with that exact size. - bool sizeMatch = xCount * bpp == texture.Info.Width * format.BytesPerPixel && tex.Height == texture.Info.Height; + bool sizeMatch = xCount * bpp == texture.Info.Width * format.BytesPerPixel && height == texture.Info.Height; bool formatMatch = !texture.Info.IsLinear && - texture.Info.GobBlocksInY == tex.MemoryLayout.UnpackGobBlocksInY() && - texture.Info.GobBlocksInZ == tex.MemoryLayout.UnpackGobBlocksInZ(); + texture.Info.GobBlocksInY == memoryLayout.UnpackGobBlocksInY() && + texture.Info.GobBlocksInZ == memoryLayout.UnpackGobBlocksInZ(); match = sizeMatch && formatMatch; }