1
1
Fork 0
forked from suyu/suyu

video_core: Update texture format

This commit is contained in:
Feng Chen 2023-03-10 15:06:56 +08:00 committed by FengChen
parent ec4e2d1fab
commit c8ad039612
3 changed files with 67 additions and 72 deletions

View file

@ -166,7 +166,7 @@ struct FormatTuple {
{VK_FORMAT_R16G16_UINT, Attachable | Storage}, // R16G16_UINT {VK_FORMAT_R16G16_UINT, Attachable | Storage}, // R16G16_UINT
{VK_FORMAT_R16G16_SINT, Attachable | Storage}, // R16G16_SINT {VK_FORMAT_R16G16_SINT, Attachable | Storage}, // R16G16_SINT
{VK_FORMAT_R16G16_SNORM, Attachable | Storage}, // R16G16_SNORM {VK_FORMAT_R16G16_SNORM, Attachable | Storage}, // R16G16_SNORM
{VK_FORMAT_UNDEFINED}, // R32G32B32_FLOAT {VK_FORMAT_R32G32B32_SFLOAT}, // R32G32B32_FLOAT
{VK_FORMAT_A8B8G8R8_SRGB_PACK32, Attachable}, // A8B8G8R8_SRGB {VK_FORMAT_A8B8G8R8_SRGB_PACK32, Attachable}, // A8B8G8R8_SRGB
{VK_FORMAT_R8G8_UNORM, Attachable | Storage}, // R8G8_UNORM {VK_FORMAT_R8G8_UNORM, Attachable | Storage}, // R8G8_UNORM
{VK_FORMAT_R8G8_SNORM, Attachable | Storage}, // R8G8_SNORM {VK_FORMAT_R8G8_SNORM, Attachable | Storage}, // R8G8_SNORM
@ -234,11 +234,6 @@ FormatInfo SurfaceFormat(const Device& device, FormatType format_type, bool with
PixelFormat pixel_format) { PixelFormat pixel_format) {
ASSERT(static_cast<size_t>(pixel_format) < std::size(tex_format_tuples)); ASSERT(static_cast<size_t>(pixel_format) < std::size(tex_format_tuples));
FormatTuple tuple = tex_format_tuples[static_cast<size_t>(pixel_format)]; FormatTuple tuple = tex_format_tuples[static_cast<size_t>(pixel_format)];
if (tuple.format == VK_FORMAT_UNDEFINED) {
UNIMPLEMENTED_MSG("Unimplemented texture format with pixel format={}", pixel_format);
return FormatInfo{VK_FORMAT_A8B8G8R8_UNORM_PACK32, true, true};
}
// Use A8B8G8R8_UNORM on hardware that doesn't support ASTC natively // Use A8B8G8R8_UNORM on hardware that doesn't support ASTC natively
if (!device.IsOptimalAstcSupported() && VideoCore::Surface::IsPixelFormatASTC(pixel_format)) { if (!device.IsOptimalAstcSupported() && VideoCore::Surface::IsPixelFormatASTC(pixel_format)) {
const bool is_srgb = with_srgb && VideoCore::Surface::IsPixelFormatSRGB(pixel_format); const bool is_srgb = with_srgb && VideoCore::Surface::IsPixelFormatSRGB(pixel_format);

View file

@ -42,15 +42,15 @@ PixelFormat PixelFormatFromTextureInfo(TextureFormat format, ComponentType red,
ComponentType blue, ComponentType alpha, ComponentType blue, ComponentType alpha,
bool is_srgb) noexcept { bool is_srgb) noexcept {
switch (Hash(format, red, green, blue, alpha, is_srgb)) { switch (Hash(format, red, green, blue, alpha, is_srgb)) {
case Hash(TextureFormat::A8R8G8B8, UNORM): case Hash(TextureFormat::A8B8G8R8, UNORM):
return PixelFormat::A8B8G8R8_UNORM; return PixelFormat::A8B8G8R8_UNORM;
case Hash(TextureFormat::A8R8G8B8, SNORM): case Hash(TextureFormat::A8B8G8R8, SNORM):
return PixelFormat::A8B8G8R8_SNORM; return PixelFormat::A8B8G8R8_SNORM;
case Hash(TextureFormat::A8R8G8B8, UINT): case Hash(TextureFormat::A8B8G8R8, UINT):
return PixelFormat::A8B8G8R8_UINT; return PixelFormat::A8B8G8R8_UINT;
case Hash(TextureFormat::A8R8G8B8, SINT): case Hash(TextureFormat::A8B8G8R8, SINT):
return PixelFormat::A8B8G8R8_SINT; return PixelFormat::A8B8G8R8_SINT;
case Hash(TextureFormat::A8R8G8B8, UNORM, SRGB): case Hash(TextureFormat::A8B8G8R8, UNORM, SRGB):
return PixelFormat::A8B8G8R8_SRGB; return PixelFormat::A8B8G8R8_SRGB;
case Hash(TextureFormat::B5G6R5, UNORM): case Hash(TextureFormat::B5G6R5, UNORM):
return PixelFormat::B5G6R5_UNORM; return PixelFormat::B5G6R5_UNORM;
@ -74,13 +74,13 @@ PixelFormat PixelFormatFromTextureInfo(TextureFormat format, ComponentType red,
return PixelFormat::R8_UINT; return PixelFormat::R8_UINT;
case Hash(TextureFormat::R8, SINT): case Hash(TextureFormat::R8, SINT):
return PixelFormat::R8_SINT; return PixelFormat::R8_SINT;
case Hash(TextureFormat::R8G8, UNORM): case Hash(TextureFormat::G8R8, UNORM):
return PixelFormat::R8G8_UNORM; return PixelFormat::R8G8_UNORM;
case Hash(TextureFormat::R8G8, SNORM): case Hash(TextureFormat::G8R8, SNORM):
return PixelFormat::R8G8_SNORM; return PixelFormat::R8G8_SNORM;
case Hash(TextureFormat::R8G8, UINT): case Hash(TextureFormat::G8R8, UINT):
return PixelFormat::R8G8_UINT; return PixelFormat::R8G8_UINT;
case Hash(TextureFormat::R8G8, SINT): case Hash(TextureFormat::G8R8, SINT):
return PixelFormat::R8G8_SINT; return PixelFormat::R8G8_SINT;
case Hash(TextureFormat::R16G16B16A16, FLOAT): case Hash(TextureFormat::R16G16B16A16, FLOAT):
return PixelFormat::R16G16B16A16_FLOAT; return PixelFormat::R16G16B16A16_FLOAT;
@ -136,49 +136,49 @@ PixelFormat PixelFormatFromTextureInfo(TextureFormat format, ComponentType red,
return PixelFormat::R32_SINT; return PixelFormat::R32_SINT;
case Hash(TextureFormat::E5B9G9R9, FLOAT): case Hash(TextureFormat::E5B9G9R9, FLOAT):
return PixelFormat::E5B9G9R9_FLOAT; return PixelFormat::E5B9G9R9_FLOAT;
case Hash(TextureFormat::D32, FLOAT): case Hash(TextureFormat::Z32, FLOAT):
return PixelFormat::D32_FLOAT; return PixelFormat::D32_FLOAT;
case Hash(TextureFormat::D16, UNORM): case Hash(TextureFormat::Z16, UNORM):
return PixelFormat::D16_UNORM; return PixelFormat::D16_UNORM;
case Hash(TextureFormat::S8D24, UINT, UNORM, UNORM, UNORM, LINEAR): case Hash(TextureFormat::Z24S8, UINT, UNORM, UNORM, UNORM, LINEAR):
return PixelFormat::S8_UINT_D24_UNORM; return PixelFormat::S8_UINT_D24_UNORM;
case Hash(TextureFormat::S8D24, UINT, UNORM, UINT, UINT, LINEAR): case Hash(TextureFormat::Z24S8, UINT, UNORM, UINT, UINT, LINEAR):
return PixelFormat::S8_UINT_D24_UNORM; return PixelFormat::S8_UINT_D24_UNORM;
case Hash(TextureFormat::R8G24, UINT, UNORM, UNORM, UNORM, LINEAR): case Hash(TextureFormat::G24R8, UINT, UNORM, UNORM, UNORM, LINEAR):
return PixelFormat::S8_UINT_D24_UNORM; return PixelFormat::S8_UINT_D24_UNORM;
case Hash(TextureFormat::D24S8, UNORM, UINT, UINT, UINT, LINEAR): case Hash(TextureFormat::S8Z24, UNORM, UINT, UINT, UINT, LINEAR):
return PixelFormat::D24_UNORM_S8_UINT; return PixelFormat::D24_UNORM_S8_UINT;
case Hash(TextureFormat::D32S8, FLOAT, UINT, UNORM, UNORM, LINEAR): case Hash(TextureFormat::Z32_X24S8, FLOAT, UINT, UNORM, UNORM, LINEAR):
return PixelFormat::D32_FLOAT_S8_UINT; return PixelFormat::D32_FLOAT_S8_UINT;
case Hash(TextureFormat::R32_B24G8, FLOAT, UINT, UNORM, UNORM, LINEAR): case Hash(TextureFormat::R32B24G8, FLOAT, UINT, UNORM, UNORM, LINEAR):
return PixelFormat::D32_FLOAT_S8_UINT; return PixelFormat::D32_FLOAT_S8_UINT;
case Hash(TextureFormat::BC1_RGBA, UNORM, LINEAR): case Hash(TextureFormat::DXT1, UNORM, LINEAR):
return PixelFormat::BC1_RGBA_UNORM; return PixelFormat::BC1_RGBA_UNORM;
case Hash(TextureFormat::BC1_RGBA, UNORM, SRGB): case Hash(TextureFormat::DXT1, UNORM, SRGB):
return PixelFormat::BC1_RGBA_SRGB; return PixelFormat::BC1_RGBA_SRGB;
case Hash(TextureFormat::BC2, UNORM, LINEAR): case Hash(TextureFormat::DXT23, UNORM, LINEAR):
return PixelFormat::BC2_UNORM; return PixelFormat::BC2_UNORM;
case Hash(TextureFormat::BC2, UNORM, SRGB): case Hash(TextureFormat::DXT23, UNORM, SRGB):
return PixelFormat::BC2_SRGB; return PixelFormat::BC2_SRGB;
case Hash(TextureFormat::BC3, UNORM, LINEAR): case Hash(TextureFormat::DXT45, UNORM, LINEAR):
return PixelFormat::BC3_UNORM; return PixelFormat::BC3_UNORM;
case Hash(TextureFormat::BC3, UNORM, SRGB): case Hash(TextureFormat::DXT45, UNORM, SRGB):
return PixelFormat::BC3_SRGB; return PixelFormat::BC3_SRGB;
case Hash(TextureFormat::BC4, UNORM): case Hash(TextureFormat::DXN1, UNORM):
return PixelFormat::BC4_UNORM; return PixelFormat::BC4_UNORM;
case Hash(TextureFormat::BC4, SNORM): case Hash(TextureFormat::DXN1, SNORM):
return PixelFormat::BC4_SNORM; return PixelFormat::BC4_SNORM;
case Hash(TextureFormat::BC5, UNORM): case Hash(TextureFormat::DXN2, UNORM):
return PixelFormat::BC5_UNORM; return PixelFormat::BC5_UNORM;
case Hash(TextureFormat::BC5, SNORM): case Hash(TextureFormat::DXN2, SNORM):
return PixelFormat::BC5_SNORM; return PixelFormat::BC5_SNORM;
case Hash(TextureFormat::BC7, UNORM, LINEAR): case Hash(TextureFormat::BC7U, UNORM, LINEAR):
return PixelFormat::BC7_UNORM; return PixelFormat::BC7_UNORM;
case Hash(TextureFormat::BC7, UNORM, SRGB): case Hash(TextureFormat::BC7U, UNORM, SRGB):
return PixelFormat::BC7_SRGB; return PixelFormat::BC7_SRGB;
case Hash(TextureFormat::BC6H_SFLOAT, FLOAT): case Hash(TextureFormat::BC6H_S16, FLOAT):
return PixelFormat::BC6H_SFLOAT; return PixelFormat::BC6H_SFLOAT;
case Hash(TextureFormat::BC6H_UFLOAT, FLOAT): case Hash(TextureFormat::BC6H_U16, FLOAT):
return PixelFormat::BC6H_UFLOAT; return PixelFormat::BC6H_UFLOAT;
case Hash(TextureFormat::ASTC_2D_4X4, UNORM, LINEAR): case Hash(TextureFormat::ASTC_2D_4X4, UNORM, LINEAR):
return PixelFormat::ASTC_2D_4X4_UNORM; return PixelFormat::ASTC_2D_4X4_UNORM;

View file

@ -15,26 +15,26 @@ enum class TextureFormat : u32 {
R32G32B32 = 0x02, R32G32B32 = 0x02,
R16G16B16A16 = 0x03, R16G16B16A16 = 0x03,
R32G32 = 0x04, R32G32 = 0x04,
R32_B24G8 = 0x05, R32B24G8 = 0x05,
ETC2_RGB = 0x06, ETC2_RGB = 0x06,
X8B8G8R8 = 0x07, X8B8G8R8 = 0x07,
A8R8G8B8 = 0x08, A8B8G8R8 = 0x08,
A2B10G10R10 = 0x09, A2B10G10R10 = 0x09,
ETC2_RGB_PTA = 0x0a, ETC2_RGB_PTA = 0x0a,
ETC2_RGBA = 0x0b, ETC2_RGBA = 0x0b,
R16G16 = 0x0c, R16G16 = 0x0c,
R24G8 = 0x0d, G8R24 = 0x0d,
R8G24 = 0x0e, G24R8 = 0x0e,
R32 = 0x0f, R32 = 0x0f,
BC6H_SFLOAT = 0x10, BC6H_S16 = 0x10,
BC6H_UFLOAT = 0x11, BC6H_U16 = 0x11,
A4B4G4R4 = 0x12, A4B4G4R4 = 0x12,
A5B5G5R1 = 0x13, A5B5G5R1 = 0x13,
A1B5G5R5 = 0x14, A1B5G5R5 = 0x14,
B5G6R5 = 0x15, B5G6R5 = 0x15,
B6G5R5 = 0x16, B6G5R5 = 0x16,
BC7 = 0x17, BC7U = 0x17,
R8G8 = 0x18, G8R8 = 0x18,
EAC = 0x19, EAC = 0x19,
EACX2 = 0x1a, EACX2 = 0x1a,
R16 = 0x1b, R16 = 0x1b,
@ -46,33 +46,33 @@ enum class TextureFormat : u32 {
B10G11R11 = 0x21, B10G11R11 = 0x21,
G8B8G8R8 = 0x22, G8B8G8R8 = 0x22,
B8G8R8G8 = 0x23, B8G8R8G8 = 0x23,
BC1_RGBA = 0x24, DXT1 = 0x24,
BC2 = 0x25, DXT23 = 0x25,
BC3 = 0x26, DXT45 = 0x26,
BC4 = 0x27, DXN1 = 0x27,
BC5 = 0x28, DXN2 = 0x28,
S8D24 = 0x29, Z24S8 = 0x29,
X8D24 = 0x2a, X8Z24 = 0x2a,
D24S8 = 0x2b, S8Z24 = 0x2b,
X4V4D24__COV4R4V = 0x2c, X4V4Z24__COV4R4V = 0x2c,
X4V4D24__COV8R8V = 0x2d, X4V4Z24__COV8R8V = 0x2d,
V8D24__COV4R12V = 0x2e, V8Z24__COV4R12V = 0x2e,
D32 = 0x2f, Z32 = 0x2f,
D32S8 = 0x30, Z32_X24S8 = 0x30,
X8D24_X20V4S8__COV4R4V = 0x31, X8Z24_X20V4S8__COV4R4V = 0x31,
X8D24_X20V4S8__COV8R8V = 0x32, X8Z24_X20V4S8__COV8R8V = 0x32,
D32_X20V4X8__COV4R4V = 0x33, Z32_X20V4X8__COV4R4V = 0x33,
D32_X20V4X8__COV8R8V = 0x34, Z32_X20V4X8__COV8R8V = 0x34,
D32_X20V4S8__COV4R4V = 0x35, Z32_X20V4S8__COV4R4V = 0x35,
D32_X20V4S8__COV8R8V = 0x36, Z32_X20V4S8__COV8R8V = 0x36,
X8D24_X16V8S8__COV4R12V = 0x37, X8Z24_X16V8S8__COV4R12V = 0x37,
D32_X16V8X8__COV4R12V = 0x38, Z32_X16V8X8__COV4R12V = 0x38,
D32_X16V8S8__COV4R12V = 0x39, Z32_X16V8S8__COV4R12V = 0x39,
D16 = 0x3a, Z16 = 0x3a,
V8D24__COV8R24V = 0x3b, V8Z24__COV8R24V = 0x3b,
X8D24_X16V8S8__COV8R24V = 0x3c, X8Z24_X16V8S8__COV8R24V = 0x3c,
D32_X16V8X8__COV8R24V = 0x3d, Z32_X16V8X8__COV8R24V = 0x3d,
D32_X16V8S8__COV8R24V = 0x3e, Z32_X16V8S8__COV8R24V = 0x3e,
ASTC_2D_4X4 = 0x40, ASTC_2D_4X4 = 0x40,
ASTC_2D_5X5 = 0x41, ASTC_2D_5X5 = 0x41,
ASTC_2D_6X6 = 0x42, ASTC_2D_6X6 = 0x42,