diff --git a/src/Ryujinx.Tests/Graphics/AstcDecoderTests.cs b/src/Ryujinx.Tests/Graphics/AstcDecoderTests.cs index 61eaca039..b44b1cafb 100644 --- a/src/Ryujinx.Tests/Graphics/AstcDecoderTests.cs +++ b/src/Ryujinx.Tests/Graphics/AstcDecoderTests.cs @@ -1,8 +1,10 @@ -using NUnit.Framework; +using Microsoft.VisualBasic; +using NUnit.Framework; using Ryujinx.Graphics.Gpu; using Ryujinx.Graphics.Texture.Astc; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -11,25 +13,60 @@ namespace Ryujinx.Tests.Graphics { public class AstcDecoderTests { + private string _workingDir; + private string _testDataDir; + [SetUp] public void SetupFixture() { - + _workingDir = TestContext.CurrentContext.TestDirectory; + _testDataDir = Path.Join(_workingDir, "Graphics", "TestData"); } [Test] public void _Test() { - var inputData = GetTestData(); - var outputBuffer = new Memory(); GraphicsConfig.EnableTextureRecompression = false; + var (original, encodedRef, decodedRef) = _getTestDataTupleFromShortname("kodim01"); + int blockWidth = 4; + int blockHeight = 4; - AstcDecoder.TryDecodeToRgba8P() + int texWidth = 768; + int texHeight = 512; + byte[] outputBuffer = Array.Empty(); + int depth = 1; + int levels = 1; + int layers = 1; + + _ = AstcDecoder.TryDecodeToRgba8P(original, blockWidth, blockHeight, texWidth, texHeight, depth, levels, layers, out outputBuffer); + var outputPath = Path.Join(_testDataDir, "kodim01.l4x4.output.png"); + + // Make sure we're clobbering the test output. + if (File.Exists(outputPath)) + File.Delete(outputPath); + File.WriteAllBytes(outputPath, outputBuffer); + + Assert.AreEqual(decodedRef, outputBuffer); - AstcDecoder target = new AstcDecoder(); } - private ReadOnlyMemory GetTestData(); + private (ReadOnlyMemory, ReadOnlyMemory, ReadOnlyMemory) _getTestDataTupleFromShortname(string shortName) + { + var original = _getFileDataFromPath($"{shortName}.png"); + // TODO: add brains for block sizes/etc + var encodedRef = _getFileDataFromPath($"{shortName}.l4x4.astc"); + var decodedRef = _getFileDataFromPath($"{shortName}.l4x4.astc.png"); + + return (original, encodedRef, decodedRef); + } + + private ReadOnlyMemory _getFileDataFromPath(string relativeFilePath) + { + var fullPath = Path.Join(_testDataDir, relativeFilePath); + return File.ReadAllBytes(fullPath); + } + + } } diff --git a/src/Ryujinx.Tests/Graphics/TestData/kodim01.l.4x4.astc b/src/Ryujinx.Tests/Graphics/TestData/kodim01.l.4x4.astc deleted file mode 100644 index a8605bfba..000000000 Binary files a/src/Ryujinx.Tests/Graphics/TestData/kodim01.l.4x4.astc and /dev/null differ diff --git a/src/Ryujinx.Tests/Graphics/TestData/kodim01.l.4x4.astc.png b/src/Ryujinx.Tests/Graphics/TestData/kodim01.l.4x4.astc.png deleted file mode 100644 index 112d2893e..000000000 Binary files a/src/Ryujinx.Tests/Graphics/TestData/kodim01.l.4x4.astc.png and /dev/null differ diff --git a/src/Ryujinx.Tests/Graphics/TestData/kodim01.l4x4.astc b/src/Ryujinx.Tests/Graphics/TestData/kodim01.l4x4.astc new file mode 100644 index 000000000..d5bf82d1c Binary files /dev/null and b/src/Ryujinx.Tests/Graphics/TestData/kodim01.l4x4.astc differ diff --git a/src/Ryujinx.Tests/Graphics/TestData/kodim01.l4x4.astc.png b/src/Ryujinx.Tests/Graphics/TestData/kodim01.l4x4.astc.png new file mode 100644 index 000000000..6194d6710 Binary files /dev/null and b/src/Ryujinx.Tests/Graphics/TestData/kodim01.l4x4.astc.png differ diff --git a/src/Ryujinx.Tests/Ryujinx.Tests.csproj b/src/Ryujinx.Tests/Ryujinx.Tests.csproj index ab331ce58..fc514366c 100644 --- a/src/Ryujinx.Tests/Ryujinx.Tests.csproj +++ b/src/Ryujinx.Tests/Ryujinx.Tests.csproj @@ -33,6 +33,18 @@ + + + Always + + + Always + + + Always + + +