mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-23 17:25:37 +00:00
Add return of Texture Size and Bytes Per Pixel of ASTC2D 5x5, 6x6, 8x8, 10x10 and 12x12 (#249)
* return correct size of ASTC 5x5, 6x6, 8x8, 10x10 and 12x12 * return correct Bytes Per Pixel * Use method in order to get CompressedTextureSize * Add Read16BptCompressedTexture method * add Bpb integer argument
This commit is contained in:
parent
b233ae964f
commit
3b00333b0c
|
@ -51,10 +51,7 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
case GalTextureFormat.BC1:
|
case GalTextureFormat.BC1:
|
||||||
case GalTextureFormat.BC4:
|
case GalTextureFormat.BC4:
|
||||||
{
|
{
|
||||||
int W = (Texture.Width + 3) / 4;
|
return CompressedTextureSize(Texture.Width, Texture.Height, 4, 4, 8);
|
||||||
int H = (Texture.Height + 3) / 4;
|
|
||||||
|
|
||||||
return W * H * 8;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case GalTextureFormat.BC7U:
|
case GalTextureFormat.BC7U:
|
||||||
|
@ -63,16 +60,86 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
case GalTextureFormat.BC5:
|
case GalTextureFormat.BC5:
|
||||||
case GalTextureFormat.Astc2D4x4:
|
case GalTextureFormat.Astc2D4x4:
|
||||||
{
|
{
|
||||||
int W = (Texture.Width + 3) / 4;
|
return CompressedTextureSize(Texture.Width, Texture.Height, 4, 4, 16);
|
||||||
int H = (Texture.Height + 3) / 4;
|
}
|
||||||
|
|
||||||
return W * H * 16;
|
case GalTextureFormat.Astc2D5x5:
|
||||||
|
{
|
||||||
|
return CompressedTextureSize(Texture.Width, Texture.Height, 5, 5, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
case GalTextureFormat.Astc2D6x6:
|
||||||
|
{
|
||||||
|
return CompressedTextureSize(Texture.Width, Texture.Height, 6, 6, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
case GalTextureFormat.Astc2D8x8:
|
||||||
|
{
|
||||||
|
return CompressedTextureSize(Texture.Width, Texture.Height, 8, 8, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
case GalTextureFormat.Astc2D10x10:
|
||||||
|
{
|
||||||
|
return CompressedTextureSize(Texture.Width, Texture.Height, 10, 10, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
case GalTextureFormat.Astc2D12x12:
|
||||||
|
{
|
||||||
|
return CompressedTextureSize(Texture.Width, Texture.Height, 12, 12, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
case GalTextureFormat.Astc2D5x4:
|
||||||
|
{
|
||||||
|
return CompressedTextureSize(Texture.Width, Texture.Height, 5, 4, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
case GalTextureFormat.Astc2D6x5:
|
||||||
|
{
|
||||||
|
return CompressedTextureSize(Texture.Width, Texture.Height, 6, 5, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
case GalTextureFormat.Astc2D8x6:
|
||||||
|
{
|
||||||
|
return CompressedTextureSize(Texture.Width, Texture.Height, 8, 6, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
case GalTextureFormat.Astc2D10x8:
|
||||||
|
{
|
||||||
|
return CompressedTextureSize(Texture.Width, Texture.Height, 10, 8, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
case GalTextureFormat.Astc2D12x10:
|
||||||
|
{
|
||||||
|
return CompressedTextureSize(Texture.Width, Texture.Height, 12, 10, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
case GalTextureFormat.Astc2D8x5:
|
||||||
|
{
|
||||||
|
return CompressedTextureSize(Texture.Width, Texture.Height, 8, 5, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
case GalTextureFormat.Astc2D10x5:
|
||||||
|
{
|
||||||
|
return CompressedTextureSize(Texture.Width, Texture.Height, 10, 5, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
case GalTextureFormat.Astc2D10x6:
|
||||||
|
{
|
||||||
|
return CompressedTextureSize(Texture.Width, Texture.Height, 10, 6, 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new NotImplementedException(Texture.Format.ToString());
|
throw new NotImplementedException(Texture.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(
|
public static (AMemory Memory, long Position) GetMemoryAndPosition(
|
||||||
IAMemory Memory,
|
IAMemory Memory,
|
||||||
long Position)
|
long Position)
|
||||||
|
|
|
@ -19,14 +19,27 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
case GalTextureFormat.G8R8: return Read2Bpp (Memory, Texture);
|
case GalTextureFormat.G8R8: return Read2Bpp (Memory, Texture);
|
||||||
case GalTextureFormat.R16: return Read2Bpp (Memory, Texture);
|
case GalTextureFormat.R16: return Read2Bpp (Memory, Texture);
|
||||||
case GalTextureFormat.R8: return Read1Bpp (Memory, Texture);
|
case GalTextureFormat.R8: return Read1Bpp (Memory, Texture);
|
||||||
case GalTextureFormat.BC7U: return Read16Bpt4x4(Memory, Texture);
|
case GalTextureFormat.BC7U: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
||||||
case GalTextureFormat.BC1: return Read8Bpt4x4 (Memory, Texture);
|
case GalTextureFormat.BC1: return Read8Bpt4x4 (Memory, Texture);
|
||||||
case GalTextureFormat.BC2: return Read16Bpt4x4(Memory, Texture);
|
case GalTextureFormat.BC2: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
||||||
case GalTextureFormat.BC3: return Read16Bpt4x4(Memory, Texture);
|
case GalTextureFormat.BC3: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
||||||
case GalTextureFormat.BC4: return Read8Bpt4x4 (Memory, Texture);
|
case GalTextureFormat.BC4: return Read8Bpt4x4 (Memory, Texture);
|
||||||
case GalTextureFormat.BC5: return Read16Bpt4x4(Memory, Texture);
|
case GalTextureFormat.BC5: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
|
||||||
case GalTextureFormat.ZF32: return Read4Bpp (Memory, Texture);
|
case GalTextureFormat.ZF32: return Read4Bpp (Memory, Texture);
|
||||||
case GalTextureFormat.Astc2D4x4: return Read16Bpt4x4(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new NotImplementedException(Texture.Format.ToString());
|
throw new NotImplementedException(Texture.Format.ToString());
|
||||||
|
@ -307,10 +320,10 @@ namespace Ryujinx.HLE.Gpu.Texture
|
||||||
return Output;
|
return Output;
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe static byte[] Read16Bpt4x4(IAMemory Memory, TextureInfo Texture)
|
private unsafe static byte[] Read16BptCompressedTexture(IAMemory Memory, TextureInfo Texture, int BlockWidth, int BlockHeight)
|
||||||
{
|
{
|
||||||
int Width = (Texture.Width + 3) / 4;
|
int Width = (Texture.Width + (BlockWidth - 1)) / BlockWidth;
|
||||||
int Height = (Texture.Height + 3) / 4;
|
int Height = (Texture.Height + (BlockHeight - 1)) / BlockHeight;
|
||||||
|
|
||||||
byte[] Output = new byte[Width * Height * 16];
|
byte[] Output = new byte[Width * Height * 16];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue