diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2018-06-02 00:50:56 -0300 |
|---|---|---|
| committer | gdkchan <gab.dark.100@gmail.com> | 2018-06-02 00:50:56 -0300 |
| commit | 53a6922f872b9380d6c2867254a2465dc7c1ea92 (patch) | |
| tree | abd3945ba8c64ac99c5b3eb0048e9a7bdaa957ca /Ryujinx.Graphics/Gal/OpenGL | |
| parent | aeb1bbf50c9996ab53a17e354798be3137ba2ae2 (diff) | |
Some small gpu improvements and shader improvements, add support for ASTC 4x4 textures (slow!)
Diffstat (limited to 'Ryujinx.Graphics/Gal/OpenGL')
| -rw-r--r-- | Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs | 20 | ||||
| -rw-r--r-- | Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs | 2 | ||||
| -rw-r--r-- | Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs | 63 |
3 files changed, 73 insertions, 12 deletions
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs index ee697097..d266a87a 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs @@ -59,14 +59,9 @@ namespace Ryujinx.Graphics.Gal.OpenGL { switch (Format) { - case GalTextureFormat.R32G32B32A32: return (PixelFormat.Rgba, PixelType.Float); - case GalTextureFormat.R16G16B16A16: return (PixelFormat.Rgba, PixelType.HalfFloat); - case GalTextureFormat.A8B8G8R8: return (PixelFormat.Rgba, PixelType.UnsignedByte); - case GalTextureFormat.R32: return (PixelFormat.Red, PixelType.Float); - case GalTextureFormat.A1B5G5R5: return (PixelFormat.Rgba, PixelType.UnsignedShort5551); - case GalTextureFormat.B5G6R5: return (PixelFormat.Rgb, PixelType.UnsignedShort565); - case GalTextureFormat.G8R8: return (PixelFormat.Rg, PixelType.UnsignedByte); - case GalTextureFormat.R8: return (PixelFormat.Red, PixelType.UnsignedByte); + case GalTextureFormat.A8B8G8R8: return (PixelFormat.Rgba, PixelType.UnsignedByte); + case GalTextureFormat.A1B5G5R5: return (PixelFormat.Rgba, PixelType.UnsignedShort5551); + case GalTextureFormat.B5G6R5: return (PixelFormat.Rgb, PixelType.UnsignedShort565); } throw new NotImplementedException(Format.ToString()); @@ -150,20 +145,20 @@ namespace Ryujinx.Graphics.Gal.OpenGL { switch (BlendEquation) { - default: case GalBlendEquation.FuncAdd: return BlendEquationMode.FuncAdd; case GalBlendEquation.FuncSubtract: return BlendEquationMode.FuncSubtract; case GalBlendEquation.FuncReverseSubtract: return BlendEquationMode.FuncReverseSubtract; case GalBlendEquation.Min: return BlendEquationMode.Min; case GalBlendEquation.Max: return BlendEquationMode.Max; } + + throw new ArgumentException(nameof(BlendEquation)); } public static BlendingFactorSrc GetBlendFactorSrc(GalBlendFactor BlendFactor) { switch (BlendFactor) { - default: case GalBlendFactor.Zero: return BlendingFactorSrc.Zero; case GalBlendFactor.One: return BlendingFactorSrc.One; case GalBlendFactor.SrcColor: return BlendingFactorSrc.SrcColor; @@ -184,13 +179,14 @@ namespace Ryujinx.Graphics.Gal.OpenGL case GalBlendFactor.Src1Alpha: return BlendingFactorSrc.Src1Alpha; case GalBlendFactor.OneMinusSrc1Alpha: return BlendingFactorSrc.OneMinusSrc1Alpha; } + + throw new ArgumentException(nameof(BlendFactor)); } public static BlendingFactorDest GetBlendFactorDst(GalBlendFactor BlendFactor) { switch (BlendFactor) { - default: case GalBlendFactor.Zero: return BlendingFactorDest.Zero; case GalBlendFactor.One: return BlendingFactorDest.One; case GalBlendFactor.SrcColor: return BlendingFactorDest.SrcColor; @@ -211,6 +207,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL case GalBlendFactor.Src1Alpha: return BlendingFactorDest.Src1Alpha; case GalBlendFactor.OneMinusSrc1Alpha: return BlendingFactorDest.OneMinusSrc1Alpha; } + + throw new ArgumentException(nameof(BlendFactor)); } } }
\ No newline at end of file diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs index a8941d69..be1bb20b 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLShader.cs @@ -91,7 +91,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL private ShaderStage ShaderStageFactory(IGalMemory Memory, long Position, GalShaderType Type) { - GlslProgram Program = GetGlslProgram(Memory, Position, Type); + GlslProgram Program = GetGlslProgram(Memory, Position, Type); return new ShaderStage( Type, diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs index 8dcfb2bd..75f09faa 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs @@ -1,4 +1,6 @@ using OpenTK.Graphics.OpenGL; +using Ryujinx.Graphics.Gal.Texture; +using System; namespace Ryujinx.Graphics.Gal.OpenGL { @@ -36,6 +38,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL } else { + if (Texture.Format >= GalTextureFormat.Astc2D4x4) + { + ConvertAstcTextureToRgba(Texture); + } + const PixelInternalFormat InternalFmt = PixelInternalFormat.Rgba; (PixelFormat Format, PixelType Type) = OGLEnumConverter.GetTextureFormat(Texture.Format); @@ -63,6 +70,62 @@ namespace Ryujinx.Graphics.Gal.OpenGL GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleA, SwizzleA); } + private void ConvertAstcTextureToRgba(GalTexture Texture) + { + Texture.Data = ASTCDecoder.DecodeToRGBA8888( + Texture.Data, + GetAstcBlockWidth(Texture.Format), + GetAstcBlockHeight(Texture.Format), 1, + Texture.Width, + Texture.Height, 1); + } + + private int GetAstcBlockWidth(GalTextureFormat Format) + { + switch (Format) + { + case GalTextureFormat.Astc2D4x4: return 4; + case GalTextureFormat.Astc2D5x5: return 5; + case GalTextureFormat.Astc2D6x6: return 6; + case GalTextureFormat.Astc2D8x8: return 8; + case GalTextureFormat.Astc2D10x10: return 10; + case GalTextureFormat.Astc2D12x12: return 12; + case GalTextureFormat.Astc2D5x4: return 5; + case GalTextureFormat.Astc2D6x5: return 6; + case GalTextureFormat.Astc2D8x6: return 8; + case GalTextureFormat.Astc2D10x8: return 10; + case GalTextureFormat.Astc2D12x10: return 12; + case GalTextureFormat.Astc2D8x5: return 8; + case GalTextureFormat.Astc2D10x5: return 10; + case GalTextureFormat.Astc2D10x6: return 10; + } + + throw new ArgumentException(nameof(Format)); + } + + private int GetAstcBlockHeight(GalTextureFormat Format) + { + switch (Format) + { + case GalTextureFormat.Astc2D4x4: return 4; + case GalTextureFormat.Astc2D5x5: return 5; + case GalTextureFormat.Astc2D6x6: return 6; + case GalTextureFormat.Astc2D8x8: return 8; + case GalTextureFormat.Astc2D10x10: return 10; + case GalTextureFormat.Astc2D12x12: return 12; + case GalTextureFormat.Astc2D5x4: return 4; + case GalTextureFormat.Astc2D6x5: return 5; + case GalTextureFormat.Astc2D8x6: return 6; + case GalTextureFormat.Astc2D10x8: return 8; + case GalTextureFormat.Astc2D12x10: return 10; + case GalTextureFormat.Astc2D8x5: return 5; + case GalTextureFormat.Astc2D10x5: return 5; + case GalTextureFormat.Astc2D10x6: return 6; + } + + throw new ArgumentException(nameof(Format)); + } + public void Bind(int Index) { int Handle = EnsureTextureInitialized(Index); |
