Add texture quality option for iOS
This commit is contained in:
@@ -24,6 +24,11 @@ IMPLEMENT_SETTINGS_GETTER(iOSPlatformSettings, iOSPlatform);
|
||||
|
||||
namespace
|
||||
{
|
||||
struct iOSPlatformCache
|
||||
{
|
||||
iOSPlatformSettings::TextureQuality TexturesQuality;
|
||||
};
|
||||
|
||||
String GetAppName()
|
||||
{
|
||||
const auto gameSettings = GameSettings::Get();
|
||||
@@ -60,6 +65,22 @@ namespace
|
||||
result = result.TrimTrailing();
|
||||
return result;
|
||||
}
|
||||
|
||||
PixelFormat GetQualityTextureFormat(bool sRGB)
|
||||
{
|
||||
const auto platformSettings = iOSPlatformSettings::Get();
|
||||
switch (platformSettings->TexturesQuality)
|
||||
{
|
||||
case iOSPlatformSettings::TextureQuality::ASTC_High:
|
||||
return sRGB ? PixelFormat::ASTC_4x4_UNorm_sRGB : PixelFormat::ASTC_4x4_UNorm;
|
||||
case iOSPlatformSettings::TextureQuality::ASTC_Medium:
|
||||
return sRGB ? PixelFormat::ASTC_6x6_UNorm_sRGB : PixelFormat::ASTC_6x6_UNorm;
|
||||
case iOSPlatformSettings::TextureQuality::ASTC_Low:
|
||||
return sRGB ? PixelFormat::ASTC_8x8_UNorm_sRGB : PixelFormat::ASTC_8x8_UNorm;
|
||||
default:
|
||||
CRASH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const Char* iOSPlatformTools::GetDisplayName() const
|
||||
@@ -89,51 +110,37 @@ DotNetAOTModes iOSPlatformTools::UseAOT() const
|
||||
|
||||
PixelFormat iOSPlatformTools::GetTextureFormat(CookingData& data, TextureBase* texture, PixelFormat format)
|
||||
{
|
||||
// TODO: add ETC compression support for iOS
|
||||
// TODO: add ASTC compression support for iOS
|
||||
|
||||
if (PixelFormatExtensions::IsCompressedBC(format))
|
||||
switch (format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case PixelFormat::BC1_Typeless:
|
||||
case PixelFormat::BC2_Typeless:
|
||||
case PixelFormat::BC3_Typeless:
|
||||
return PixelFormat::R8G8B8A8_Typeless;
|
||||
case PixelFormat::BC1_UNorm:
|
||||
case PixelFormat::BC2_UNorm:
|
||||
case PixelFormat::BC3_UNorm:
|
||||
return PixelFormat::R8G8B8A8_UNorm;
|
||||
case PixelFormat::BC1_UNorm_sRGB:
|
||||
case PixelFormat::BC2_UNorm_sRGB:
|
||||
case PixelFormat::BC3_UNorm_sRGB:
|
||||
return PixelFormat::R8G8B8A8_UNorm_sRGB;
|
||||
case PixelFormat::BC4_Typeless:
|
||||
return PixelFormat::R8_Typeless;
|
||||
case PixelFormat::BC4_UNorm:
|
||||
return PixelFormat::R8_UNorm;
|
||||
case PixelFormat::BC4_SNorm:
|
||||
return PixelFormat::R8_SNorm;
|
||||
case PixelFormat::BC5_Typeless:
|
||||
return PixelFormat::R16G16_Typeless;
|
||||
case PixelFormat::BC5_UNorm:
|
||||
return PixelFormat::R16G16_UNorm;
|
||||
case PixelFormat::BC5_SNorm:
|
||||
return PixelFormat::R16G16_SNorm;
|
||||
case PixelFormat::BC7_Typeless:
|
||||
case PixelFormat::BC6H_Typeless:
|
||||
return PixelFormat::R16G16B16A16_Typeless;
|
||||
case PixelFormat::BC7_UNorm:
|
||||
case PixelFormat::BC6H_Uf16:
|
||||
case PixelFormat::BC6H_Sf16:
|
||||
return PixelFormat::R16G16B16A16_Float;
|
||||
case PixelFormat::BC7_UNorm_sRGB:
|
||||
return PixelFormat::R16G16B16A16_UNorm;
|
||||
default:
|
||||
return format;
|
||||
}
|
||||
case PixelFormat::BC1_Typeless:
|
||||
case PixelFormat::BC2_Typeless:
|
||||
case PixelFormat::BC3_Typeless:
|
||||
case PixelFormat::BC4_Typeless:
|
||||
case PixelFormat::BC5_Typeless:
|
||||
case PixelFormat::BC1_UNorm:
|
||||
case PixelFormat::BC2_UNorm:
|
||||
case PixelFormat::BC3_UNorm:
|
||||
case PixelFormat::BC4_UNorm:
|
||||
case PixelFormat::BC5_UNorm:
|
||||
return GetQualityTextureFormat(false);
|
||||
case PixelFormat::BC1_UNorm_sRGB:
|
||||
case PixelFormat::BC2_UNorm_sRGB:
|
||||
case PixelFormat::BC3_UNorm_sRGB:
|
||||
case PixelFormat::BC7_UNorm_sRGB:
|
||||
return GetQualityTextureFormat(true);
|
||||
case PixelFormat::BC4_SNorm:
|
||||
return PixelFormat::R8_SNorm;
|
||||
case PixelFormat::BC5_SNorm:
|
||||
return PixelFormat::R16G16_SNorm;
|
||||
case PixelFormat::BC6H_Typeless:
|
||||
case PixelFormat::BC6H_Uf16:
|
||||
case PixelFormat::BC6H_Sf16:
|
||||
case PixelFormat::BC7_Typeless:
|
||||
case PixelFormat::BC7_UNorm:
|
||||
return PixelFormat::R16G16B16A16_Typeless; // TODO: ASTC HDR
|
||||
default:
|
||||
return format;
|
||||
}
|
||||
|
||||
return format;
|
||||
}
|
||||
|
||||
@@ -143,6 +150,32 @@ bool iOSPlatformTools::IsNativeCodeFile(CookingData& data, const String& file)
|
||||
return extension.IsEmpty() || extension == TEXT("dylib");
|
||||
}
|
||||
|
||||
void iOSPlatformTools::LoadCache(CookingData& data, IBuildCache* cache, const Span<byte>& bytes)
|
||||
{
|
||||
const auto platformSettings = iOSPlatformSettings::Get();
|
||||
bool invalidTextures = true;
|
||||
if (bytes.Length() == sizeof(iOSPlatformCache))
|
||||
{
|
||||
auto* platformCache = (iOSPlatformCache*)bytes.Get();
|
||||
invalidTextures = platformCache->TexturesQuality != platformSettings->TexturesQuality;
|
||||
}
|
||||
if (invalidTextures)
|
||||
{
|
||||
LOG(Info, "{0} option has been modified.", TEXT("TexturesQuality"));
|
||||
cache->InvalidateCacheTextures();
|
||||
}
|
||||
}
|
||||
|
||||
Array<byte> iOSPlatformTools::SaveCache(CookingData& data, IBuildCache* cache)
|
||||
{
|
||||
const auto platformSettings = iOSPlatformSettings::Get();
|
||||
iOSPlatformCache platformCache;
|
||||
platformCache.TexturesQuality = platformSettings->TexturesQuality;
|
||||
Array<byte> result;
|
||||
result.Add((const byte*)&platformCache, sizeof(platformCache));
|
||||
return result;
|
||||
}
|
||||
|
||||
void iOSPlatformTools::OnBuildStarted(CookingData& data)
|
||||
{
|
||||
// Adjust the cooking output folders for packaging app
|
||||
|
||||
@@ -19,6 +19,8 @@ public:
|
||||
ArchitectureType GetArchitecture() const override;
|
||||
DotNetAOTModes UseAOT() const override;
|
||||
PixelFormat GetTextureFormat(CookingData& data, TextureBase* texture, PixelFormat format) override;
|
||||
void LoadCache(CookingData& data, IBuildCache* cache, const Span<byte>& bytes) override;
|
||||
Array<byte> SaveCache(CookingData& data, IBuildCache* cache) override;
|
||||
bool IsNativeCodeFile(CookingData& data, const String& file) override;
|
||||
void OnBuildStarted(CookingData& data) override;
|
||||
bool OnPostProcess(CookingData& data) override;
|
||||
|
||||
@@ -519,10 +519,40 @@ API_ENUM() enum class PixelFormat : uint32
|
||||
ASTC_4x4_UNorm = 100,
|
||||
|
||||
/// <summary>
|
||||
/// A four-component ASTC (4x4 pixel block in 128 bits) block-compression format that supports RGBA channels.
|
||||
/// A four-component ASTC (4x4 pixel block in 128 bits) block-compression format that supports RGBA channels. Data in sRGB color space.
|
||||
/// </summary>
|
||||
ASTC_4x4_UNorm_sRGB = 101,
|
||||
|
||||
/// <summary>
|
||||
/// A four-component ASTC (6x6 pixel block in 128 bits) block-compression format that supports RGBA channels.
|
||||
/// </summary>
|
||||
ASTC_6x6_UNorm = 102,
|
||||
|
||||
/// <summary>
|
||||
/// A four-component ASTC (6x6 pixel block in 128 bits) block-compression format that supports RGBA channels. Data in sRGB color space.
|
||||
/// </summary>
|
||||
ASTC_6x6_UNorm_sRGB = 103,
|
||||
|
||||
/// <summary>
|
||||
/// A four-component ASTC (8x8 pixel block in 128 bits) block-compression format that supports RGBA channels.
|
||||
/// </summary>
|
||||
ASTC_8x8_UNorm = 104,
|
||||
|
||||
/// <summary>
|
||||
/// A four-component ASTC (8x8 pixel block in 128 bits) block-compression format that supports RGBA channels. Data in sRGB color space.
|
||||
/// </summary>
|
||||
ASTC_8x8_UNorm_sRGB = 105,
|
||||
|
||||
/// <summary>
|
||||
/// A four-component ASTC (10x10 pixel block in 128 bits) block-compression format that supports RGBA channels.
|
||||
/// </summary>
|
||||
ASTC_10x10_UNorm = 106,
|
||||
|
||||
/// <summary>
|
||||
/// A four-component ASTC (10x10 pixel block in 128 bits) block-compression format that supports RGBA channels. Data in sRGB color space.
|
||||
/// </summary>
|
||||
ASTC_10x10_UNorm_sRGB = 107,
|
||||
|
||||
/// <summary>
|
||||
/// The maximum format value (for internal use only).
|
||||
/// </summary>
|
||||
|
||||
@@ -46,6 +46,22 @@ API_CLASS(Sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API
|
||||
All = Portrait | PortraitUpsideDown | LandscapeLeft | LandscapeRight
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The output textures quality (compression).
|
||||
/// </summary>
|
||||
API_ENUM() enum class TextureQuality
|
||||
{
|
||||
// ASTC 4x4 block compression.
|
||||
API_ENUM(Attributes="EditorDisplay(null, \"ASTC High\")")
|
||||
ASTC_High = 0,
|
||||
// ASTC 6x6 block compression.
|
||||
API_ENUM(Attributes="EditorDisplay(null, \"ASTC Medium\")")
|
||||
ASTC_Medium = 1,
|
||||
// ASTC 8x8 block compression.
|
||||
API_ENUM(Attributes="EditorDisplay(null, \"ASTC Low\")")
|
||||
ASTC_Low = 2,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The app developer name - App Store Team ID. For example: 'VG6K6HT8B'.
|
||||
/// </summary>
|
||||
@@ -64,6 +80,12 @@ API_CLASS(Sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API
|
||||
API_FIELD(Attributes="EditorOrder(50), EditorDisplay(\"General\")")
|
||||
ExportMethods ExportMethod = ExportMethods::Development;
|
||||
|
||||
/// <summary>
|
||||
/// The output textures quality (compression).
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorOrder(100), EditorDisplay(\"General\")")
|
||||
TextureQuality TexturesQuality = TextureQuality::ASTC_Medium;
|
||||
|
||||
/// <summary>
|
||||
/// The UI interface orientation modes supported on iPhone devices.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user