aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Image
diff options
context:
space:
mode:
authorriperiperi <rhy3756547@hotmail.com>2021-03-19 01:17:38 +0000
committerGitHub <noreply@github.com>2021-03-19 02:17:38 +0100
commit9b7335a63bd921d38866090e8c53f35b8e050939 (patch)
treebfb6aa5d5e1cef0b1cf02f5683bb5cbdd923c1ca /Ryujinx.Graphics.Gpu/Image
parent39899c04076a8e9004b173320ffbb6dbf45ff3e4 (diff)
Improve linear texture compatibility rules (#2099)
* Improve linear texture compatibility rules Fixes an issue where small or width-aligned (rather than byte aligned) textures would fail to create a view of existing data. Creates a copy dependency as size change may be risky. * Minor cleanup * Remove Size Change for Copy Depenedencies The copy to the target (potentially different sized) texture can properly deal with cropping by itself. * Move StrideAlignment and GobAlignment into Constants
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Image')
-rw-r--r--Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs20
-rw-r--r--Ryujinx.Graphics.Gpu/Image/TextureGroup.cs3
-rw-r--r--Ryujinx.Graphics.Gpu/Image/TextureManager.cs4
3 files changed, 17 insertions, 10 deletions
diff --git a/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs b/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs
index d613612f..3140f4a1 100644
--- a/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs
+++ b/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs
@@ -231,8 +231,21 @@ namespace Ryujinx.Graphics.Gpu.Image
result = TextureViewCompatibility.CopyOnly;
}
- return (size.Width == otherSize.Width &&
- size.Height == otherSize.Height) ? result : TextureViewCompatibility.Incompatible;
+ if (size.Width == otherSize.Width && size.Height == otherSize.Height)
+ {
+ return result;
+ }
+ else if (lhs.IsLinear && rhs.IsLinear)
+ {
+ // Copy between linear textures with matching stride.
+ int stride = BitUtils.AlignUp(Math.Max(1, lhs.Stride >> level), Constants.StrideAlignment);
+
+ return stride == rhs.Stride ? TextureViewCompatibility.CopyOnly : TextureViewCompatibility.Incompatible;
+ }
+ else
+ {
+ return TextureViewCompatibility.Incompatible;
+ }
}
/// <summary>
@@ -372,8 +385,7 @@ namespace Ryujinx.Graphics.Gpu.Image
// For block linear textures, the stride is ignored.
if (rhs.IsLinear)
{
- int width = Math.Max(1, lhs.Width >> level);
- int stride = width * lhs.FormatInfo.BytesPerPixel;
+ int stride = Math.Max(1, lhs.Stride >> level);
stride = BitUtils.AlignUp(stride, 32);
return stride == rhs.Stride;
diff --git a/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs b/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs
index 39567a82..52129d64 100644
--- a/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs
+++ b/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs
@@ -16,9 +16,6 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </summary>
class TextureGroup : IDisposable
{
- private const int StrideAlignment = 32;
- private const int GobAlignment = 64;
-
private delegate void HandlesCallbackDelegate(int baseHandle, int regionCount, bool split = false);
/// <summary>
diff --git a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs
index 07bc7c7e..2b756e4c 100644
--- a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs
+++ b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs
@@ -429,7 +429,7 @@ namespace Ryujinx.Graphics.Gpu.Image
// Discount square textures that aren't depth-stencil like. (excludes game textures, cubemap faces, most 3D texture LUT, texture atlas)
// Detect if the texture is possibly square. Widths may be aligned, so to remove the uncertainty we align both the width and height.
- int widthAlignment = (info.IsLinear ? 32 : 64) / info.FormatInfo.BytesPerPixel;
+ int widthAlignment = (info.IsLinear ? Constants.StrideAlignment : Constants.GobAlignment) / info.FormatInfo.BytesPerPixel;
bool possiblySquare = BitUtils.AlignUp(info.Width, widthAlignment) == BitUtils.AlignUp(info.Height, widthAlignment);
@@ -977,8 +977,6 @@ namespace Ryujinx.Graphics.Gpu.Image
{
// Copy only compatibility, or target texture is already a view.
- ChangeSizeIfNeeded(overlapInfo, overlap, false, sizeHint); // Force a size match for copy
-
overlap.SynchronizeMemory();
texture.CreateCopyDependency(overlap, oInfo.FirstLayer, oInfo.FirstLevel, false);
}