aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Gpu/Image/FormatTable.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/FormatTable.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/FormatTable.cs')
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/FormatTable.cs30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/Image/FormatTable.cs b/src/Ryujinx.Graphics.Gpu/Image/FormatTable.cs
index 1b517e63..0af0725a 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/FormatTable.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/FormatTable.cs
@@ -651,9 +651,35 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <returns>True if the format is valid, false otherwise</returns>
public static bool TryGetTextureFormat(uint encoded, bool isSrgb, out FormatInfo format)
{
- encoded |= (isSrgb ? 1u << 19 : 0u);
+ bool isPacked = (encoded & 0x80000000u) != 0;
+ if (isPacked)
+ {
+ encoded &= ~0x80000000u;
+ }
- return _textureFormats.TryGetValue((TextureFormat)encoded, out format);
+ encoded |= isSrgb ? 1u << 19 : 0u;
+
+ bool found = _textureFormats.TryGetValue((TextureFormat)encoded, out format);
+
+ if (found && isPacked && !format.Format.IsDepthOrStencil())
+ {
+ // If the packed flag is set, then the components of the pixel are tightly packed into the
+ // GPU registers on the shader.
+ // We can get the same behaviour by aliasing the texture as a format with the same amount of
+ // bytes per pixel, but only a single or the lowest possible number of components.
+
+ format = format.BytesPerPixel switch
+ {
+ 1 => new FormatInfo(Format.R8Unorm, 1, 1, 1, 1),
+ 2 => new FormatInfo(Format.R16Unorm, 1, 1, 2, 1),
+ 4 => new FormatInfo(Format.R32Float, 1, 1, 4, 1),
+ 8 => new FormatInfo(Format.R32G32Float, 1, 1, 8, 2),
+ 16 => new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16, 4),
+ _ => format,
+ };
+ }
+
+ return found;
}
/// <summary>