Merge pull request #620 from Subv/depth_z32f

GPU: Implemented the 32 bit float depth buffer format.
This commit is contained in:
bunnei 2018-07-05 11:09:15 -04:00 committed by GitHub
commit 9a3c0b161e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -108,7 +108,8 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
{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,
false}, // Z24S8 false}, // Z24S8
{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,
false}, // S8Z24 false}, // S8Z24
{GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, ComponentType::Float, false}, // Z32F
}}; }};
static const FormatTuple& GetFormatTuple(PixelFormat pixel_format, ComponentType component_type) { static const FormatTuple& GetFormatTuple(PixelFormat pixel_format, ComponentType component_type) {
@ -191,7 +192,7 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>, MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>,
MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>, MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>,
MortonCopy<true, PixelFormat::ASTC_2D_4X4>, MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>, MortonCopy<true, PixelFormat::Z24S8>,
MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32F>,
}; };
static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
@ -213,6 +214,7 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
MortonCopy<false, PixelFormat::ABGR8>, MortonCopy<false, PixelFormat::ABGR8>,
MortonCopy<false, PixelFormat::Z24S8>, MortonCopy<false, PixelFormat::Z24S8>,
MortonCopy<false, PixelFormat::S8Z24>, MortonCopy<false, PixelFormat::S8Z24>,
MortonCopy<false, PixelFormat::Z32F>,
}; };
// Allocate an uninitialized texture of appropriate size and format for the surface // Allocate an uninitialized texture of appropriate size and format for the surface

View File

@ -42,6 +42,7 @@ struct SurfaceParams {
// DepthStencil formats // DepthStencil formats
Z24S8 = 13, Z24S8 = 13,
S8Z24 = 14, S8Z24 = 14,
Z32F = 15,
MaxDepthStencilFormat, MaxDepthStencilFormat,
@ -94,6 +95,7 @@ struct SurfaceParams {
4, // ASTC_2D_4X4 4, // ASTC_2D_4X4
1, // Z24S8 1, // Z24S8
1, // S8Z24 1, // S8Z24
1, // Z32F
}}; }};
ASSERT(static_cast<size_t>(format) < compression_factor_table.size()); ASSERT(static_cast<size_t>(format) < compression_factor_table.size());
@ -120,6 +122,7 @@ struct SurfaceParams {
32, // ASTC_2D_4X4 32, // ASTC_2D_4X4
32, // Z24S8 32, // Z24S8
32, // S8Z24 32, // S8Z24
32, // Z32F
}}; }};
ASSERT(static_cast<size_t>(format) < bpp_table.size()); ASSERT(static_cast<size_t>(format) < bpp_table.size());
@ -135,6 +138,8 @@ struct SurfaceParams {
return PixelFormat::S8Z24; return PixelFormat::S8Z24;
case Tegra::DepthFormat::Z24_S8_UNORM: case Tegra::DepthFormat::Z24_S8_UNORM:
return PixelFormat::Z24S8; return PixelFormat::Z24S8;
case Tegra::DepthFormat::Z32_FLOAT:
return PixelFormat::Z32F;
default: default:
LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
UNREACHABLE(); UNREACHABLE();
@ -235,6 +240,8 @@ struct SurfaceParams {
return Tegra::DepthFormat::S8_Z24_UNORM; return Tegra::DepthFormat::S8_Z24_UNORM;
case PixelFormat::Z24S8: case PixelFormat::Z24S8:
return Tegra::DepthFormat::Z24_S8_UNORM; return Tegra::DepthFormat::Z24_S8_UNORM;
case PixelFormat::Z32F:
return Tegra::DepthFormat::Z32_FLOAT;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
@ -284,6 +291,8 @@ struct SurfaceParams {
case Tegra::DepthFormat::S8_Z24_UNORM: case Tegra::DepthFormat::S8_Z24_UNORM:
case Tegra::DepthFormat::Z24_S8_UNORM: case Tegra::DepthFormat::Z24_S8_UNORM:
return ComponentType::UNorm; return ComponentType::UNorm;
case Tegra::DepthFormat::Z32_FLOAT:
return ComponentType::Float;
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

@ -78,6 +78,7 @@ static u32 DepthBytesPerPixel(DepthFormat format) {
switch (format) { switch (format) {
case DepthFormat::S8_Z24_UNORM: case DepthFormat::S8_Z24_UNORM:
case DepthFormat::Z24_S8_UNORM: case DepthFormat::Z24_S8_UNORM:
case DepthFormat::Z32_FLOAT:
return 4; return 4;
default: default:
UNIMPLEMENTED_MSG("Format not implemented"); UNIMPLEMENTED_MSG("Format not implemented");
@ -132,6 +133,7 @@ std::vector<u8> UnswizzleDepthTexture(VAddr address, DepthFormat format, u32 wid
switch (format) { switch (format) {
case DepthFormat::S8_Z24_UNORM: case DepthFormat::S8_Z24_UNORM:
case DepthFormat::Z24_S8_UNORM: case DepthFormat::Z24_S8_UNORM:
case DepthFormat::Z32_FLOAT:
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;