GPU: Implemented the DXN1 (BC4) texture format.
This commit is contained in:
parent
bbbe34429e
commit
99f9d47d16
@ -53,6 +53,7 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
|
|||||||
{GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT1
|
{GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT1
|
||||||
{GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT23
|
{GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT23
|
||||||
{GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT45
|
{GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT45
|
||||||
|
{GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, true}, // DXN1
|
||||||
}};
|
}};
|
||||||
|
|
||||||
static const FormatTuple& GetFormatTuple(PixelFormat pixel_format, ComponentType component_type) {
|
static const FormatTuple& GetFormatTuple(PixelFormat pixel_format, ComponentType component_type) {
|
||||||
@ -113,7 +114,7 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra:
|
|||||||
MortonCopy<true, PixelFormat::A2B10G10R10>, MortonCopy<true, PixelFormat::A1B5G5R5>,
|
MortonCopy<true, PixelFormat::A2B10G10R10>, MortonCopy<true, PixelFormat::A1B5G5R5>,
|
||||||
MortonCopy<true, PixelFormat::R8>, MortonCopy<true, PixelFormat::RGBA16F>,
|
MortonCopy<true, PixelFormat::R8>, MortonCopy<true, PixelFormat::RGBA16F>,
|
||||||
MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>,
|
MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>,
|
||||||
MortonCopy<true, PixelFormat::DXT45>,
|
MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>,
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra::GPUVAddr,
|
static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra::GPUVAddr,
|
||||||
@ -126,7 +127,8 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra:
|
|||||||
MortonCopy<false, PixelFormat::A1B5G5R5>,
|
MortonCopy<false, PixelFormat::A1B5G5R5>,
|
||||||
MortonCopy<false, PixelFormat::R8>,
|
MortonCopy<false, PixelFormat::R8>,
|
||||||
MortonCopy<false, PixelFormat::RGBA16F>,
|
MortonCopy<false, PixelFormat::RGBA16F>,
|
||||||
// TODO(Subv): Swizzling the DXT1/DXT23/DXT45 formats is not yet supported
|
// TODO(Subv): Swizzling the DXT1/DXT23/DXT45/DXN1 formats is not yet supported
|
||||||
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
|
@ -63,6 +63,7 @@ struct SurfaceParams {
|
|||||||
DXT1 = 6,
|
DXT1 = 6,
|
||||||
DXT23 = 7,
|
DXT23 = 7,
|
||||||
DXT45 = 8,
|
DXT45 = 8,
|
||||||
|
DXN1 = 9, // This is also known as BC4
|
||||||
|
|
||||||
Max,
|
Max,
|
||||||
Invalid = 255,
|
Invalid = 255,
|
||||||
@ -107,6 +108,7 @@ struct SurfaceParams {
|
|||||||
4, // DXT1
|
4, // DXT1
|
||||||
4, // DXT23
|
4, // DXT23
|
||||||
4, // DXT45
|
4, // DXT45
|
||||||
|
4, // DXN1
|
||||||
}};
|
}};
|
||||||
|
|
||||||
ASSERT(static_cast<size_t>(format) < compression_factor_table.size());
|
ASSERT(static_cast<size_t>(format) < compression_factor_table.size());
|
||||||
@ -130,6 +132,7 @@ struct SurfaceParams {
|
|||||||
64, // DXT1
|
64, // DXT1
|
||||||
128, // DXT23
|
128, // DXT23
|
||||||
128, // DXT45
|
128, // DXT45
|
||||||
|
64, // DXN1
|
||||||
}};
|
}};
|
||||||
|
|
||||||
ASSERT(static_cast<size_t>(format) < bpp_table.size());
|
ASSERT(static_cast<size_t>(format) < bpp_table.size());
|
||||||
@ -185,6 +188,8 @@ struct SurfaceParams {
|
|||||||
return PixelFormat::DXT23;
|
return PixelFormat::DXT23;
|
||||||
case Tegra::Texture::TextureFormat::DXT45:
|
case Tegra::Texture::TextureFormat::DXT45:
|
||||||
return PixelFormat::DXT45;
|
return PixelFormat::DXT45;
|
||||||
|
case Tegra::Texture::TextureFormat::DXN1:
|
||||||
|
return PixelFormat::DXN1;
|
||||||
default:
|
default:
|
||||||
NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
|
NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
@ -212,6 +217,8 @@ struct SurfaceParams {
|
|||||||
return Tegra::Texture::TextureFormat::DXT23;
|
return Tegra::Texture::TextureFormat::DXT23;
|
||||||
case PixelFormat::DXT45:
|
case PixelFormat::DXT45:
|
||||||
return Tegra::Texture::TextureFormat::DXT45;
|
return Tegra::Texture::TextureFormat::DXT45;
|
||||||
|
case PixelFormat::DXN1:
|
||||||
|
return Tegra::Texture::TextureFormat::DXN1;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ void CopySwizzledData(u32 width, u32 height, u32 bytes_per_pixel, u32 out_bytes_
|
|||||||
u32 BytesPerPixel(TextureFormat format) {
|
u32 BytesPerPixel(TextureFormat format) {
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case TextureFormat::DXT1:
|
case TextureFormat::DXT1:
|
||||||
|
case TextureFormat::DXN1:
|
||||||
// In this case a 'pixel' actually refers to a 4x4 tile.
|
// In this case a 'pixel' actually refers to a 4x4 tile.
|
||||||
return 8;
|
return 8;
|
||||||
case TextureFormat::DXT23:
|
case TextureFormat::DXT23:
|
||||||
@ -79,7 +80,9 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width,
|
|||||||
case TextureFormat::DXT1:
|
case TextureFormat::DXT1:
|
||||||
case TextureFormat::DXT23:
|
case TextureFormat::DXT23:
|
||||||
case TextureFormat::DXT45:
|
case TextureFormat::DXT45:
|
||||||
// In the DXT formats, each 4x4 tile is swizzled instead of just individual pixel values.
|
case TextureFormat::DXN1:
|
||||||
|
// In the DXT and DXN formats, each 4x4 tile is swizzled instead of just individual pixel
|
||||||
|
// values.
|
||||||
CopySwizzledData(width / 4, height / 4, bytes_per_pixel, bytes_per_pixel, data,
|
CopySwizzledData(width / 4, height / 4, bytes_per_pixel, bytes_per_pixel, data,
|
||||||
unswizzled_data.data(), true, block_height);
|
unswizzled_data.data(), true, block_height);
|
||||||
break;
|
break;
|
||||||
@ -109,6 +112,7 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat
|
|||||||
case TextureFormat::DXT1:
|
case TextureFormat::DXT1:
|
||||||
case TextureFormat::DXT23:
|
case TextureFormat::DXT23:
|
||||||
case TextureFormat::DXT45:
|
case TextureFormat::DXT45:
|
||||||
|
case TextureFormat::DXN1:
|
||||||
case TextureFormat::A8R8G8B8:
|
case TextureFormat::A8R8G8B8:
|
||||||
case TextureFormat::A2B10G10R10:
|
case TextureFormat::A2B10G10R10:
|
||||||
case TextureFormat::A1B5G5R5:
|
case TextureFormat::A1B5G5R5:
|
||||||
|
Loading…
Reference in New Issue
Block a user