Implement R32G32B32

This commit is contained in:
Unknown 2018-07-19 02:05:59 +02:00
parent 120fe6b74a
commit 58f179fbe7
4 changed files with 39 additions and 0 deletions

View file

@ -3,6 +3,7 @@ namespace Ryujinx.Graphics.Gal
public enum GalTextureFormat public enum GalTextureFormat
{ {
R32G32B32A32 = 0x1, R32G32B32A32 = 0x1,
R32G32B32 = 0x2,
R16G16B16A16 = 0x3, R16G16B16A16 = 0x3,
A8B8G8R8 = 0x8, A8B8G8R8 = 0x8,
R32 = 0xf, R32 = 0xf,

View file

@ -130,6 +130,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
switch (Format) switch (Format)
{ {
case GalTextureFormat.R32G32B32A32: return (PixelFormat.Rgba, PixelType.Float); case GalTextureFormat.R32G32B32A32: return (PixelFormat.Rgba, PixelType.Float);
case GalTextureFormat.R32G32B32: return (PixelFormat.Rgb, PixelType.Float);
case GalTextureFormat.R16G16B16A16: return (PixelFormat.Rgba, PixelType.HalfFloat); case GalTextureFormat.R16G16B16A16: return (PixelFormat.Rgba, PixelType.HalfFloat);
case GalTextureFormat.A8B8G8R8: return (PixelFormat.Rgba, PixelType.UnsignedByte); case GalTextureFormat.A8B8G8R8: return (PixelFormat.Rgba, PixelType.UnsignedByte);
case GalTextureFormat.R32: return (PixelFormat.Red, PixelType.Float); case GalTextureFormat.R32: return (PixelFormat.Red, PixelType.Float);

View file

@ -31,6 +31,9 @@ namespace Ryujinx.HLE.Gpu.Texture
case GalTextureFormat.R32G32B32A32: case GalTextureFormat.R32G32B32A32:
return Texture.Width * Texture.Height * 16; return Texture.Width * Texture.Height * 16;
case GalTextureFormat.R32G32B32:
return Texture.Width * Texture.Height * 12;
case GalTextureFormat.R16G16B16A16: case GalTextureFormat.R16G16B16A16:
return Texture.Width * Texture.Height * 8; return Texture.Width * Texture.Height * 8;

View file

@ -11,6 +11,7 @@ namespace Ryujinx.HLE.Gpu.Texture
switch (Texture.Format) switch (Texture.Format)
{ {
case GalTextureFormat.R32G32B32A32: return Read16Bpp (Memory, Texture); case GalTextureFormat.R32G32B32A32: return Read16Bpp (Memory, Texture);
case GalTextureFormat.R32G32B32: return Read12Bpp (Memory, Texture);
case GalTextureFormat.R16G16B16A16: return Read8Bpp (Memory, Texture); case GalTextureFormat.R16G16B16A16: return Read8Bpp (Memory, Texture);
case GalTextureFormat.A8B8G8R8: return Read4Bpp (Memory, Texture); case GalTextureFormat.A8B8G8R8: return Read4Bpp (Memory, Texture);
case GalTextureFormat.R32: return Read4Bpp (Memory, Texture); case GalTextureFormat.R32: return Read4Bpp (Memory, Texture);
@ -256,6 +257,39 @@ namespace Ryujinx.HLE.Gpu.Texture
return Output; return Output;
} }
private unsafe static byte[] Read12Bpp(IAMemory Memory, TextureInfo Texture)
{
int Width = Texture.Width;
int Height = Texture.Height;
byte[] Output = new byte[Width * Height * 12];
ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 12);
(AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
Memory,
Texture.Position);
fixed (byte* BuffPtr = Output)
{
long OutOffs = 0;
for (int Y = 0; Y < Height; Y++)
for (int X = 0; X < Width; X++)
{
long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
long Pixel = CpuMem.ReadInt64Unchecked(Position + Offset);
*(long*)(BuffPtr + OutOffs) = Pixel;
OutOffs += 12;
}
}
return Output;
}
private unsafe static byte[] Read16Bpp(IAMemory Memory, TextureInfo Texture) private unsafe static byte[] Read16Bpp(IAMemory Memory, TextureInfo Texture)
{ {
int Width = Texture.Width; int Width = Texture.Width;