#pragma once
#include "CesiumGltf/Library.h"
namespace CesiumGltf {
/**
* @brief Supported GPU compressed pixel formats.
*/
enum class CESIUMGLTF_API GpuCompressedPixelFormat {
/**
* @brief The data is uncompressed.
*/
NONE,
/**
* @brief The data is an ETC1-compressed
* RGB888 texture.
*/
ETC1_RGB,
/**
* @brief The data is an ETC2-compressed RGBA8888 texture.
*/
ETC2_RGBA,
/**
* @brief The data is a BC1-compressed
* RGB565 texture.
*/
BC1_RGB,
/**
* @brief The data is a BC3-compressed
* RGBA5658 texture.
*/
BC3_RGBA,
/**
* @brief The data is a BC4-compressed
* R8 texture.
*/
BC4_R,
/**
* @brief The data is a BC5-compressed
* RG88 texture.
*/
BC5_RG,
/**
* @brief The data is a BC7-compressed
* RGBA8888 texture.
*/
BC7_RGBA,
/**
* @brief The data is a PVRTC1-compressed
* RGB444 texture.
*/
PVRTC1_4_RGB,
/**
* @brief The data is a PVRTC1-compressed
* RGBA4444 texture.
*/
PVRTC1_4_RGBA,
/**
* @brief The data is a ASTC-compressed
* RGBA texture with a 4x4 block footprint.
*/
ASTC_4x4_RGBA,
/**
* @brief The data is a PVRTC2-compressed
* RGB444 texture.
*/
PVRTC2_4_RGB,
/**
* @brief The data is a PVRTC2-compressed
* RGBA4444 texture.
*/
PVRTC2_4_RGBA,
/**
* @brief The data is a ETC2
* R11 EAC-compressed texture with a single channel.
*/
ETC2_EAC_R11,
/**
* @brief The data is a ETC2
* RG11 EAC-compressed texture with two channels.
*/
ETC2_EAC_RG11
};
/**
* @brief Represents the status of support for all
* {@link GpuCompressedPixelFormat}s on a client platform.
*
* Clients can use this struct to convey which gpu compressed pixel formats are
* supported. This can be used to construct a {@link Ktx2TranscodeTargets}.
*
* Each entry in the struct is a bool that represents whether the gpu
* compressed pixel format with the corresponding name is supported.
*/
struct CESIUMGLTF_API SupportedGpuCompressedPixelFormats {
/** @copydoc GpuCompressedPixelFormat::ETC1_RGB */
bool ETC1_RGB{};
/** @copydoc GpuCompressedPixelFormat::ETC2_RGBA */
bool ETC2_RGBA{};
/** @copydoc GpuCompressedPixelFormat::BC1_RGB */
bool BC1_RGB{};
/** @copydoc GpuCompressedPixelFormat::BC3_RGBA */
bool BC3_RGBA{};
/** @copydoc GpuCompressedPixelFormat::BC4_R */
bool BC4_R{};
/** @copydoc GpuCompressedPixelFormat::BC5_RG */
bool BC5_RG{};
/** @copydoc GpuCompressedPixelFormat::BC7_RGBA */
bool BC7_RGBA{};
/** @copydoc GpuCompressedPixelFormat::PVRTC1_4_RGB */
bool PVRTC1_4_RGB{};
/** @copydoc GpuCompressedPixelFormat::PVRTC1_4_RGBA */
bool PVRTC1_4_RGBA{};
/** @copydoc GpuCompressedPixelFormat::ASTC_4x4_RGBA */
bool ASTC_4x4_RGBA{};
/** @copydoc GpuCompressedPixelFormat::PVRTC2_4_RGB */
bool PVRTC2_4_RGB{};
/** @copydoc GpuCompressedPixelFormat::PVRTC2_4_RGBA */
bool PVRTC2_4_RGBA{};
/** @copydoc GpuCompressedPixelFormat::ETC2_EAC_R11 */
bool ETC2_EAC_R11{};
/** @copydoc GpuCompressedPixelFormat::ETC2_EAC_RG11 */
bool ETC2_EAC_RG11{};
};
/**
* @brief For each possible input transmission format, this struct names
* the ideal target gpu-compressed pixel format to transcode to.
*
* When built with the constructor, these targets can take into account
* platform-specific support for target formats as reported by the client.
*/
struct CESIUMGLTF_API Ktx2TranscodeTargets {
/**
* @brief The gpu pixel compression format to transcode Red ETC1S textures
* into. If NONE, it will be decompressed into raw pixels.
*/
GpuCompressedPixelFormat ETC1S_R = GpuCompressedPixelFormat::NONE;
/**
* @brief The gpu pixel compression format to transcode Red-Green ETC1S
* textures into, if one exists. Otherwise it will be decompressed into raw
* pixels.
*/
GpuCompressedPixelFormat ETC1S_RG = GpuCompressedPixelFormat::NONE;
/**
* @brief The gpu pixel compression format to transcode RGB ETC1S textures
* into. If NONE, it will be decompressed into raw pixels.
*/
GpuCompressedPixelFormat ETC1S_RGB = GpuCompressedPixelFormat::NONE;
/**
* @brief The gpu pixel compression format to transcode RGBA ETC1S textures
* into. If NONE, it will be decompressed into raw pixels.
*/
GpuCompressedPixelFormat ETC1S_RGBA = GpuCompressedPixelFormat::NONE;
/**
* @brief The gpu pixel compression format to transcode Red UASTC textures
* into. If NONE, it will be decompressed into raw pixels.
*/
GpuCompressedPixelFormat UASTC_R = GpuCompressedPixelFormat::NONE;
/**
* @brief The gpu pixel compression format to transcode Red-Green UASTC
* textures into. If NONE, it will be decompressed into raw pixels.
*/
GpuCompressedPixelFormat UASTC_RG = GpuCompressedPixelFormat::NONE;
/**
* @brief The gpu pixel compression format to transcode RGB UASTC textures
* into. If NONE, it will be decompressed into raw pixels.
*/
GpuCompressedPixelFormat UASTC_RGB = GpuCompressedPixelFormat::NONE;
/**
* @brief The gpu pixel compression format to transcode RGBA UASTC textures
* into. If NONE, it will be decompressed into raw pixels.
*/
GpuCompressedPixelFormat UASTC_RGBA = GpuCompressedPixelFormat::NONE;
Ktx2TranscodeTargets() = default;
/**
* @brief Determine ideal transcode targets based on a list of supported gpu
* compressed formats.
*
* @param supportedFormats The supported gpu compressed pixel formats.
* @param preserveHighQuality Whether to preserve texture quality when
* transcoding KTXv2 textures. If this is true, the texture may be fully
* decompressed instead of picking a lossy target gpu compressed pixel format.
*/
Ktx2TranscodeTargets(
const SupportedGpuCompressedPixelFormats& supportedFormats,
bool preserveHighQuality);
};
} // namespace CesiumGltf