From 4d1579acbf60ff23f14b591db762267f93092d0c Mon Sep 17 00:00:00 2001 From: gdkchan Date: Wed, 3 May 2023 21:20:12 -0300 Subject: Fix some invalid blits involving depth textures (#4723) --- src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/Ryujinx.Graphics.Gpu/Engine') diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs index 4ce53e78..2ac84ab5 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs @@ -300,11 +300,16 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod IsCopyRegionComplete(srcCopyTexture, srcCopyTextureFormat, srcX1, srcY1, srcX2, srcY2) && IsCopyRegionComplete(dstCopyTexture, dstCopyTextureFormat, dstX1, dstY1, dstX2, dstY2); + // We can only allow aliasing of color formats as depth if the source and destination textures + // are the same, as we can't blit between different depth formats. + bool srcDepthAlias = srcCopyTexture.Format == dstCopyTexture.Format; + var srcTexture = memoryManager.Physical.TextureCache.FindOrCreateTexture( memoryManager, srcCopyTexture, offset, srcCopyTextureFormat, + srcDepthAlias, !canDirectCopy, false, srcHint); @@ -325,6 +330,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod // When the source texture that was found has a depth format, // we must enforce the target texture also has a depth format, // as copies between depth and color formats are not allowed. + // For depth blit, the destination texture format should always match exactly. if (srcTexture.Format.IsDepthOrStencil()) { @@ -340,7 +346,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod dstCopyTexture, 0, dstCopyTextureFormat, - true, + depthAlias: false, + shouldCreate: true, srcTexture.ScaleMode == TextureScaleMode.Scaled, dstHint); -- cgit v1.2.3