diff options
Diffstat (limited to 'src/video_core/textures/decoders.cpp')
| -rw-r--r-- | src/video_core/textures/decoders.cpp | 85 |
1 files changed, 4 insertions, 81 deletions
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index 7ea66584c..70746a34e 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp | |||
| @@ -86,88 +86,11 @@ u32 BytesPerPixel(TextureFormat format) { | |||
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | static u32 DepthBytesPerPixel(DepthFormat format) { | 89 | std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size, u32 bytes_per_pixel, u32 width, |
| 90 | switch (format) { | 90 | u32 height, u32 block_height) { |
| 91 | case DepthFormat::Z16_UNORM: | ||
| 92 | return 2; | ||
| 93 | case DepthFormat::S8_Z24_UNORM: | ||
| 94 | case DepthFormat::Z24_S8_UNORM: | ||
| 95 | case DepthFormat::Z32_FLOAT: | ||
| 96 | return 4; | ||
| 97 | case DepthFormat::Z32_S8_X24_FLOAT: | ||
| 98 | return 8; | ||
| 99 | default: | ||
| 100 | UNIMPLEMENTED_MSG("Format not implemented"); | ||
| 101 | break; | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width, u32 height, | ||
| 106 | u32 block_height) { | ||
| 107 | u8* data = Memory::GetPointer(address); | ||
| 108 | u32 bytes_per_pixel = BytesPerPixel(format); | ||
| 109 | |||
| 110 | std::vector<u8> unswizzled_data(width * height * bytes_per_pixel); | ||
| 111 | |||
| 112 | switch (format) { | ||
| 113 | case TextureFormat::DXT1: | ||
| 114 | case TextureFormat::DXT23: | ||
| 115 | case TextureFormat::DXT45: | ||
| 116 | case TextureFormat::DXN1: | ||
| 117 | case TextureFormat::DXN2: | ||
| 118 | case TextureFormat::BC7U: | ||
| 119 | // In the DXT and DXN formats, each 4x4 tile is swizzled instead of just individual pixel | ||
| 120 | // values. | ||
| 121 | CopySwizzledData(width / 4, height / 4, bytes_per_pixel, bytes_per_pixel, data, | ||
| 122 | unswizzled_data.data(), true, block_height); | ||
| 123 | break; | ||
| 124 | case TextureFormat::A8R8G8B8: | ||
| 125 | case TextureFormat::A2B10G10R10: | ||
| 126 | case TextureFormat::A1B5G5R5: | ||
| 127 | case TextureFormat::B5G6R5: | ||
| 128 | case TextureFormat::R8: | ||
| 129 | case TextureFormat::G8R8: | ||
| 130 | case TextureFormat::R16_G16_B16_A16: | ||
| 131 | case TextureFormat::R32_G32_B32_A32: | ||
| 132 | case TextureFormat::R32_G32: | ||
| 133 | case TextureFormat::R32: | ||
| 134 | case TextureFormat::R16: | ||
| 135 | case TextureFormat::R16_G16: | ||
| 136 | case TextureFormat::BF10GF11RF11: | ||
| 137 | case TextureFormat::ASTC_2D_4X4: | ||
| 138 | case TextureFormat::R32_G32_B32: | ||
| 139 | CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, | ||
| 140 | unswizzled_data.data(), true, block_height); | ||
| 141 | break; | ||
| 142 | default: | ||
| 143 | UNIMPLEMENTED_MSG("Format not implemented"); | ||
| 144 | break; | ||
| 145 | } | ||
| 146 | |||
| 147 | return unswizzled_data; | ||
| 148 | } | ||
| 149 | |||
| 150 | std::vector<u8> UnswizzleDepthTexture(VAddr address, DepthFormat format, u32 width, u32 height, | ||
| 151 | u32 block_height) { | ||
| 152 | u8* data = Memory::GetPointer(address); | ||
| 153 | u32 bytes_per_pixel = DepthBytesPerPixel(format); | ||
| 154 | |||
| 155 | std::vector<u8> unswizzled_data(width * height * bytes_per_pixel); | 91 | std::vector<u8> unswizzled_data(width * height * bytes_per_pixel); |
| 156 | 92 | CopySwizzledData(width / tile_size, height / tile_size, bytes_per_pixel, bytes_per_pixel, | |
| 157 | switch (format) { | 93 | Memory::GetPointer(address), unswizzled_data.data(), true, block_height); |
| 158 | case DepthFormat::Z16_UNORM: | ||
| 159 | case DepthFormat::S8_Z24_UNORM: | ||
| 160 | case DepthFormat::Z24_S8_UNORM: | ||
| 161 | case DepthFormat::Z32_FLOAT: | ||
| 162 | case DepthFormat::Z32_S8_X24_FLOAT: | ||
| 163 | CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, | ||
| 164 | unswizzled_data.data(), true, block_height); | ||
| 165 | break; | ||
| 166 | default: | ||
| 167 | UNIMPLEMENTED_MSG("Format not implemented"); | ||
| 168 | break; | ||
| 169 | } | ||
| 170 | |||
| 171 | return unswizzled_data; | 94 | return unswizzled_data; |
| 172 | } | 95 | } |
| 173 | 96 | ||