diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2018-10-17 18:02:23 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-17 18:02:23 -0300 |
| commit | 0e1e094b7a8f0134831fc4cebdb0841b9c10fe6a (patch) | |
| tree | 81ba6446851a033f27adeafbfb94751032108047 /Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs | |
| parent | 02a8e7fc9369d7882db08a69d108beefb0f98677 (diff) | |
Improve texture tables (#457)
* Improve texture tables
* More renaming and other tweaks
* Minor tweaks
Diffstat (limited to 'Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs')
| -rw-r--r-- | Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs | 75 |
1 files changed, 26 insertions, 49 deletions
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs index 3347afbd..6c608528 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs @@ -39,41 +39,25 @@ namespace Ryujinx.Graphics.Gal.OpenGL TextureCache.AddOrUpdate(Key, new ImageHandler(Handle, Image), (uint)Size); - GalImageFormat TypeLess = Image.Format & GalImageFormat.FormatMask; - - bool IsASTC = TypeLess >= GalImageFormat.ASTC_BEGIN && TypeLess <= GalImageFormat.ASTC_END; - - if (ImageUtils.IsCompressed(Image.Format) && !IsASTC) + if (ImageUtils.IsCompressed(Image.Format)) { - InternalFormat InternalFmt = OGLEnumConverter.GetCompressedImageFormat(Image.Format); - - GL.CompressedTexImage2D( - TextureTarget.Texture2D, - Level, - InternalFmt, - Image.Width, - Image.Height, - Border, - Size, - IntPtr.Zero); + throw new InvalidOperationException("Surfaces with compressed formats are not supported!"); } - else - { - (PixelInternalFormat InternalFmt, - PixelFormat Format, - PixelType Type) = OGLEnumConverter.GetImageFormat(Image.Format); - GL.TexImage2D( - TextureTarget.Texture2D, - Level, - InternalFmt, - Image.Width, - Image.Height, - Border, - Format, - Type, - IntPtr.Zero); - } + (PixelInternalFormat InternalFmt, + PixelFormat Format, + PixelType Type) = OGLEnumConverter.GetImageFormat(Image.Format); + + GL.TexImage2D( + TextureTarget.Texture2D, + Level, + InternalFmt, + Image.Width, + Image.Height, + Border, + Format, + Type, + IntPtr.Zero); } public void Create(long Key, byte[] Data, GalImage Image) @@ -87,11 +71,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL TextureCache.AddOrUpdate(Key, new ImageHandler(Handle, Image), (uint)Data.Length); - GalImageFormat TypeLess = Image.Format & GalImageFormat.FormatMask; - - bool IsASTC = TypeLess >= GalImageFormat.ASTC_BEGIN && TypeLess <= GalImageFormat.ASTC_END; - - if (ImageUtils.IsCompressed(Image.Format) && !IsASTC) + if (ImageUtils.IsCompressed(Image.Format) && !IsAstc(Image.Format)) { InternalFormat InternalFmt = OGLEnumConverter.GetCompressedImageFormat(Image.Format); @@ -108,7 +88,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL else { //TODO: Use KHR_texture_compression_astc_hdr when available - if (IsASTC) + if (IsAstc(Image.Format)) { int TextureBlockWidth = ImageUtils.GetBlockWidth(Image.Format); int TextureBlockHeight = ImageUtils.GetBlockHeight(Image.Format); @@ -120,17 +100,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL Image.Width, Image.Height, 1); - Image.Format = GalImageFormat.A8B8G8R8 | GalImageFormat.Unorm; - } - else if (TypeLess == GalImageFormat.G8R8) - { - Data = ImageConverter.G8R8ToR8G8( - Data, - Image.Width, - Image.Height, - 1); - - Image.Format = GalImageFormat.R8G8 | (Image.Format & GalImageFormat.TypeMask); + Image.Format = GalImageFormat.RGBA8 | GalImageFormat.Unorm; } (PixelInternalFormat InternalFmt, @@ -150,6 +120,13 @@ namespace Ryujinx.Graphics.Gal.OpenGL } } + private static bool IsAstc(GalImageFormat Format) + { + Format &= GalImageFormat.FormatMask; + + return Format > GalImageFormat.Astc2DStart && Format < GalImageFormat.Astc2DEnd; + } + public bool TryGetImage(long Key, out GalImage Image) { if (TextureCache.TryGetValue(Key, out ImageHandler CachedImage)) |
