aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Texture/Astc/AstcDecoder.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2019-12-08 01:30:48 -0300
committerThog <thog@protonmail.com>2020-01-09 02:13:00 +0100
commit23b8a86d35e5b499d75d4f65b6d6a226e7529fd4 (patch)
treec409d2e9361b023e46619a5b03c3315f1d4a1685 /Ryujinx.Graphics.Texture/Astc/AstcDecoder.cs
parent6b13c5b439a54d0bb0139a2e33a2f76707db5fe7 (diff)
Support 3D ASTC textures (using 2D blocks)
Diffstat (limited to 'Ryujinx.Graphics.Texture/Astc/AstcDecoder.cs')
-rw-r--r--Ryujinx.Graphics.Texture/Astc/AstcDecoder.cs20
1 files changed, 6 insertions, 14 deletions
diff --git a/Ryujinx.Graphics.Texture/Astc/AstcDecoder.cs b/Ryujinx.Graphics.Texture/Astc/AstcDecoder.cs
index 41db7e05..2f24fd1e 100644
--- a/Ryujinx.Graphics.Texture/Astc/AstcDecoder.cs
+++ b/Ryujinx.Graphics.Texture/Astc/AstcDecoder.cs
@@ -51,7 +51,6 @@ namespace Ryujinx.Graphics.Texture.Astc
Span<byte> data,
int blockWidth,
int blockHeight,
- int blockDepth,
int width,
int height,
int depth,
@@ -64,17 +63,6 @@ namespace Ryujinx.Graphics.Texture.Astc
{
BinaryReader binReader = new BinaryReader(inputStream);
- if (blockWidth > 12 || blockHeight > 12)
- {
- throw new AstcDecoderException("Invalid block size.");
- }
-
- if (blockDepth != 1 || depth != 1)
- {
- // TODO: Support 3D textures.
- throw new NotImplementedException("3D compressed textures are not unsupported.");
- }
-
using (MemoryStream outputStream = new MemoryStream())
{
int blockIndex = 0;
@@ -83,6 +71,9 @@ namespace Ryujinx.Graphics.Texture.Astc
for (int l = 0; l < levels; l++)
{
+ int sliceSize = width * height * 4;
+
+ for (int k = 0; k < depth; k++)
for (int j = 0; j < height; j += blockHeight)
for (int i = 0; i < width; i += blockWidth)
{
@@ -100,7 +91,7 @@ namespace Ryujinx.Graphics.Texture.Astc
int decompressedWidth = Math.Min(blockWidth, width - i);
int decompressedHeight = Math.Min(blockHeight, height - j);
- int baseOffset = mipOffset + (j * width + i) * 4;
+ int baseOffset = mipOffset + k * sliceSize + (j * width + i) * 4;
for (int jj = 0; jj < decompressedHeight; jj++)
{
@@ -116,10 +107,11 @@ namespace Ryujinx.Graphics.Texture.Astc
blockIndex++;
}
- mipOffset += width * height * 4;
+ mipOffset += sliceSize * depth;
width = Math.Max(1, width >> 1);
height = Math.Max(1, height >> 1);
+ depth = Math.Max(1, depth >> 1);
}
decoded = outputStream.ToArray();