Use tables for image formats
This commit is contained in:
parent
c632222c81
commit
8decba08cf
9 changed files with 550 additions and 497 deletions
|
@ -1,279 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.Gal
|
||||
{
|
||||
public static class ImageFormatConverter
|
||||
{
|
||||
public static GalImageFormat ConvertTexture(
|
||||
GalTextureFormat Format,
|
||||
GalTextureType RType,
|
||||
GalTextureType GType,
|
||||
GalTextureType BType,
|
||||
GalTextureType AType)
|
||||
{
|
||||
if (RType != GType || RType != BType || RType != AType)
|
||||
{
|
||||
throw new NotImplementedException("Per component types are not implemented");
|
||||
}
|
||||
|
||||
GalTextureType Type = RType;
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case GalTextureType.Snorm:
|
||||
switch (Format)
|
||||
{
|
||||
case GalTextureFormat.R16G16B16A16: return GalImageFormat.R16G16B16A16_SNORM;
|
||||
case GalTextureFormat.A8B8G8R8: return GalImageFormat.A8B8G8R8_SNORM_PACK32;
|
||||
case GalTextureFormat.A2B10G10R10: return GalImageFormat.A2B10G10R10_SNORM_PACK32;
|
||||
case GalTextureFormat.G8R8: return GalImageFormat.R8G8_SNORM;
|
||||
case GalTextureFormat.R16: return GalImageFormat.R16_SNORM;
|
||||
case GalTextureFormat.R8: return GalImageFormat.R8_SNORM;
|
||||
case GalTextureFormat.BC4: return GalImageFormat.BC4_SNORM_BLOCK;
|
||||
case GalTextureFormat.BC5: return GalImageFormat.BC5_SNORM_BLOCK;
|
||||
}
|
||||
break;
|
||||
|
||||
case GalTextureType.Unorm:
|
||||
switch (Format)
|
||||
{
|
||||
case GalTextureFormat.R16G16B16A16: return GalImageFormat.R16G16B16A16_UNORM;
|
||||
case GalTextureFormat.A8B8G8R8: return GalImageFormat.A8B8G8R8_UNORM_PACK32;
|
||||
case GalTextureFormat.A2B10G10R10: return GalImageFormat.A2B10G10R10_UNORM_PACK32;
|
||||
case GalTextureFormat.A4B4G4R4: return GalImageFormat.R4G4B4A4_UNORM_PACK16_REVERSED;
|
||||
case GalTextureFormat.A1B5G5R5: return GalImageFormat.A1R5G5B5_UNORM_PACK16;
|
||||
case GalTextureFormat.B5G6R5: return GalImageFormat.B5G6R5_UNORM_PACK16;
|
||||
case GalTextureFormat.BC7U: return GalImageFormat.BC7_UNORM_BLOCK;
|
||||
case GalTextureFormat.G8R8: return GalImageFormat.R8G8_UNORM;
|
||||
case GalTextureFormat.R16: return GalImageFormat.R16_UNORM;
|
||||
case GalTextureFormat.R8: return GalImageFormat.R8_UNORM;
|
||||
case GalTextureFormat.BC1: return GalImageFormat.BC1_RGBA_UNORM_BLOCK;
|
||||
case GalTextureFormat.BC2: return GalImageFormat.BC2_UNORM_BLOCK;
|
||||
case GalTextureFormat.BC3: return GalImageFormat.BC3_UNORM_BLOCK;
|
||||
case GalTextureFormat.BC4: return GalImageFormat.BC4_UNORM_BLOCK;
|
||||
case GalTextureFormat.BC5: return GalImageFormat.BC5_UNORM_BLOCK;
|
||||
case GalTextureFormat.Z24S8: return GalImageFormat.D24_UNORM_S8_UINT;
|
||||
case GalTextureFormat.ZF32_X24S8: return GalImageFormat.D32_SFLOAT_S8_UINT;
|
||||
case GalTextureFormat.Astc2D4x4: return GalImageFormat.ASTC_4x4_UNORM_BLOCK;
|
||||
case GalTextureFormat.Astc2D5x5: return GalImageFormat.ASTC_5x5_UNORM_BLOCK;
|
||||
case GalTextureFormat.Astc2D6x6: return GalImageFormat.ASTC_6x6_UNORM_BLOCK;
|
||||
case GalTextureFormat.Astc2D8x8: return GalImageFormat.ASTC_8x8_UNORM_BLOCK;
|
||||
case GalTextureFormat.Astc2D10x10: return GalImageFormat.ASTC_10x10_UNORM_BLOCK;
|
||||
case GalTextureFormat.Astc2D12x12: return GalImageFormat.ASTC_12x12_UNORM_BLOCK;
|
||||
case GalTextureFormat.Astc2D5x4: return GalImageFormat.ASTC_5x4_UNORM_BLOCK;
|
||||
case GalTextureFormat.Astc2D6x5: return GalImageFormat.ASTC_6x5_UNORM_BLOCK;
|
||||
case GalTextureFormat.Astc2D8x6: return GalImageFormat.ASTC_8x6_UNORM_BLOCK;
|
||||
case GalTextureFormat.Astc2D10x8: return GalImageFormat.ASTC_10x8_UNORM_BLOCK;
|
||||
case GalTextureFormat.Astc2D12x10: return GalImageFormat.ASTC_12x10_UNORM_BLOCK;
|
||||
case GalTextureFormat.Astc2D8x5: return GalImageFormat.ASTC_8x5_UNORM_BLOCK;
|
||||
case GalTextureFormat.Astc2D10x5: return GalImageFormat.ASTC_10x5_UNORM_BLOCK;
|
||||
case GalTextureFormat.Astc2D10x6: return GalImageFormat.ASTC_10x6_UNORM_BLOCK;
|
||||
}
|
||||
break;
|
||||
|
||||
case GalTextureType.Sint:
|
||||
switch (Format)
|
||||
{
|
||||
case GalTextureFormat.R32G32B32A32: return GalImageFormat.R32G32B32A32_SINT;
|
||||
case GalTextureFormat.R16G16B16A16: return GalImageFormat.R16G16B16A16_SINT;
|
||||
case GalTextureFormat.R32G32: return GalImageFormat.R32G32_SINT;
|
||||
case GalTextureFormat.A8B8G8R8: return GalImageFormat.A8B8G8R8_SINT_PACK32;
|
||||
case GalTextureFormat.A2B10G10R10: return GalImageFormat.A2B10G10R10_SINT_PACK32;
|
||||
case GalTextureFormat.R32: return GalImageFormat.R32_SINT;
|
||||
case GalTextureFormat.G8R8: return GalImageFormat.R8G8_SINT;
|
||||
case GalTextureFormat.R16: return GalImageFormat.R16_SINT;
|
||||
case GalTextureFormat.R8: return GalImageFormat.R8_SINT;
|
||||
}
|
||||
break;
|
||||
|
||||
case GalTextureType.Uint:
|
||||
switch (Format)
|
||||
{
|
||||
case GalTextureFormat.R32G32B32A32: return GalImageFormat.R32G32B32A32_UINT;
|
||||
case GalTextureFormat.R16G16B16A16: return GalImageFormat.R16G16B16A16_UINT;
|
||||
case GalTextureFormat.R32G32: return GalImageFormat.R32G32_UINT;
|
||||
case GalTextureFormat.A8B8G8R8: return GalImageFormat.A8B8G8R8_UINT_PACK32;
|
||||
case GalTextureFormat.A2B10G10R10: return GalImageFormat.A2B10G10R10_UINT_PACK32;
|
||||
case GalTextureFormat.R32: return GalImageFormat.R32_UINT;
|
||||
case GalTextureFormat.G8R8: return GalImageFormat.R8G8_UINT;
|
||||
case GalTextureFormat.R16: return GalImageFormat.R16_UINT;
|
||||
case GalTextureFormat.R8: return GalImageFormat.R8_UINT;
|
||||
}
|
||||
break;
|
||||
|
||||
case GalTextureType.Snorm_Force_Fp16:
|
||||
//TODO
|
||||
break;
|
||||
|
||||
case GalTextureType.Unorm_Force_Fp16:
|
||||
//TODO
|
||||
break;
|
||||
|
||||
case GalTextureType.Float:
|
||||
switch (Format)
|
||||
{
|
||||
case GalTextureFormat.R32G32B32A32: return GalImageFormat.R32G32B32A32_SFLOAT;
|
||||
case GalTextureFormat.R16G16B16A16: return GalImageFormat.R16G16B16A16_SFLOAT;
|
||||
case GalTextureFormat.R32G32: return GalImageFormat.R32G32_SFLOAT;
|
||||
case GalTextureFormat.R32: return GalImageFormat.R32_SFLOAT;
|
||||
case GalTextureFormat.BC6H_SF16: return GalImageFormat.BC6H_SFLOAT_BLOCK;
|
||||
case GalTextureFormat.BC6H_UF16: return GalImageFormat.BC6H_UFLOAT_BLOCK;
|
||||
case GalTextureFormat.R16: return GalImageFormat.R16_SFLOAT;
|
||||
case GalTextureFormat.BF10GF11RF11: return GalImageFormat.B10G11R11_UFLOAT_PACK32;
|
||||
case GalTextureFormat.ZF32: return GalImageFormat.D32_SFLOAT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
throw new NotImplementedException("0x" + ((int)Format).ToString("x2") + " " + Type.ToString());
|
||||
}
|
||||
|
||||
public static GalImageFormat ConvertFrameBuffer(GalFrameBufferFormat Format)
|
||||
{
|
||||
switch (Format)
|
||||
{
|
||||
case GalFrameBufferFormat.R32Float: return GalImageFormat.R32_SFLOAT;
|
||||
case GalFrameBufferFormat.RGB10A2Unorm: return GalImageFormat.A2B10G10R10_UNORM_PACK32;
|
||||
case GalFrameBufferFormat.RGBA8Srgb: return GalImageFormat.A8B8G8R8_SRGB_PACK32;
|
||||
case GalFrameBufferFormat.RGBA16Float: return GalImageFormat.R16G16B16A16_SFLOAT;
|
||||
case GalFrameBufferFormat.R16Float: return GalImageFormat.R16_SFLOAT;
|
||||
case GalFrameBufferFormat.R8Unorm: return GalImageFormat.R8_UNORM;
|
||||
case GalFrameBufferFormat.RGBA8Unorm: return GalImageFormat.A8B8G8R8_UNORM_PACK32;
|
||||
case GalFrameBufferFormat.R11G11B10Float: return GalImageFormat.B10G11R11_UFLOAT_PACK32;
|
||||
case GalFrameBufferFormat.RGBA32Float: return GalImageFormat.R32G32B32A32_SFLOAT;
|
||||
case GalFrameBufferFormat.RG16Snorm: return GalImageFormat.R16G16_SNORM;
|
||||
case GalFrameBufferFormat.RG16Float: return GalImageFormat.R16G16_SFLOAT;
|
||||
case GalFrameBufferFormat.RG8Snorm: return GalImageFormat.R8_SNORM;
|
||||
case GalFrameBufferFormat.RGBA8Snorm: return GalImageFormat.A8B8G8R8_SNORM_PACK32;
|
||||
case GalFrameBufferFormat.RG8Unorm: return GalImageFormat.R8G8_UNORM;
|
||||
case GalFrameBufferFormat.BGRA8Unorm: return GalImageFormat.A8B8G8R8_UNORM_PACK32;
|
||||
case GalFrameBufferFormat.BGRA8Srgb: return GalImageFormat.A8B8G8R8_SRGB_PACK32;
|
||||
case GalFrameBufferFormat.RG32Float: return GalImageFormat.R32G32_SFLOAT;
|
||||
case GalFrameBufferFormat.RG32Sint: return GalImageFormat.R32G32_SINT;
|
||||
case GalFrameBufferFormat.RG32Uint: return GalImageFormat.R32G32_UINT;
|
||||
}
|
||||
|
||||
throw new NotImplementedException(Format.ToString());
|
||||
}
|
||||
|
||||
public static GalImageFormat ConvertZeta(GalZetaFormat Format)
|
||||
{
|
||||
switch (Format)
|
||||
{
|
||||
case GalZetaFormat.Z32Float: return GalImageFormat.D32_SFLOAT;
|
||||
case GalZetaFormat.S8Z24Unorm: return GalImageFormat.D24_UNORM_S8_UINT;
|
||||
case GalZetaFormat.Z16Unorm: return GalImageFormat.D16_UNORM;
|
||||
case GalZetaFormat.Z32S8X24Float: return GalImageFormat.D32_SFLOAT_S8_UINT;
|
||||
}
|
||||
|
||||
throw new NotImplementedException(Format.ToString());
|
||||
}
|
||||
|
||||
public static bool HasColor(GalImageFormat Format)
|
||||
{
|
||||
switch (Format)
|
||||
{
|
||||
case GalImageFormat.R32G32B32A32_SFLOAT:
|
||||
case GalImageFormat.R32G32B32A32_SINT:
|
||||
case GalImageFormat.R32G32B32A32_UINT:
|
||||
case GalImageFormat.R16G16B16A16_SFLOAT:
|
||||
case GalImageFormat.R16G16B16A16_SINT:
|
||||
case GalImageFormat.R16G16B16A16_UINT:
|
||||
case GalImageFormat.R32G32_SFLOAT:
|
||||
case GalImageFormat.R32G32_SINT:
|
||||
case GalImageFormat.R32G32_UINT:
|
||||
case GalImageFormat.A8B8G8R8_SNORM_PACK32:
|
||||
case GalImageFormat.A8B8G8R8_UNORM_PACK32:
|
||||
case GalImageFormat.A8B8G8R8_SINT_PACK32:
|
||||
case GalImageFormat.A8B8G8R8_UINT_PACK32:
|
||||
case GalImageFormat.A2B10G10R10_SINT_PACK32:
|
||||
case GalImageFormat.A2B10G10R10_SNORM_PACK32:
|
||||
case GalImageFormat.A2B10G10R10_UINT_PACK32:
|
||||
case GalImageFormat.A2B10G10R10_UNORM_PACK32:
|
||||
case GalImageFormat.R32_SFLOAT:
|
||||
case GalImageFormat.R32_SINT:
|
||||
case GalImageFormat.R32_UINT:
|
||||
case GalImageFormat.BC6H_SFLOAT_BLOCK:
|
||||
case GalImageFormat.BC6H_UFLOAT_BLOCK:
|
||||
case GalImageFormat.A1R5G5B5_UNORM_PACK16:
|
||||
case GalImageFormat.B5G6R5_UNORM_PACK16:
|
||||
case GalImageFormat.BC7_UNORM_BLOCK:
|
||||
case GalImageFormat.R16G16_SFLOAT:
|
||||
case GalImageFormat.R16G16_SINT:
|
||||
case GalImageFormat.R16G16_SNORM:
|
||||
case GalImageFormat.R16G16_UNORM:
|
||||
case GalImageFormat.R8G8_SINT:
|
||||
case GalImageFormat.R8G8_SNORM:
|
||||
case GalImageFormat.R8G8_UINT:
|
||||
case GalImageFormat.R8G8_UNORM:
|
||||
case GalImageFormat.R16_SFLOAT:
|
||||
case GalImageFormat.R16_SINT:
|
||||
case GalImageFormat.R16_SNORM:
|
||||
case GalImageFormat.R16_UINT:
|
||||
case GalImageFormat.R16_UNORM:
|
||||
case GalImageFormat.R8_SINT:
|
||||
case GalImageFormat.R8_SNORM:
|
||||
case GalImageFormat.R8_UINT:
|
||||
case GalImageFormat.R8_UNORM:
|
||||
case GalImageFormat.B10G11R11_UFLOAT_PACK32:
|
||||
case GalImageFormat.BC1_RGBA_UNORM_BLOCK:
|
||||
case GalImageFormat.BC2_UNORM_BLOCK:
|
||||
case GalImageFormat.BC3_UNORM_BLOCK:
|
||||
case GalImageFormat.BC4_UNORM_BLOCK:
|
||||
case GalImageFormat.BC5_UNORM_BLOCK:
|
||||
case GalImageFormat.ASTC_4x4_UNORM_BLOCK:
|
||||
case GalImageFormat.ASTC_5x5_UNORM_BLOCK:
|
||||
case GalImageFormat.ASTC_6x6_UNORM_BLOCK:
|
||||
case GalImageFormat.ASTC_8x8_UNORM_BLOCK:
|
||||
case GalImageFormat.ASTC_10x10_UNORM_BLOCK:
|
||||
case GalImageFormat.ASTC_12x12_UNORM_BLOCK:
|
||||
case GalImageFormat.ASTC_5x4_UNORM_BLOCK:
|
||||
case GalImageFormat.ASTC_6x5_UNORM_BLOCK:
|
||||
case GalImageFormat.ASTC_8x6_UNORM_BLOCK:
|
||||
case GalImageFormat.ASTC_10x8_UNORM_BLOCK:
|
||||
case GalImageFormat.ASTC_12x10_UNORM_BLOCK:
|
||||
case GalImageFormat.ASTC_8x5_UNORM_BLOCK:
|
||||
case GalImageFormat.ASTC_10x5_UNORM_BLOCK:
|
||||
case GalImageFormat.ASTC_10x6_UNORM_BLOCK:
|
||||
case GalImageFormat.R4G4B4A4_UNORM_PACK16_REVERSED:
|
||||
return true;
|
||||
|
||||
case GalImageFormat.D24_UNORM_S8_UINT:
|
||||
case GalImageFormat.D32_SFLOAT:
|
||||
case GalImageFormat.D16_UNORM:
|
||||
case GalImageFormat.D32_SFLOAT_S8_UINT:
|
||||
return false;
|
||||
}
|
||||
|
||||
throw new NotImplementedException(Format.ToString());
|
||||
}
|
||||
|
||||
public static bool HasDepth(GalImageFormat Format)
|
||||
{
|
||||
switch (Format)
|
||||
{
|
||||
case GalImageFormat.D24_UNORM_S8_UINT:
|
||||
case GalImageFormat.D32_SFLOAT:
|
||||
case GalImageFormat.D16_UNORM:
|
||||
case GalImageFormat.D32_SFLOAT_S8_UINT:
|
||||
return true;
|
||||
}
|
||||
|
||||
//Depth formats are fewer than colors, so it's harder to miss one
|
||||
//Instead of checking for individual formats, return false
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool HasStencil(GalImageFormat Format)
|
||||
{
|
||||
switch (Format)
|
||||
{
|
||||
case GalImageFormat.D24_UNORM_S8_UINT:
|
||||
case GalImageFormat.D32_SFLOAT_S8_UINT:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using OpenTK.Graphics.OpenGL;
|
||||
using Ryujinx.Graphics.Texture;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.Gal.OpenGL
|
||||
|
@ -117,8 +118,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
|||
}
|
||||
}
|
||||
|
||||
public bool HasColor { get => ImageFormatConverter.HasColor(Format); }
|
||||
public bool HasDepth { get => ImageFormatConverter.HasDepth(Format); }
|
||||
public bool HasStencil { get => ImageFormatConverter.HasStencil(Format); }
|
||||
public bool HasColor { get => ImageTable.HasColor(Image); }
|
||||
public bool HasDepth { get => ImageTable.HasDepth(Image); }
|
||||
public bool HasStencil { get => ImageTable.HasStencil(Image); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,6 +158,7 @@ namespace Ryujinx.Graphics
|
|||
int Stencil = ReadRegister(NvGpuEngine3dReg.ClearStencil);
|
||||
|
||||
SetFrameBuffer(Vmm, FbIndex);
|
||||
|
||||
SetZeta(Vmm);
|
||||
|
||||
Gpu.Renderer.Rasterizer.ClearBuffers(
|
||||
|
@ -200,13 +201,14 @@ namespace Ryujinx.Graphics
|
|||
int VpW = (int)(TX + MathF.Abs(SX)) - VpX;
|
||||
int VpH = (int)(TY + MathF.Abs(SY)) - VpY;
|
||||
|
||||
GalImageFormat ImageFormat = ImageFormatConverter.ConvertFrameBuffer((GalFrameBufferFormat)Format);
|
||||
GalImageFormat ImageFormat = ImageTable.ConvertFrameBuffer((GalFrameBufferFormat)Format);
|
||||
|
||||
GalImage Image = new GalImage(Width, Height, ImageFormat);
|
||||
|
||||
long Size = TextureHelper.GetTextureSize(Image);
|
||||
long Size = ImageTable.GetImageSize(Image);
|
||||
|
||||
Gpu.Renderer.Texture.CreateFb(Key, Size, Image);
|
||||
|
||||
Gpu.Renderer.FrameBuffer.BindColor(Key, FbIndex);
|
||||
|
||||
Gpu.Renderer.FrameBuffer.SetViewport(VpX, VpY, VpW, VpH);
|
||||
|
@ -232,13 +234,14 @@ namespace Ryujinx.Graphics
|
|||
int Width = ReadRegister(NvGpuEngine3dReg.ZetaHoriz);
|
||||
int Height = ReadRegister(NvGpuEngine3dReg.ZetaVert);
|
||||
|
||||
GalImageFormat ImageFormat = ImageFormatConverter.ConvertZeta((GalZetaFormat)Format);
|
||||
GalImageFormat ImageFormat = ImageTable.ConvertZeta((GalZetaFormat)Format);
|
||||
|
||||
GalImage Image = new GalImage(Width, Height, ImageFormat);
|
||||
|
||||
long Size = TextureHelper.GetTextureSize(Image);
|
||||
long Size = ImageTable.GetImageSize(Image);
|
||||
|
||||
Gpu.Renderer.Texture.CreateFb(Key, Size, Image);
|
||||
|
||||
Gpu.Renderer.FrameBuffer.BindZeta(Key);
|
||||
}
|
||||
|
||||
|
@ -525,7 +528,7 @@ namespace Ryujinx.Graphics
|
|||
{
|
||||
GalImage NewImage = TextureFactory.MakeTexture(Vmm, TicPosition);
|
||||
|
||||
long Size = (uint)TextureHelper.GetTextureSize(NewImage);
|
||||
long Size = (uint)ImageTable.GetImageSize(NewImage);
|
||||
|
||||
bool HasCachedTexture = false;
|
||||
|
||||
|
|
416
Ryujinx.Graphics/Texture/ImageTable.cs
Normal file
416
Ryujinx.Graphics/Texture/ImageTable.cs
Normal file
|
@ -0,0 +1,416 @@
|
|||
using Ryujinx.Graphics.Gal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.Graphics.Texture
|
||||
{
|
||||
static class ImageTable
|
||||
{
|
||||
struct ImageDescriptor
|
||||
{
|
||||
public bool HasColor;
|
||||
public bool HasDepth;
|
||||
public bool HasStencil;
|
||||
|
||||
public ImageDescriptor(
|
||||
bool HasColor,
|
||||
bool HasDepth,
|
||||
bool HasStencil)
|
||||
{
|
||||
this.HasColor = HasColor;
|
||||
this.HasDepth = HasDepth;
|
||||
this.HasStencil = HasStencil;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Dictionary<GalTextureFormat, TextureDescriptor> s_TextureTable =
|
||||
new Dictionary<GalTextureFormat, TextureDescriptor>()
|
||||
{
|
||||
{ GalTextureFormat.R16G16B16A16, new TextureDescriptor(TextureReader.Read8Bpp, GalImageFormat.R16G16B16A16_SNORM, GalImageFormat.R16G16B16A16_UNORM, GalImageFormat.R16G16B16A16_SINT, GalImageFormat.R16G16B16A16_UINT, GalImageFormat.R16G16B16A16_SFLOAT, null, null) },
|
||||
{ GalTextureFormat.A8B8G8R8, new TextureDescriptor(TextureReader.Read4Bpp, GalImageFormat.A8B8G8R8_SNORM_PACK32, GalImageFormat.A8B8G8R8_UNORM_PACK32, GalImageFormat.A8B8G8R8_SINT_PACK32, GalImageFormat.A8B8G8R8_UINT_PACK32, null, null, null) },
|
||||
{ GalTextureFormat.A2B10G10R10, new TextureDescriptor(TextureReader.Read4Bpp, GalImageFormat.A2B10G10R10_SNORM_PACK32, GalImageFormat.A2B10G10R10_UNORM_PACK32, GalImageFormat.A2B10G10R10_SINT_PACK32, GalImageFormat.A2B10G10R10_UINT_PACK32, null, null, null) },
|
||||
{ GalTextureFormat.G8R8, new TextureDescriptor(TextureReader.Read2Bpp, GalImageFormat.R8G8_SNORM, GalImageFormat.R8G8_UNORM, GalImageFormat.R8G8_SINT, GalImageFormat.R8G8_UINT, null, null, null) },
|
||||
{ GalTextureFormat.R16, new TextureDescriptor(TextureReader.Read2Bpp, GalImageFormat.R16_SNORM, GalImageFormat.R16_UNORM, GalImageFormat.R16_SINT, GalImageFormat.R16_UINT, GalImageFormat.R16_SFLOAT, null, null) },
|
||||
{ GalTextureFormat.R8, new TextureDescriptor(TextureReader.Read1Bpp, GalImageFormat.R8_SNORM, GalImageFormat.R8_UNORM, GalImageFormat.R8_SINT, GalImageFormat.R8_UINT, null, null, null) },
|
||||
{ GalTextureFormat.R32G32B32A32, new TextureDescriptor(TextureReader.Read16Bpp, null, null, GalImageFormat.R32G32B32A32_SINT, GalImageFormat.R32G32B32A32_UINT, GalImageFormat.R32G32B32A32_SFLOAT, null, null) },
|
||||
{ GalTextureFormat.R32G32, new TextureDescriptor(TextureReader.Read8Bpp, null, null, GalImageFormat.R32G32_SINT, GalImageFormat.R32G32_UINT, GalImageFormat.R32G32_SFLOAT, null, null) },
|
||||
{ GalTextureFormat.R32, new TextureDescriptor(TextureReader.Read4Bpp, null, null, GalImageFormat.R32_SINT, GalImageFormat.R32_UINT, GalImageFormat.R32_SFLOAT, null, null) },
|
||||
|
||||
{ GalTextureFormat.A4B4G4R4, new TextureDescriptor(TextureReader.Read2Bpp, Unorm: GalImageFormat.R4G4B4A4_UNORM_PACK16_REVERSED) }, //TODO: Reverse this one in the reader
|
||||
{ GalTextureFormat.A1B5G5R5, new TextureDescriptor(TextureReader.Read5551, Unorm: GalImageFormat.A1R5G5B5_UNORM_PACK16) },
|
||||
{ GalTextureFormat.B5G6R5, new TextureDescriptor(TextureReader.Read565, Unorm: GalImageFormat.B5G6R5_UNORM_PACK16) },
|
||||
{ GalTextureFormat.BF10GF11RF11, new TextureDescriptor(TextureReader.Read4Bpp, Float: GalImageFormat.B10G11R11_UFLOAT_PACK32) },
|
||||
|
||||
//Zeta formats
|
||||
{ GalTextureFormat.ZF32, new TextureDescriptor(TextureReader.Read4Bpp, Float: GalImageFormat.D32_SFLOAT) },
|
||||
{ GalTextureFormat.Z24S8, new TextureDescriptor(TextureReader.Read4Bpp, Unorm: GalImageFormat.D24_UNORM_S8_UINT) },
|
||||
{ GalTextureFormat.ZF32_X24S8, new TextureDescriptor(TextureReader.Read8Bpp, Unorm: GalImageFormat.D32_SFLOAT_S8_UINT) },
|
||||
|
||||
//Compressed formats
|
||||
{ GalTextureFormat.BC4, new TextureDescriptor(TextureReader.Read8Bpt4x4, Snorm: GalImageFormat.BC4_SNORM_BLOCK, Unorm: GalImageFormat.BC4_UNORM_BLOCK) },
|
||||
{ GalTextureFormat.BC5, new TextureDescriptor(TextureReader.Read16BptCompressedTexture4x4, Snorm: GalImageFormat.BC5_SNORM_BLOCK, Unorm: GalImageFormat.BC5_UNORM_BLOCK) },
|
||||
|
||||
{ GalTextureFormat.BC7U, new TextureDescriptor(TextureReader.Read16BptCompressedTexture4x4, Unorm: GalImageFormat.BC7_UNORM_BLOCK) },
|
||||
{ GalTextureFormat.BC1, new TextureDescriptor(TextureReader.Read8Bpt4x4, Unorm: GalImageFormat.BC1_RGBA_UNORM_BLOCK) },
|
||||
{ GalTextureFormat.BC2, new TextureDescriptor(TextureReader.Read16BptCompressedTexture4x4, Unorm: GalImageFormat.BC2_UNORM_BLOCK) },
|
||||
{ GalTextureFormat.BC3, new TextureDescriptor(TextureReader.Read16BptCompressedTexture4x4, Unorm: GalImageFormat.BC3_UNORM_BLOCK) },
|
||||
{ GalTextureFormat.BC6H_SF16, new TextureDescriptor(TextureReader.Read16BptCompressedTexture4x4, Unorm: GalImageFormat.BC6H_SFLOAT_BLOCK) },
|
||||
{ GalTextureFormat.BC6H_UF16, new TextureDescriptor(TextureReader.Read16BptCompressedTexture4x4, Unorm: GalImageFormat.BC6H_UFLOAT_BLOCK) },
|
||||
|
||||
{ GalTextureFormat.Astc2D4x4, new TextureDescriptor(TextureReader.Read16BptCompressedTexture4x4, Unorm: GalImageFormat.ASTC_4x4_UNORM_BLOCK) },
|
||||
{ GalTextureFormat.Astc2D5x5, new TextureDescriptor(TextureReader.Read16BptCompressedTexture5x5, Unorm: GalImageFormat.ASTC_5x5_UNORM_BLOCK) },
|
||||
{ GalTextureFormat.Astc2D6x6, new TextureDescriptor(TextureReader.Read16BptCompressedTexture6x6, Unorm: GalImageFormat.ASTC_6x6_UNORM_BLOCK) },
|
||||
{ GalTextureFormat.Astc2D8x8, new TextureDescriptor(TextureReader.Read16BptCompressedTexture8x8, Unorm: GalImageFormat.ASTC_8x8_UNORM_BLOCK) },
|
||||
{ GalTextureFormat.Astc2D10x10, new TextureDescriptor(TextureReader.Read16BptCompressedTexture10x10, Unorm: GalImageFormat.ASTC_10x10_UNORM_BLOCK) },
|
||||
{ GalTextureFormat.Astc2D12x12, new TextureDescriptor(TextureReader.Read16BptCompressedTexture12x12, Unorm: GalImageFormat.ASTC_12x12_UNORM_BLOCK) },
|
||||
{ GalTextureFormat.Astc2D5x4, new TextureDescriptor(TextureReader.Read16BptCompressedTexture5x4, Unorm: GalImageFormat.ASTC_5x4_UNORM_BLOCK) },
|
||||
{ GalTextureFormat.Astc2D6x5, new TextureDescriptor(TextureReader.Read16BptCompressedTexture6x5, Unorm: GalImageFormat.ASTC_6x5_UNORM_BLOCK) },
|
||||
{ GalTextureFormat.Astc2D8x6, new TextureDescriptor(TextureReader.Read16BptCompressedTexture8x6, Unorm: GalImageFormat.ASTC_8x6_UNORM_BLOCK) },
|
||||
{ GalTextureFormat.Astc2D10x8, new TextureDescriptor(TextureReader.Read16BptCompressedTexture10x8, Unorm: GalImageFormat.ASTC_10x8_UNORM_BLOCK) },
|
||||
{ GalTextureFormat.Astc2D12x10, new TextureDescriptor(TextureReader.Read16BptCompressedTexture12x10, Unorm: GalImageFormat.ASTC_12x10_UNORM_BLOCK) },
|
||||
{ GalTextureFormat.Astc2D8x5, new TextureDescriptor(TextureReader.Read16BptCompressedTexture8x5, Unorm: GalImageFormat.ASTC_8x5_UNORM_BLOCK) },
|
||||
{ GalTextureFormat.Astc2D10x5, new TextureDescriptor(TextureReader.Read16BptCompressedTexture10x5, Unorm: GalImageFormat.ASTC_10x5_UNORM_BLOCK) },
|
||||
{ GalTextureFormat.Astc2D10x6, new TextureDescriptor(TextureReader.Read16BptCompressedTexture10x6, Unorm: GalImageFormat.ASTC_10x6_UNORM_BLOCK) },
|
||||
|
||||
};
|
||||
|
||||
private static readonly Dictionary<GalImageFormat, ImageDescriptor> s_ImageTable =
|
||||
new Dictionary<GalImageFormat, ImageDescriptor>()
|
||||
{
|
||||
{ GalImageFormat.R32G32B32A32_SFLOAT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R32G32B32A32_SINT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R32G32B32A32_UINT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R16G16B16A16_SFLOAT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R16G16B16A16_SINT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R16G16B16A16_UINT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R32G32_SFLOAT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R32G32_SINT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R32G32_UINT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.A8B8G8R8_SNORM_PACK32, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.A8B8G8R8_UNORM_PACK32, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.A8B8G8R8_SINT_PACK32, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.A8B8G8R8_UINT_PACK32, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.A2B10G10R10_SINT_PACK32, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.A2B10G10R10_SNORM_PACK32, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.A2B10G10R10_UINT_PACK32, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.A2B10G10R10_UNORM_PACK32, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R32_SFLOAT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R32_SINT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R32_UINT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.BC6H_SFLOAT_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.BC6H_UFLOAT_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.A1R5G5B5_UNORM_PACK16, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.B5G6R5_UNORM_PACK16, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.BC7_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R16G16_SFLOAT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R16G16_SINT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R16G16_SNORM, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R16G16_UNORM, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R8G8_SINT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R8G8_SNORM, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R8G8_UINT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R8G8_UNORM, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R16_SFLOAT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R16_SINT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R16_SNORM, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R16_UINT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R16_UNORM, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R8_SINT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R8_SNORM, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R8_UINT, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.R8_UNORM, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.B10G11R11_UFLOAT_PACK32, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.BC1_RGBA_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.BC2_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.BC3_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.BC4_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.BC5_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.ASTC_4x4_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.ASTC_5x5_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.ASTC_6x6_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.ASTC_8x8_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.ASTC_10x10_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.ASTC_12x12_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.ASTC_5x4_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.ASTC_6x5_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.ASTC_8x6_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.ASTC_10x8_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.ASTC_12x10_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.ASTC_8x5_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.ASTC_10x5_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
{ GalImageFormat.ASTC_10x6_UNORM_BLOCK, new ImageDescriptor(true, false, false) },
|
||||
|
||||
{ GalImageFormat.D24_UNORM_S8_UINT, new ImageDescriptor(false, true, true) },
|
||||
{ GalImageFormat.D32_SFLOAT, new ImageDescriptor(false, true, false) },
|
||||
{ GalImageFormat.D16_UNORM, new ImageDescriptor(false, true, false) },
|
||||
{ GalImageFormat.D32_SFLOAT_S8_UINT, new ImageDescriptor(false, true, true) },
|
||||
|
||||
{ GalImageFormat.R4G4B4A4_UNORM_PACK16_REVERSED, new ImageDescriptor(true, false, false) }
|
||||
};
|
||||
|
||||
public static GalImageFormat ConvertTexture(
|
||||
GalTextureFormat Format,
|
||||
GalTextureType RType,
|
||||
GalTextureType GType,
|
||||
GalTextureType BType,
|
||||
GalTextureType AType)
|
||||
{
|
||||
if (RType != GType || RType != BType || RType != AType)
|
||||
{
|
||||
throw new NotImplementedException("Per component types are not implemented");
|
||||
}
|
||||
|
||||
TextureDescriptor Descriptor = GetTextureDescriptor(Format);
|
||||
|
||||
GalTextureType Type = RType;
|
||||
|
||||
GalImageFormat? ImageFormat;
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case GalTextureType.Snorm: ImageFormat = Descriptor.Snorm; break;
|
||||
case GalTextureType.Unorm: ImageFormat = Descriptor.Unorm; break;
|
||||
case GalTextureType.Sint: ImageFormat = Descriptor.Sint; break;
|
||||
case GalTextureType.Uint: ImageFormat = Descriptor.Uint; break;
|
||||
case GalTextureType.Float: ImageFormat = Descriptor.Float; break;
|
||||
case GalTextureType.Snorm_Force_Fp16: ImageFormat = Descriptor.Snorm_Force_Fp16; break;
|
||||
case GalTextureType.Unorm_Force_Fp16: ImageFormat = Descriptor.Unorm_Force_Fp16; break;
|
||||
|
||||
default: throw new NotImplementedException("Unknown component type " + ((int)Type).ToString("x2"));
|
||||
}
|
||||
|
||||
if (!ImageFormat.HasValue)
|
||||
{
|
||||
throw new NotImplementedException("Texture with format " + Format +
|
||||
" and component type " + Type + " is not implemented");
|
||||
}
|
||||
|
||||
return ImageFormat.Value;
|
||||
}
|
||||
|
||||
public static GalImageFormat ConvertFrameBuffer(GalFrameBufferFormat Format)
|
||||
{
|
||||
switch (Format)
|
||||
{
|
||||
case GalFrameBufferFormat.R32Float: return GalImageFormat.R32_SFLOAT;
|
||||
case GalFrameBufferFormat.RGB10A2Unorm: return GalImageFormat.A2B10G10R10_UNORM_PACK32;
|
||||
case GalFrameBufferFormat.RGBA8Srgb: return GalImageFormat.A8B8G8R8_SRGB_PACK32;
|
||||
case GalFrameBufferFormat.RGBA16Float: return GalImageFormat.R16G16B16A16_SFLOAT;
|
||||
case GalFrameBufferFormat.R16Float: return GalImageFormat.R16_SFLOAT;
|
||||
case GalFrameBufferFormat.R8Unorm: return GalImageFormat.R8_UNORM;
|
||||
case GalFrameBufferFormat.RGBA8Unorm: return GalImageFormat.A8B8G8R8_UNORM_PACK32;
|
||||
case GalFrameBufferFormat.R11G11B10Float: return GalImageFormat.B10G11R11_UFLOAT_PACK32;
|
||||
case GalFrameBufferFormat.RGBA32Float: return GalImageFormat.R32G32B32A32_SFLOAT;
|
||||
case GalFrameBufferFormat.RG16Snorm: return GalImageFormat.R16G16_SNORM;
|
||||
case GalFrameBufferFormat.RG16Float: return GalImageFormat.R16G16_SFLOAT;
|
||||
case GalFrameBufferFormat.RG8Snorm: return GalImageFormat.R8_SNORM;
|
||||
case GalFrameBufferFormat.RGBA8Snorm: return GalImageFormat.A8B8G8R8_SNORM_PACK32;
|
||||
case GalFrameBufferFormat.RG8Unorm: return GalImageFormat.R8G8_UNORM;
|
||||
case GalFrameBufferFormat.BGRA8Unorm: return GalImageFormat.A8B8G8R8_UNORM_PACK32;
|
||||
case GalFrameBufferFormat.BGRA8Srgb: return GalImageFormat.A8B8G8R8_SRGB_PACK32;
|
||||
case GalFrameBufferFormat.RG32Float: return GalImageFormat.R32G32_SFLOAT;
|
||||
case GalFrameBufferFormat.RG32Sint: return GalImageFormat.R32G32_SINT;
|
||||
case GalFrameBufferFormat.RG32Uint: return GalImageFormat.R32G32_UINT;
|
||||
}
|
||||
|
||||
throw new NotImplementedException(Format.ToString());
|
||||
}
|
||||
|
||||
public static GalImageFormat ConvertZeta(GalZetaFormat Format)
|
||||
{
|
||||
switch (Format)
|
||||
{
|
||||
case GalZetaFormat.Z32Float: return GalImageFormat.D32_SFLOAT;
|
||||
case GalZetaFormat.S8Z24Unorm: return GalImageFormat.D24_UNORM_S8_UINT;
|
||||
case GalZetaFormat.Z16Unorm: return GalImageFormat.D16_UNORM;
|
||||
case GalZetaFormat.Z32S8X24Float: return GalImageFormat.D32_SFLOAT_S8_UINT;
|
||||
}
|
||||
|
||||
throw new NotImplementedException(Format.ToString());
|
||||
}
|
||||
|
||||
public static int GetImageSize(GalImage Image)
|
||||
{
|
||||
switch (Image.Format)
|
||||
{
|
||||
case GalImageFormat.R32G32B32A32_SFLOAT:
|
||||
case GalImageFormat.R32G32B32A32_SINT:
|
||||
case GalImageFormat.R32G32B32A32_UINT:
|
||||
return Image.Width * Image.Height * 16;
|
||||
|
||||
case GalImageFormat.R16G16B16A16_SFLOAT:
|
||||
case GalImageFormat.R16G16B16A16_SINT:
|
||||
case GalImageFormat.R16G16B16A16_SNORM:
|
||||
case GalImageFormat.R16G16B16A16_UINT:
|
||||
case GalImageFormat.R16G16B16A16_UNORM:
|
||||
case GalImageFormat.D32_SFLOAT_S8_UINT:
|
||||
case GalImageFormat.R32G32_SFLOAT:
|
||||
case GalImageFormat.R32G32_SINT:
|
||||
case GalImageFormat.R32G32_UINT:
|
||||
return Image.Width * Image.Height * 8;
|
||||
|
||||
case GalImageFormat.A8B8G8R8_SINT_PACK32:
|
||||
case GalImageFormat.A8B8G8R8_SNORM_PACK32:
|
||||
case GalImageFormat.A8B8G8R8_UINT_PACK32:
|
||||
case GalImageFormat.A8B8G8R8_UNORM_PACK32:
|
||||
case GalImageFormat.A8B8G8R8_SRGB_PACK32:
|
||||
case GalImageFormat.A2B10G10R10_SINT_PACK32:
|
||||
case GalImageFormat.A2B10G10R10_SNORM_PACK32:
|
||||
case GalImageFormat.A2B10G10R10_UINT_PACK32:
|
||||
case GalImageFormat.A2B10G10R10_UNORM_PACK32:
|
||||
case GalImageFormat.R16G16_SFLOAT:
|
||||
case GalImageFormat.R16G16_SINT:
|
||||
case GalImageFormat.R16G16_SNORM:
|
||||
case GalImageFormat.R16G16_UINT:
|
||||
case GalImageFormat.R16G16_UNORM:
|
||||
case GalImageFormat.R32_SFLOAT:
|
||||
case GalImageFormat.R32_SINT:
|
||||
case GalImageFormat.R32_UINT:
|
||||
case GalImageFormat.D32_SFLOAT:
|
||||
case GalImageFormat.B10G11R11_UFLOAT_PACK32:
|
||||
case GalImageFormat.D24_UNORM_S8_UINT:
|
||||
return Image.Width * Image.Height * 4;
|
||||
|
||||
case GalImageFormat.B4G4R4A4_UNORM_PACK16:
|
||||
case GalImageFormat.A1R5G5B5_UNORM_PACK16:
|
||||
case GalImageFormat.B5G6R5_UNORM_PACK16:
|
||||
case GalImageFormat.R8G8_SINT:
|
||||
case GalImageFormat.R8G8_SNORM:
|
||||
case GalImageFormat.R8G8_UINT:
|
||||
case GalImageFormat.R8G8_UNORM:
|
||||
case GalImageFormat.R16_SFLOAT:
|
||||
case GalImageFormat.R16_SINT:
|
||||
case GalImageFormat.R16_SNORM:
|
||||
case GalImageFormat.R16_UINT:
|
||||
case GalImageFormat.R16_UNORM:
|
||||
case GalImageFormat.D16_UNORM:
|
||||
return Image.Width * Image.Height * 2;
|
||||
|
||||
case GalImageFormat.R8_SINT:
|
||||
case GalImageFormat.R8_SNORM:
|
||||
case GalImageFormat.R8_UINT:
|
||||
case GalImageFormat.R8_UNORM:
|
||||
return Image.Width * Image.Height;
|
||||
|
||||
case GalImageFormat.BC1_RGBA_UNORM_BLOCK:
|
||||
case GalImageFormat.BC4_SNORM_BLOCK:
|
||||
case GalImageFormat.BC4_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 4, 4, 8);
|
||||
}
|
||||
|
||||
case GalImageFormat.BC6H_SFLOAT_BLOCK:
|
||||
case GalImageFormat.BC6H_UFLOAT_BLOCK:
|
||||
case GalImageFormat.BC7_UNORM_BLOCK:
|
||||
case GalImageFormat.BC2_UNORM_BLOCK:
|
||||
case GalImageFormat.BC3_UNORM_BLOCK:
|
||||
case GalImageFormat.BC5_SNORM_BLOCK:
|
||||
case GalImageFormat.BC5_UNORM_BLOCK:
|
||||
case GalImageFormat.ASTC_4x4_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 4, 4, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_5x5_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 5, 5, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_6x6_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 6, 6, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_8x8_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 8, 8, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_10x10_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 10, 10, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_12x12_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 12, 12, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_5x4_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 5, 4, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_6x5_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 6, 5, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_8x6_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 8, 6, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_10x8_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 10, 8, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_12x10_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 12, 10, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_8x5_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 8, 5, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_10x5_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 10, 5, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_10x6_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 10, 6, 16);
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotImplementedException(Image.Format.ToString());
|
||||
}
|
||||
|
||||
public static bool HasColor(GalImage Image)
|
||||
{
|
||||
return s_ImageTable[Image.Format].HasColor;
|
||||
}
|
||||
|
||||
public static bool HasDepth(GalImage Image)
|
||||
{
|
||||
return s_ImageTable[Image.Format].HasDepth;
|
||||
}
|
||||
|
||||
public static bool HasStencil(GalImage Image)
|
||||
{
|
||||
return s_ImageTable[Image.Format].HasStencil;
|
||||
}
|
||||
|
||||
public static TextureDescriptor GetTextureDescriptor(GalTextureFormat Format)
|
||||
{
|
||||
if (s_TextureTable.TryGetValue(Format, out TextureDescriptor Descriptor))
|
||||
{
|
||||
return Descriptor;
|
||||
}
|
||||
|
||||
throw new NotImplementedException("Texture with format code " + ((int)Format).ToString("x2") + " not implemented");
|
||||
}
|
||||
|
||||
private static int CompressedTextureSize(int TextureWidth, int TextureHeight, int BlockWidth, int BlockHeight, int Bpb)
|
||||
{
|
||||
int W = (TextureWidth + (BlockWidth - 1)) / BlockWidth;
|
||||
int H = (TextureHeight + (BlockHeight - 1)) / BlockHeight;
|
||||
|
||||
return W * H * Bpb;
|
||||
}
|
||||
}
|
||||
}
|
37
Ryujinx.Graphics/Texture/TextureDescriptor.cs
Normal file
37
Ryujinx.Graphics/Texture/TextureDescriptor.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using Ryujinx.Graphics.Gal;
|
||||
|
||||
namespace Ryujinx.Graphics.Texture
|
||||
{
|
||||
struct TextureDescriptor
|
||||
{
|
||||
public TextureReaderDelegate Reader;
|
||||
|
||||
public GalImageFormat? Snorm;
|
||||
public GalImageFormat? Unorm;
|
||||
public GalImageFormat? Sint;
|
||||
public GalImageFormat? Uint;
|
||||
public GalImageFormat? Float;
|
||||
public GalImageFormat? Snorm_Force_Fp16;
|
||||
public GalImageFormat? Unorm_Force_Fp16;
|
||||
|
||||
public TextureDescriptor(
|
||||
TextureReaderDelegate Reader,
|
||||
GalImageFormat? Snorm = null,
|
||||
GalImageFormat? Unorm = null,
|
||||
GalImageFormat? Sint = null,
|
||||
GalImageFormat? Uint = null,
|
||||
GalImageFormat? Float = null,
|
||||
GalImageFormat? Snorm_Force_Fp16 = null,
|
||||
GalImageFormat? Unorm_Force_Fp16 = null)
|
||||
{
|
||||
this.Reader = Reader;
|
||||
this.Snorm = Snorm;
|
||||
this.Unorm = Unorm;
|
||||
this.Sint = Sint;
|
||||
this.Uint = Uint;
|
||||
this.Float = Float;
|
||||
this.Snorm_Force_Fp16 = Snorm_Force_Fp16;
|
||||
this.Unorm_Force_Fp16 = Unorm_Force_Fp16;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Texture
|
|||
GalTextureType BType = (GalTextureType)((Tic[0] >> 13) & 7);
|
||||
GalTextureType AType = (GalTextureType)((Tic[0] >> 16) & 7);
|
||||
|
||||
GalImageFormat Format = ImageFormatConverter.ConvertTexture((GalTextureFormat)(Tic[0] & 0x7f), RType, GType, BType, AType);
|
||||
GalImageFormat Format = ImageTable.ConvertTexture((GalTextureFormat)(Tic[0] & 0x7f), RType, GType, BType, AType);
|
||||
|
||||
GalTextureSource XSource = (GalTextureSource)((Tic[0] >> 19) & 7);
|
||||
GalTextureSource YSource = (GalTextureSource)((Tic[0] >> 22) & 7);
|
||||
|
|
|
@ -30,165 +30,6 @@ namespace Ryujinx.Graphics.Texture
|
|||
throw new NotImplementedException(Texture.Swizzle.ToString());
|
||||
}
|
||||
|
||||
public static int GetTextureSize(GalImage Image)
|
||||
{
|
||||
switch (Image.Format)
|
||||
{
|
||||
case GalImageFormat.R32G32B32A32_SFLOAT:
|
||||
case GalImageFormat.R32G32B32A32_SINT:
|
||||
case GalImageFormat.R32G32B32A32_UINT:
|
||||
return Image.Width * Image.Height * 16;
|
||||
|
||||
case GalImageFormat.R16G16B16A16_SFLOAT:
|
||||
case GalImageFormat.R16G16B16A16_SINT:
|
||||
case GalImageFormat.R16G16B16A16_SNORM:
|
||||
case GalImageFormat.R16G16B16A16_UINT:
|
||||
case GalImageFormat.R16G16B16A16_UNORM:
|
||||
case GalImageFormat.D32_SFLOAT_S8_UINT:
|
||||
case GalImageFormat.R32G32_SFLOAT:
|
||||
case GalImageFormat.R32G32_SINT:
|
||||
case GalImageFormat.R32G32_UINT:
|
||||
return Image.Width * Image.Height * 8;
|
||||
|
||||
case GalImageFormat.A8B8G8R8_SINT_PACK32:
|
||||
case GalImageFormat.A8B8G8R8_SNORM_PACK32:
|
||||
case GalImageFormat.A8B8G8R8_UINT_PACK32:
|
||||
case GalImageFormat.A8B8G8R8_UNORM_PACK32:
|
||||
case GalImageFormat.A8B8G8R8_SRGB_PACK32:
|
||||
case GalImageFormat.A2B10G10R10_SINT_PACK32:
|
||||
case GalImageFormat.A2B10G10R10_SNORM_PACK32:
|
||||
case GalImageFormat.A2B10G10R10_UINT_PACK32:
|
||||
case GalImageFormat.A2B10G10R10_UNORM_PACK32:
|
||||
case GalImageFormat.R16G16_SFLOAT:
|
||||
case GalImageFormat.R16G16_SINT:
|
||||
case GalImageFormat.R16G16_SNORM:
|
||||
case GalImageFormat.R16G16_UINT:
|
||||
case GalImageFormat.R16G16_UNORM:
|
||||
case GalImageFormat.R32_SFLOAT:
|
||||
case GalImageFormat.R32_SINT:
|
||||
case GalImageFormat.R32_UINT:
|
||||
case GalImageFormat.D32_SFLOAT:
|
||||
case GalImageFormat.B10G11R11_UFLOAT_PACK32:
|
||||
case GalImageFormat.D24_UNORM_S8_UINT:
|
||||
return Image.Width * Image.Height * 4;
|
||||
|
||||
case GalImageFormat.B4G4R4A4_UNORM_PACK16:
|
||||
case GalImageFormat.A1R5G5B5_UNORM_PACK16:
|
||||
case GalImageFormat.B5G6R5_UNORM_PACK16:
|
||||
case GalImageFormat.R8G8_SINT:
|
||||
case GalImageFormat.R8G8_SNORM:
|
||||
case GalImageFormat.R8G8_UINT:
|
||||
case GalImageFormat.R8G8_UNORM:
|
||||
case GalImageFormat.R16_SFLOAT:
|
||||
case GalImageFormat.R16_SINT:
|
||||
case GalImageFormat.R16_SNORM:
|
||||
case GalImageFormat.R16_UINT:
|
||||
case GalImageFormat.R16_UNORM:
|
||||
case GalImageFormat.D16_UNORM:
|
||||
return Image.Width * Image.Height * 2;
|
||||
|
||||
case GalImageFormat.R8_SINT:
|
||||
case GalImageFormat.R8_SNORM:
|
||||
case GalImageFormat.R8_UINT:
|
||||
case GalImageFormat.R8_UNORM:
|
||||
return Image.Width * Image.Height;
|
||||
|
||||
case GalImageFormat.BC1_RGBA_UNORM_BLOCK:
|
||||
case GalImageFormat.BC4_SNORM_BLOCK:
|
||||
case GalImageFormat.BC4_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 4, 4, 8);
|
||||
}
|
||||
|
||||
case GalImageFormat.BC6H_SFLOAT_BLOCK:
|
||||
case GalImageFormat.BC6H_UFLOAT_BLOCK:
|
||||
case GalImageFormat.BC7_UNORM_BLOCK:
|
||||
case GalImageFormat.BC2_UNORM_BLOCK:
|
||||
case GalImageFormat.BC3_UNORM_BLOCK:
|
||||
case GalImageFormat.BC5_SNORM_BLOCK:
|
||||
case GalImageFormat.BC5_UNORM_BLOCK:
|
||||
case GalImageFormat.ASTC_4x4_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 4, 4, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_5x5_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 5, 5, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_6x6_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 6, 6, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_8x8_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 8, 8, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_10x10_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 10, 10, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_12x12_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 12, 12, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_5x4_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 5, 4, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_6x5_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 6, 5, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_8x6_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 8, 6, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_10x8_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 10, 8, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_12x10_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 12, 10, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_8x5_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 8, 5, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_10x5_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 10, 5, 16);
|
||||
}
|
||||
|
||||
case GalImageFormat.ASTC_10x6_UNORM_BLOCK:
|
||||
{
|
||||
return CompressedTextureSize(Image.Width, Image.Height, 10, 6, 16);
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotImplementedException(Image.Format.ToString());
|
||||
}
|
||||
|
||||
public static int CompressedTextureSize(int TextureWidth, int TextureHeight, int BlockWidth, int BlockHeight, int Bpb)
|
||||
{
|
||||
int W = (TextureWidth + (BlockWidth - 1)) / BlockWidth;
|
||||
int H = (TextureHeight + (BlockHeight - 1)) / BlockHeight;
|
||||
|
||||
return W * H * Bpb;
|
||||
}
|
||||
|
||||
public static (AMemory Memory, long Position) GetMemoryAndPosition(
|
||||
IAMemory Memory,
|
||||
long Position)
|
||||
|
|
|
@ -4,56 +4,18 @@ using System;
|
|||
|
||||
namespace Ryujinx.Graphics.Texture
|
||||
{
|
||||
delegate byte[] TextureReaderDelegate(IAMemory Memory, TextureInfo Texture);
|
||||
|
||||
public static class TextureReader
|
||||
{
|
||||
public static byte[] Read(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
switch (Texture.Format)
|
||||
{
|
||||
case GalTextureFormat.R32G32B32A32: return Read16Bpp (Memory, Texture);
|
||||
case GalTextureFormat.R16G16B16A16: return Read8Bpp (Memory, Texture);
|
||||
case GalTextureFormat.R32G32: return Read8Bpp (Memory, Texture);
|
||||
case GalTextureFormat.A8B8G8R8: return Read4Bpp (Memory, Texture);
|
||||
case GalTextureFormat.A2B10G10R10: return Read4Bpp (Memory, Texture);
|
||||
case GalTextureFormat.R32: return Read4Bpp (Memory, Texture);
|
||||
case GalTextureFormat.BF10GF11RF11: return Read4Bpp (Memory, Texture);
|
||||
case GalTextureFormat.Z24S8: return Read4Bpp (Memory, Texture);
|
||||
case GalTextureFormat.A1B5G5R5: return Read5551 (Memory, Texture);
|
||||
case GalTextureFormat.B5G6R5: return Read565 (Memory, Texture);
|
||||
case GalTextureFormat.A4B4G4R4: return Read2Bpp (Memory, Texture);
|
||||
case GalTextureFormat.G8R8: return Read2Bpp (Memory, Texture);
|
||||
case GalTextureFormat.R16: return Read2Bpp (Memory, Texture);
|
||||
case GalTextureFormat.R8: return Read1Bpp (Memory, Texture);
|
||||
case GalTextureFormat.BC6H_SF16: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
||||
case GalTextureFormat.BC6H_UF16: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
||||
case GalTextureFormat.BC7U: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
||||
case GalTextureFormat.BC1: return Read8Bpt4x4 (Memory, Texture);
|
||||
case GalTextureFormat.BC2: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
||||
case GalTextureFormat.BC3: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
||||
case GalTextureFormat.BC4: return Read8Bpt4x4 (Memory, Texture);
|
||||
case GalTextureFormat.BC5: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
||||
case GalTextureFormat.ZF32: return Read4Bpp (Memory, Texture);
|
||||
case GalTextureFormat.ZF32_X24S8: return Read8Bpp (Memory, Texture);
|
||||
case GalTextureFormat.Astc2D4x4: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
||||
case GalTextureFormat.Astc2D5x5: return Read16BptCompressedTexture(Memory, Texture, 5, 5);
|
||||
case GalTextureFormat.Astc2D6x6: return Read16BptCompressedTexture(Memory, Texture, 6, 6);
|
||||
case GalTextureFormat.Astc2D8x8: return Read16BptCompressedTexture(Memory, Texture, 8, 8);
|
||||
case GalTextureFormat.Astc2D10x10: return Read16BptCompressedTexture(Memory, Texture, 10, 10);
|
||||
case GalTextureFormat.Astc2D12x12: return Read16BptCompressedTexture(Memory, Texture, 12, 12);
|
||||
case GalTextureFormat.Astc2D5x4: return Read16BptCompressedTexture(Memory, Texture, 5, 4);
|
||||
case GalTextureFormat.Astc2D6x5: return Read16BptCompressedTexture(Memory, Texture, 6, 5);
|
||||
case GalTextureFormat.Astc2D8x6: return Read16BptCompressedTexture(Memory, Texture, 8, 6);
|
||||
case GalTextureFormat.Astc2D10x8: return Read16BptCompressedTexture(Memory, Texture, 10, 8);
|
||||
case GalTextureFormat.Astc2D12x10: return Read16BptCompressedTexture(Memory, Texture, 12, 10);
|
||||
case GalTextureFormat.Astc2D8x5: return Read16BptCompressedTexture(Memory, Texture, 8, 5);
|
||||
case GalTextureFormat.Astc2D10x5: return Read16BptCompressedTexture(Memory, Texture, 10, 5);
|
||||
case GalTextureFormat.Astc2D10x6: return Read16BptCompressedTexture(Memory, Texture, 10, 6);
|
||||
}
|
||||
TextureReaderDelegate Reader = ImageTable.GetTextureDescriptor(Texture.Format).Reader;
|
||||
|
||||
throw new NotImplementedException("0x" + ((int)Texture.Format).ToString("x2"));
|
||||
return Reader(Memory, Texture);
|
||||
}
|
||||
|
||||
private unsafe static byte[] Read1Bpp(IAMemory Memory, TextureInfo Texture)
|
||||
public unsafe static byte[] Read1Bpp(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
int Width = Texture.Width;
|
||||
int Height = Texture.Height;
|
||||
|
@ -86,7 +48,7 @@ namespace Ryujinx.Graphics.Texture
|
|||
return Output;
|
||||
}
|
||||
|
||||
private unsafe static byte[] Read5551(IAMemory Memory, TextureInfo Texture)
|
||||
public unsafe static byte[] Read5551(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
int Width = Texture.Width;
|
||||
int Height = Texture.Height;
|
||||
|
@ -124,7 +86,7 @@ namespace Ryujinx.Graphics.Texture
|
|||
return Output;
|
||||
}
|
||||
|
||||
private unsafe static byte[] Read565(IAMemory Memory, TextureInfo Texture)
|
||||
public unsafe static byte[] Read565(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
int Width = Texture.Width;
|
||||
int Height = Texture.Height;
|
||||
|
@ -161,7 +123,7 @@ namespace Ryujinx.Graphics.Texture
|
|||
return Output;
|
||||
}
|
||||
|
||||
private unsafe static byte[] Read2Bpp(IAMemory Memory, TextureInfo Texture)
|
||||
public unsafe static byte[] Read2Bpp(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
int Width = Texture.Width;
|
||||
int Height = Texture.Height;
|
||||
|
@ -194,7 +156,7 @@ namespace Ryujinx.Graphics.Texture
|
|||
return Output;
|
||||
}
|
||||
|
||||
private unsafe static byte[] Read4Bpp(IAMemory Memory, TextureInfo Texture)
|
||||
public unsafe static byte[] Read4Bpp(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
int Width = Texture.Width;
|
||||
int Height = Texture.Height;
|
||||
|
@ -227,7 +189,7 @@ namespace Ryujinx.Graphics.Texture
|
|||
return Output;
|
||||
}
|
||||
|
||||
private unsafe static byte[] Read8Bpp(IAMemory Memory, TextureInfo Texture)
|
||||
public unsafe static byte[] Read8Bpp(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
int Width = Texture.Width;
|
||||
int Height = Texture.Height;
|
||||
|
@ -260,7 +222,7 @@ namespace Ryujinx.Graphics.Texture
|
|||
return Output;
|
||||
}
|
||||
|
||||
private unsafe static byte[] Read16Bpp(IAMemory Memory, TextureInfo Texture)
|
||||
public unsafe static byte[] Read16Bpp(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
int Width = Texture.Width;
|
||||
int Height = Texture.Height;
|
||||
|
@ -295,7 +257,7 @@ namespace Ryujinx.Graphics.Texture
|
|||
return Output;
|
||||
}
|
||||
|
||||
private unsafe static byte[] Read8Bpt4x4(IAMemory Memory, TextureInfo Texture)
|
||||
public unsafe static byte[] Read8Bpt4x4(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
int Width = (Texture.Width + 3) / 4;
|
||||
int Height = (Texture.Height + 3) / 4;
|
||||
|
@ -362,5 +324,75 @@ namespace Ryujinx.Graphics.Texture
|
|||
|
||||
return Output;
|
||||
}
|
||||
|
||||
public static byte[] Read16BptCompressedTexture4x4(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
||||
}
|
||||
|
||||
public static byte[] Read16BptCompressedTexture5x5(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
return Read16BptCompressedTexture(Memory, Texture, 5, 5);
|
||||
}
|
||||
|
||||
public static byte[] Read16BptCompressedTexture6x6(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
return Read16BptCompressedTexture(Memory, Texture, 6, 6);
|
||||
}
|
||||
|
||||
public static byte[] Read16BptCompressedTexture8x8(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
return Read16BptCompressedTexture(Memory, Texture, 8, 8);
|
||||
}
|
||||
|
||||
public static byte[] Read16BptCompressedTexture10x10(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
return Read16BptCompressedTexture(Memory, Texture, 10, 10);
|
||||
}
|
||||
|
||||
public static byte[] Read16BptCompressedTexture12x12(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
return Read16BptCompressedTexture(Memory, Texture, 12, 12);
|
||||
}
|
||||
|
||||
public static byte[] Read16BptCompressedTexture5x4(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
return Read16BptCompressedTexture(Memory, Texture, 5, 4);
|
||||
}
|
||||
|
||||
public static byte[] Read16BptCompressedTexture6x5(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
return Read16BptCompressedTexture(Memory, Texture, 6, 5);
|
||||
}
|
||||
|
||||
public static byte[] Read16BptCompressedTexture8x6(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
return Read16BptCompressedTexture(Memory, Texture, 8, 6);
|
||||
}
|
||||
|
||||
public static byte[] Read16BptCompressedTexture10x8(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
return Read16BptCompressedTexture(Memory, Texture, 10, 8);
|
||||
}
|
||||
|
||||
public static byte[] Read16BptCompressedTexture12x10(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
return Read16BptCompressedTexture(Memory, Texture, 12, 10);
|
||||
}
|
||||
|
||||
public static byte[] Read16BptCompressedTexture8x5(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
return Read16BptCompressedTexture(Memory, Texture, 5, 5);
|
||||
}
|
||||
|
||||
public static byte[] Read16BptCompressedTexture10x5(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
return Read16BptCompressedTexture(Memory, Texture, 10, 5);
|
||||
}
|
||||
|
||||
public static byte[] Read16BptCompressedTexture10x6(IAMemory Memory, TextureInfo Texture)
|
||||
{
|
||||
return Read16BptCompressedTexture(Memory, Texture, 10, 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using ChocolArm64.Memory;
|
||||
using Ryujinx.Graphics.Gal;
|
||||
using Ryujinx.Graphics.Memory;
|
||||
|
||||
namespace Ryujinx.Graphics.Texture
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue