diff options
author | gdkchan <gab.dark.100@gmail.com> | 2020-11-01 15:32:53 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-01 15:32:53 -0300 |
commit | 11a7c99764ed4e6c575c877c69ca627645702a42 (patch) | |
tree | 27f085e7242dd417dbe691a7a4f13d42f76cf58b /Ryujinx.Graphics.Gpu/Image/Texture.cs | |
parent | 6222f173f0c85a55d31655ddb78638907c07e1ce (diff) |
Support 3D BC4 and BC5 compressed textures (#1655)
* Support 3D BC4 and BC5 compressed textures
* PR feedback
* Fix some typos
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Image/Texture.cs')
-rw-r--r-- | Ryujinx.Graphics.Gpu/Image/Texture.cs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/Ryujinx.Graphics.Gpu/Image/Texture.cs b/Ryujinx.Graphics.Gpu/Image/Texture.cs index 01610629..b1d6af9b 100644 --- a/Ryujinx.Graphics.Gpu/Image/Texture.cs +++ b/Ryujinx.Graphics.Gpu/Image/Texture.cs @@ -671,6 +671,9 @@ namespace Ryujinx.Graphics.Gpu.Image data); } + // Handle compressed cases not supported by the host: + // - ASTC is usually not supported on desktop cards. + // - BC4/BC5 is not supported on 3D textures. if (!_context.Capabilities.SupportsAstcCompression && Info.FormatInfo.Format.IsAstc()) { if (!AstcDecoder.TryDecodeToRgba8( @@ -691,6 +694,14 @@ namespace Ryujinx.Graphics.Gpu.Image data = decoded; } + else if (Info.Target == Target.Texture3D && Info.FormatInfo.Format.IsBc4()) + { + data = BCnDecoder.DecodeBC4(data, Info.Width, Info.Height, _depth, Info.Levels, _layers, Info.FormatInfo.Format == Format.Bc4Snorm); + } + else if (Info.Target == Target.Texture3D && Info.FormatInfo.Format.IsBc5()) + { + data = BCnDecoder.DecodeBC5(data, Info.Width, Info.Height, _depth, Info.Levels, _layers, Info.FormatInfo.Format == Format.Bc5Snorm); + } return data; } @@ -707,8 +718,7 @@ namespace Ryujinx.Graphics.Gpu.Image public void Flush(bool tracked = true) { IsModified = false; - - if (Info.FormatInfo.Format.IsAstc()) + if (TextureCompatibility.IsFormatHostIncompatible(Info, _context.Capabilities)) { return; // Flushing this format is not supported, as it may have been converted to another host format. } @@ -739,10 +749,9 @@ namespace Ryujinx.Graphics.Gpu.Image _context.Renderer.BackgroundContextAction(() => { IsModified = false; - if (Info.FormatInfo.Format.IsAstc()) + if (TextureCompatibility.IsFormatHostIncompatible(Info, _context.Capabilities)) { - // ASTC textures are not in their original format, so cannot be flushed. - return; + return; // Flushing this format is not supported, as it may have been converted to another host format. } ITexture texture = HostTexture; |