From 016e357c752e3aed1094c664e7387ebed9738f03 Mon Sep 17 00:00:00 2001 From: Subv Date: Wed, 4 Jul 2018 10:42:33 -0500 Subject: [PATCH] GPU: Implemented the 32 bit float depth buffer format. --- src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 6 ++++-- src/video_core/renderer_opengl/gl_rasterizer_cache.h | 9 +++++++++ src/video_core/textures/decoders.cpp | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 50469c05cc..57d7763ff5 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -108,7 +108,8 @@ static constexpr std::array tex_form {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm, false}, // Z24S8 {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) { @@ -191,7 +192,7 @@ static constexpr std::array, MortonCopy, MortonCopy, MortonCopy, MortonCopy, MortonCopy, - MortonCopy, + MortonCopy, MortonCopy, }; static constexpr std::array, MortonCopy, MortonCopy, + MortonCopy, }; // Allocate an uninitialized texture of appropriate size and format for the surface diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 8005a81b83..b4d7f8ebe8 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h @@ -42,6 +42,7 @@ struct SurfaceParams { // DepthStencil formats Z24S8 = 13, S8Z24 = 14, + Z32F = 15, MaxDepthStencilFormat, @@ -94,6 +95,7 @@ struct SurfaceParams { 4, // ASTC_2D_4X4 1, // Z24S8 1, // S8Z24 + 1, // Z32F }}; ASSERT(static_cast(format) < compression_factor_table.size()); @@ -120,6 +122,7 @@ struct SurfaceParams { 32, // ASTC_2D_4X4 32, // Z24S8 32, // S8Z24 + 32, // Z32F }}; ASSERT(static_cast(format) < bpp_table.size()); @@ -135,6 +138,8 @@ struct SurfaceParams { return PixelFormat::S8Z24; case Tegra::DepthFormat::Z24_S8_UNORM: return PixelFormat::Z24S8; + case Tegra::DepthFormat::Z32_FLOAT: + return PixelFormat::Z32F; default: LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast(format)); UNREACHABLE(); @@ -235,6 +240,8 @@ struct SurfaceParams { return Tegra::DepthFormat::S8_Z24_UNORM; case PixelFormat::Z24S8: return Tegra::DepthFormat::Z24_S8_UNORM; + case PixelFormat::Z32F: + return Tegra::DepthFormat::Z32_FLOAT; default: UNREACHABLE(); } @@ -284,6 +291,8 @@ struct SurfaceParams { case Tegra::DepthFormat::S8_Z24_UNORM: case Tegra::DepthFormat::Z24_S8_UNORM: return ComponentType::UNorm; + case Tegra::DepthFormat::Z32_FLOAT: + return ComponentType::Float; default: LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast(format)); UNREACHABLE(); diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index 7b06fea3e2..d5ab4e4f90 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp @@ -78,6 +78,7 @@ static u32 DepthBytesPerPixel(DepthFormat format) { switch (format) { case DepthFormat::S8_Z24_UNORM: case DepthFormat::Z24_S8_UNORM: + case DepthFormat::Z32_FLOAT: return 4; default: UNIMPLEMENTED_MSG("Format not implemented"); @@ -132,6 +133,7 @@ std::vector UnswizzleDepthTexture(VAddr address, DepthFormat format, u32 wid switch (format) { case DepthFormat::S8_Z24_UNORM: case DepthFormat::Z24_S8_UNORM: + case DepthFormat::Z32_FLOAT: CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, unswizzled_data.data(), true, block_height); break;