diff --git a/Source/Engine/Graphics/PixelFormat.h b/Source/Engine/Graphics/PixelFormat.h
index 1257e42b7..f6793e543 100644
--- a/Source/Engine/Graphics/PixelFormat.h
+++ b/Source/Engine/Graphics/PixelFormat.h
@@ -513,6 +513,16 @@ API_ENUM() enum class PixelFormat : uint32
///
BC7_UNorm_sRGB = 99,
+ ///
+ /// A four-component ASTC (4x4 pixel block in 128 bits) block-compression format that supports RGBA channels.
+ ///
+ ASTC_4x4_UNorm = 100,
+
+ ///
+ /// A four-component ASTC (4x4 pixel block in 128 bits) block-compression format that supports RGBA channels.
+ ///
+ ASTC_4x4_UNorm_sRGB = 101,
+
///
/// The maximum format value (for internal use only).
///
diff --git a/Source/Engine/Graphics/PixelFormatExtensions.cpp b/Source/Engine/Graphics/PixelFormatExtensions.cpp
index 991844b22..4369ebb8b 100644
--- a/Source/Engine/Graphics/PixelFormatExtensions.cpp
+++ b/Source/Engine/Graphics/PixelFormatExtensions.cpp
@@ -5,19 +5,12 @@
// ReSharper disable CppClangTidyClangDiagnosticSwitchEnum
-#define MAX_PIXEL_FORMATS 256
-
namespace
{
- int32 sizeOfInBits[MAX_PIXEL_FORMATS];
-
- int32 GetIndex(const PixelFormat format)
- {
- return (int32)format;
- }
+ int32 sizeOfInBits[(int32)PixelFormat::MAX];
}
-#define InitFormat(formats, bitCount) for(int i = 0; i < ARRAY_COUNT(formats); i++) { sizeOfInBits[GetIndex(formats[i])] = bitCount; }
+#define InitFormat(formats, bitCount) for(int i = 0; i < ARRAY_COUNT(formats); i++) { sizeOfInBits[(int32)formats[i]] = bitCount; }
void PixelFormatExtensions::Init()
{
@@ -35,7 +28,9 @@ void PixelFormatExtensions::Init()
PixelFormat::R8_SNorm,
PixelFormat::R8_Typeless,
PixelFormat::R8_UInt,
- PixelFormat::R8_UNorm
+ PixelFormat::R8_UNorm,
+ PixelFormat::ASTC_4x4_UNorm,
+ PixelFormat::ASTC_4x4_UNorm_sRGB,
};
InitFormat(formats2, 8);
@@ -53,8 +48,7 @@ void PixelFormatExtensions::Init()
PixelFormat::R8G8_SNorm,
PixelFormat::R8G8_Typeless,
PixelFormat::R8G8_UInt,
- PixelFormat::R8G8_UNorm
-
+ PixelFormat::R8G8_UNorm,
};
InitFormat(formats3, 16);
@@ -163,7 +157,7 @@ void PixelFormatExtensions::Init()
int32 PixelFormatExtensions::SizeInBits(PixelFormat format)
{
- return sizeOfInBits[GetIndex(format)];
+ return sizeOfInBits[(int32)format];
}
int32 PixelFormatExtensions::AlphaSizeInBits(const PixelFormat format)
@@ -319,6 +313,8 @@ bool PixelFormatExtensions::IsCompressed(const PixelFormat format)
case PixelFormat::BC7_Typeless:
case PixelFormat::BC7_UNorm:
case PixelFormat::BC7_UNorm_sRGB:
+ case PixelFormat::ASTC_4x4_UNorm:
+ case PixelFormat::ASTC_4x4_UNorm_sRGB:
return true;
default:
return false;
@@ -356,6 +352,18 @@ bool PixelFormatExtensions::IsCompressedBC(PixelFormat format)
}
}
+bool PixelFormatExtensions::IsCompressedASTC(PixelFormat format)
+{
+ switch (format)
+ {
+ case PixelFormat::ASTC_4x4_UNorm:
+ case PixelFormat::ASTC_4x4_UNorm_sRGB:
+ return true;
+ default:
+ return false;
+ }
+}
+
bool PixelFormatExtensions::IsPacked(const PixelFormat format)
{
return format == PixelFormat::R8G8_B8G8_UNorm || format == PixelFormat::G8R8_G8B8_UNorm;
@@ -382,6 +390,7 @@ bool PixelFormatExtensions::IsSRGB(const PixelFormat format)
case PixelFormat::B8G8R8A8_UNorm_sRGB:
case PixelFormat::B8G8R8X8_UNorm_sRGB:
case PixelFormat::BC7_UNorm_sRGB:
+ case PixelFormat::ASTC_4x4_UNorm_sRGB:
return true;
default:
return false;
@@ -392,6 +401,8 @@ bool PixelFormatExtensions::IsHDR(const PixelFormat format)
{
switch (format)
{
+ case PixelFormat::R11G11B10_Float:
+ case PixelFormat::R10G10B10A2_UNorm:
case PixelFormat::R16G16B16A16_Float:
case PixelFormat::R32G32B32A32_Float:
case PixelFormat::R16G16_Float:
@@ -399,7 +410,6 @@ bool PixelFormatExtensions::IsHDR(const PixelFormat format)
case PixelFormat::BC6H_Sf16:
case PixelFormat::BC6H_Uf16:
return true;
-
default:
return false;
}
@@ -527,7 +537,7 @@ bool PixelFormatExtensions::IsInteger(const PixelFormat format)
}
}
-int PixelFormatExtensions::ComputeScanlineCount(const PixelFormat format, int32 height)
+int32 PixelFormatExtensions::ComputeScanlineCount(const PixelFormat format, int32 height)
{
switch (format)
{
@@ -552,13 +562,15 @@ int PixelFormatExtensions::ComputeScanlineCount(const PixelFormat format, int32
case PixelFormat::BC7_Typeless:
case PixelFormat::BC7_UNorm:
case PixelFormat::BC7_UNorm_sRGB:
+ case PixelFormat::ASTC_4x4_UNorm:
+ case PixelFormat::ASTC_4x4_UNorm_sRGB:
return Math::Max(1, (height + 3) / 4);
default:
return height;
}
}
-int PixelFormatExtensions::ComputeComponentsCount(const PixelFormat format)
+int32 PixelFormatExtensions::ComputeComponentsCount(const PixelFormat format)
{
switch (format)
{
@@ -599,6 +611,8 @@ int PixelFormatExtensions::ComputeComponentsCount(const PixelFormat format)
case PixelFormat::B8G8R8A8_UNorm_sRGB:
case PixelFormat::B8G8R8X8_Typeless:
case PixelFormat::B8G8R8X8_UNorm_sRGB:
+ case PixelFormat::ASTC_4x4_UNorm:
+ case PixelFormat::ASTC_4x4_UNorm_sRGB:
return 4;
case PixelFormat::R32G32B32_Typeless:
case PixelFormat::R32G32B32_Float:
@@ -678,6 +692,8 @@ PixelFormat PixelFormatExtensions::TosRGB(const PixelFormat format)
return PixelFormat::B8G8R8X8_UNorm_sRGB;
case PixelFormat::BC7_UNorm:
return PixelFormat::BC7_UNorm_sRGB;
+ case PixelFormat::ASTC_4x4_UNorm:
+ return PixelFormat::ASTC_4x4_UNorm_sRGB;
default:
return format;
}
@@ -701,6 +717,8 @@ PixelFormat PixelFormatExtensions::ToNonsRGB(const PixelFormat format)
return PixelFormat::B8G8R8X8_UNorm;
case PixelFormat::BC7_UNorm_sRGB:
return PixelFormat::BC7_UNorm;
+ case PixelFormat::ASTC_4x4_UNorm_sRGB:
+ return PixelFormat::ASTC_4x4_UNorm;
default:
return format;
}
diff --git a/Source/Engine/Graphics/PixelFormatExtensions.h b/Source/Engine/Graphics/PixelFormatExtensions.h
index 604bcb2c3..67049cd5a 100644
--- a/Source/Engine/Graphics/PixelFormatExtensions.h
+++ b/Source/Engine/Graphics/PixelFormatExtensions.h
@@ -95,6 +95,13 @@ public:
/// True if the is a compressed format from BC formats family.
API_FUNCTION() static bool IsCompressedBC(PixelFormat format);
+ ///
+ /// Returns true if the is a compressed format from ASTC formats family (various block sizes).
+ ///
+ /// The format to check for compressed.
+ /// True if the is a compressed format from ASTC formats family.
+ API_FUNCTION() static bool IsCompressedASTC(PixelFormat format);
+
///
/// Determines whether the specified is packed.
///
@@ -164,14 +171,14 @@ public:
/// The .
/// The height.
/// The scanline count.
- API_FUNCTION() static int ComputeScanlineCount(PixelFormat format, int32 height);
+ API_FUNCTION() static int32 ComputeScanlineCount(PixelFormat format, int32 height);
///
/// Computes the format components count (number of R, G, B, A channels).
///
/// The .
/// The components count.
- API_FUNCTION() static int ComputeComponentsCount(PixelFormat format);
+ API_FUNCTION() static int32 ComputeComponentsCount(PixelFormat format);
///
/// Finds the equivalent sRGB format to the provided format.
diff --git a/Source/Engine/GraphicsDevice/Vulkan/RenderToolsVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/RenderToolsVulkan.cpp
index 7bf254f6a..3a5a91e5e 100644
--- a/Source/Engine/GraphicsDevice/Vulkan/RenderToolsVulkan.cpp
+++ b/Source/Engine/GraphicsDevice/Vulkan/RenderToolsVulkan.cpp
@@ -6,8 +6,8 @@
#include "Engine/Core/Types/StringBuilder.h"
#include "Engine/Core/Log.h"
-VkFormat RenderToolsVulkan::PixelFormatToVkFormat[static_cast(PixelFormat::MAX)] = {
-
+VkFormat RenderToolsVulkan::PixelFormatToVkFormat[102] =
+{
VK_FORMAT_UNDEFINED,
VK_FORMAT_R32G32B32A32_SFLOAT,
VK_FORMAT_R32G32B32A32_SFLOAT,
@@ -27,13 +27,10 @@ VkFormat RenderToolsVulkan::PixelFormatToVkFormat[static_cast(PixelFormat
VK_FORMAT_R32G32_SFLOAT,
VK_FORMAT_R32G32_UINT,
VK_FORMAT_R32G32_SINT,
- VK_FORMAT_UNDEFINED,
- // TODO: R32G8X24_Typeless
+ VK_FORMAT_UNDEFINED, // TODO: R32G8X24_Typeless
VK_FORMAT_D32_SFLOAT_S8_UINT,
- VK_FORMAT_UNDEFINED,
- // TODO: R32_Float_X8X24_Typeless
- VK_FORMAT_UNDEFINED,
- // TODO: X32_Typeless_G8X24_UInt
+ VK_FORMAT_UNDEFINED, // TODO: R32_Float_X8X24_Typeless
+ VK_FORMAT_UNDEFINED, // TODO: X32_Typeless_G8X24_UInt
VK_FORMAT_A2B10G10R10_UNORM_PACK32,
VK_FORMAT_A2B10G10R10_UNORM_PACK32,
VK_FORMAT_A2B10G10R10_UINT_PACK32,
@@ -76,15 +73,11 @@ VkFormat RenderToolsVulkan::PixelFormatToVkFormat[static_cast(PixelFormat
VK_FORMAT_R8_UINT,
VK_FORMAT_R8_SNORM,
VK_FORMAT_R8_SINT,
- VK_FORMAT_UNDEFINED,
- // TODO: A8_UNorm
- VK_FORMAT_UNDEFINED,
- // TODO: R1_UNorm
+ VK_FORMAT_UNDEFINED, // TODO: A8_UNorm
+ VK_FORMAT_UNDEFINED, // TODO: R1_UNorm
VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
- VK_FORMAT_UNDEFINED,
- // TODO: R8G8_B8G8_UNorm
- VK_FORMAT_UNDEFINED,
- // TODO: G8R8_G8B8_UNorm
+ VK_FORMAT_UNDEFINED, // TODO: R8G8_B8G8_UNorm
+ VK_FORMAT_UNDEFINED, // TODO: G8R8_G8B8_UNorm
VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
@@ -104,8 +97,7 @@ VkFormat RenderToolsVulkan::PixelFormatToVkFormat[static_cast(PixelFormat
VK_FORMAT_B5G5R5A1_UNORM_PACK16,
VK_FORMAT_B8G8R8A8_UNORM,
VK_FORMAT_B8G8R8A8_UNORM,
- VK_FORMAT_UNDEFINED,
- // TODO: R10G10B10_Xr_Bias_A2_UNorm
+ VK_FORMAT_UNDEFINED, // TODO: R10G10B10_Xr_Bias_A2_UNorm
VK_FORMAT_B8G8R8A8_UNORM,
VK_FORMAT_B8G8R8A8_SRGB,
VK_FORMAT_B8G8R8A8_UNORM,
@@ -116,81 +108,53 @@ VkFormat RenderToolsVulkan::PixelFormatToVkFormat[static_cast(PixelFormat
VK_FORMAT_BC7_UNORM_BLOCK,
VK_FORMAT_BC7_UNORM_BLOCK,
VK_FORMAT_BC7_SRGB_BLOCK,
+ VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
+ VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
};
-VkBlendFactor RenderToolsVulkan::BlendToVkBlendFactor[static_cast(BlendingMode::Blend::MAX)] =
+VkBlendFactor RenderToolsVulkan::BlendToVkBlendFactor[20] =
{
VK_BLEND_FACTOR_MAX_ENUM,
- VK_BLEND_FACTOR_ZERO,
- // Zero
- VK_BLEND_FACTOR_ONE,
- // One
- VK_BLEND_FACTOR_SRC_COLOR,
- // SrcColor
- VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR,
- // InvSrcColor
- VK_BLEND_FACTOR_SRC_ALPHA,
- // SrcAlpha
- VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
- // InvSrcAlpha
- VK_BLEND_FACTOR_DST_ALPHA,
- // DestAlpha
- VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA,
- // InvDestAlpha
- VK_BLEND_FACTOR_DST_COLOR,
- // DestColor,
- VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR,
- // InvDestColor
- VK_BLEND_FACTOR_SRC_ALPHA_SATURATE,
- // SrcAlphaSat
- VK_BLEND_FACTOR_CONSTANT_ALPHA,
- // BlendFactor
- VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA,
- // BlendInvFactor
- VK_BLEND_FACTOR_SRC1_COLOR,
- // Src1Color
- VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR,
- // InvSrc1Color
- VK_BLEND_FACTOR_SRC1_ALPHA,
- // Src1Alpha
- VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA,
- // InvSrc1Alpha
+ VK_BLEND_FACTOR_ZERO, // Zero
+ VK_BLEND_FACTOR_ONE, // One
+ VK_BLEND_FACTOR_SRC_COLOR, // SrcColor
+ VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR, // InvSrcColor
+ VK_BLEND_FACTOR_SRC_ALPHA, // SrcAlpha
+ VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, // InvSrcAlpha
+ VK_BLEND_FACTOR_DST_ALPHA, // DestAlpha
+ VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA, // InvDestAlpha
+ VK_BLEND_FACTOR_DST_COLOR, // DestColor,
+ VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR, // InvDestColor
+ VK_BLEND_FACTOR_SRC_ALPHA_SATURATE, // SrcAlphaSat
+ VK_BLEND_FACTOR_CONSTANT_ALPHA, // BlendFactor
+ VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA, // BlendInvFactor
+ VK_BLEND_FACTOR_SRC1_COLOR, // Src1Color
+ VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR, // InvSrc1Color
+ VK_BLEND_FACTOR_SRC1_ALPHA, // Src1Alpha
+ VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA, // InvSrc1Alpha
};
-VkBlendOp RenderToolsVulkan::OperationToVkBlendOp[static_cast(BlendingMode::Operation::MAX)] =
+VkBlendOp RenderToolsVulkan::OperationToVkBlendOp[6] =
{
VK_BLEND_OP_MAX_ENUM,
- VK_BLEND_OP_ADD,
- // Add
- VK_BLEND_OP_SUBTRACT,
- // Subtract
- VK_BLEND_OP_REVERSE_SUBTRACT,
- // RevSubtract
- VK_BLEND_OP_MIN,
- // Min
- VK_BLEND_OP_MAX,
- // Max
+ VK_BLEND_OP_ADD, // Add
+ VK_BLEND_OP_SUBTRACT, // Subtract
+ VK_BLEND_OP_REVERSE_SUBTRACT, // RevSubtract
+ VK_BLEND_OP_MIN, // Min
+ VK_BLEND_OP_MAX, // Max
};
-VkCompareOp RenderToolsVulkan::ComparisonFuncToVkCompareOp[static_cast(ComparisonFunc::MAX)] =
+VkCompareOp RenderToolsVulkan::ComparisonFuncToVkCompareOp[9] =
{
VK_COMPARE_OP_MAX_ENUM,
- VK_COMPARE_OP_NEVER,
- // Never
- VK_COMPARE_OP_LESS,
- // Less
- VK_COMPARE_OP_EQUAL,
- // Equal
- VK_COMPARE_OP_LESS_OR_EQUAL,
- // LessEqual
- VK_COMPARE_OP_GREATER,
- // Grather
- VK_COMPARE_OP_NOT_EQUAL,
- // NotEqual
- VK_COMPARE_OP_GREATER_OR_EQUAL,
- // GratherEqual
- VK_COMPARE_OP_ALWAYS,
- // Always
+ VK_COMPARE_OP_NEVER, // Never
+ VK_COMPARE_OP_LESS, // Less
+ VK_COMPARE_OP_EQUAL, // Equal
+ VK_COMPARE_OP_LESS_OR_EQUAL, // LessEqual
+ VK_COMPARE_OP_GREATER, // Grather
+ VK_COMPARE_OP_NOT_EQUAL, // NotEqual
+ VK_COMPARE_OP_GREATER_OR_EQUAL, // GratherEqual
+ VK_COMPARE_OP_ALWAYS, // Always
};
#define VKERR(x) case x: sb.Append(TEXT(#x)); break