More complete DataFormat enum

This commit is contained in:
Henrik Rydgård 2016-12-25 22:11:14 +01:00
parent 425940b433
commit cce1ee332b
5 changed files with 48 additions and 11 deletions

View file

@ -180,7 +180,7 @@ static DataFormat ZimToT3DFormat(int zim) {
switch (zim) {
case ZIM_ETC1: return DataFormat::ETC1;
case ZIM_RGBA8888: return DataFormat::R8G8B8A8_UNORM;
case ZIM_LUMINANCE: return DataFormat::LUMINANCE;
case ZIM_LUMINANCE: return DataFormat::R8_UNORM;
default: return DataFormat::R8G8B8A8_UNORM;
}
}

View file

@ -160,19 +160,56 @@ enum TextureType : uint8_t {
};
enum class DataFormat : uint8_t {
UNKNOWN,
LUMINANCE,
UNDEFINED,
R8_UNORM,
R8G8_UNORM,
R8G8B8_UNORM,
R8G8B8A8_UNORM,
R8G8B8A8_UNORM_SRGB,
R8G8B8A8_SNORM,
R8G8B8A8_UINT,
R8G8B8A8_SINT,
R4G4_UNORM,
R4G4B4A4_UNORM,
R16_FLOAT,
R16G16_FLOAT,
R16G16B16A16_FLOAT,
R32_FLOAT,
R32G32_FLOAT,
R32G32B32_FLOAT,
R32G32B32A32_FLOAT,
DXT1,
ETC1, // Needs simulation on many platforms
// Block compression formats.
// These are modern names for DXT and friends, now patent free.
// https://msdn.microsoft.com/en-us/library/bb694531.aspx
BC1_RGBA_UNORM_BLOCK,
BC1_RGBA_SRGB_BLOCK,
BC2_UNORM_BLOCK, // 4-bit straight alpha + DXT1 color. Usually not worth using
BC2_SRGB_BLOCK,
BC3_UNORM_BLOCK, // 3-bit alpha with 2 ref values (+ magic) + DXT1 color
BC3_SRGB_BLOCK,
BC4_UNORM_BLOCK, // 1-channel, same storage as BC3 alpha
BC4_SNORM_BLOCK,
BC5_UNORM_BLOCK, // 2-channel RG, each has same storage as BC3 alpha
BC5_SNORM_BLOCK,
BC6H_UFLOAT_BLOCK, // TODO
BC6H_SFLOAT_BLOCK,
BC7_UNORM_BLOCK, // Highly advanced, very expensive to compress, very good quality.
BC7_SRGB_BLOCK,
ETC1,
S8,
D16,
D24S8,
D24X8,
D24_S8,
D32F,
D32F_S8,
};
enum ImageFileType {
@ -263,7 +300,7 @@ protected:
};
struct VertexComponent {
VertexComponent() : name(nullptr), type(DataFormat::UNKNOWN), semantic(255), offset(255) {}
VertexComponent() : name(nullptr), type(DataFormat::UNDEFINED), semantic(255), offset(255) {}
VertexComponent(const char *name, Semantic semantic, DataFormat dataType, uint8_t offset) {
this->name = name;
this->semantic = semantic;

View file

@ -316,7 +316,7 @@ D3DFORMAT FormatToD3D(DataFormat fmt) {
switch (fmt) {
case DataFormat::R8G8B8A8_UNORM: return D3DFMT_A8R8G8B8;
case DataFormat::R4G4B4A4_UNORM: return D3DFMT_A4R4G4B4;
case DataFormat::D24S8: return D3DFMT_D24S8;
case DataFormat::D24_S8: return D3DFMT_D24S8;
case DataFormat::D16: return D3DFMT_D16;
default: return D3DFMT_UNKNOWN;
}

View file

@ -1027,7 +1027,7 @@ void OpenGLVertexFormat::Apply(const void *base) {
case DataFormat::R8G8B8A8_UNORM:
glVertexAttribPointer(components_[i].semantic, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride_, (void *)(b + (intptr_t)components_[i].offset));
break;
case DataFormat::UNKNOWN:
case DataFormat::UNDEFINED:
default:
ELOG("Thin3DGLVertexFormat: Invalid or unknown component type applied.");
break;

View file

@ -526,7 +526,7 @@ VkFormat FormatToVulkan(DataFormat fmt, int *bpp) {
switch (fmt) {
case DataFormat::R8G8B8A8_UNORM: *bpp = 32; return VK_FORMAT_R8G8B8A8_UNORM;
case DataFormat::R4G4B4A4_UNORM: *bpp = 16; return VK_FORMAT_R4G4B4A4_UNORM_PACK16;
case DataFormat::D24S8: *bpp = 32; return VK_FORMAT_D24_UNORM_S8_UINT;
case DataFormat::D24_S8: *bpp = 32; return VK_FORMAT_D24_UNORM_S8_UINT;
case DataFormat::D16: *bpp = 16; return VK_FORMAT_D16_UNORM;
default: return VK_FORMAT_UNDEFINED;
}