mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-15 23:40:05 +00:00
video_core: Fix DXT4 and RGB565
This commit is contained in:
parent
a8dab2ffb3
commit
eda37ff26b
@ -46,6 +46,7 @@ static constexpr ConversionArray morton_to_linear_fns = {
|
|||||||
MortonCopy<true, PixelFormat::ABGR8I>,
|
MortonCopy<true, PixelFormat::ABGR8I>,
|
||||||
MortonCopy<true, PixelFormat::ABGR8UI>,
|
MortonCopy<true, PixelFormat::ABGR8UI>,
|
||||||
MortonCopy<true, PixelFormat::B5G6R5U>,
|
MortonCopy<true, PixelFormat::B5G6R5U>,
|
||||||
|
MortonCopy<true, PixelFormat::R5G6B5U>,
|
||||||
MortonCopy<true, PixelFormat::B5G5R5A1U>,
|
MortonCopy<true, PixelFormat::B5G5R5A1U>,
|
||||||
MortonCopy<true, PixelFormat::A2B10G10R10U>,
|
MortonCopy<true, PixelFormat::A2B10G10R10U>,
|
||||||
MortonCopy<true, PixelFormat::A2B10G10R10UI>,
|
MortonCopy<true, PixelFormat::A2B10G10R10UI>,
|
||||||
@ -64,7 +65,8 @@ static constexpr ConversionArray morton_to_linear_fns = {
|
|||||||
MortonCopy<true, PixelFormat::DXT1>,
|
MortonCopy<true, PixelFormat::DXT1>,
|
||||||
MortonCopy<true, PixelFormat::DXT23>,
|
MortonCopy<true, PixelFormat::DXT23>,
|
||||||
MortonCopy<true, PixelFormat::DXT45>,
|
MortonCopy<true, PixelFormat::DXT45>,
|
||||||
MortonCopy<true, PixelFormat::DXN1>,
|
MortonCopy<true, PixelFormat::DXN1UNORM>,
|
||||||
|
MortonCopy<true, PixelFormat::DXN1SNORM>,
|
||||||
MortonCopy<true, PixelFormat::DXN2UNORM>,
|
MortonCopy<true, PixelFormat::DXN2UNORM>,
|
||||||
MortonCopy<true, PixelFormat::DXN2SNORM>,
|
MortonCopy<true, PixelFormat::DXN2SNORM>,
|
||||||
MortonCopy<true, PixelFormat::BC7U>,
|
MortonCopy<true, PixelFormat::BC7U>,
|
||||||
@ -138,6 +140,7 @@ static constexpr ConversionArray linear_to_morton_fns = {
|
|||||||
MortonCopy<false, PixelFormat::ABGR8I>,
|
MortonCopy<false, PixelFormat::ABGR8I>,
|
||||||
MortonCopy<false, PixelFormat::ABGR8UI>,
|
MortonCopy<false, PixelFormat::ABGR8UI>,
|
||||||
MortonCopy<false, PixelFormat::B5G6R5U>,
|
MortonCopy<false, PixelFormat::B5G6R5U>,
|
||||||
|
MortonCopy<false, PixelFormat::R5G6B5U>,
|
||||||
MortonCopy<false, PixelFormat::B5G5R5A1U>,
|
MortonCopy<false, PixelFormat::B5G5R5A1U>,
|
||||||
MortonCopy<false, PixelFormat::A2B10G10R10U>,
|
MortonCopy<false, PixelFormat::A2B10G10R10U>,
|
||||||
MortonCopy<false, PixelFormat::A2B10G10R10UI>,
|
MortonCopy<false, PixelFormat::A2B10G10R10UI>,
|
||||||
@ -156,7 +159,8 @@ static constexpr ConversionArray linear_to_morton_fns = {
|
|||||||
MortonCopy<false, PixelFormat::DXT1>,
|
MortonCopy<false, PixelFormat::DXT1>,
|
||||||
MortonCopy<false, PixelFormat::DXT23>,
|
MortonCopy<false, PixelFormat::DXT23>,
|
||||||
MortonCopy<false, PixelFormat::DXT45>,
|
MortonCopy<false, PixelFormat::DXT45>,
|
||||||
MortonCopy<false, PixelFormat::DXN1>,
|
MortonCopy<false, PixelFormat::DXN1UNORM>,
|
||||||
|
MortonCopy<false, PixelFormat::DXN1SNORM>,
|
||||||
MortonCopy<false, PixelFormat::DXN2UNORM>,
|
MortonCopy<false, PixelFormat::DXN2UNORM>,
|
||||||
MortonCopy<false, PixelFormat::DXN2SNORM>,
|
MortonCopy<false, PixelFormat::DXN2SNORM>,
|
||||||
MortonCopy<false, PixelFormat::BC7U>,
|
MortonCopy<false, PixelFormat::BC7U>,
|
||||||
|
@ -46,6 +46,7 @@ constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> tex_format
|
|||||||
{GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE}, // ABGR8I
|
{GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE}, // ABGR8I
|
||||||
{GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE}, // ABGR8UI
|
{GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE}, // ABGR8UI
|
||||||
{GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5}, // B5G6R5U
|
{GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5}, // B5G6R5U
|
||||||
|
{GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV}, // R5G6B5U
|
||||||
{GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV}, // B5G5R5A1U
|
{GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV}, // B5G5R5A1U
|
||||||
{GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV}, // A2B10G10R10U
|
{GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV}, // A2B10G10R10U
|
||||||
{GL_RGB10_A2UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV}, // A2B10G10R10UI
|
{GL_RGB10_A2UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV}, // A2B10G10R10UI
|
||||||
@ -64,7 +65,8 @@ constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> tex_format
|
|||||||
{GL_COMPRESSED_RGBA_S3TC_DXT1_EXT}, // DXT1
|
{GL_COMPRESSED_RGBA_S3TC_DXT1_EXT}, // DXT1
|
||||||
{GL_COMPRESSED_RGBA_S3TC_DXT3_EXT}, // DXT23
|
{GL_COMPRESSED_RGBA_S3TC_DXT3_EXT}, // DXT23
|
||||||
{GL_COMPRESSED_RGBA_S3TC_DXT5_EXT}, // DXT45
|
{GL_COMPRESSED_RGBA_S3TC_DXT5_EXT}, // DXT45
|
||||||
{GL_COMPRESSED_RED_RGTC1}, // DXN1
|
{GL_COMPRESSED_RED_RGTC1}, // DXN1UNORM
|
||||||
|
{GL_COMPRESSED_SIGNED_RED_RGTC1}, // DXN1SNORM
|
||||||
{GL_COMPRESSED_RG_RGTC2}, // DXN2UNORM
|
{GL_COMPRESSED_RG_RGTC2}, // DXN2UNORM
|
||||||
{GL_COMPRESSED_SIGNED_RG_RGTC2}, // DXN2SNORM
|
{GL_COMPRESSED_SIGNED_RG_RGTC2}, // DXN2SNORM
|
||||||
{GL_COMPRESSED_RGBA_BPTC_UNORM}, // BC7U
|
{GL_COMPRESSED_RGBA_BPTC_UNORM}, // BC7U
|
||||||
|
@ -122,6 +122,7 @@ struct FormatTuple {
|
|||||||
{VK_FORMAT_A8B8G8R8_SINT_PACK32, Attachable | Storage}, // ABGR8I
|
{VK_FORMAT_A8B8G8R8_SINT_PACK32, Attachable | Storage}, // ABGR8I
|
||||||
{VK_FORMAT_A8B8G8R8_UINT_PACK32, Attachable | Storage}, // ABGR8UI
|
{VK_FORMAT_A8B8G8R8_UINT_PACK32, Attachable | Storage}, // ABGR8UI
|
||||||
{VK_FORMAT_R5G6B5_UNORM_PACK16, Attachable}, // B5G6R5U
|
{VK_FORMAT_R5G6B5_UNORM_PACK16, Attachable}, // B5G6R5U
|
||||||
|
{VK_FORMAT_B5G6R5_UNORM_PACK16, Attachable}, // R5G6B5U
|
||||||
{VK_FORMAT_A1R5G5B5_UNORM_PACK16, Attachable}, // B5G5R5A1U
|
{VK_FORMAT_A1R5G5B5_UNORM_PACK16, Attachable}, // B5G5R5A1U
|
||||||
{VK_FORMAT_A2B10G10R10_UNORM_PACK32, Attachable | Storage}, // A2B10G10R10U
|
{VK_FORMAT_A2B10G10R10_UNORM_PACK32, Attachable | Storage}, // A2B10G10R10U
|
||||||
{VK_FORMAT_A2B10G10R10_UINT_PACK32, Attachable | Storage}, // A2B10G10R10UI
|
{VK_FORMAT_A2B10G10R10_UINT_PACK32, Attachable | Storage}, // A2B10G10R10UI
|
||||||
@ -140,7 +141,8 @@ struct FormatTuple {
|
|||||||
{VK_FORMAT_BC1_RGBA_UNORM_BLOCK}, // DXT1
|
{VK_FORMAT_BC1_RGBA_UNORM_BLOCK}, // DXT1
|
||||||
{VK_FORMAT_BC2_UNORM_BLOCK}, // DXT23
|
{VK_FORMAT_BC2_UNORM_BLOCK}, // DXT23
|
||||||
{VK_FORMAT_BC3_UNORM_BLOCK}, // DXT45
|
{VK_FORMAT_BC3_UNORM_BLOCK}, // DXT45
|
||||||
{VK_FORMAT_BC4_UNORM_BLOCK}, // DXN1
|
{VK_FORMAT_BC4_UNORM_BLOCK}, // DXN1UNORM
|
||||||
|
{VK_FORMAT_BC4_SNORM_BLOCK}, // DXN1SNORM
|
||||||
{VK_FORMAT_BC5_UNORM_BLOCK}, // DXN2UNORM
|
{VK_FORMAT_BC5_UNORM_BLOCK}, // DXN2UNORM
|
||||||
{VK_FORMAT_BC5_SNORM_BLOCK}, // DXN2SNORM
|
{VK_FORMAT_BC5_SNORM_BLOCK}, // DXN2SNORM
|
||||||
{VK_FORMAT_BC7_UNORM_BLOCK}, // BC7U
|
{VK_FORMAT_BC7_UNORM_BLOCK}, // BC7U
|
||||||
|
@ -125,6 +125,7 @@ std::unordered_map<VkFormat, VkFormatProperties> GetFormatProperties(
|
|||||||
VK_FORMAT_BC2_UNORM_BLOCK,
|
VK_FORMAT_BC2_UNORM_BLOCK,
|
||||||
VK_FORMAT_BC3_UNORM_BLOCK,
|
VK_FORMAT_BC3_UNORM_BLOCK,
|
||||||
VK_FORMAT_BC4_UNORM_BLOCK,
|
VK_FORMAT_BC4_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_BC4_SNORM_BLOCK,
|
||||||
VK_FORMAT_BC5_UNORM_BLOCK,
|
VK_FORMAT_BC5_UNORM_BLOCK,
|
||||||
VK_FORMAT_BC5_SNORM_BLOCK,
|
VK_FORMAT_BC5_SNORM_BLOCK,
|
||||||
VK_FORMAT_BC7_UNORM_BLOCK,
|
VK_FORMAT_BC7_UNORM_BLOCK,
|
||||||
|
@ -283,25 +283,4 @@ std::pair<u32, u32> GetASTCBlockSize(PixelFormat format) {
|
|||||||
return {GetDefaultBlockWidth(format), GetDefaultBlockHeight(format)};
|
return {GetDefaultBlockWidth(format), GetDefaultBlockHeight(format)};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsFormatBCn(PixelFormat format) {
|
|
||||||
switch (format) {
|
|
||||||
case PixelFormat::DXT1:
|
|
||||||
case PixelFormat::DXT23:
|
|
||||||
case PixelFormat::DXT45:
|
|
||||||
case PixelFormat::DXN1:
|
|
||||||
case PixelFormat::DXN2SNORM:
|
|
||||||
case PixelFormat::DXN2UNORM:
|
|
||||||
case PixelFormat::BC7U:
|
|
||||||
case PixelFormat::BC6H_UF16:
|
|
||||||
case PixelFormat::BC6H_SF16:
|
|
||||||
case PixelFormat::DXT1_SRGB:
|
|
||||||
case PixelFormat::DXT23_SRGB:
|
|
||||||
case PixelFormat::DXT45_SRGB:
|
|
||||||
case PixelFormat::BC7U_SRGB:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace VideoCore::Surface
|
} // namespace VideoCore::Surface
|
||||||
|
@ -20,6 +20,7 @@ enum class PixelFormat {
|
|||||||
ABGR8I,
|
ABGR8I,
|
||||||
ABGR8UI,
|
ABGR8UI,
|
||||||
B5G6R5U,
|
B5G6R5U,
|
||||||
|
R5G6B5U,
|
||||||
B5G5R5A1U,
|
B5G5R5A1U,
|
||||||
A2B10G10R10U,
|
A2B10G10R10U,
|
||||||
A2B10G10R10UI,
|
A2B10G10R10UI,
|
||||||
@ -38,7 +39,8 @@ enum class PixelFormat {
|
|||||||
DXT1,
|
DXT1,
|
||||||
DXT23,
|
DXT23,
|
||||||
DXT45,
|
DXT45,
|
||||||
DXN1, // This is also known as BC4
|
DXN1UNORM, // This is also known as BC4
|
||||||
|
DXN1SNORM,
|
||||||
DXN2UNORM,
|
DXN2UNORM,
|
||||||
DXN2SNORM,
|
DXN2SNORM,
|
||||||
BC7U,
|
BC7U,
|
||||||
@ -144,6 +146,7 @@ constexpr std::array<u32, MaxPixelFormat> compression_factor_shift_table = {{
|
|||||||
0, // ABGR8I
|
0, // ABGR8I
|
||||||
0, // ABGR8UI
|
0, // ABGR8UI
|
||||||
0, // B5G6R5U
|
0, // B5G6R5U
|
||||||
|
0, // R5G6B5U
|
||||||
0, // B5G5R5A1U
|
0, // B5G5R5A1U
|
||||||
0, // A2B10G10R10U
|
0, // A2B10G10R10U
|
||||||
0, // A2B10G10R10UI
|
0, // A2B10G10R10UI
|
||||||
@ -162,7 +165,8 @@ constexpr std::array<u32, MaxPixelFormat> compression_factor_shift_table = {{
|
|||||||
2, // DXT1
|
2, // DXT1
|
||||||
2, // DXT23
|
2, // DXT23
|
||||||
2, // DXT45
|
2, // DXT45
|
||||||
2, // DXN1
|
2, // DXN1UNORM
|
||||||
|
2, // DXN1SNORM
|
||||||
2, // DXN2UNORM
|
2, // DXN2UNORM
|
||||||
2, // DXN2SNORM
|
2, // DXN2SNORM
|
||||||
2, // BC7U
|
2, // BC7U
|
||||||
@ -252,6 +256,7 @@ constexpr std::array<u32, MaxPixelFormat> block_width_table = {{
|
|||||||
1, // ABGR8I
|
1, // ABGR8I
|
||||||
1, // ABGR8UI
|
1, // ABGR8UI
|
||||||
1, // B5G6R5U
|
1, // B5G6R5U
|
||||||
|
1, // R5G6B5U
|
||||||
1, // B5G5R5A1U
|
1, // B5G5R5A1U
|
||||||
1, // A2B10G10R10U
|
1, // A2B10G10R10U
|
||||||
1, // A2B10G10R10UI
|
1, // A2B10G10R10UI
|
||||||
@ -270,7 +275,8 @@ constexpr std::array<u32, MaxPixelFormat> block_width_table = {{
|
|||||||
4, // DXT1
|
4, // DXT1
|
||||||
4, // DXT23
|
4, // DXT23
|
||||||
4, // DXT45
|
4, // DXT45
|
||||||
4, // DXN1
|
4, // DXN1UNORM
|
||||||
|
4, // DXN1SNORM
|
||||||
4, // DXN2UNORM
|
4, // DXN2UNORM
|
||||||
4, // DXN2SNORM
|
4, // DXN2SNORM
|
||||||
4, // BC7U
|
4, // BC7U
|
||||||
@ -352,6 +358,7 @@ constexpr std::array<u32, MaxPixelFormat> block_height_table = {{
|
|||||||
1, // ABGR8I
|
1, // ABGR8I
|
||||||
1, // ABGR8UI
|
1, // ABGR8UI
|
||||||
1, // B5G6R5U
|
1, // B5G6R5U
|
||||||
|
1, // R5G6B5U
|
||||||
1, // B5G5R5A1U
|
1, // B5G5R5A1U
|
||||||
1, // A2B10G10R10U
|
1, // A2B10G10R10U
|
||||||
1, // A2B10G10R10UI
|
1, // A2B10G10R10UI
|
||||||
@ -370,7 +377,8 @@ constexpr std::array<u32, MaxPixelFormat> block_height_table = {{
|
|||||||
4, // DXT1
|
4, // DXT1
|
||||||
4, // DXT23
|
4, // DXT23
|
||||||
4, // DXT45
|
4, // DXT45
|
||||||
4, // DXN1
|
4, // DXN1UNORM
|
||||||
|
4, // DXN1SNORM
|
||||||
4, // DXN2UNORM
|
4, // DXN2UNORM
|
||||||
4, // DXN2SNORM
|
4, // DXN2SNORM
|
||||||
4, // BC7U
|
4, // BC7U
|
||||||
@ -452,6 +460,7 @@ constexpr std::array<u32, MaxPixelFormat> bpp_table = {{
|
|||||||
32, // ABGR8I
|
32, // ABGR8I
|
||||||
32, // ABGR8UI
|
32, // ABGR8UI
|
||||||
16, // B5G6R5U
|
16, // B5G6R5U
|
||||||
|
16, // R5G6B5U
|
||||||
16, // B5G5R5A1U
|
16, // B5G5R5A1U
|
||||||
32, // A2B10G10R10U
|
32, // A2B10G10R10U
|
||||||
32, // A2B10G10R10UI
|
32, // A2B10G10R10UI
|
||||||
@ -470,7 +479,8 @@ constexpr std::array<u32, MaxPixelFormat> bpp_table = {{
|
|||||||
64, // DXT1
|
64, // DXT1
|
||||||
128, // DXT23
|
128, // DXT23
|
||||||
128, // DXT45
|
128, // DXT45
|
||||||
64, // DXN1
|
64, // DXN1UNORM
|
||||||
|
64, // DXN1SNORM
|
||||||
128, // DXN2UNORM
|
128, // DXN2UNORM
|
||||||
128, // DXN2SNORM
|
128, // DXN2SNORM
|
||||||
128, // BC7U
|
128, // BC7U
|
||||||
@ -574,7 +584,4 @@ bool IsPixelFormatSRGB(PixelFormat format);
|
|||||||
|
|
||||||
std::pair<u32, u32> GetASTCBlockSize(PixelFormat format);
|
std::pair<u32, u32> GetASTCBlockSize(PixelFormat format);
|
||||||
|
|
||||||
/// Returns true if the specified PixelFormat is a BCn format, e.g. DXT or DXN
|
|
||||||
bool IsFormatBCn(PixelFormat format);
|
|
||||||
|
|
||||||
} // namespace VideoCore::Surface
|
} // namespace VideoCore::Surface
|
||||||
|
@ -48,7 +48,7 @@ constexpr std::array<Table, 86> DefinitionTable = {{
|
|||||||
{TextureFormat::A8R8G8B8, C, SINT, SINT, SINT, SINT, PixelFormat::ABGR8I},
|
{TextureFormat::A8R8G8B8, C, SINT, SINT, SINT, SINT, PixelFormat::ABGR8I},
|
||||||
{TextureFormat::A8R8G8B8, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::RGBA8_SRGB},
|
{TextureFormat::A8R8G8B8, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::RGBA8_SRGB},
|
||||||
|
|
||||||
{TextureFormat::B5G6R5, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::B5G6R5U},
|
{TextureFormat::B5G6R5, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::R5G6B5U},
|
||||||
|
|
||||||
{TextureFormat::A2B10G10R10, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::A2B10G10R10U},
|
{TextureFormat::A2B10G10R10, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::A2B10G10R10U},
|
||||||
{TextureFormat::A2B10G10R10, C, UINT, UINT, UINT, UINT, PixelFormat::A2B10G10R10UI},
|
{TextureFormat::A2B10G10R10, C, UINT, UINT, UINT, UINT, PixelFormat::A2B10G10R10UI},
|
||||||
@ -118,9 +118,8 @@ constexpr std::array<Table, 86> DefinitionTable = {{
|
|||||||
{TextureFormat::DXT45, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXT45},
|
{TextureFormat::DXT45, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXT45},
|
||||||
{TextureFormat::DXT45, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXT45_SRGB},
|
{TextureFormat::DXT45, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXT45_SRGB},
|
||||||
|
|
||||||
// TODO: Use a different pixel format for SNORM
|
{TextureFormat::DXN1, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXN1UNORM},
|
||||||
{TextureFormat::DXN1, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXN1},
|
{TextureFormat::DXN1, C, SNORM, SNORM, SNORM, SNORM, PixelFormat::DXN1SNORM},
|
||||||
{TextureFormat::DXN1, C, SNORM, SNORM, SNORM, SNORM, PixelFormat::DXN1},
|
|
||||||
|
|
||||||
{TextureFormat::DXN2, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXN2UNORM},
|
{TextureFormat::DXN2, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXN2UNORM},
|
||||||
{TextureFormat::DXN2, C, SNORM, SNORM, SNORM, SNORM, PixelFormat::DXN2SNORM},
|
{TextureFormat::DXN2, C, SNORM, SNORM, SNORM, SNORM, PixelFormat::DXN2SNORM},
|
||||||
|
Loading…
Reference in New Issue
Block a user