aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/Gpu/Texture/TextureHelper.cs
diff options
context:
space:
mode:
authorgreggameplayer <33609333+greggameplayer@users.noreply.github.com>2018-07-13 02:27:59 +0200
committergdkchan <gab.dark.100@gmail.com>2018-07-12 21:27:59 -0300
commit3b00333b0ce21538e5ff361e3e41d89bee586d36 (patch)
treef4a47ba9c34205af6f0ae3eaad050e4ba1fb712e /Ryujinx.HLE/Gpu/Texture/TextureHelper.cs
parentb233ae964fcaae900cdefa6ce51b0edb2892dfaf (diff)
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
Diffstat (limited to 'Ryujinx.HLE/Gpu/Texture/TextureHelper.cs')
-rw-r--r--Ryujinx.HLE/Gpu/Texture/TextureHelper.cs83
1 files changed, 75 insertions, 8 deletions
diff --git a/Ryujinx.HLE/Gpu/Texture/TextureHelper.cs b/Ryujinx.HLE/Gpu/Texture/TextureHelper.cs
index 3c633b69..6b9a3063 100644
--- a/Ryujinx.HLE/Gpu/Texture/TextureHelper.cs
+++ b/Ryujinx.HLE/Gpu/Texture/TextureHelper.cs
@@ -51,10 +51,7 @@ namespace Ryujinx.HLE.Gpu.Texture
case GalTextureFormat.BC1:
case GalTextureFormat.BC4:
{
- int W = (Texture.Width + 3) / 4;
- int H = (Texture.Height + 3) / 4;
-
- return W * H * 8;
+ return CompressedTextureSize(Texture.Width, Texture.Height, 4, 4, 8);
}
case GalTextureFormat.BC7U:
@@ -63,16 +60,86 @@ namespace Ryujinx.HLE.Gpu.Texture
case GalTextureFormat.BC5:
case GalTextureFormat.Astc2D4x4:
{
- int W = (Texture.Width + 3) / 4;
- int H = (Texture.Height + 3) / 4;
-
- return W * H * 16;
+ return CompressedTextureSize(Texture.Width, Texture.Height, 4, 4, 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());
}
+ 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)