@ -6,11 +6,15 @@ namespace Ryujinx.Graphics.OpenGL
|
||||
{
|
||||
struct FormatTable
|
||||
{
|
||||
private static FormatInfo[] _table;
|
||||
private static FormatInfo[] Table;
|
||||
private static SizedInternalFormat[] TableImage;
|
||||
|
||||
static FormatTable()
|
||||
{
|
||||
_table = new FormatInfo[Enum.GetNames(typeof(Format)).Length];
|
||||
int tableSize = Enum.GetNames(typeof(Format)).Length;
|
||||
|
||||
Table = new FormatInfo[tableSize];
|
||||
TableImage = new SizedInternalFormat[tableSize];
|
||||
|
||||
Add(Format.R8Unorm, new FormatInfo(1, true, false, All.R8, PixelFormat.Red, PixelType.UnsignedByte));
|
||||
Add(Format.R8Snorm, new FormatInfo(1, true, false, All.R8Snorm, PixelFormat.Red, PixelType.Byte));
|
||||
@ -168,16 +172,66 @@ namespace Ryujinx.Graphics.OpenGL
|
||||
Add(Format.B8G8R8A8Unorm, new FormatInfo(4, true, false, All.Rgba8, PixelFormat.Rgba, PixelType.UnsignedByte));
|
||||
Add(Format.B8G8R8X8Srgb, new FormatInfo(4, false, false, All.Srgb8, PixelFormat.Rgba, PixelType.UnsignedByte));
|
||||
Add(Format.B8G8R8A8Srgb, new FormatInfo(4, false, false, All.Srgb8Alpha8, PixelFormat.Rgba, PixelType.UnsignedByte));
|
||||
|
||||
Add(Format.R8Unorm, SizedInternalFormat.R8);
|
||||
Add(Format.R8Uint, SizedInternalFormat.R8ui);
|
||||
Add(Format.R8Sint, SizedInternalFormat.R8i);
|
||||
Add(Format.R16Float, SizedInternalFormat.R16f);
|
||||
Add(Format.R16Unorm, SizedInternalFormat.R16);
|
||||
Add(Format.R16Snorm, (SizedInternalFormat)All.R16Snorm);
|
||||
Add(Format.R16Uint, SizedInternalFormat.R16ui);
|
||||
Add(Format.R16Sint, SizedInternalFormat.R16i);
|
||||
Add(Format.R32Float, SizedInternalFormat.R32f);
|
||||
Add(Format.R32Uint, SizedInternalFormat.R32ui);
|
||||
Add(Format.R32Sint, SizedInternalFormat.R32i);
|
||||
Add(Format.R8G8Unorm, SizedInternalFormat.Rg8);
|
||||
Add(Format.R8G8Snorm, (SizedInternalFormat)All.Rg8Snorm);
|
||||
Add(Format.R8G8Uint, SizedInternalFormat.Rg8ui);
|
||||
Add(Format.R8G8Sint, SizedInternalFormat.Rg8i);
|
||||
Add(Format.R16G16Float, SizedInternalFormat.Rg16f);
|
||||
Add(Format.R16G16Unorm, SizedInternalFormat.Rg16);
|
||||
Add(Format.R16G16Snorm, (SizedInternalFormat)All.Rg16Snorm);
|
||||
Add(Format.R16G16Uint, SizedInternalFormat.Rg16ui);
|
||||
Add(Format.R16G16Sint, SizedInternalFormat.Rg16i);
|
||||
Add(Format.R32G32Float, SizedInternalFormat.Rg32f);
|
||||
Add(Format.R32G32Uint, SizedInternalFormat.Rg32ui);
|
||||
Add(Format.R32G32Sint, SizedInternalFormat.Rg32i);
|
||||
Add(Format.R8G8B8A8Unorm, SizedInternalFormat.Rgba8);
|
||||
Add(Format.R8G8B8A8Snorm, (SizedInternalFormat)All.Rgba8Snorm);
|
||||
Add(Format.R8G8B8A8Uint, SizedInternalFormat.Rgba8ui);
|
||||
Add(Format.R8G8B8A8Sint, SizedInternalFormat.Rgba8i);
|
||||
Add(Format.R16G16B16A16Float, SizedInternalFormat.Rgba16f);
|
||||
Add(Format.R16G16B16A16Unorm, SizedInternalFormat.Rgba16);
|
||||
Add(Format.R16G16B16A16Snorm, (SizedInternalFormat)All.Rgba16Snorm);
|
||||
Add(Format.R16G16B16A16Uint, SizedInternalFormat.Rgba16ui);
|
||||
Add(Format.R16G16B16A16Sint, SizedInternalFormat.Rgba16i);
|
||||
Add(Format.R32G32B32A32Float, SizedInternalFormat.Rgba32f);
|
||||
Add(Format.R32G32B32A32Uint, SizedInternalFormat.Rgba32ui);
|
||||
Add(Format.R32G32B32A32Sint, SizedInternalFormat.Rgba32i);
|
||||
Add(Format.R8G8B8A8Srgb, SizedInternalFormat.Rgba8);
|
||||
Add(Format.R10G10B10A2Unorm, (SizedInternalFormat)All.Rgb10A2);
|
||||
Add(Format.R10G10B10A2Uint, (SizedInternalFormat)All.Rgb10A2ui);
|
||||
Add(Format.R11G11B10Float, (SizedInternalFormat)All.R11fG11fB10f);
|
||||
}
|
||||
|
||||
private static void Add(Format format, FormatInfo info)
|
||||
{
|
||||
_table[(int)format] = info;
|
||||
Table[(int)format] = info;
|
||||
}
|
||||
|
||||
private static void Add(Format format, SizedInternalFormat sif)
|
||||
{
|
||||
TableImage[(int)format] = sif;
|
||||
}
|
||||
|
||||
public static FormatInfo GetFormatInfo(Format format)
|
||||
{
|
||||
return _table[(int)format];
|
||||
return Table[(int)format];
|
||||
}
|
||||
|
||||
public static SizedInternalFormat GetImageFormat(Format format)
|
||||
{
|
||||
return TableImage[(int)format];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -693,7 +693,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||
SetFrontFace(_frontFace = frontFace.Convert());
|
||||
}
|
||||
|
||||
public void SetImage(int index, ShaderStage stage, ITexture texture)
|
||||
public void SetImage(int index, ShaderStage stage, ITexture texture, Format imageFormat)
|
||||
{
|
||||
int unit = _program.GetImageUnit(stage, index);
|
||||
|
||||
@ -701,11 +701,12 @@ namespace Ryujinx.Graphics.OpenGL
|
||||
{
|
||||
TextureBase texBase = (TextureBase)texture;
|
||||
|
||||
FormatInfo formatInfo = FormatTable.GetFormatInfo(texBase.Format);
|
||||
SizedInternalFormat format = FormatTable.GetImageFormat(imageFormat);
|
||||
|
||||
SizedInternalFormat format = (SizedInternalFormat)formatInfo.PixelInternalFormat;
|
||||
|
||||
GL.BindImageTexture(unit, texBase.Handle, 0, true, 0, TextureAccess.ReadWrite, format);
|
||||
if (format != 0)
|
||||
{
|
||||
GL.BindImageTexture(unit, texBase.Handle, 0, true, 0, TextureAccess.ReadWrite, format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user