diff options
Diffstat (limited to 'src/video_core/textures/decoders.cpp')
| -rw-r--r-- | src/video_core/textures/decoders.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index 7eabd34f1..bbae9285f 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp | |||
| @@ -127,7 +127,8 @@ void FastProcessBlock(u8* const swizzled_data, u8* const unswizzled_data, const | |||
| 127 | template <bool fast> | 127 | template <bool fast> |
| 128 | void SwizzledData(u8* const swizzled_data, u8* const unswizzled_data, const bool unswizzle, | 128 | void SwizzledData(u8* const swizzled_data, u8* const unswizzled_data, const bool unswizzle, |
| 129 | const u32 width, const u32 height, const u32 depth, const u32 bytes_per_pixel, | 129 | const u32 width, const u32 height, const u32 depth, const u32 bytes_per_pixel, |
| 130 | const u32 out_bytes_per_pixel, const u32 block_height, const u32 block_depth) { | 130 | const u32 out_bytes_per_pixel, const u32 block_height, const u32 block_depth, |
| 131 | const u32 width_spacing) { | ||
| 131 | auto div_ceil = [](const u32 x, const u32 y) { return ((x + y - 1) / y); }; | 132 | auto div_ceil = [](const u32 x, const u32 y) { return ((x + y - 1) / y); }; |
| 132 | const u32 stride_x = width * out_bytes_per_pixel; | 133 | const u32 stride_x = width * out_bytes_per_pixel; |
| 133 | const u32 layer_z = height * stride_x; | 134 | const u32 layer_z = height * stride_x; |
| @@ -137,7 +138,8 @@ void SwizzledData(u8* const swizzled_data, u8* const unswizzled_data, const bool | |||
| 137 | const u32 block_x_elements = gob_elements_x; | 138 | const u32 block_x_elements = gob_elements_x; |
| 138 | const u32 block_y_elements = gob_elements_y * block_height; | 139 | const u32 block_y_elements = gob_elements_y * block_height; |
| 139 | const u32 block_z_elements = gob_elements_z * block_depth; | 140 | const u32 block_z_elements = gob_elements_z * block_depth; |
| 140 | const u32 blocks_on_x = div_ceil(width, block_x_elements); | 141 | const u32 aligned_width = Common::AlignUp(width, gob_elements_x * width_spacing); |
| 142 | const u32 blocks_on_x = div_ceil(aligned_width, block_x_elements); | ||
| 141 | const u32 blocks_on_y = div_ceil(height, block_y_elements); | 143 | const u32 blocks_on_y = div_ceil(height, block_y_elements); |
| 142 | const u32 blocks_on_z = div_ceil(depth, block_z_elements); | 144 | const u32 blocks_on_z = div_ceil(depth, block_z_elements); |
| 143 | const u32 xy_block_size = gob_size * block_height; | 145 | const u32 xy_block_size = gob_size * block_height; |
| @@ -169,13 +171,15 @@ void SwizzledData(u8* const swizzled_data, u8* const unswizzled_data, const bool | |||
| 169 | 171 | ||
| 170 | void CopySwizzledData(u32 width, u32 height, u32 depth, u32 bytes_per_pixel, | 172 | void CopySwizzledData(u32 width, u32 height, u32 depth, u32 bytes_per_pixel, |
| 171 | u32 out_bytes_per_pixel, u8* const swizzled_data, u8* const unswizzled_data, | 173 | u32 out_bytes_per_pixel, u8* const swizzled_data, u8* const unswizzled_data, |
| 172 | bool unswizzle, u32 block_height, u32 block_depth) { | 174 | bool unswizzle, u32 block_height, u32 block_depth, u32 width_spacing) { |
| 173 | if (bytes_per_pixel % 3 != 0 && (width * bytes_per_pixel) % fast_swizzle_align == 0) { | 175 | if (bytes_per_pixel % 3 != 0 && (width * bytes_per_pixel) % fast_swizzle_align == 0) { |
| 174 | SwizzledData<true>(swizzled_data, unswizzled_data, unswizzle, width, height, depth, | 176 | SwizzledData<true>(swizzled_data, unswizzled_data, unswizzle, width, height, depth, |
| 175 | bytes_per_pixel, out_bytes_per_pixel, block_height, block_depth); | 177 | bytes_per_pixel, out_bytes_per_pixel, block_height, block_depth, |
| 178 | width_spacing); | ||
| 176 | } else { | 179 | } else { |
| 177 | SwizzledData<false>(swizzled_data, unswizzled_data, unswizzle, width, height, depth, | 180 | SwizzledData<false>(swizzled_data, unswizzled_data, unswizzle, width, height, depth, |
| 178 | bytes_per_pixel, out_bytes_per_pixel, block_height, block_depth); | 181 | bytes_per_pixel, out_bytes_per_pixel, block_height, block_depth, |
| 182 | width_spacing); | ||
| 179 | } | 183 | } |
| 180 | } | 184 | } |
| 181 | 185 | ||
| @@ -228,19 +232,19 @@ u32 BytesPerPixel(TextureFormat format) { | |||
| 228 | 232 | ||
| 229 | void UnswizzleTexture(u8* const unswizzled_data, VAddr address, u32 tile_size_x, u32 tile_size_y, | 233 | void UnswizzleTexture(u8* const unswizzled_data, VAddr address, u32 tile_size_x, u32 tile_size_y, |
| 230 | u32 bytes_per_pixel, u32 width, u32 height, u32 depth, u32 block_height, | 234 | u32 bytes_per_pixel, u32 width, u32 height, u32 depth, u32 block_height, |
| 231 | u32 block_depth) { | 235 | u32 block_depth, u32 width_spacing) { |
| 232 | CopySwizzledData((width + tile_size_x - 1) / tile_size_x, | 236 | CopySwizzledData((width + tile_size_x - 1) / tile_size_x, |
| 233 | (height + tile_size_y - 1) / tile_size_y, depth, bytes_per_pixel, | 237 | (height + tile_size_y - 1) / tile_size_y, depth, bytes_per_pixel, |
| 234 | bytes_per_pixel, Memory::GetPointer(address), unswizzled_data, true, | 238 | bytes_per_pixel, Memory::GetPointer(address), unswizzled_data, true, |
| 235 | block_height, block_depth); | 239 | block_height, block_depth, width_spacing); |
| 236 | } | 240 | } |
| 237 | 241 | ||
| 238 | std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size_x, u32 tile_size_y, | 242 | std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size_x, u32 tile_size_y, |
| 239 | u32 bytes_per_pixel, u32 width, u32 height, u32 depth, | 243 | u32 bytes_per_pixel, u32 width, u32 height, u32 depth, |
| 240 | u32 block_height, u32 block_depth) { | 244 | u32 block_height, u32 block_depth, u32 width_spacing) { |
| 241 | std::vector<u8> unswizzled_data(width * height * depth * bytes_per_pixel); | 245 | std::vector<u8> unswizzled_data(width * height * depth * bytes_per_pixel); |
| 242 | UnswizzleTexture(unswizzled_data.data(), address, tile_size_x, tile_size_y, bytes_per_pixel, | 246 | UnswizzleTexture(unswizzled_data.data(), address, tile_size_x, tile_size_y, bytes_per_pixel, |
| 243 | width, height, depth, block_height, block_depth); | 247 | width, height, depth, block_height, block_depth, width_spacing); |
| 244 | return unswizzled_data; | 248 | return unswizzled_data; |
| 245 | } | 249 | } |
| 246 | 250 | ||