Skip to content

Commit

Permalink
[TextureConverter] Removed unused formats (PVRTC and ATC)
Browse files Browse the repository at this point in the history
  • Loading branch information
xen2 committed Oct 7, 2019
1 parent 3d70fee commit 71e9e25
Show file tree
Hide file tree
Showing 24 changed files with 28 additions and 961 deletions.
3 changes: 0 additions & 3 deletions deps/TextureWrappers/Debug/x64/AtitcWrapper.dll

This file was deleted.

3 changes: 0 additions & 3 deletions deps/TextureWrappers/Debug/x64/AtitcWrapper.pdb

This file was deleted.

3 changes: 0 additions & 3 deletions deps/TextureWrappers/Debug/x86/AtitcWrapper.dll

This file was deleted.

3 changes: 0 additions & 3 deletions deps/TextureWrappers/Debug/x86/AtitcWrapper.pdb

This file was deleted.

3 changes: 0 additions & 3 deletions deps/TextureWrappers/Release/x64/AtitcWrapper.dll

This file was deleted.

3 changes: 0 additions & 3 deletions deps/TextureWrappers/Release/x64/AtitcWrapper.pdb

This file was deleted.

3 changes: 0 additions & 3 deletions deps/TextureWrappers/Release/x86/AtitcWrapper.dll

This file was deleted.

3 changes: 0 additions & 3 deletions deps/TextureWrappers/Release/x86/AtitcWrapper.pdb

This file was deleted.

16 changes: 8 additions & 8 deletions sources/engine/Xenko.Assets.Tests2/AutoAlphaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public class AutoAlphaTests : GameTestBase
{ Tuple.Create(PlatformType.UWP, AlphaFormat.Interpolated), PixelFormat.BC3_UNorm },

{ Tuple.Create(PlatformType.Android, AlphaFormat.None), PixelFormat.ETC1 },
{ Tuple.Create(PlatformType.Android, AlphaFormat.Mask), PixelFormat.R8G8B8A8_UNorm },
{ Tuple.Create(PlatformType.Android, AlphaFormat.Explicit), PixelFormat.R8G8B8A8_UNorm },
{ Tuple.Create(PlatformType.Android, AlphaFormat.Interpolated), PixelFormat.R8G8B8A8_UNorm },

{ Tuple.Create(PlatformType.iOS, AlphaFormat.None), PixelFormat.PVRTC_4bpp_RGB },
{ Tuple.Create(PlatformType.iOS, AlphaFormat.Mask), PixelFormat.PVRTC_4bpp_RGBA },
{ Tuple.Create(PlatformType.iOS, AlphaFormat.Explicit), PixelFormat.PVRTC_4bpp_RGBA },
{ Tuple.Create(PlatformType.iOS, AlphaFormat.Interpolated), PixelFormat.PVRTC_4bpp_RGBA },
{ Tuple.Create(PlatformType.Android, AlphaFormat.Mask), PixelFormat.ETC2_RGB_A1 },
{ Tuple.Create(PlatformType.Android, AlphaFormat.Explicit), PixelFormat.ETC2_RGBA },
{ Tuple.Create(PlatformType.Android, AlphaFormat.Interpolated), PixelFormat.ETC2_RGBA },

{ Tuple.Create(PlatformType.iOS, AlphaFormat.None), PixelFormat.ETC1 },
{ Tuple.Create(PlatformType.iOS, AlphaFormat.Mask), PixelFormat.ETC2_RGB_A1 },
{ Tuple.Create(PlatformType.iOS, AlphaFormat.Explicit), PixelFormat.ETC2_RGBA },
{ Tuple.Create(PlatformType.iOS, AlphaFormat.Interpolated), PixelFormat.ETC2_RGBA },
};

private static void CheckTextureFormat(Game game, string textureUrl, AlphaFormat expectedFormat)
Expand Down
64 changes: 20 additions & 44 deletions sources/engine/Xenko.Assets/Textures/TextureHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,6 @@ public ImportParameters(SpriteSheetAssetCompiler.SpriteSheetParameters spriteShe
}
}

/// <summary>
/// Returns true if the PVRTC can be used for the provided texture size.
/// </summary>
/// <param name="textureSize">the size of the texture</param>
/// <returns>true if PVRTC is supported</returns>
public static bool SupportPVRTC(Size2 textureSize)
{
return textureSize.Width == textureSize.Height && MathUtil.IsPow2(textureSize.Width);
}

