Test WIP, pushing so I can get 2nd look
This commit is contained in:
parent
4b40ffdb2d
commit
601c924699
6 changed files with 56 additions and 7 deletions
|
@ -1,8 +1,10 @@
|
||||||
using NUnit.Framework;
|
using Microsoft.VisualBasic;
|
||||||
|
using NUnit.Framework;
|
||||||
using Ryujinx.Graphics.Gpu;
|
using Ryujinx.Graphics.Gpu;
|
||||||
using Ryujinx.Graphics.Texture.Astc;
|
using Ryujinx.Graphics.Texture.Astc;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -11,25 +13,60 @@ namespace Ryujinx.Tests.Graphics
|
||||||
{
|
{
|
||||||
public class AstcDecoderTests
|
public class AstcDecoderTests
|
||||||
{
|
{
|
||||||
|
private string _workingDir;
|
||||||
|
private string _testDataDir;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetupFixture()
|
public void SetupFixture()
|
||||||
{
|
{
|
||||||
|
_workingDir = TestContext.CurrentContext.TestDirectory;
|
||||||
|
_testDataDir = Path.Join(_workingDir, "Graphics", "TestData");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void _Test()
|
public void _Test()
|
||||||
{
|
{
|
||||||
var inputData = GetTestData();
|
|
||||||
var outputBuffer = new Memory<byte>();
|
|
||||||
GraphicsConfig.EnableTextureRecompression = false;
|
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<byte>();
|
||||||
|
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<byte> GetTestData();
|
private (ReadOnlyMemory<byte>, ReadOnlyMemory<byte>, ReadOnlyMemory<byte>) _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<byte> _getFileDataFromPath(string relativeFilePath)
|
||||||
|
{
|
||||||
|
var fullPath = Path.Join(_testDataDir, relativeFilePath);
|
||||||
|
return File.ReadAllBytes(fullPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 997 KiB |
BIN
src/Ryujinx.Tests/Graphics/TestData/kodim01.l4x4.astc
Normal file
BIN
src/Ryujinx.Tests/Graphics/TestData/kodim01.l4x4.astc
Normal file
Binary file not shown.
BIN
src/Ryujinx.Tests/Graphics/TestData/kodim01.l4x4.astc.png
Normal file
BIN
src/Ryujinx.Tests/Graphics/TestData/kodim01.l4x4.astc.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 985 KiB |
|
@ -33,6 +33,18 @@
|
||||||
<ProjectReference Include="..\ARMeilleure\ARMeilleure.csproj" />
|
<ProjectReference Include="..\ARMeilleure\ARMeilleure.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="Graphics\TestData\kodim01.l4x4.astc">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Graphics\TestData\kodim01.l4x4.astc.png">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="Graphics\TestData\kodim01.png">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="CopyUnicorn" AfterTargets="Build">
|
<Target Name="CopyUnicorn" AfterTargets="Build">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<UnicornLib Include="..\Ryujinx.Tests.Unicorn\libs\$(TargetOS)\*unicorn.*" />
|
<UnicornLib Include="..\Ryujinx.Tests.Unicorn\libs\$(TargetOS)\*unicorn.*" />
|
||||||
|
|
Loading…
Reference in a new issue