diff --git a/Source/Engine/Tools/TextureTool/TextureTool.Build.cs b/Source/Engine/Tools/TextureTool/TextureTool.Build.cs
index 00e0a18a9..a6a68617c 100644
--- a/Source/Engine/Tools/TextureTool/TextureTool.Build.cs
+++ b/Source/Engine/Tools/TextureTool/TextureTool.Build.cs
@@ -58,7 +58,7 @@ public class TextureTool : EngineModule
options.PrivateDependencies.Add("bc7enc16");
}
}
- if (options.Target.IsEditor && options.Platform.Target == TargetPlatform.Mac) // TODO: add ASTC for Editor on Linux and Windows
+ if (options.Target.IsEditor && options.Platform.Target != TargetPlatform.Linux) // TODO: add ASTC for Editor on Linux
{
// ASTC for mobile (iOS and Android)
options.SourceFiles.Add(Path.Combine(FolderPath, "TextureTool.astc.cpp"));
diff --git a/Source/Engine/Tools/TextureTool/TextureTool.DirectXTex.cpp b/Source/Engine/Tools/TextureTool/TextureTool.DirectXTex.cpp
index 84e1c5adf..cf81aed50 100644
--- a/Source/Engine/Tools/TextureTool/TextureTool.DirectXTex.cpp
+++ b/Source/Engine/Tools/TextureTool/TextureTool.DirectXTex.cpp
@@ -836,10 +836,10 @@ bool TextureTool::ConvertDirectXTex(TextureData& dst, const TextureData& src, co
{
if (PixelFormatExtensions::IsCompressedASTC(dstFormat))
{
- // TODO: decompress if need to
#if COMPILE_WITH_ASTC
- return ConvertAstc(dst, *textureData, dstFormat);
+ return ConvertAstc(dst, src, dstFormat);
#else
+ LOG(Error, "Missing ASTC texture format compression lib.");
return true;
#endif
}
diff --git a/Source/Engine/Tools/TextureTool/TextureTool.astc.cpp b/Source/Engine/Tools/TextureTool/TextureTool.astc.cpp
index 3eceb837e..ebb9c07af 100644
--- a/Source/Engine/Tools/TextureTool/TextureTool.astc.cpp
+++ b/Source/Engine/Tools/TextureTool/TextureTool.astc.cpp
@@ -5,7 +5,6 @@
#include "TextureTool.h"
#include "Engine/Core/Log.h"
#include "Engine/Core/Math/Math.h"
-#include "Engine/Core/Math/Color32.h"
#include "Engine/Graphics/Textures/TextureData.h"
#include "Engine/Graphics/PixelFormatExtensions.h"
#include "Engine/Graphics/RenderTools.h"
@@ -49,7 +48,9 @@ bool TextureTool::ConvertAstc(TextureData& dst, const TextureData& src, const Pi
TextureData converted;
// Encoder uses full 4-component RGBA input image so convert it if needed
- if (PixelFormatExtensions::ComputeComponentsCount(src.Format) != 4)
+ if (PixelFormatExtensions::ComputeComponentsCount(src.Format) != 4 ||
+ PixelFormatExtensions::IsCompressed(textureData->Format) ||
+ !PixelFormatExtensions::IsRgbAOrder(textureData->Format))
{
if (textureData != &src)
converted = src;
@@ -71,6 +72,13 @@ bool TextureTool::ConvertAstc(TextureData& dst, const TextureData& src, const Pi
textureData = &converted;
}
+ // Setup output
+ dst.Items.Resize(textureData->Items.Count());
+ dst.Width = textureData->Width;
+ dst.Height = textureData->Height;
+ dst.Depth = 1;
+ dst.Format = dstFormat;
+
// Compress all array slices
for (int32 arrayIndex = 0; arrayIndex < textureData->Items.Count() && astcError == ASTCENC_SUCCESS; arrayIndex++)
{
@@ -124,4 +132,4 @@ bool TextureTool::ConvertAstc(TextureData& dst, const TextureData& src, const Pi
return astcError != ASTCENC_SUCCESS;
}
-#endif
\ No newline at end of file
+#endif
diff --git a/Source/Engine/Tools/TextureTool/TextureTool.stb.cpp b/Source/Engine/Tools/TextureTool/TextureTool.stb.cpp
index d45c9d465..53b8621ab 100644
--- a/Source/Engine/Tools/TextureTool/TextureTool.stb.cpp
+++ b/Source/Engine/Tools/TextureTool/TextureTool.stb.cpp
@@ -666,6 +666,8 @@ bool TextureTool::ConvertStb(TextureData& dst, const TextureData& src, const Pix
{
#if COMPILE_WITH_ASTC
if (ConvertAstc(dst, *textureData, dstFormat))
+#else
+ LOG(Error, "Missing ASTC texture format compression lib.");
#endif
{
return true;
diff --git a/Source/Platforms/Windows/Binaries/ThirdParty/x64/astcenc.lib b/Source/Platforms/Windows/Binaries/ThirdParty/x64/astcenc.lib
new file mode 100644
index 000000000..d89395539
--- /dev/null
+++ b/Source/Platforms/Windows/Binaries/ThirdParty/x64/astcenc.lib
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:38500ac222bd4132dd81ea03016462add2b0c8188b7cb7101223d19bf209cd01
+size 536548
diff --git a/Source/Tools/Flax.Build/Deps/Dependencies/astc.cs b/Source/Tools/Flax.Build/Deps/Dependencies/astc.cs
index f062cd91d..a1c9edcee 100644
--- a/Source/Tools/Flax.Build/Deps/Dependencies/astc.cs
+++ b/Source/Tools/Flax.Build/Deps/Dependencies/astc.cs
@@ -18,6 +18,11 @@ namespace Flax.Deps.Dependencies
{
switch (BuildPlatform)
{
+ case TargetPlatform.Windows:
+ return new[]
+ {
+ TargetPlatform.Windows,
+ };
case TargetPlatform.Mac:
return new[]
{
@@ -42,6 +47,18 @@ namespace Flax.Deps.Dependencies
{
switch (platform)
{
+ case TargetPlatform.Windows:
+ foreach (var architecture in new []{ TargetArchitecture.x64 })
+ {
+ var isa = "-DASTCENC_ISA_SSE2=ON";
+ var lib = "astcenc-sse2-static.lib";
+ SetupDirectory(buildDir, true);
+ RunCmake(buildDir, platform, architecture, ".. -DCMAKE_BUILD_TYPE=Release -DASTCENC_CLI=OFF -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL " + isa);
+ BuildCmake(buildDir);
+ var depsFolder = GetThirdPartyFolder(options, platform, architecture);
+ Utilities.FileCopy(Path.Combine(buildDir, "Source/Release", lib), Path.Combine(depsFolder, "astcenc.lib"));
+ }
+ break;
case TargetPlatform.Mac:
foreach (var architecture in new []{ TargetArchitecture.x64, TargetArchitecture.ARM64 })
{
diff --git a/Source/Tools/Flax.Build/Deps/Dependency.cs b/Source/Tools/Flax.Build/Deps/Dependency.cs
index db65289c4..4e940c824 100644
--- a/Source/Tools/Flax.Build/Deps/Dependency.cs
+++ b/Source/Tools/Flax.Build/Deps/Dependency.cs
@@ -244,7 +244,7 @@ namespace Flax.Deps
/// Custom environment variables to pass to the child process.
public static void BuildCmake(string path, Dictionary envVars = null)
{
- Utilities.Run("cmake", "--build .", null, path, Utilities.RunOptions.DefaultTool, envVars);
+ Utilities.Run("cmake", "--build . --config Release", null, path, Utilities.RunOptions.DefaultTool, envVars);
}
///