From 42c75dbb8f9472f434d0324a37a87e91ee7b50f3 Mon Sep 17 00:00:00 2001 From: gdkchan <gab.dark.100@gmail.com> Date: Sat, 22 Jan 2022 15:23:00 -0300 Subject: Add support for BC1/2/3 decompression (for 3D textures) (#2987) * Add support for BC1/2/3 decompression (for 3D textures) * Optimize and clean up * Unsafe not needed here * Fix alpha value interpolation when a0 <= a1 --- Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs') diff --git a/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs b/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs index 0461a81f..188e1e09 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs @@ -14,9 +14,6 @@ namespace Ryujinx.Graphics.Gpu.Image private enum FormatClass { Unclassified, - BCn64, - BCn128, - Bc1Rgb, Bc1Rgba, Bc2, Bc3, @@ -88,13 +85,21 @@ namespace Ryujinx.Graphics.Gpu.Image return new FormatInfo(Format.R4G4B4A4Unorm, 1, 1, 2, 4); } - if (info.Target == Target.Texture3D) + if (!caps.Supports3DTextureCompression && info.Target == Target.Texture3D) { - // The host API does not support 3D BC4/BC5 compressed formats. + // The host API does not support 3D compressed formats. // 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: + case Format.Bc2Srgb: + case Format.Bc3Srgb: + return new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4, 4); + case Format.Bc1RgbaUnorm: + case Format.Bc2Unorm: + case Format.Bc3Unorm: + return new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4); case Format.Bc4Unorm: return new FormatInfo(Format.R8Unorm, 1, 1, 1, 1); case Format.Bc4Snorm: @@ -749,9 +754,6 @@ namespace Ryujinx.Graphics.Gpu.Image { switch (format) { - case Format.Bc1RgbSrgb: - case Format.Bc1RgbUnorm: - return FormatClass.Bc1Rgb; case Format.Bc1RgbaSrgb: case Format.Bc1RgbaUnorm: return FormatClass.Bc1Rgba; -- cgit v1.2.3-70-g09d2