Add astc lib for Windows x64
This commit is contained in:
@@ -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"));
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
#endif
|
||||
|
||||
@@ -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;
|
||||
|
||||
BIN
Source/Platforms/Windows/Binaries/ThirdParty/x64/astcenc.lib
(Stored with Git LFS)
vendored
Normal file
BIN
Source/Platforms/Windows/Binaries/ThirdParty/x64/astcenc.lib
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
@@ -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 })
|
||||
{
|
||||
|
||||
@@ -244,7 +244,7 @@ namespace Flax.Deps
|
||||
/// <param name="envVars">Custom environment variables to pass to the child process.</param>
|
||||
public static void BuildCmake(string path, Dictionary<string, string> envVars = null)
|
||||
{
|
||||
Utilities.Run("cmake", "--build .", null, path, Utilities.RunOptions.DefaultTool, envVars);
|
||||
Utilities.Run("cmake", "--build . --config Release", null, path, Utilities.RunOptions.DefaultTool, envVars);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user