diff --git a/CHANGELOG.md b/CHANGELOG.md index a6277d50..e3f2dafc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,12 @@ ### Changelog +#### Version - 3.0.6.2 - 1/28/2023 +* Add fallback for DDS compression when installing older lists. This should keep older DDS files from not being compressed without any mipmaps at all. +* + #### Version - 3.0.6.1 - 1/28/2023 * Game support: - * Added Mount & Blade II: Bennerlord support (Steam,GOG) + * Added Mount & Blade II: Bennerlord support (Steam,GOG) * Fixed BA2 files not being compressed properly due to MipMaps not being detected properly #### Version - 3.0.6.0 - 1/21/2023 diff --git a/Wabbajack.Hashing.PHash.Test/FileLoadingTests.cs b/Wabbajack.Hashing.PHash.Test/FileLoadingTests.cs index e8e21e97..826660c5 100644 --- a/Wabbajack.Hashing.PHash.Test/FileLoadingTests.cs +++ b/Wabbajack.Hashing.PHash.Test/FileLoadingTests.cs @@ -46,8 +46,9 @@ public class FileLoadingTests : IAsyncDisposable { foreach (var imageLoader in _imageLoaders) { + var inputFile = "TestData/test-dxt5.dds".ToRelativePath().RelativeTo(KnownFolders.EntryPoint); var baseState = - await imageLoader.Load("TestData/test-dxt5.dds".ToRelativePath().RelativeTo(KnownFolders.EntryPoint)); + await imageLoader.Load(inputFile); var state = await imageLoader.Load("TestData".ToRelativePath().Combine(file) .RelativeTo(KnownFolders.EntryPoint)); @@ -58,6 +59,9 @@ public class FileLoadingTests : IAsyncDisposable new Digest { Coefficients = baseState.PerceptualHash.Data }, new Digest { Coefficients = state.PerceptualHash.Data }), 1.0); + + await using var outFile = _tmp.CreateFile(); + await imageLoader.Recompress(inputFile, 64, 64, 0, DXGI_FORMAT.BC7_UNORM, outFile, CancellationToken.None); } } diff --git a/Wabbajack.Hashing.PHash/CrossPlatformImageLoader.cs b/Wabbajack.Hashing.PHash/CrossPlatformImageLoader.cs index 71a042f4..37045d84 100644 --- a/Wabbajack.Hashing.PHash/CrossPlatformImageLoader.cs +++ b/Wabbajack.Hashing.PHash/CrossPlatformImageLoader.cs @@ -101,7 +101,7 @@ public class CrossPlatformImageLoader : IImageLoader GenerateMipMaps = true, Format = ToCompressionFormat(format), FileFormat = OutputFileFormat.Dds, - MaxMipMapLevel = mipMaps + MaxMipMapLevel = mipMaps != 0 ? mipMaps : -1 } }; diff --git a/Wabbajack.Hashing.PHash/TexConvImageLoader.cs b/Wabbajack.Hashing.PHash/TexConvImageLoader.cs index 40fdefbe..4e42f36a 100644 --- a/Wabbajack.Hashing.PHash/TexConvImageLoader.cs +++ b/Wabbajack.Hashing.PHash/TexConvImageLoader.cs @@ -83,11 +83,29 @@ public class TexConvImageLoader : IImageLoader public async Task ConvertImage(AbsolutePath from, AbsolutePath toFolder, int w, int h, int mipMaps, DXGI_FORMAT format, Extension fileFormat) { - // User isn't renaming the file, so we don't have to create a temporary folder + object[] args; + if (mipMaps != 0) + { + args = new object[] + { + from, "-ft", fileFormat.ToString()[1..], "-f", format, "-o", toFolder, "-w", w, "-h", h, "-m", mipMaps, + "-if", "CUBIC", "-singleproc" + }; + } + else + { + args = new object[] + { + from, "-ft", fileFormat.ToString()[1..], "-f", format, "-o", toFolder, "-w", w, "-h", h, + "-if", "CUBIC", "-singleproc" + }; + } + + // User isn't renaming the file, so we don't have to create a temporary folder var ph = new ProcessHelper { Path = @"Tools\texconv.exe".ToRelativePath().RelativeTo(KnownFolders.EntryPoint), - Arguments = new object[] {from, "-ft", fileFormat.ToString()[1..], "-f", format, "-o", toFolder, "-w", w, "-h", h, "-m", mipMaps, "-if", "CUBIC", "-singleproc"}, + Arguments = args, ThrowOnNonZeroExitCode = true, LogError = true };