[GPU] Add more shader instructions, add support for rgb565 textures

This commit is contained in:
gdkchan 2018-04-10 16:50:32 -03:00
parent e9cfdef098
commit feb2680a6c
22 changed files with 817 additions and 238 deletions

View file

@ -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)

View file

@ -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);
PixelInternalFormat InternalFmt = OGLEnumConverter.GetCompressedTextureFormat(Texture.Format);
GL.CompressedTexImage2D(TextureTarget.Texture2D, 0, Pif, W, H, 0, Length, Data);
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 PixelInternalFormat InternalFmt = PixelInternalFormat.Rgba;
const PixelFormat Pf = PixelFormat.Rgba;
(PixelFormat, PixelType) Format = OGLEnumConverter.GetTextureFormat(Texture.Format);
const PixelType Pt = PixelType.UnsignedByte;
GL.TexImage2D(TextureTarget.Texture2D, 0, Pif, W, H, 0, Pf, Pt, Data);
GL.TexImage2D(
TextureTarget.Texture2D,
0,
InternalFmt,
Texture.Width,
Texture.Height,
Border,
Format.Item1,
Format.Item2,
Texture.Data);
}
}

View file

@ -63,7 +63,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
public void Render()
{
FbRenderer.Render();
//FbRenderer.Render();
}
public void SetWindowSize(int Width, int Height)