Implement RGB32F PixelFormat (#886) (used by Go Vacation)

This commit is contained in:
greggameplayer 2018-08-02 20:56:38 +02:00 committed by bunnei
parent d0bd01146e
commit fe64e1d38e
3 changed files with 23 additions and 9 deletions

View file

@ -118,6 +118,7 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
{GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, ComponentType::UInt, false}, // RG16UI {GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, ComponentType::UInt, false}, // RG16UI
{GL_RG16I, GL_RG_INTEGER, GL_SHORT, ComponentType::SInt, false}, // RG16I {GL_RG16I, GL_RG_INTEGER, GL_SHORT, ComponentType::SInt, false}, // RG16I
{GL_RG16_SNORM, GL_RG, GL_SHORT, ComponentType::SNorm, false}, // RG16S {GL_RG16_SNORM, GL_RG, GL_SHORT, ComponentType::SNorm, false}, // RG16S
{GL_RGB32F, GL_RGB, GL_FLOAT, ComponentType::Float, false}, // RGB32F
{GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, ComponentType::UNorm, false}, // SRGBA8 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, ComponentType::UNorm, false}, // SRGBA8
// DepthStencil formats // DepthStencil formats
@ -218,9 +219,10 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
MortonCopy<true, PixelFormat::R16UNORM>, MortonCopy<true, PixelFormat::RG16>, MortonCopy<true, PixelFormat::R16UNORM>, MortonCopy<true, PixelFormat::RG16>,
MortonCopy<true, PixelFormat::RG16F>, MortonCopy<true, PixelFormat::RG16UI>, MortonCopy<true, PixelFormat::RG16F>, MortonCopy<true, PixelFormat::RG16UI>,
MortonCopy<true, PixelFormat::RG16I>, MortonCopy<true, PixelFormat::RG16S>, MortonCopy<true, PixelFormat::RG16I>, MortonCopy<true, PixelFormat::RG16S>,
MortonCopy<true, PixelFormat::SRGBA8>, MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::RGB32F>, MortonCopy<true, PixelFormat::SRGBA8>,
MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32F>, MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::S8Z24>,
MortonCopy<true, PixelFormat::Z16>, MortonCopy<true, PixelFormat::Z32FS8>, MortonCopy<true, PixelFormat::Z32F>, MortonCopy<true, PixelFormat::Z16>,
MortonCopy<true, PixelFormat::Z32FS8>,
}; };
static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
@ -253,6 +255,7 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
MortonCopy<false, PixelFormat::RG16UI>, MortonCopy<false, PixelFormat::RG16UI>,
MortonCopy<false, PixelFormat::RG16I>, MortonCopy<false, PixelFormat::RG16I>,
MortonCopy<false, PixelFormat::RG16S>, MortonCopy<false, PixelFormat::RG16S>,
MortonCopy<false, PixelFormat::RGB32F>,
MortonCopy<false, PixelFormat::SRGBA8>, MortonCopy<false, PixelFormat::SRGBA8>,
MortonCopy<false, PixelFormat::Z24S8>, MortonCopy<false, PixelFormat::Z24S8>,
MortonCopy<false, PixelFormat::S8Z24>, MortonCopy<false, PixelFormat::S8Z24>,

View file

@ -48,16 +48,17 @@ struct SurfaceParams {
RG16UI = 23, RG16UI = 23,
RG16I = 24, RG16I = 24,
RG16S = 25, RG16S = 25,
SRGBA8 = 26, RGB32F = 26,
SRGBA8 = 27,
MaxColorFormat, MaxColorFormat,
// DepthStencil formats // DepthStencil formats
Z24S8 = 27, Z24S8 = 28,
S8Z24 = 28, S8Z24 = 29,
Z32F = 29, Z32F = 30,
Z16 = 30, Z16 = 31,
Z32FS8 = 31, Z32FS8 = 32,
MaxDepthStencilFormat, MaxDepthStencilFormat,
@ -121,6 +122,7 @@ struct SurfaceParams {
1, // RG16UI 1, // RG16UI
1, // RG16I 1, // RG16I
1, // RG16S 1, // RG16S
1, // RGB32F
1, // SRGBA8 1, // SRGBA8
1, // Z24S8 1, // Z24S8
1, // S8Z24 1, // S8Z24
@ -164,6 +166,7 @@ struct SurfaceParams {
32, // RG16UI 32, // RG16UI
32, // RG16I 32, // RG16I
32, // RG16S 32, // RG16S
96, // RGB32F
32, // SRGBA8 32, // SRGBA8
32, // Z24S8 32, // Z24S8
32, // S8Z24 32, // S8Z24
@ -272,6 +275,8 @@ struct SurfaceParams {
UNREACHABLE(); UNREACHABLE();
case Tegra::Texture::TextureFormat::R32_G32: case Tegra::Texture::TextureFormat::R32_G32:
return PixelFormat::RG32F; return PixelFormat::RG32F;
case Tegra::Texture::TextureFormat::R32_G32_B32:
return PixelFormat::RGB32F;
case Tegra::Texture::TextureFormat::R16: case Tegra::Texture::TextureFormat::R16:
switch (component_type) { switch (component_type) {
case Tegra::Texture::ComponentType::FLOAT: case Tegra::Texture::ComponentType::FLOAT:
@ -363,6 +368,8 @@ struct SurfaceParams {
return Tegra::Texture::TextureFormat::A8R8G8B8; return Tegra::Texture::TextureFormat::A8R8G8B8;
case PixelFormat::RGBA32F: case PixelFormat::RGBA32F:
return Tegra::Texture::TextureFormat::R32_G32_B32_A32; return Tegra::Texture::TextureFormat::R32_G32_B32_A32;
case PixelFormat::RGB32F:
return Tegra::Texture::TextureFormat::R32_G32_B32;
case PixelFormat::RG32F: case PixelFormat::RG32F:
return Tegra::Texture::TextureFormat::R32_G32; return Tegra::Texture::TextureFormat::R32_G32;
case PixelFormat::R32F: case PixelFormat::R32F:

View file

@ -57,6 +57,8 @@ u32 BytesPerPixel(TextureFormat format) {
case TextureFormat::BC7U: case TextureFormat::BC7U:
// In this case a 'pixel' actually refers to a 4x4 tile. // In this case a 'pixel' actually refers to a 4x4 tile.
return 16; return 16;
case TextureFormat::R32_G32_B32:
return 12;
case TextureFormat::ASTC_2D_4X4: case TextureFormat::ASTC_2D_4X4:
case TextureFormat::A8R8G8B8: case TextureFormat::A8R8G8B8:
case TextureFormat::A2B10G10R10: case TextureFormat::A2B10G10R10:
@ -131,6 +133,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width,
case TextureFormat::R16_G16: case TextureFormat::R16_G16:
case TextureFormat::BF10GF11RF11: case TextureFormat::BF10GF11RF11:
case TextureFormat::ASTC_2D_4X4: case TextureFormat::ASTC_2D_4X4:
case TextureFormat::R32_G32_B32:
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;
@ -190,6 +193,7 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat
case TextureFormat::R32: case TextureFormat::R32:
case TextureFormat::R16: case TextureFormat::R16:
case TextureFormat::R16_G16: case TextureFormat::R16_G16:
case TextureFormat::R32_G32_B32:
// 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;