aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Gal/OpenGL
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-04-10 16:50:32 -0300
committergdkchan <gab.dark.100@gmail.com>2018-04-10 16:50:32 -0300
commitfeb2680a6ce1512c08980ee55c1c8215b8b5c3e4 (patch)
treeb41d2c8558ece834b2c1c5c9afba0afe226e0553 /Ryujinx.Graphics/Gal/OpenGL
parente9cfdef0982824b673c60b362524408a263946df (diff)
[GPU] Add more shader instructions, add support for rgb565 textures
Diffstat (limited to 'Ryujinx.Graphics/Gal/OpenGL')
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs12
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs47
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs2
3 files changed, 41 insertions, 20 deletions
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs
index 6518de5f..03c3ef52 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OGLEnumConverter.cs
@@ -55,6 +55,18 @@ namespace Ryujinx.Graphics.Gal.OpenGL
throw new ArgumentException(nameof(Type));
}
+ public static (PixelFormat, PixelType) GetTextureFormat(GalTextureFormat Format)
+ {
+ switch (Format)
+ {
+ 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());
+ }
+
public static PixelInternalFormat GetCompressedTextureFormat(GalTextureFormat Format)
{
switch (Format)
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs
index 559e0eda..681e6d67 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs
@@ -11,7 +11,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Textures = new int[80];
}
- public void Set(int Index, GalTexture Tex)
+ public void Set(int Index, GalTexture Texture)
{
GL.ActiveTexture(TextureUnit.Texture0 + Index);
@@ -19,29 +19,38 @@ namespace Ryujinx.Graphics.Gal.OpenGL
GL.BindTexture(TextureTarget.Texture2D, Handle);
- int W = Tex.Width;
- int H = Tex.Height;
+ const int Border = 0;
- byte[] Data = Tex.Data;
-
- int Length = Data.Length;
-
- if (IsCompressedTextureFormat(Tex.Format))
+ if (IsCompressedTextureFormat(Texture.Format))
{
- PixelInternalFormat Pif = OGLEnumConverter.GetCompressedTextureFormat(Tex.Format);
-
- GL.CompressedTexImage2D(TextureTarget.Texture2D, 0, Pif, W, H, 0, Length, Data);
+ PixelInternalFormat InternalFmt = OGLEnumConverter.GetCompressedTextureFormat(Texture.Format);
+
+ GL.CompressedTexImage2D(
+ TextureTarget.Texture2D,
+ 0,
+ InternalFmt,
+ Texture.Width,
+ Texture.Height,
+ Border,
+ Texture.Data.Length,
+ Texture.Data);
}
else
{
- //TODO: Get those from Texture format.
- const PixelInternalFormat Pif = PixelInternalFormat.Rgba;
-
- const PixelFormat Pf = PixelFormat.Rgba;
-
- const PixelType Pt = PixelType.UnsignedByte;
-
- GL.TexImage2D(TextureTarget.Texture2D, 0, Pif, W, H, 0, Pf, Pt, Data);
+ const PixelInternalFormat InternalFmt = PixelInternalFormat.Rgba;
+
+ (PixelFormat, PixelType) Format = OGLEnumConverter.GetTextureFormat(Texture.Format);
+
+ GL.TexImage2D(
+ TextureTarget.Texture2D,
+ 0,
+ InternalFmt,
+ Texture.Width,
+ Texture.Height,
+ Border,
+ Format.Item1,
+ Format.Item2,
+ Texture.Data);
}
}
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs b/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs
index 0b7bf92a..8d8e6425 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs
@@ -63,7 +63,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
public void Render()
{
- FbRenderer.Render();
+ //FbRenderer.Render();
}
public void SetWindowSize(int Width, int Height)