aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs')
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs99
1 files changed, 47 insertions, 52 deletions
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs
index e4d4bd64..82f9c913 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs
@@ -1,5 +1,5 @@
using OpenTK.Graphics.OpenGL;
-using Ryujinx.Graphics.Gal.Texture;
+using Ryujinx.Graphics.Texture;
using System;
namespace Ryujinx.Graphics.Gal.OpenGL
@@ -39,7 +39,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL
const int Level = 0; //TODO: Support mipmap textures.
const int Border = 0;
- if (IsCompressedTextureFormat(Image.Format))
+ GalImageFormat TypeLess = Image.Format & GalImageFormat.FormatMask;
+
+ bool IsASTC = TypeLess >= GalImageFormat.ASTC_BEGIN && TypeLess <= GalImageFormat.ASTC_END;
+
+ if (ImageUtils.IsCompressed(Image.Format) && !IsASTC)
{
InternalFormat InternalFmt = OGLEnumConverter.GetCompressedImageFormat(Image.Format);
@@ -55,7 +59,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL
}
else
{
- if (Image.Format >= GalImageFormat.ASTC_BEGIN && Image.Format <= GalImageFormat.ASTC_END)
+ //TODO: Use KHR_texture_compression_astc_hdr when available
+ if (IsASTC)
{
int TextureBlockWidth = GetAstcBlockWidth(Image.Format);
int TextureBlockHeight = GetAstcBlockHeight(Image.Format);
@@ -67,7 +72,17 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Image.Width,
Image.Height, 1);
- Image.Format = GalImageFormat.A8B8G8R8_UNORM_PACK32;
+ 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.FormatMask);
}
(PixelInternalFormat InternalFormat, PixelFormat Format, PixelType Type) = OGLEnumConverter.GetImageFormat(Image.Format);
@@ -123,20 +138,20 @@ namespace Ryujinx.Graphics.Gal.OpenGL
{
switch (Format)
{
- case GalImageFormat.ASTC_4x4_UNORM_BLOCK: return 4;
- case GalImageFormat.ASTC_5x5_UNORM_BLOCK: return 5;
- case GalImageFormat.ASTC_6x6_UNORM_BLOCK: return 6;
- case GalImageFormat.ASTC_8x8_UNORM_BLOCK: return 8;
- case GalImageFormat.ASTC_10x10_UNORM_BLOCK: return 10;
- case GalImageFormat.ASTC_12x12_UNORM_BLOCK: return 12;
- case GalImageFormat.ASTC_5x4_UNORM_BLOCK: return 5;
- case GalImageFormat.ASTC_6x5_UNORM_BLOCK: return 6;
- case GalImageFormat.ASTC_8x6_UNORM_BLOCK: return 8;
- case GalImageFormat.ASTC_10x8_UNORM_BLOCK: return 10;
- case GalImageFormat.ASTC_12x10_UNORM_BLOCK: return 12;
- case GalImageFormat.ASTC_8x5_UNORM_BLOCK: return 8;
- case GalImageFormat.ASTC_10x5_UNORM_BLOCK: return 10;
- case GalImageFormat.ASTC_10x6_UNORM_BLOCK: return 10;
+ case GalImageFormat.ASTC_4x4 | GalImageFormat.Unorm: return 4;
+ case GalImageFormat.ASTC_5x5 | GalImageFormat.Unorm: return 5;
+ case GalImageFormat.ASTC_6x6 | GalImageFormat.Unorm: return 6;
+ case GalImageFormat.ASTC_8x8 | GalImageFormat.Unorm: return 8;
+ case GalImageFormat.ASTC_10x10 | GalImageFormat.Unorm: return 10;
+ case GalImageFormat.ASTC_12x12 | GalImageFormat.Unorm: return 12;
+ case GalImageFormat.ASTC_5x4 | GalImageFormat.Unorm: return 5;
+ case GalImageFormat.ASTC_6x5 | GalImageFormat.Unorm: return 6;
+ case GalImageFormat.ASTC_8x6 | GalImageFormat.Unorm: return 8;
+ case GalImageFormat.ASTC_10x8 | GalImageFormat.Unorm: return 10;
+ case GalImageFormat.ASTC_12x10 | GalImageFormat.Unorm: return 12;
+ case GalImageFormat.ASTC_8x5 | GalImageFormat.Unorm: return 8;
+ case GalImageFormat.ASTC_10x5 | GalImageFormat.Unorm: return 10;
+ case GalImageFormat.ASTC_10x6 | GalImageFormat.Unorm: return 10;
}
throw new ArgumentException(nameof(Format));
@@ -146,20 +161,20 @@ namespace Ryujinx.Graphics.Gal.OpenGL
{
switch (Format)
{
- case GalImageFormat.ASTC_4x4_UNORM_BLOCK: return 4;
- case GalImageFormat.ASTC_5x5_UNORM_BLOCK: return 5;
- case GalImageFormat.ASTC_6x6_UNORM_BLOCK: return 6;
- case GalImageFormat.ASTC_8x8_UNORM_BLOCK: return 8;
- case GalImageFormat.ASTC_10x10_UNORM_BLOCK: return 10;
- case GalImageFormat.ASTC_12x12_UNORM_BLOCK: return 12;
- case GalImageFormat.ASTC_5x4_UNORM_BLOCK: return 4;
- case GalImageFormat.ASTC_6x5_UNORM_BLOCK: return 5;
- case GalImageFormat.ASTC_8x6_UNORM_BLOCK: return 6;
- case GalImageFormat.ASTC_10x8_UNORM_BLOCK: return 8;
- case GalImageFormat.ASTC_12x10_UNORM_BLOCK: return 10;
- case GalImageFormat.ASTC_8x5_UNORM_BLOCK: return 5;
- case GalImageFormat.ASTC_10x5_UNORM_BLOCK: return 5;
- case GalImageFormat.ASTC_10x6_UNORM_BLOCK: return 6;
+ case GalImageFormat.ASTC_4x4 | GalImageFormat.Unorm: return 4;
+ case GalImageFormat.ASTC_5x5 | GalImageFormat.Unorm: return 5;
+ case GalImageFormat.ASTC_6x6 | GalImageFormat.Unorm: return 6;
+ case GalImageFormat.ASTC_8x8 | GalImageFormat.Unorm: return 8;
+ case GalImageFormat.ASTC_10x10 | GalImageFormat.Unorm: return 10;
+ case GalImageFormat.ASTC_12x12 | GalImageFormat.Unorm: return 12;
+ case GalImageFormat.ASTC_5x4 | GalImageFormat.Unorm: return 4;
+ case GalImageFormat.ASTC_6x5 | GalImageFormat.Unorm: return 5;
+ case GalImageFormat.ASTC_8x6 | GalImageFormat.Unorm: return 6;
+ case GalImageFormat.ASTC_10x8 | GalImageFormat.Unorm: return 8;
+ case GalImageFormat.ASTC_12x10 | GalImageFormat.Unorm: return 10;
+ case GalImageFormat.ASTC_8x5 | GalImageFormat.Unorm: return 5;
+ case GalImageFormat.ASTC_10x5 | GalImageFormat.Unorm: return 5;
+ case GalImageFormat.ASTC_10x6 | GalImageFormat.Unorm: return 6;
}
throw new ArgumentException(nameof(Format));
@@ -216,25 +231,5 @@ namespace Ryujinx.Graphics.Gal.OpenGL
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureBorderColor, Color);
}
-
- private static bool IsCompressedTextureFormat(GalImageFormat Format)
- {
- switch (Format)
- {
- case GalImageFormat.BC6H_UFLOAT_BLOCK:
- case GalImageFormat.BC6H_SFLOAT_BLOCK:
- case GalImageFormat.BC7_UNORM_BLOCK:
- case GalImageFormat.BC1_RGBA_UNORM_BLOCK:
- case GalImageFormat.BC2_UNORM_BLOCK:
- case GalImageFormat.BC3_UNORM_BLOCK:
- case GalImageFormat.BC4_SNORM_BLOCK:
- case GalImageFormat.BC4_UNORM_BLOCK:
- case GalImageFormat.BC5_SNORM_BLOCK:
- case GalImageFormat.BC5_UNORM_BLOCK:
- return true;
- }
-
- return false;
- }
}
}