/// <summary>
/// Utility function to check that the texture size is supported on the graphics platform for the provided graphics profile.
/// </summary>
Expand Down Expand Up @@ -214,6 +204,7 @@ public static PixelFormat DetermineOutputFormat(ImportParameters parameters, Siz
switch (parameters.Platform)
{
case PlatformType.Android:
case PlatformType.iOS:
if (inputImageFormat.IsHDR())
{
outputFormat = inputImageFormat;
Expand All @@ -233,46 +224,31 @@ public static PixelFormat DetermineOutputFormat(ImportParameters parameters, Siz
case GraphicsProfile.Level_11_1:
case GraphicsProfile.Level_11_2:
// GLES3.0 starting from Level_10_0, this profile enables ETC2 compression on Android
outputFormat = alphaMode == AlphaFormat.None && !parameters.IsSRgb ? PixelFormat.ETC1 : parameters.IsSRgb ? PixelFormat.ETC2_RGBA_SRgb : PixelFormat.ETC2_RGBA;
switch (alphaMode)
{
case AlphaFormat.None:
outputFormat = parameters.IsSRgb ? PixelFormat.ETC2_RGB_SRgb : PixelFormat.ETC2_RGB;
break;
case AlphaFormat.Mask:
// DXT1 handles 1-bit alpha channel
// TODO: Not sure about the equivalent here?
outputFormat = parameters.IsSRgb ? PixelFormat.ETC2_RGBA_SRgb : PixelFormat.ETC2_RGB_A1;
break;
case AlphaFormat.Explicit:
case AlphaFormat.Interpolated:
// DXT3 is good at sharp alpha transitions
// TODO: Not sure about the equivalent here?
outputFormat = parameters.IsSRgb ? PixelFormat.ETC2_RGBA_SRgb : PixelFormat.ETC2_RGBA;
break;
default:
throw new ArgumentOutOfRangeException();
}
break;
default:
throw new ArgumentOutOfRangeException("GraphicsProfile");
}
}
break;
case PlatformType.iOS:
// PVRTC works only for square POT textures
if (inputImageFormat.IsHDR())
{
outputFormat = inputImageFormat;
}
else if (SupportPVRTC(imageSize))
{
switch (alphaMode)
{
case AlphaFormat.None:
outputFormat = parameters.IsSRgb ? PixelFormat.PVRTC_4bpp_RGB_SRgb : PixelFormat.PVRTC_4bpp_RGB;
break;
case AlphaFormat.Mask:
// DXT1 handles 1-bit alpha channel
// TODO: Not sure about the equivalent here?
outputFormat = parameters.IsSRgb ? PixelFormat.PVRTC_4bpp_RGBA_SRgb : PixelFormat.PVRTC_4bpp_RGBA;
break;
case AlphaFormat.Explicit:
case AlphaFormat.Interpolated:
// DXT3 is good at sharp alpha transitions
// TODO: Not sure about the equivalent here?
outputFormat = parameters.IsSRgb ? PixelFormat.PVRTC_4bpp_RGBA_SRgb : PixelFormat.PVRTC_4bpp_RGBA;
break;
default:
throw new ArgumentOutOfRangeException();
}
}
else
{
outputFormat = parameters.IsSRgb ? PixelFormat.R8G8B8A8_UNorm_SRgb : PixelFormat.R8G8B8A8_UNorm;
}
break;
case PlatformType.Windows:
case PlatformType.UWP:
case PlatformType.Linux:
Expand Down
12 changes: 0 additions & 12 deletions sources/engine/Xenko.Graphics/OpenGL/OpenGLConvertExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,6 @@ public static void ConvertPixelFormat(GraphicsDevice graphicsDevice, ref PixelFo
{
switch (inputFormat)
{
case PixelFormat.PVRTC_2bpp_RGB_SRgb:
inputFormat = PixelFormat.PVRTC_2bpp_RGB;
break;
case PixelFormat.PVRTC_2bpp_RGBA_SRgb:
inputFormat = PixelFormat.PVRTC_2bpp_RGBA;
break;
case PixelFormat.PVRTC_4bpp_RGB_SRgb:
inputFormat = PixelFormat.PVRTC_4bpp_RGB;
break;
case PixelFormat.PVRTC_4bpp_RGBA_SRgb:
inputFormat = PixelFormat.PVRTC_4bpp_RGBA;
break;
case PixelFormat.ETC2_RGB_SRgb:
inputFormat = PixelFormat.ETC2_RGB;
break;
Expand Down
17 changes: 0 additions & 17 deletions sources/engine/Xenko/Graphics/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -850,23 +850,6 @@ internal static void ComputePitch(PixelFormat fmt, int width, int height, out in
case PixelFormat.ETC1:
bpb = 8;
break;
case PixelFormat.PVRTC_4bpp_RGB:
case PixelFormat.PVRTC_4bpp_RGB_SRgb:
case PixelFormat.PVRTC_4bpp_RGBA:
case PixelFormat.PVRTC_4bpp_RGBA_SRgb:
case PixelFormat.PVRTC_II_4bpp:
minWidth = 8;
minHeight = 8;
break;
case PixelFormat.PVRTC_2bpp_RGB:
case PixelFormat.PVRTC_2bpp_RGB_SRgb:
case PixelFormat.PVRTC_2bpp_RGBA:
case PixelFormat.PVRTC_2bpp_RGBA_SRgb:
case PixelFormat.PVRTC_II_2bpp:
minWidth = 16;
minHeight = 8;
bpb = 4;
break;
default:
bpb = 16;
break;
Expand Down
20 changes: 0 additions & 20 deletions sources/engine/Xenko/Graphics/PixelFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -531,22 +531,6 @@ public enum PixelFormat
/// </summary>
BC7_UNorm_SRgb = unchecked((int)99),

/// <summary>
/// <dd> <p>A block-compression format. For information about block-compression formats, see Texture Block Compression in PowerVC Texture Compression.</p> </dd>
/// </summary>

PVRTC_2bpp_RGB = unchecked((int)1024),
PVRTC_2bpp_RGBA = unchecked((int)1025),
PVRTC_4bpp_RGB = unchecked((int)1026),
PVRTC_4bpp_RGBA = unchecked((int)1027),
PVRTC_II_2bpp = unchecked((int)1028),
PVRTC_II_4bpp = unchecked((int)1029),

PVRTC_2bpp_RGB_SRgb = unchecked((int)1030),
PVRTC_2bpp_RGBA_SRgb = unchecked((int)1031),
PVRTC_4bpp_RGB_SRgb = unchecked((int)1032),
PVRTC_4bpp_RGBA_SRgb = unchecked((int)1033),

ETC1 = unchecked((int)1088),
ETC2_RGB = unchecked((int)1089),
ETC2_RGBA = unchecked((int)1090),
Expand All @@ -557,9 +541,5 @@ public enum PixelFormat
EAC_RG11_Signed = unchecked((int)1095),
ETC2_RGBA_SRgb = unchecked((int)1096),
ETC2_RGB_SRgb = unchecked((int)1097),

ATC_RGB = unchecked((int)1120),
ATC_RGBA_Explicit = unchecked((int)1121),
ATC_RGBA_Interpolated = unchecked((int)1122),
}
}
54 changes: 0 additions & 54 deletions sources/engine/Xenko/Graphics/PixelFormatExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,28 +138,12 @@ public static int AlphaSizeInBits(this PixelFormat format)
case PixelFormat.BC7_UNorm_SRgb:
return 8; // or 0

case PixelFormat.PVRTC_2bpp_RGBA:
case PixelFormat.PVRTC_4bpp_RGBA:
case PixelFormat.PVRTC_2bpp_RGBA_SRgb:
case PixelFormat.PVRTC_4bpp_RGBA_SRgb:
return 8;

case PixelFormat.PVRTC_II_2bpp:
case PixelFormat.PVRTC_II_4bpp:
return 8; // or 0

case PixelFormat.ETC2_RGBA:
case PixelFormat.ETC2_RGBA_SRgb:
return 8;

case PixelFormat.ETC2_RGB_A1:
return 1;

case PixelFormat.ATC_RGBA_Explicit:
return 4;

case PixelFormat.ATC_RGBA_Interpolated:
return 8;
}
return 0;
}
Expand Down Expand Up @@ -318,16 +302,6 @@ public static int ComputeScanlineCount(this PixelFormat fmt, int height)
case PixelFormat.BC7_Typeless:
case PixelFormat.BC7_UNorm:
case PixelFormat.BC7_UNorm_SRgb:
case PixelFormat.PVRTC_2bpp_RGB:
case PixelFormat.PVRTC_2bpp_RGBA:
case PixelFormat.PVRTC_4bpp_RGB:
case PixelFormat.PVRTC_4bpp_RGBA:
case PixelFormat.PVRTC_2bpp_RGB_SRgb:
case PixelFormat.PVRTC_2bpp_RGBA_SRgb:
case PixelFormat.PVRTC_4bpp_RGB_SRgb:
case PixelFormat.PVRTC_4bpp_RGBA_SRgb:
case PixelFormat.PVRTC_II_2bpp:
case PixelFormat.PVRTC_II_4bpp:
case PixelFormat.ETC1:
case PixelFormat.ETC2_RGB:
case PixelFormat.ETC2_RGB_SRgb:
Expand All @@ -338,9 +312,6 @@ public static int ComputeScanlineCount(this PixelFormat fmt, int height)
case PixelFormat.EAC_R11_Signed:
case PixelFormat.EAC_RG11_Unsigned:
case PixelFormat.EAC_RG11_Signed:
case PixelFormat.ATC_RGB:
case PixelFormat.ATC_RGBA_Explicit:
case PixelFormat.ATC_RGBA_Interpolated:
return Math.Max(1, (height + 3) / 4);

default:
Expand Down Expand Up @@ -629,16 +600,6 @@ static PixelFormatExtensions()
PixelFormat.BC7_Typeless,
PixelFormat.BC7_UNorm,
PixelFormat.BC7_UNorm_SRgb,
PixelFormat.PVRTC_2bpp_RGB,
PixelFormat.PVRTC_2bpp_RGBA,
PixelFormat.PVRTC_4bpp_RGB,
PixelFormat.PVRTC_4bpp_RGBA,
PixelFormat.PVRTC_2bpp_RGB_SRgb,
PixelFormat.PVRTC_2bpp_RGBA_SRgb,
PixelFormat.PVRTC_4bpp_RGB_SRgb,
PixelFormat.PVRTC_4bpp_RGBA_SRgb,
PixelFormat.PVRTC_II_2bpp,
PixelFormat.PVRTC_II_4bpp,
PixelFormat.ETC1,
PixelFormat.ETC2_RGB,
PixelFormat.ETC2_RGB_SRgb,
Expand All @@ -649,9 +610,6 @@ static PixelFormatExtensions()
PixelFormat.EAC_R11_Signed,
PixelFormat.EAC_RG11_Unsigned,
PixelFormat.EAC_RG11_Signed,
PixelFormat.ATC_RGB,
PixelFormat.ATC_RGBA_Explicit,
PixelFormat.ATC_RGBA_Interpolated,
}, compressedFormats);

