1
0
Fork 0
forked from suyu/suyu

gl_rasterizer_cache: Implement RenderTargetFormat RGBA32_FLOAT.

This commit is contained in:
bunnei 2018-07-23 17:12:16 -04:00
parent bcc184acfa
commit 3a19c1098d
2 changed files with 34 additions and 10 deletions

View file

@ -38,7 +38,8 @@ struct FormatTuple {
params.addr = config.tic.Address(); params.addr = config.tic.Address();
params.is_tiled = config.tic.IsTiled(); params.is_tiled = config.tic.IsTiled();
params.block_height = params.is_tiled ? config.tic.BlockHeight() : 0, params.block_height = params.is_tiled ? config.tic.BlockHeight() : 0,
params.pixel_format = PixelFormatFromTextureFormat(config.tic.format); params.pixel_format =
PixelFormatFromTextureFormat(config.tic.format, config.tic.r_type.Value());
params.component_type = ComponentTypeFromTexture(config.tic.r_type.Value()); params.component_type = ComponentTypeFromTexture(config.tic.r_type.Value());
params.type = GetFormatType(params.pixel_format); params.type = GetFormatType(params.pixel_format);
params.width = Common::AlignUp(config.tic.Width(), GetCompressionFactor(params.pixel_format)); params.width = Common::AlignUp(config.tic.Width(), GetCompressionFactor(params.pixel_format));
@ -107,6 +108,7 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
{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
// DepthStencil formats // DepthStencil formats
{GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm, {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm,
@ -199,8 +201,9 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>, MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>,
MortonCopy<true, PixelFormat::BC7U>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>, MortonCopy<true, PixelFormat::BC7U>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>,
MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::BGRA8>, MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::BGRA8>,
MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::RGBA32F>, MortonCopy<true, PixelFormat::Z24S8>,
MortonCopy<true, PixelFormat::Z32F>, MortonCopy<true, PixelFormat::Z16>, MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32F>,
MortonCopy<true, PixelFormat::Z16>,
}; };
static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
@ -223,6 +226,7 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
nullptr, nullptr,
MortonCopy<false, PixelFormat::G8R8>, MortonCopy<false, PixelFormat::G8R8>,
MortonCopy<false, PixelFormat::BGRA8>, MortonCopy<false, PixelFormat::BGRA8>,
MortonCopy<false, PixelFormat::RGBA32F>,
MortonCopy<false, PixelFormat::Z24S8>, MortonCopy<false, PixelFormat::Z24S8>,
MortonCopy<false, PixelFormat::S8Z24>, MortonCopy<false, PixelFormat::S8Z24>,
MortonCopy<false, PixelFormat::Z32F>, MortonCopy<false, PixelFormat::Z32F>,

View file

@ -38,14 +38,15 @@ struct SurfaceParams {
ASTC_2D_4X4 = 13, ASTC_2D_4X4 = 13,
G8R8 = 14, G8R8 = 14,
BGRA8 = 15, BGRA8 = 15,
RGBA32F = 16,
MaxColorFormat, MaxColorFormat,
// DepthStencil formats // DepthStencil formats
Z24S8 = 16, Z24S8 = 17,
S8Z24 = 17, S8Z24 = 18,
Z32F = 18, Z32F = 19,
Z16 = 19, Z16 = 20,
MaxDepthStencilFormat, MaxDepthStencilFormat,
@ -99,6 +100,7 @@ struct SurfaceParams {
4, // ASTC_2D_4X4 4, // ASTC_2D_4X4
1, // G8R8 1, // G8R8
1, // BGRA8 1, // BGRA8
1, // RGBA32F
1, // Z24S8 1, // Z24S8
1, // S8Z24 1, // S8Z24
1, // Z32F 1, // Z32F
@ -130,6 +132,7 @@ struct SurfaceParams {
32, // ASTC_2D_4X4 32, // ASTC_2D_4X4
16, // G8R8 16, // G8R8
32, // BGRA8 32, // BGRA8
128, // RGBA32F
32, // Z24S8 32, // Z24S8
32, // S8Z24 32, // S8Z24
32, // Z32F 32, // Z32F
@ -171,6 +174,8 @@ struct SurfaceParams {
return PixelFormat::A2B10G10R10; return PixelFormat::A2B10G10R10;
case Tegra::RenderTargetFormat::RGBA16_FLOAT: case Tegra::RenderTargetFormat::RGBA16_FLOAT:
return PixelFormat::RGBA16F; return PixelFormat::RGBA16F;
case Tegra::RenderTargetFormat::RGBA32_FLOAT:
return PixelFormat::RGBA32F;
case Tegra::RenderTargetFormat::R11G11B10_FLOAT: case Tegra::RenderTargetFormat::R11G11B10_FLOAT:
return PixelFormat::R11FG11FB10F; return PixelFormat::R11FG11FB10F;
case Tegra::RenderTargetFormat::RGBA32_UINT: case Tegra::RenderTargetFormat::RGBA32_UINT:
@ -181,7 +186,8 @@ struct SurfaceParams {
} }
} }
static PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format) { static PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format,
Tegra::Texture::ComponentType component_type) {
// TODO(Subv): Properly implement this // TODO(Subv): Properly implement this
switch (format) { switch (format) {
case Tegra::Texture::TextureFormat::A8R8G8B8: case Tegra::Texture::TextureFormat::A8R8G8B8:
@ -201,7 +207,15 @@ struct SurfaceParams {
case Tegra::Texture::TextureFormat::BF10GF11RF11: case Tegra::Texture::TextureFormat::BF10GF11RF11:
return PixelFormat::R11FG11FB10F; return PixelFormat::R11FG11FB10F;
case Tegra::Texture::TextureFormat::R32_G32_B32_A32: case Tegra::Texture::TextureFormat::R32_G32_B32_A32:
return PixelFormat::RGBA32UI; switch (component_type) {
case Tegra::Texture::ComponentType::FLOAT:
return PixelFormat::RGBA32F;
case Tegra::Texture::ComponentType::UINT:
return PixelFormat::RGBA32UI;
}
LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}",
static_cast<u32>(component_type));
UNREACHABLE();
case Tegra::Texture::TextureFormat::DXT1: case Tegra::Texture::TextureFormat::DXT1:
return PixelFormat::DXT1; return PixelFormat::DXT1;
case Tegra::Texture::TextureFormat::DXT23: case Tegra::Texture::TextureFormat::DXT23:
@ -215,7 +229,8 @@ struct SurfaceParams {
case Tegra::Texture::TextureFormat::ASTC_2D_4X4: case Tegra::Texture::TextureFormat::ASTC_2D_4X4:
return PixelFormat::ASTC_2D_4X4; return PixelFormat::ASTC_2D_4X4;
default: default:
LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); LOG_CRITICAL(HW_GPU, "Unimplemented format={}, component_type={}",
static_cast<u32>(format), static_cast<u32>(component_type));
UNREACHABLE(); UNREACHABLE();
} }
} }
@ -257,6 +272,8 @@ struct SurfaceParams {
// TODO(bunnei): This is fine for unswizzling (since we just need the right component // TODO(bunnei): This is fine for unswizzling (since we just need the right component
// sizes), but could be a bug if we used this function in different ways. // sizes), but could be a bug if we used this function in different ways.
return Tegra::Texture::TextureFormat::A8R8G8B8; return Tegra::Texture::TextureFormat::A8R8G8B8;
case PixelFormat::RGBA32F:
return Tegra::Texture::TextureFormat::R32_G32_B32_A32;
default: default:
LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
UNREACHABLE(); UNREACHABLE();
@ -284,6 +301,8 @@ struct SurfaceParams {
switch (type) { switch (type) {
case Tegra::Texture::ComponentType::UNORM: case Tegra::Texture::ComponentType::UNORM:
return ComponentType::UNorm; return ComponentType::UNorm;
case Tegra::Texture::ComponentType::FLOAT:
return ComponentType::Float;
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();
@ -300,6 +319,7 @@ struct SurfaceParams {
return ComponentType::UNorm; return ComponentType::UNorm;
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:
return ComponentType::Float; return ComponentType::Float;
case Tegra::RenderTargetFormat::RGBA32_UINT: case Tegra::RenderTargetFormat::RGBA32_UINT:
return ComponentType::UInt; return ComponentType::UInt;