diff options
author | bunnei <bunneidev@gmail.com> | 2018-07-03 03:24:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-03 03:24:43 +0200 |
commit | 92c713506542d5e628a5495943792b11e8de5c20 (patch) | |
tree | 1b46282f09e46b163be059965aaf1dc410ba1be4 /src/video_core/textures/decoders.cpp | |
parent | Merge pull request #606 from Subv/base_vertex (diff) | |
parent | GPU: Set up the culling configuration on each draw. (diff) | |
download | yuzu-92c713506542d5e628a5495943792b11e8de5c20.tar yuzu-92c713506542d5e628a5495943792b11e8de5c20.tar.gz yuzu-92c713506542d5e628a5495943792b11e8de5c20.tar.bz2 yuzu-92c713506542d5e628a5495943792b11e8de5c20.tar.lz yuzu-92c713506542d5e628a5495943792b11e8de5c20.tar.xz yuzu-92c713506542d5e628a5495943792b11e8de5c20.tar.zst yuzu-92c713506542d5e628a5495943792b11e8de5c20.zip |
Diffstat (limited to 'src/video_core/textures/decoders.cpp')
-rw-r--r-- | src/video_core/textures/decoders.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
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 <cstring> #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<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width, u32 height, u32 block_height) { u8* data = Memory::GetPointer(address); @@ -110,6 +121,26 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width, return unswizzled_data; } +std::vector<u8> 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<u8> 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<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat format, u32 width, u32 height) { std::vector<u8> rgba_data; |