#pragma once
#include <cstdint>
#include <cstdlib>
namespace Draw {
enum class DataFormat : uint8_t {
UNDEFINED,
R8_UNORM,
R8G8_UNORM,
R8G8B8_UNORM,
R8G8B8A8_UNORM,
R8G8B8A8_UNORM_SRGB,
B8G8R8A8_UNORM,
B8G8R8A8_UNORM_SRGB,
R8G8B8A8_SNORM,
R8G8B8A8_UINT,
R8G8B8A8_SINT,
R4G4_UNORM_PACK8,
A4R4G4B4_UNORM_PACK16,
B4G4R4A4_UNORM_PACK16,
R4G4B4A4_UNORM_PACK16,
R5G6B5_UNORM_PACK16,
B5G6R5_UNORM_PACK16,
R5G5B5A1_UNORM_PACK16,
B5G5R5A1_UNORM_PACK16,
A1R5G5B5_UNORM_PACK16,
A1B5G5R5_UNORM_PACK16,
R16_UNORM,
R16_FLOAT,
R16G16_FLOAT,
R16G16B16A16_FLOAT,
R32_FLOAT,
R32G32_FLOAT,
R32G32B32_FLOAT,
R32G32B32A32_FLOAT,
BC1_RGBA_UNORM_BLOCK,
BC2_UNORM_BLOCK,
BC3_UNORM_BLOCK,
BC4_UNORM_BLOCK,
BC5_UNORM_BLOCK,
BC7_UNORM_BLOCK,
ETC2_R8G8B8_UNORM_BLOCK,
ETC2_R8G8B8A1_UNORM_BLOCK,
ETC2_R8G8B8A8_UNORM_BLOCK,
ASTC_4x4_UNORM_BLOCK,
S8,
D16,
D16_S8,
D24_S8,
D32F,
D32F_S8,
};
size_t DataFormatSizeInBytes(DataFormat fmt);
bool DataFormatIsDepthStencil(DataFormat fmt);
inline bool DataFormatIsColor(DataFormat fmt) {
return !DataFormatIsDepthStencil(fmt);
}
int DataFormatNumChannels(DataFormat fmt);
bool DataFormatIsBlockCompressed(DataFormat fmt, int *blockSize);
const char *DataFormatToString(DataFormat fmt);
void ConvertFromRGBA8888(uint8_t *dst, const uint8_t *src, uint32_t dstStride, uint32_t srcStride, uint32_t width, uint32_t height, DataFormat format);
void ConvertFromBGRA8888(uint8_t *dst, const uint8_t *src, uint32_t dstStride, uint32_t srcStride, uint32_t width, uint32_t height, DataFormat format);
void ConvertToD32F(uint8_t *dst, const uint8_t *src, uint32_t dstStride, uint32_t srcStride, uint32_t width, uint32_t height, DataFormat format);
void ConvertToD16(uint8_t *dst, const uint8_t *src, uint32_t dstStride, uint32_t srcStride, uint32_t width, uint32_t height, DataFormat format);
}