// Init srgb formats
Expand All @@ -664,10 +622,6 @@ static PixelFormatExtensions()
PixelFormat.B8G8R8A8_UNorm_SRgb,
PixelFormat.B8G8R8X8_UNorm_SRgb,
PixelFormat.BC7_UNorm_SRgb,
PixelFormat.PVRTC_2bpp_RGB_SRgb,
PixelFormat.PVRTC_2bpp_RGBA_SRgb,
PixelFormat.PVRTC_4bpp_RGB_SRgb,
PixelFormat.PVRTC_4bpp_RGBA_SRgb,
PixelFormat.ETC2_RGBA_SRgb,
PixelFormat.ETC2_RGB_SRgb,
}, srgbFormats);
Expand Down Expand Up @@ -739,14 +693,6 @@ static PixelFormatExtensions()
{ PixelFormat.B8G8R8X8_UNorm, PixelFormat.B8G8R8X8_UNorm_SRgb },
{ PixelFormat.BC7_UNorm_SRgb, PixelFormat.BC7_UNorm },
{ PixelFormat.BC7_UNorm, PixelFormat.BC7_UNorm_SRgb },
{ PixelFormat.PVRTC_2bpp_RGB_SRgb, PixelFormat.PVRTC_2bpp_RGB },
{ PixelFormat.PVRTC_2bpp_RGB, PixelFormat.PVRTC_2bpp_RGB_SRgb },
{ PixelFormat.PVRTC_2bpp_RGBA_SRgb, PixelFormat.PVRTC_2bpp_RGBA },
{ PixelFormat.PVRTC_2bpp_RGBA, PixelFormat.PVRTC_2bpp_RGBA_SRgb },
{ PixelFormat.PVRTC_4bpp_RGB_SRgb, PixelFormat.PVRTC_4bpp_RGB },
{ PixelFormat.PVRTC_4bpp_RGB, PixelFormat.PVRTC_4bpp_RGB_SRgb },
{ PixelFormat.PVRTC_4bpp_RGBA_SRgb, PixelFormat.PVRTC_4bpp_RGBA },
{ PixelFormat.PVRTC_4bpp_RGBA, PixelFormat.PVRTC_4bpp_RGBA_SRgb },
{ PixelFormat.ETC2_RGBA_SRgb, PixelFormat.ETC2_RGBA },
{ PixelFormat.ETC2_RGBA, PixelFormat.ETC2_RGBA_SRgb },
{ PixelFormat.ETC2_RGB_SRgb, PixelFormat.ETC2_RGB },
Expand Down
Loading

0 comments on commit 71e9e25

Please sign in to comment.