From 0f929762b3ba722bab1290a9fe23fc8ad6e909f4 Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 2 Jul 2018 12:42:04 -0500 Subject: GPU: Implemented the Z24S8 depth format and load the depth framebuffer. --- src/video_core/textures/decoders.cpp | 31 +++++++++++++++++++++++++++++++ src/video_core/textures/decoders.h | 6 ++++++ 2 files changed, 37 insertions(+) (limited to 'src/video_core/textures') diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index eaf15da32..680f22ddb 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp @@ -5,6 +5,7 @@ #include #include "common/assert.h" #include "core/memory.h" +#include "video_core/gpu.h" #include "video_core/textures/decoders.h" #include "video_core/textures/texture.h" @@ -73,6 +74,16 @@ u32 BytesPerPixel(TextureFormat format) { } } +static u32 DepthBytesPerPixel(DepthFormat format) { + switch (format) { + case DepthFormat::Z24_S8_UNORM: + return 4; + default: + UNIMPLEMENTED_MSG("Format not implemented"); + break; + } +} + std::vector UnswizzleTexture(VAddr address, TextureFormat format, u32 width, u32 height, u32 block_height) { u8* data = Memory::GetPointer(address); @@ -110,6 +121,26 @@ std::vector UnswizzleTexture(VAddr address, TextureFormat format, u32 width, return unswizzled_data; } +std::vector UnswizzleDepthTexture(VAddr address, DepthFormat format, u32 width, u32 height, + u32 block_height) { + u8* data = Memory::GetPointer(address); + u32 bytes_per_pixel = DepthBytesPerPixel(format); + + std::vector unswizzled_data(width * height * bytes_per_pixel); + + switch (format) { + case DepthFormat::Z24_S8_UNORM: + CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, + unswizzled_data.data(), true, block_height); + break; + default: + UNIMPLEMENTED_MSG("Format not implemented"); + break; + } + + return unswizzled_data; +} + std::vector DecodeTexture(const std::vector& texture_data, TextureFormat format, u32 width, u32 height) { std::vector rgba_data; diff --git a/src/video_core/textures/decoders.h b/src/video_core/textures/decoders.h index 2562c4b06..2b088c077 100644 --- a/src/video_core/textures/decoders.h +++ b/src/video_core/textures/decoders.h @@ -17,6 +17,12 @@ namespace Texture { std::vector UnswizzleTexture(VAddr address, TextureFormat format, u32 width, u32 height, u32 block_height = TICEntry::DefaultBlockHeight); +/** + * Unswizzles a swizzled depth texture without changing its format. + */ +std::vector UnswizzleDepthTexture(VAddr address, DepthFormat format, u32 width, u32 height, + u32 block_height = TICEntry::DefaultBlockHeight); + /// Copies texture data from a buffer and performs swizzling/unswizzling as necessary. void CopySwizzledData(u32 width, u32 height, u32 bytes_per_pixel, u32 out_bytes_per_pixel, u8* swizzled_data, u8* unswizzled_data, bool unswizzle, u32 block_height); -- cgit v1.2.3