aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2023-11-19 15:27:34 -0300
committerGitHub <noreply@github.com>2023-11-19 15:27:34 -0300
commit70d65d3d8e77e66226ebab7f23d9b6e8c271319f (patch)
treea6fe4d0638cd3ddc4d2d8b1cf2a8c44086968c82 /src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs
parent0b58f462668694db1a035e8be40d2a6d366635e1 (diff)
Enable copy dependency between RGBA8 and RGBA32 formats (#5943)1.1.1092
* Enable copy dependency between RGBA8 and RGBA32 formats * Take packed flag into account for texture formats * Account for widths not being a multiple of each other * Don't try to alias depth textures as color, fix log condition * PR feedback
Diffstat (limited to 'src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs')
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs
index 5af0471c0..eef38948d 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs
@@ -2,6 +2,8 @@ using Ryujinx.Common;
2using Ryujinx.Graphics.GAL; 2using Ryujinx.Graphics.GAL;
3using Ryujinx.Graphics.Texture; 3using Ryujinx.Graphics.Texture;
4using System; 4using System;
5using System.Diagnostics;
6using System.Numerics;
5 7
6namespace Ryujinx.Graphics.Gpu.Image 8namespace Ryujinx.Graphics.Gpu.Image
7{ 9{
@@ -339,7 +341,20 @@ namespace Ryujinx.Graphics.Gpu.Image
339 341
340 if (lhs.FormatInfo.BytesPerPixel != rhs.FormatInfo.BytesPerPixel && IsIncompatibleFormatAliasingAllowed(lhs.FormatInfo, rhs.FormatInfo)) 342 if (lhs.FormatInfo.BytesPerPixel != rhs.FormatInfo.BytesPerPixel && IsIncompatibleFormatAliasingAllowed(lhs.FormatInfo, rhs.FormatInfo))
341 { 343 {
342 alignedWidthMatches = lhsSize.Width * lhs.FormatInfo.BytesPerPixel == rhsSize.Width * rhs.FormatInfo.BytesPerPixel; 344 // If the formats are incompatible, but the texture strides match,
345 // we might allow them to be copy compatible depending on the format.
346 // The strides are aligned because the format with higher bytes per pixel
347 // might need a bit of padding at the end due to one width not being a multiple of the other.
348
349 Debug.Assert((1 << BitOperations.Log2((uint)lhs.FormatInfo.BytesPerPixel)) == lhs.FormatInfo.BytesPerPixel);
350 Debug.Assert((1 << BitOperations.Log2((uint)rhs.FormatInfo.BytesPerPixel)) == rhs.FormatInfo.BytesPerPixel);
351
352 int alignment = Math.Max(lhs.FormatInfo.BytesPerPixel, rhs.FormatInfo.BytesPerPixel);
353
354 int lhsStride = BitUtils.AlignUp(lhsSize.Width * lhs.FormatInfo.BytesPerPixel, alignment);
355 int rhsStride = BitUtils.AlignUp(rhsSize.Width * rhs.FormatInfo.BytesPerPixel, alignment);
356
357 alignedWidthMatches = lhsStride == rhsStride;
343 } 358 }
344 359
345 TextureViewCompatibility result = TextureViewCompatibility.Full; 360 TextureViewCompatibility result = TextureViewCompatibility.Full;
@@ -718,7 +733,8 @@ namespace Ryujinx.Graphics.Gpu.Image
718 (lhsFormat, rhsFormat) = (rhsFormat, lhsFormat); 733 (lhsFormat, rhsFormat) = (rhsFormat, lhsFormat);
719 } 734 }
720 735
721 return lhsFormat.Format == Format.R8Unorm && rhsFormat.Format == Format.R8G8B8A8Unorm; 736 return (lhsFormat.Format == Format.R8G8B8A8Unorm && rhsFormat.Format == Format.R32G32B32A32Float) ||
737 (lhsFormat.Format == Format.R8Unorm && rhsFormat.Format == Format.R8G8B8A8Unorm);
722 } 738 }
723 739
724 /// <summary> 740 /// <summary>