diff options
author | gdkchan <gab.dark.100@gmail.com> | 2022-12-21 20:39:58 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-21 20:39:58 -0300 |
commit | f906eb06c28880c20160cb4a969e3f6fddb3029b (patch) | |
tree | 50b716246caeda439272b3d929bbeab1bfcf87c7 /Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs | |
parent | 219f63ff4ebb739f349ca3ddd6c11e5068bcf0f1 (diff) |
Implement a software ETC2 texture decoder (#4121)1.1.488
* Implement a software ETC2 texture decoder
* Fix output size calculation for non-2D textures
* Address PR feedback
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs')
-rw-r--r-- | Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs b/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs index 91a1a728..642e03b6 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs @@ -67,6 +67,10 @@ namespace Ryujinx.Graphics.Gpu.Image /// <returns>A host compatible format</returns> public static FormatInfo ToHostCompatibleFormat(TextureInfo info, Capabilities caps) { + // The host API does not support those compressed formats. + // We assume software decompression will be done for those textures, + // and so we adjust the format here to match the decompressor output. + if (!caps.SupportsAstcCompression) { if (info.FormatInfo.Format.IsAstcUnorm()) @@ -83,16 +87,8 @@ namespace Ryujinx.Graphics.Gpu.Image } } - if (!caps.SupportsR4G4Format && info.FormatInfo.Format == Format.R4G4Unorm) - { - return new FormatInfo(Format.R4G4B4A4Unorm, 1, 1, 2, 4); - } - if (!HostSupportsBcFormat(info.FormatInfo.Format, info.Target, caps)) { - // The host API does not this compressed format. - // We assume software decompression will be done for those textures, - // and so we adjust the format here to match the decompressor output. switch (info.FormatInfo.Format) { case Format.Bc1RgbaSrgb: @@ -119,6 +115,26 @@ namespace Ryujinx.Graphics.Gpu.Image } } + if (!caps.SupportsEtc2Compression) + { + switch (info.FormatInfo.Format) + { + case Format.Etc2RgbaSrgb: + case Format.Etc2RgbPtaSrgb: + case Format.Etc2RgbSrgb: + return new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4, 4); + case Format.Etc2RgbaUnorm: + case Format.Etc2RgbPtaUnorm: + case Format.Etc2RgbUnorm: + return new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4); + } + } + + if (!caps.SupportsR4G4Format && info.FormatInfo.Format == Format.R4G4Unorm) + { + return new FormatInfo(Format.R4G4B4A4Unorm, 1, 1, 2, 4); + } + return info.FormatInfo; } |