diff options
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 @@ | |||
| 5 | #include <cstring> | 5 | #include <cstring> |
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "core/memory.h" | 7 | #include "core/memory.h" |
| 8 | #include "video_core/gpu.h" | ||
| 8 | #include "video_core/textures/decoders.h" | 9 | #include "video_core/textures/decoders.h" |
| 9 | #include "video_core/textures/texture.h" | 10 | #include "video_core/textures/texture.h" |
| 10 | 11 | ||
| @@ -73,6 +74,16 @@ u32 BytesPerPixel(TextureFormat format) { | |||
| 73 | } | 74 | } |
| 74 | } | 75 | } |
| 75 | 76 | ||
| 77 | static u32 DepthBytesPerPixel(DepthFormat format) { | ||
| 78 | switch (format) { | ||
| 79 | case DepthFormat::Z24_S8_UNORM: | ||
| 80 | return 4; | ||
| 81 | default: | ||
| 82 | UNIMPLEMENTED_MSG("Format not implemented"); | ||
| 83 | break; | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 76 | std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width, u32 height, | 87 | std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width, u32 height, |
| 77 | u32 block_height) { | 88 | u32 block_height) { |
| 78 | u8* data = Memory::GetPointer(address); | 89 | u8* data = Memory::GetPointer(address); |
| @@ -110,6 +121,26 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width, | |||
| 110 | return unswizzled_data; | 121 | return unswizzled_data; |
| 111 | } | 122 | } |
| 112 | 123 | ||
| 124 | std::vector<u8> UnswizzleDepthTexture(VAddr address, DepthFormat format, u32 width, u32 height, | ||
| 125 | u32 block_height) { | ||
| 126 | u8* data = Memory::GetPointer(address); | ||
| 127 | u32 bytes_per_pixel = DepthBytesPerPixel(format); | ||
| 128 | |||
| 129 | std::vector<u8> unswizzled_data(width * height * bytes_per_pixel); | ||
| 130 | |||
| 131 | switch (format) { | ||
| 132 | case DepthFormat::Z24_S8_UNORM: | ||
| 133 | CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, | ||
| 134 | unswizzled_data.data(), true, block_height); | ||
| 135 | break; | ||
| 136 | default: | ||
| 137 | UNIMPLEMENTED_MSG("Format not implemented"); | ||
| 138 | break; | ||
| 139 | } | ||
| 140 | |||
| 141 | return unswizzled_data; | ||
| 142 | } | ||
| 143 | |||
| 113 | std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat format, u32 width, | 144 | std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat format, u32 width, |
| 114 | u32 height) { | 145 | u32 height) { |
| 115 | std::vector<u8> rgba_data; | 146 | std::vector<u8> rgba_data; |