1
0
Fork 0
forked from suyu/suyu

Implement R16_G16

correct trailing white spaces


Delete tabs


correct placement
Add RG16F & RG16UI & RG16I & RG16S PixelFormats
Return correct data according to changes done previously
correct PixelFormat declaration
correct coding style error
correct coding style error part 2
correct RG16S Declaration error
correct alignment
This commit is contained in:
Unknown 2018-07-26 02:01:29 +02:00
parent c88382517c
commit 4672a01cbf
4 changed files with 100 additions and 19 deletions

View file

@ -23,6 +23,11 @@ enum class RenderTargetFormat : u32 {
RGB10_A2_UNORM = 0xD1, RGB10_A2_UNORM = 0xD1,
RGBA8_UNORM = 0xD5, RGBA8_UNORM = 0xD5,
RGBA8_SRGB = 0xD6, RGBA8_SRGB = 0xD6,
RG16_UNORM = 0xDA,
RG16_SNORM = 0xDB,
RG16_SINT = 0xDC,
RG16_UINT = 0xDD,
RG16_FLOAT = 0xDE,
R11G11B10_FLOAT = 0xE0, R11G11B10_FLOAT = 0xE0,
R8_UNORM = 0xF3, R8_UNORM = 0xF3,
}; };

View file

@ -104,15 +104,20 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
true}, // DXT45 true}, // DXT45
{GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, true}, // DXN1 {GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, true}, // DXN1
{GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, {GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
true}, // BC7U true}, // BC7U
{GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4
{GL_RG8, GL_RG, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // G8R8 {GL_RG8, GL_RG, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // G8R8
{GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // BGRA8 {GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // BGRA8
{GL_RGBA32F, GL_RGBA, GL_FLOAT, ComponentType::Float, false}, // RGBA32F {GL_RGBA32F, GL_RGBA, GL_FLOAT, ComponentType::Float, false}, // RGBA32F
{GL_RG32F, GL_RG, GL_FLOAT, ComponentType::Float, false}, // RG32F {GL_RG32F, GL_RG, GL_FLOAT, ComponentType::Float, false}, // RG32F
{GL_R32F, GL_RED, GL_FLOAT, ComponentType::Float, false}, // R32F {GL_R32F, GL_RED, GL_FLOAT, ComponentType::Float, false}, // R32F
{GL_R16F, GL_RED, GL_HALF_FLOAT, ComponentType::Float, false}, // R16F {GL_R16F, GL_RED, GL_HALF_FLOAT, ComponentType::Float, false}, // R16F
{GL_R16, GL_RED, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // R16UNORM {GL_R16, GL_RED, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // R16UNORM
{GL_RG16, GL_RG, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // RG16
{GL_RG16F, GL_RG, GL_HALF_FLOAT, ComponentType::Float, false}, // RG16F
{GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, ComponentType::UInt, false}, // RG16UI
{GL_RG16I, GL_RG_INTEGER, GL_SHORT, ComponentType::SInt, false}, // RG16I
{GL_RG16_SNORM, GL_RG, GL_SHORT, ComponentType::SNorm, false}, // RG16S
{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
@ -210,10 +215,12 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::BGRA8>, MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::BGRA8>,
MortonCopy<true, PixelFormat::RGBA32F>, MortonCopy<true, PixelFormat::RG32F>, MortonCopy<true, PixelFormat::RGBA32F>, MortonCopy<true, PixelFormat::RG32F>,
MortonCopy<true, PixelFormat::R32F>, MortonCopy<true, PixelFormat::R16F>, MortonCopy<true, PixelFormat::R32F>, MortonCopy<true, PixelFormat::R16F>,
MortonCopy<true, PixelFormat::R16UNORM>, MortonCopy<true, PixelFormat::SRGBA8>, MortonCopy<true, PixelFormat::R16UNORM>, MortonCopy<true, PixelFormat::RG16>,
MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::RG16F>, MortonCopy<true, PixelFormat::RG16UI>,
MortonCopy<true, PixelFormat::Z32F>, MortonCopy<true, PixelFormat::Z16>, MortonCopy<true, PixelFormat::RG16I>, MortonCopy<true, PixelFormat::RG16S>,
MortonCopy<true, PixelFormat::Z32FS8>, MortonCopy<true, PixelFormat::SRGBA8>, MortonCopy<true, PixelFormat::Z24S8>,
MortonCopy<true, PixelFormat::S8Z24>, 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),
@ -241,6 +248,11 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
MortonCopy<false, PixelFormat::R32F>, MortonCopy<false, PixelFormat::R32F>,
MortonCopy<false, PixelFormat::R16F>, MortonCopy<false, PixelFormat::R16F>,
MortonCopy<false, PixelFormat::R16UNORM>, MortonCopy<false, PixelFormat::R16UNORM>,
MortonCopy<false, PixelFormat::RG16>,
MortonCopy<false, PixelFormat::RG16F>,
MortonCopy<false, PixelFormat::RG16UI>,
MortonCopy<false, PixelFormat::RG16I>,
MortonCopy<false, PixelFormat::RG16S>,
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

@ -43,16 +43,21 @@ struct SurfaceParams {
R32F = 18, R32F = 18,
R16F = 19, R16F = 19,
R16UNORM = 20, R16UNORM = 20,
SRGBA8 = 21, RG16 = 21,
RG16F = 22,
RG16UI = 23,
RG16I = 24,
RG16S = 25,
SRGBA8 = 26,
MaxColorFormat, MaxColorFormat,
// DepthStencil formats // DepthStencil formats
Z24S8 = 22, Z24S8 = 27,
S8Z24 = 23, S8Z24 = 28,
Z32F = 24, Z32F = 29,
Z16 = 25, Z16 = 30,
Z32FS8 = 26, Z32FS8 = 31,
MaxDepthStencilFormat, MaxDepthStencilFormat,
@ -111,6 +116,11 @@ struct SurfaceParams {
1, // R32F 1, // R32F
1, // R16F 1, // R16F
1, // R16UNORM 1, // R16UNORM
1, // RG16
1, // RG16F
1, // RG16UI
1, // RG16I
1, // RG16S
1, // SRGBA8 1, // SRGBA8
1, // Z24S8 1, // Z24S8
1, // S8Z24 1, // S8Z24
@ -149,6 +159,11 @@ struct SurfaceParams {
32, // R32F 32, // R32F
16, // R16F 16, // R16F
16, // R16UNORM 16, // R16UNORM
32, // RG16
32, // RG16F
32, // RG16UI
32, // RG16I
32, // RG16S
32, // SRGBA8 32, // SRGBA8
32, // Z24S8 32, // Z24S8
32, // S8Z24 32, // S8Z24
@ -205,6 +220,17 @@ struct SurfaceParams {
return PixelFormat::RGBA32UI; return PixelFormat::RGBA32UI;
case Tegra::RenderTargetFormat::R8_UNORM: case Tegra::RenderTargetFormat::R8_UNORM:
return PixelFormat::R8; return PixelFormat::R8;
case Tegra::RenderTargetFormat::RG16_FLOAT:
return PixelFormat::RG16F;
case Tegra::RenderTargetFormat::RG16_UINT:
return PixelFormat::RG16UI;
case Tegra::RenderTargetFormat::RG16_SINT:
return PixelFormat::RG16I;
case Tegra::RenderTargetFormat::RG16_UNORM:
return PixelFormat::RG16;
case Tegra::RenderTargetFormat::RG16_SNORM:
return PixelFormat::RG16S;
default: default:
LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
UNREACHABLE(); UNREACHABLE();
@ -271,6 +297,22 @@ struct SurfaceParams {
return PixelFormat::BC7U; return PixelFormat::BC7U;
case Tegra::Texture::TextureFormat::ASTC_2D_4X4: case Tegra::Texture::TextureFormat::ASTC_2D_4X4:
return PixelFormat::ASTC_2D_4X4; return PixelFormat::ASTC_2D_4X4;
case Tegra::Texture::TextureFormat::R16_G16:
switch (component_type) {
case Tegra::Texture::ComponentType::FLOAT:
return PixelFormat::RG16F;
case Tegra::Texture::ComponentType::UNORM:
return PixelFormat::RG16;
case Tegra::Texture::ComponentType::SNORM:
return PixelFormat::RG16S;
case Tegra::Texture::ComponentType::UINT:
return PixelFormat::RG16UI;
case Tegra::Texture::ComponentType::SINT:
return PixelFormat::RG16I;
}
LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}",
static_cast<u32>(component_type));
UNREACHABLE();
default: default:
LOG_CRITICAL(HW_GPU, "Unimplemented format={}, component_type={}", LOG_CRITICAL(HW_GPU, "Unimplemented format={}, component_type={}",
static_cast<u32>(format), static_cast<u32>(component_type)); static_cast<u32>(format), static_cast<u32>(component_type));
@ -329,6 +371,12 @@ struct SurfaceParams {
return Tegra::Texture::TextureFormat::ZF32; return Tegra::Texture::TextureFormat::ZF32;
case PixelFormat::Z24S8: case PixelFormat::Z24S8:
return Tegra::Texture::TextureFormat::Z24S8; return Tegra::Texture::TextureFormat::Z24S8;
case PixelFormat::RG16F:
case PixelFormat::RG16:
case PixelFormat::RG16UI:
case PixelFormat::RG16I:
case PixelFormat::RG16S:
return Tegra::Texture::TextureFormat::R16_G16;
default: default:
LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
UNREACHABLE(); UNREACHABLE();
@ -360,6 +408,12 @@ struct SurfaceParams {
return ComponentType::UNorm; return ComponentType::UNorm;
case Tegra::Texture::ComponentType::FLOAT: case Tegra::Texture::ComponentType::FLOAT:
return ComponentType::Float; return ComponentType::Float;
case Tegra::Texture::ComponentType::SNORM:
return ComponentType::SNorm;
case Tegra::Texture::ComponentType::UINT:
return ComponentType::UInt;
case Tegra::Texture::ComponentType::SINT:
return ComponentType::SInt;
default: default:
LOG_CRITICAL(HW_GPU, "Unimplemented component type={}", static_cast<u32>(type)); LOG_CRITICAL(HW_GPU, "Unimplemented component type={}", static_cast<u32>(type));
UNREACHABLE(); UNREACHABLE();
@ -374,14 +428,21 @@ struct SurfaceParams {
case Tegra::RenderTargetFormat::BGRA8_UNORM: case Tegra::RenderTargetFormat::BGRA8_UNORM:
case Tegra::RenderTargetFormat::RGB10_A2_UNORM: case Tegra::RenderTargetFormat::RGB10_A2_UNORM:
case Tegra::RenderTargetFormat::R8_UNORM: case Tegra::RenderTargetFormat::R8_UNORM:
case Tegra::RenderTargetFormat::RG16_UNORM:
return ComponentType::UNorm; return ComponentType::UNorm;
case Tegra::RenderTargetFormat::RG16_SNORM:
return ComponentType::SNorm;
case Tegra::RenderTargetFormat::RGBA16_FLOAT: case Tegra::RenderTargetFormat::RGBA16_FLOAT:
case Tegra::RenderTargetFormat::R11G11B10_FLOAT: case Tegra::RenderTargetFormat::R11G11B10_FLOAT:
case Tegra::RenderTargetFormat::RGBA32_FLOAT: case Tegra::RenderTargetFormat::RGBA32_FLOAT:
case Tegra::RenderTargetFormat::RG32_FLOAT: case Tegra::RenderTargetFormat::RG32_FLOAT:
case Tegra::RenderTargetFormat::RG16_FLOAT:
return ComponentType::Float; return ComponentType::Float;
case Tegra::RenderTargetFormat::RGBA32_UINT: case Tegra::RenderTargetFormat::RGBA32_UINT:
case Tegra::RenderTargetFormat::RG16_UINT:
return ComponentType::UInt; return ComponentType::UInt;
case Tegra::RenderTargetFormat::RG16_SINT:
return ComponentType::SInt;
default: default:
LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
UNREACHABLE(); UNREACHABLE();

View file

@ -62,6 +62,7 @@ u32 BytesPerPixel(TextureFormat format) {
case TextureFormat::A2B10G10R10: case TextureFormat::A2B10G10R10:
case TextureFormat::BF10GF11RF11: case TextureFormat::BF10GF11RF11:
case TextureFormat::R32: case TextureFormat::R32:
case TextureFormat::R16_G16:
return 4; return 4;
case TextureFormat::A1B5G5R5: case TextureFormat::A1B5G5R5:
case TextureFormat::B5G6R5: case TextureFormat::B5G6R5:
@ -127,6 +128,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width,
case TextureFormat::R32_G32: case TextureFormat::R32_G32:
case TextureFormat::R32: case TextureFormat::R32:
case TextureFormat::R16: case TextureFormat::R16:
case TextureFormat::R16_G16:
case TextureFormat::BF10GF11RF11: case TextureFormat::BF10GF11RF11:
case TextureFormat::ASTC_2D_4X4: case TextureFormat::ASTC_2D_4X4:
CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data,
@ -187,6 +189,7 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat
case TextureFormat::R32_G32: case TextureFormat::R32_G32:
case TextureFormat::R32: case TextureFormat::R32:
case TextureFormat::R16: case TextureFormat::R16:
case TextureFormat::R16_G16:
// 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;