Merge pull request #351 from Subv/tex_formats
GPU: Implemented the B5G6R5 format.
This commit is contained in:
commit
60e6e8953e
@ -48,8 +48,9 @@ struct FormatTuple {
|
|||||||
u32 compression_factor;
|
u32 compression_factor;
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr std::array<FormatTuple, 2> tex_format_tuples = {{
|
static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_format_tuples = {{
|
||||||
{GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false, 1}, // ABGR8
|
{GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false, 1}, // ABGR8
|
||||||
|
{GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, false, 1}, // B5G6R5
|
||||||
{GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true, 16}, // DXT1
|
{GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true, 16}, // DXT1
|
||||||
}};
|
}};
|
||||||
|
|
||||||
@ -117,15 +118,19 @@ void MortonCopy(u32 stride, u32 block_height, u32 height, u8* gl_buffer, VAddr b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr std::array<void (*)(u32, u32, u32, u8*, VAddr, VAddr, VAddr), 2> morton_to_gl_fns =
|
static constexpr std::array<void (*)(u32, u32, u32, u8*, VAddr, VAddr, VAddr),
|
||||||
{
|
SurfaceParams::MaxPixelFormat>
|
||||||
|
morton_to_gl_fns = {
|
||||||
MortonCopy<true, PixelFormat::ABGR8>,
|
MortonCopy<true, PixelFormat::ABGR8>,
|
||||||
|
MortonCopy<true, PixelFormat::B5G6R5>,
|
||||||
MortonCopy<true, PixelFormat::DXT1>,
|
MortonCopy<true, PixelFormat::DXT1>,
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr std::array<void (*)(u32, u32, u32, u8*, VAddr, VAddr, VAddr), 2> gl_to_morton_fns =
|
static constexpr std::array<void (*)(u32, u32, u32, u8*, VAddr, VAddr, VAddr),
|
||||||
{
|
SurfaceParams::MaxPixelFormat>
|
||||||
|
gl_to_morton_fns = {
|
||||||
MortonCopy<false, PixelFormat::ABGR8>,
|
MortonCopy<false, PixelFormat::ABGR8>,
|
||||||
|
MortonCopy<false, PixelFormat::B5G6R5>,
|
||||||
// TODO(Subv): Swizzling the DXT1 format is not yet supported
|
// TODO(Subv): Swizzling the DXT1 format is not yet supported
|
||||||
nullptr,
|
nullptr,
|
||||||
};
|
};
|
||||||
|
@ -53,10 +53,15 @@ enum class ScaleMatch {
|
|||||||
struct SurfaceParams {
|
struct SurfaceParams {
|
||||||
enum class PixelFormat {
|
enum class PixelFormat {
|
||||||
ABGR8 = 0,
|
ABGR8 = 0,
|
||||||
DXT1 = 1,
|
B5G6R5 = 1,
|
||||||
|
DXT1 = 2,
|
||||||
|
|
||||||
|
Max,
|
||||||
Invalid = 255,
|
Invalid = 255,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static constexpr size_t MaxPixelFormat = static_cast<size_t>(PixelFormat::Max);
|
||||||
|
|
||||||
enum class ComponentType {
|
enum class ComponentType {
|
||||||
Invalid = 0,
|
Invalid = 0,
|
||||||
SNorm = 1,
|
SNorm = 1,
|
||||||
@ -78,8 +83,9 @@ struct SurfaceParams {
|
|||||||
if (format == PixelFormat::Invalid)
|
if (format == PixelFormat::Invalid)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
constexpr std::array<unsigned int, 2> bpp_table = {
|
constexpr std::array<unsigned int, MaxPixelFormat> bpp_table = {
|
||||||
32, // ABGR8
|
32, // ABGR8
|
||||||
|
16, // B5G6R5
|
||||||
64, // DXT1
|
64, // DXT1
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -115,6 +121,8 @@ struct SurfaceParams {
|
|||||||
switch (format) {
|
switch (format) {
|
||||||
case Tegra::Texture::TextureFormat::A8R8G8B8:
|
case Tegra::Texture::TextureFormat::A8R8G8B8:
|
||||||
return PixelFormat::ABGR8;
|
return PixelFormat::ABGR8;
|
||||||
|
case Tegra::Texture::TextureFormat::B5G6R5:
|
||||||
|
return PixelFormat::B5G6R5;
|
||||||
case Tegra::Texture::TextureFormat::DXT1:
|
case Tegra::Texture::TextureFormat::DXT1:
|
||||||
return PixelFormat::DXT1;
|
return PixelFormat::DXT1;
|
||||||
default:
|
default:
|
||||||
@ -128,6 +136,8 @@ struct SurfaceParams {
|
|||||||
switch (format) {
|
switch (format) {
|
||||||
case PixelFormat::ABGR8:
|
case PixelFormat::ABGR8:
|
||||||
return Tegra::Texture::TextureFormat::A8R8G8B8;
|
return Tegra::Texture::TextureFormat::A8R8G8B8;
|
||||||
|
case PixelFormat::B5G6R5:
|
||||||
|
return Tegra::Texture::TextureFormat::B5G6R5;
|
||||||
case PixelFormat::DXT1:
|
case PixelFormat::DXT1:
|
||||||
return Tegra::Texture::TextureFormat::DXT1;
|
return Tegra::Texture::TextureFormat::DXT1;
|
||||||
default:
|
default:
|
||||||
@ -189,7 +199,7 @@ struct SurfaceParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static SurfaceType GetFormatType(PixelFormat pixel_format) {
|
static SurfaceType GetFormatType(PixelFormat pixel_format) {
|
||||||
if ((unsigned int)pixel_format <= static_cast<unsigned int>(PixelFormat::DXT1)) {
|
if (static_cast<size_t>(pixel_format) < MaxPixelFormat) {
|
||||||
return SurfaceType::ColorTexture;
|
return SurfaceType::ColorTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +50,8 @@ u32 BytesPerPixel(TextureFormat format) {
|
|||||||
return 8;
|
return 8;
|
||||||
case TextureFormat::A8R8G8B8:
|
case TextureFormat::A8R8G8B8:
|
||||||
return 4;
|
return 4;
|
||||||
|
case TextureFormat::B5G6R5:
|
||||||
|
return 2;
|
||||||
default:
|
default:
|
||||||
UNIMPLEMENTED_MSG("Format not implemented");
|
UNIMPLEMENTED_MSG("Format not implemented");
|
||||||
break;
|
break;
|
||||||
@ -70,6 +72,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width,
|
|||||||
unswizzled_data.data(), true, block_height);
|
unswizzled_data.data(), true, block_height);
|
||||||
break;
|
break;
|
||||||
case TextureFormat::A8R8G8B8:
|
case TextureFormat::A8R8G8B8:
|
||||||
|
case TextureFormat::B5G6R5:
|
||||||
CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data,
|
CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data,
|
||||||
unswizzled_data.data(), true, block_height);
|
unswizzled_data.data(), true, block_height);
|
||||||
break;
|
break;
|
||||||
@ -89,6 +92,7 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat
|
|||||||
switch (format) {
|
switch (format) {
|
||||||
case TextureFormat::DXT1:
|
case TextureFormat::DXT1:
|
||||||
case TextureFormat::A8R8G8B8:
|
case TextureFormat::A8R8G8B8:
|
||||||
|
case TextureFormat::B5G6R5:
|
||||||
// TODO(Subv): For the time being just forward the same data without any decoding.
|
// TODO(Subv): For the time being just forward the same data without any decoding.
|
||||||
rgba_data = texture_data;
|
rgba_data = texture_data;
|
||||||
break;
|
break;
|
||||||
|
@ -15,6 +15,7 @@ namespace Texture {
|
|||||||
|
|
||||||
enum class TextureFormat : u32 {
|
enum class TextureFormat : u32 {
|
||||||
A8R8G8B8 = 0x8,
|
A8R8G8B8 = 0x8,
|
||||||
|
B5G6R5 = 0x15,
|
||||||
DXT1 = 0x24,
|
DXT1 = 0x24,
|
||||||
DXT23 = 0x25,
|
DXT23 = 0x25,
|
||||||
DXT45 = 0x26,
|
DXT45 = 0x26,
|
||||||
|
Loading…
Reference in New Issue
Block a user