diff options
| author | 2018-10-11 19:11:47 -0400 | |
|---|---|---|
| committer | 2018-10-13 15:25:18 -0400 | |
| commit | e0ca938b222584cdbf9e03460171c03484882bd4 (patch) | |
| tree | 508abef3fcef21a6fecc6c783bf7da1d93b198f0 /src/video_core/textures/decoders.cpp | |
| parent | Remove old Swizzle algorithms and use 3d Swizzle (diff) | |
| download | yuzu-e0ca938b222584cdbf9e03460171c03484882bd4.tar.gz yuzu-e0ca938b222584cdbf9e03460171c03484882bd4.tar.xz yuzu-e0ca938b222584cdbf9e03460171c03484882bd4.zip | |
Propagate depth and depth_block on modules using decoders
Diffstat (limited to 'src/video_core/textures/decoders.cpp')
| -rw-r--r-- | src/video_core/textures/decoders.cpp | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index 5e2d3ac32..6693067f8 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp | |||
| @@ -51,18 +51,18 @@ void Precise3DProcessBlock(u8* swizzled_data, u8* unswizzled_data, const bool un | |||
| 51 | const u32 xy_block_size, const u32 layer_z, const u32 stride_x, | 51 | const u32 xy_block_size, const u32 layer_z, const u32 stride_x, |
| 52 | const u32 bytes_per_pixel, const u32 out_bytes_per_pixel) { | 52 | const u32 bytes_per_pixel, const u32 out_bytes_per_pixel) { |
| 53 | std::array<u8*, 2> data_ptrs; | 53 | std::array<u8*, 2> data_ptrs; |
| 54 | u32 z_adress = tile_offset; | 54 | u32 z_address = tile_offset; |
| 55 | const u32 gob_size_x = 64; | 55 | const u32 gob_size_x = 64; |
| 56 | const u32 gob_size_y = 8; | 56 | const u32 gob_size_y = 8; |
| 57 | const u32 gob_size_z = 1; | 57 | const u32 gob_size_z = 1; |
| 58 | const u32 gob_size = gob_size_x * gob_size_y * gob_size_z; | 58 | const u32 gob_size = gob_size_x * gob_size_y * gob_size_z; |
| 59 | for (u32 z = z_start; z < z_end; z++) { | 59 | for (u32 z = z_start; z < z_end; z++) { |
| 60 | u32 y_adress = z_adress; | 60 | u32 y_address = z_address; |
| 61 | u32 pixel_base = layer_z * z + y_start * stride_x; | 61 | u32 pixel_base = layer_z * z + y_start * stride_x; |
| 62 | for (u32 y = y_start; y < y_end; y++) { | 62 | for (u32 y = y_start; y < y_end; y++) { |
| 63 | const auto& table = legacy_swizzle_table[y % gob_size_y]; | 63 | const auto& table = legacy_swizzle_table[y % gob_size_y]; |
| 64 | for (u32 x = x_start; x < x_end; x++) { | 64 | for (u32 x = x_start; x < x_end; x++) { |
| 65 | const u32 swizzle_offset{y_adress + table[x * bytes_per_pixel % gob_size_x]}; | 65 | const u32 swizzle_offset{y_address + table[x * bytes_per_pixel % gob_size_x]}; |
| 66 | const u32 pixel_index{x * out_bytes_per_pixel + pixel_base}; | 66 | const u32 pixel_index{x * out_bytes_per_pixel + pixel_base}; |
| 67 | data_ptrs[unswizzle] = swizzled_data + swizzle_offset; | 67 | data_ptrs[unswizzle] = swizzled_data + swizzle_offset; |
| 68 | data_ptrs[!unswizzle] = unswizzled_data + pixel_index; | 68 | data_ptrs[!unswizzle] = unswizzled_data + pixel_index; |
| @@ -70,9 +70,9 @@ void Precise3DProcessBlock(u8* swizzled_data, u8* unswizzled_data, const bool un | |||
| 70 | } | 70 | } |
| 71 | pixel_base += stride_x; | 71 | pixel_base += stride_x; |
| 72 | if ((y + 1) % gob_size_y == 0) | 72 | if ((y + 1) % gob_size_y == 0) |
| 73 | y_adress += gob_size; | 73 | y_address += gob_size; |
| 74 | } | 74 | } |
| 75 | z_adress += xy_block_size; | 75 | z_address += xy_block_size; |
| 76 | } | 76 | } |
| 77 | } | 77 | } |
| 78 | 78 | ||
| @@ -136,7 +136,7 @@ void Fast3DProcessBlock(u8* swizzled_data, u8* unswizzled_data, const bool unswi | |||
| 136 | const u32 xy_block_size, const u32 layer_z, const u32 stride_x, | 136 | const u32 xy_block_size, const u32 layer_z, const u32 stride_x, |
| 137 | const u32 bytes_per_pixel, const u32 out_bytes_per_pixel) { | 137 | const u32 bytes_per_pixel, const u32 out_bytes_per_pixel) { |
| 138 | std::array<u8*, 2> data_ptrs; | 138 | std::array<u8*, 2> data_ptrs; |
| 139 | u32 z_adress = tile_offset; | 139 | u32 z_address = tile_offset; |
| 140 | const u32 x_startb = x_start * bytes_per_pixel; | 140 | const u32 x_startb = x_start * bytes_per_pixel; |
| 141 | const u32 x_endb = x_end * bytes_per_pixel; | 141 | const u32 x_endb = x_end * bytes_per_pixel; |
| 142 | const u32 copy_size = 16; | 142 | const u32 copy_size = 16; |
| @@ -145,12 +145,12 @@ void Fast3DProcessBlock(u8* swizzled_data, u8* unswizzled_data, const bool unswi | |||
| 145 | const u32 gob_size_z = 1; | 145 | const u32 gob_size_z = 1; |
| 146 | const u32 gob_size = gob_size_x * gob_size_y * gob_size_z; | 146 | const u32 gob_size = gob_size_x * gob_size_y * gob_size_z; |
| 147 | for (u32 z = z_start; z < z_end; z++) { | 147 | for (u32 z = z_start; z < z_end; z++) { |
| 148 | u32 y_adress = z_adress; | 148 | u32 y_address = z_address; |
| 149 | u32 pixel_base = layer_z * z + y_start * stride_x; | 149 | u32 pixel_base = layer_z * z + y_start * stride_x; |
| 150 | for (u32 y = y_start; y < y_end; y++) { | 150 | for (u32 y = y_start; y < y_end; y++) { |
| 151 | const auto& table = fast_swizzle_table[y % gob_size_y]; | 151 | const auto& table = fast_swizzle_table[y % gob_size_y]; |
| 152 | for (u32 xb = x_startb; xb < x_endb; xb += copy_size) { | 152 | for (u32 xb = x_startb; xb < x_endb; xb += copy_size) { |
| 153 | const u32 swizzle_offset{y_adress + table[(xb / copy_size) % 4]}; | 153 | const u32 swizzle_offset{y_address + table[(xb / copy_size) % 4]}; |
| 154 | const u32 out_x = xb * out_bytes_per_pixel / bytes_per_pixel; | 154 | const u32 out_x = xb * out_bytes_per_pixel / bytes_per_pixel; |
| 155 | const u32 pixel_index{out_x + pixel_base}; | 155 | const u32 pixel_index{out_x + pixel_base}; |
| 156 | data_ptrs[unswizzle] = swizzled_data + swizzle_offset; | 156 | data_ptrs[unswizzle] = swizzled_data + swizzle_offset; |
| @@ -159,9 +159,9 @@ void Fast3DProcessBlock(u8* swizzled_data, u8* unswizzled_data, const bool unswi | |||
| 159 | } | 159 | } |
| 160 | pixel_base += stride_x; | 160 | pixel_base += stride_x; |
| 161 | if ((y + 1) % gob_size_y == 0) | 161 | if ((y + 1) % gob_size_y == 0) |
| 162 | y_adress += gob_size; | 162 | y_address += gob_size; |
| 163 | } | 163 | } |
| 164 | z_adress += xy_block_size; | 164 | z_address += xy_block_size; |
| 165 | } | 165 | } |
| 166 | } | 166 | } |
| 167 | 167 | ||
| @@ -214,14 +214,15 @@ void Fast3DSwizzledData(u8* swizzled_data, u8* unswizzled_data, const bool unswi | |||
| 214 | } | 214 | } |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | void CopySwizzledData(u32 width, u32 height, u32 bytes_per_pixel, u32 out_bytes_per_pixel, | 217 | void CopySwizzledData(u32 width, u32 height, u32 depth, u32 bytes_per_pixel, |
| 218 | u8* swizzled_data, u8* unswizzled_data, bool unswizzle, u32 block_height) { | 218 | u32 out_bytes_per_pixel, u8* swizzled_data, u8* unswizzled_data, |
| 219 | bool unswizzle, u32 block_height, u32 block_depth) { | ||
| 219 | if (bytes_per_pixel % 3 != 0 && (width * bytes_per_pixel) % 16 == 0) { | 220 | if (bytes_per_pixel % 3 != 0 && (width * bytes_per_pixel) % 16 == 0) { |
| 220 | Fast3DSwizzledData(swizzled_data, unswizzled_data, unswizzle, width, height, 1U, | 221 | Fast3DSwizzledData(swizzled_data, unswizzled_data, unswizzle, width, height, depth, |
| 221 | bytes_per_pixel, out_bytes_per_pixel, block_height, 1U); | 222 | bytes_per_pixel, out_bytes_per_pixel, block_height, block_depth); |
| 222 | } else { | 223 | } else { |
| 223 | Precise3DSwizzledData(swizzled_data, unswizzled_data, unswizzle, width, height, 1U, | 224 | Precise3DSwizzledData(swizzled_data, unswizzled_data, unswizzle, width, height, depth, |
| 224 | bytes_per_pixel, out_bytes_per_pixel, block_height, 1U); | 225 | bytes_per_pixel, out_bytes_per_pixel, block_height, block_depth); |
| 225 | } | 226 | } |
| 226 | } | 227 | } |
| 227 | 228 | ||
| @@ -269,10 +270,11 @@ u32 BytesPerPixel(TextureFormat format) { | |||
| 269 | } | 270 | } |
| 270 | 271 | ||
| 271 | std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size, u32 bytes_per_pixel, u32 width, | 272 | std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size, u32 bytes_per_pixel, u32 width, |
| 272 | u32 height, u32 block_height) { | 273 | u32 height, u32 depth, u32 block_height, u32 block_depth) { |
| 273 | std::vector<u8> unswizzled_data(width * height * bytes_per_pixel); | 274 | std::vector<u8> unswizzled_data(width * height * bytes_per_pixel); |
| 274 | CopySwizzledData(width / tile_size, height / tile_size, bytes_per_pixel, bytes_per_pixel, | 275 | CopySwizzledData(width / tile_size, height / tile_size, depth, bytes_per_pixel, bytes_per_pixel, |
| 275 | Memory::GetPointer(address), unswizzled_data.data(), true, block_height); | 276 | Memory::GetPointer(address), unswizzled_data.data(), true, block_height, |
| 277 | block_depth); | ||
| 276 | return unswizzled_data; | 278 | return unswizzled_data; |
| 277 | } | 279 | } |
| 278 | 280 | ||