diff options
| author | 2019-03-16 21:59:45 -0400 | |
|---|---|---|
| committer | 2019-03-16 21:59:45 -0400 | |
| commit | 2392e146b09c2a4b3bb557bb3a20c4afc7f75957 (patch) | |
| tree | 1eafa50be7af78d74b4781fbe858277ac8ab1d35 /src/video_core/textures | |
| parent | Merge pull request #2243 from bunnei/mem-simplify-cache (diff) | |
| parent | video_core: Refactor to use MemoryManager interface for all memory access. (diff) | |
| download | yuzu-2392e146b09c2a4b3bb557bb3a20c4afc7f75957.tar.gz yuzu-2392e146b09c2a4b3bb557bb3a20c4afc7f75957.tar.xz yuzu-2392e146b09c2a4b3bb557bb3a20c4afc7f75957.zip | |
Merge pull request #2244 from bunnei/gpu-mem-refactor
video_core: Refactor to use MemoryManager interface for all memory access.
Diffstat (limited to 'src/video_core/textures')
| -rw-r--r-- | src/video_core/textures/decoders.cpp | 32 | ||||
| -rw-r--r-- | src/video_core/textures/decoders.h | 13 |
2 files changed, 21 insertions, 24 deletions
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index cad7340f5..995d0e068 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | #include <cstring> | 6 | #include <cstring> |
| 7 | #include "common/alignment.h" | 7 | #include "common/alignment.h" |
| 8 | #include "common/assert.h" | 8 | #include "common/assert.h" |
| 9 | #include "core/memory.h" | ||
| 10 | #include "video_core/gpu.h" | 9 | #include "video_core/gpu.h" |
| 11 | #include "video_core/textures/decoders.h" | 10 | #include "video_core/textures/decoders.h" |
| 12 | #include "video_core/textures/texture.h" | 11 | #include "video_core/textures/texture.h" |
| @@ -230,18 +229,18 @@ u32 BytesPerPixel(TextureFormat format) { | |||
| 230 | } | 229 | } |
| 231 | } | 230 | } |
| 232 | 231 | ||
| 233 | void UnswizzleTexture(u8* const unswizzled_data, VAddr address, u32 tile_size_x, u32 tile_size_y, | 232 | void UnswizzleTexture(u8* const unswizzled_data, u8* address, u32 tile_size_x, u32 tile_size_y, |
| 234 | u32 bytes_per_pixel, u32 width, u32 height, u32 depth, u32 block_height, | 233 | u32 bytes_per_pixel, u32 width, u32 height, u32 depth, u32 block_height, |
| 235 | u32 block_depth, u32 width_spacing) { | 234 | u32 block_depth, u32 width_spacing) { |
| 236 | CopySwizzledData((width + tile_size_x - 1) / tile_size_x, | 235 | CopySwizzledData((width + tile_size_x - 1) / tile_size_x, |
| 237 | (height + tile_size_y - 1) / tile_size_y, depth, bytes_per_pixel, | 236 | (height + tile_size_y - 1) / tile_size_y, depth, bytes_per_pixel, |
| 238 | bytes_per_pixel, Memory::GetPointer(address), unswizzled_data, true, | 237 | bytes_per_pixel, address, unswizzled_data, true, block_height, block_depth, |
| 239 | block_height, block_depth, width_spacing); | 238 | width_spacing); |
| 240 | } | 239 | } |
| 241 | 240 | ||
| 242 | std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size_x, u32 tile_size_y, | 241 | std::vector<u8> UnswizzleTexture(u8* address, u32 tile_size_x, u32 tile_size_y, u32 bytes_per_pixel, |
| 243 | u32 bytes_per_pixel, u32 width, u32 height, u32 depth, | 242 | u32 width, u32 height, u32 depth, u32 block_height, |
| 244 | u32 block_height, u32 block_depth, u32 width_spacing) { | 243 | u32 block_depth, u32 width_spacing) { |
| 245 | std::vector<u8> unswizzled_data(width * height * depth * bytes_per_pixel); | 244 | std::vector<u8> unswizzled_data(width * height * depth * bytes_per_pixel); |
| 246 | UnswizzleTexture(unswizzled_data.data(), address, tile_size_x, tile_size_y, bytes_per_pixel, | 245 | UnswizzleTexture(unswizzled_data.data(), address, tile_size_x, tile_size_y, bytes_per_pixel, |
| 247 | width, height, depth, block_height, block_depth, width_spacing); | 246 | width, height, depth, block_height, block_depth, width_spacing); |
| @@ -249,8 +248,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size_x, u32 tile_size_y | |||
| 249 | } | 248 | } |
| 250 | 249 | ||
| 251 | void SwizzleSubrect(u32 subrect_width, u32 subrect_height, u32 source_pitch, u32 swizzled_width, | 250 | void SwizzleSubrect(u32 subrect_width, u32 subrect_height, u32 source_pitch, u32 swizzled_width, |
| 252 | u32 bytes_per_pixel, VAddr swizzled_data, VAddr unswizzled_data, | 251 | u32 bytes_per_pixel, u8* swizzled_data, u8* unswizzled_data, u32 block_height) { |
| 253 | u32 block_height) { | ||
| 254 | const u32 image_width_in_gobs{(swizzled_width * bytes_per_pixel + (gob_size_x - 1)) / | 252 | const u32 image_width_in_gobs{(swizzled_width * bytes_per_pixel + (gob_size_x - 1)) / |
| 255 | gob_size_x}; | 253 | gob_size_x}; |
| 256 | for (u32 line = 0; line < subrect_height; ++line) { | 254 | for (u32 line = 0; line < subrect_height; ++line) { |
| @@ -262,17 +260,17 @@ void SwizzleSubrect(u32 subrect_width, u32 subrect_height, u32 source_pitch, u32 | |||
| 262 | const u32 gob_address = | 260 | const u32 gob_address = |
| 263 | gob_address_y + (x * bytes_per_pixel / gob_size_x) * gob_size * block_height; | 261 | gob_address_y + (x * bytes_per_pixel / gob_size_x) * gob_size * block_height; |
| 264 | const u32 swizzled_offset = gob_address + table[(x * bytes_per_pixel) % gob_size_x]; | 262 | const u32 swizzled_offset = gob_address + table[(x * bytes_per_pixel) % gob_size_x]; |
| 265 | const VAddr source_line = unswizzled_data + line * source_pitch + x * bytes_per_pixel; | 263 | u8* source_line = unswizzled_data + line * source_pitch + x * bytes_per_pixel; |
| 266 | const VAddr dest_addr = swizzled_data + swizzled_offset; | 264 | u8* dest_addr = swizzled_data + swizzled_offset; |
| 267 | 265 | ||
| 268 | Memory::CopyBlock(dest_addr, source_line, bytes_per_pixel); | 266 | std::memcpy(dest_addr, source_line, bytes_per_pixel); |
| 269 | } | 267 | } |
| 270 | } | 268 | } |
| 271 | } | 269 | } |
| 272 | 270 | ||
| 273 | void UnswizzleSubrect(u32 subrect_width, u32 subrect_height, u32 dest_pitch, u32 swizzled_width, | 271 | void UnswizzleSubrect(u32 subrect_width, u32 subrect_height, u32 dest_pitch, u32 swizzled_width, |
| 274 | u32 bytes_per_pixel, VAddr swizzled_data, VAddr unswizzled_data, | 272 | u32 bytes_per_pixel, u8* swizzled_data, u8* unswizzled_data, u32 block_height, |
| 275 | u32 block_height, u32 offset_x, u32 offset_y) { | 273 | u32 offset_x, u32 offset_y) { |
| 276 | for (u32 line = 0; line < subrect_height; ++line) { | 274 | for (u32 line = 0; line < subrect_height; ++line) { |
| 277 | const u32 y2 = line + offset_y; | 275 | const u32 y2 = line + offset_y; |
| 278 | const u32 gob_address_y = (y2 / (gob_size_y * block_height)) * gob_size * block_height + | 276 | const u32 gob_address_y = (y2 / (gob_size_y * block_height)) * gob_size * block_height + |
| @@ -282,10 +280,10 @@ void UnswizzleSubrect(u32 subrect_width, u32 subrect_height, u32 dest_pitch, u32 | |||
| 282 | const u32 x2 = (x + offset_x) * bytes_per_pixel; | 280 | const u32 x2 = (x + offset_x) * bytes_per_pixel; |
| 283 | const u32 gob_address = gob_address_y + (x2 / gob_size_x) * gob_size * block_height; | 281 | const u32 gob_address = gob_address_y + (x2 / gob_size_x) * gob_size * block_height; |
| 284 | const u32 swizzled_offset = gob_address + table[x2 % gob_size_x]; | 282 | const u32 swizzled_offset = gob_address + table[x2 % gob_size_x]; |
| 285 | const VAddr dest_line = unswizzled_data + line * dest_pitch + x * bytes_per_pixel; | 283 | u8* dest_line = unswizzled_data + line * dest_pitch + x * bytes_per_pixel; |
| 286 | const VAddr source_addr = swizzled_data + swizzled_offset; | 284 | u8* source_addr = swizzled_data + swizzled_offset; |
| 287 | 285 | ||
| 288 | Memory::CopyBlock(dest_line, source_addr, bytes_per_pixel); | 286 | std::memcpy(dest_line, source_addr, bytes_per_pixel); |
| 289 | } | 287 | } |
| 290 | } | 288 | } |
| 291 | } | 289 | } |
diff --git a/src/video_core/textures/decoders.h b/src/video_core/textures/decoders.h index 65df86890..e078fa274 100644 --- a/src/video_core/textures/decoders.h +++ b/src/video_core/textures/decoders.h | |||
| @@ -17,14 +17,14 @@ inline std::size_t GetGOBSize() { | |||
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | /// Unswizzles a swizzled texture without changing its format. | 19 | /// Unswizzles a swizzled texture without changing its format. |
| 20 | void UnswizzleTexture(u8* unswizzled_data, VAddr address, u32 tile_size_x, u32 tile_size_y, | 20 | void UnswizzleTexture(u8* unswizzled_data, u8* address, u32 tile_size_x, u32 tile_size_y, |
| 21 | u32 bytes_per_pixel, u32 width, u32 height, u32 depth, | 21 | u32 bytes_per_pixel, u32 width, u32 height, u32 depth, |
| 22 | u32 block_height = TICEntry::DefaultBlockHeight, | 22 | u32 block_height = TICEntry::DefaultBlockHeight, |
| 23 | u32 block_depth = TICEntry::DefaultBlockHeight, u32 width_spacing = 0); | 23 | u32 block_depth = TICEntry::DefaultBlockHeight, u32 width_spacing = 0); |
| 24 | 24 | ||
| 25 | /// Unswizzles a swizzled texture without changing its format. | 25 | /// Unswizzles a swizzled texture without changing its format. |
| 26 | std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size_x, u32 tile_size_y, | 26 | std::vector<u8> UnswizzleTexture(u8* address, u32 tile_size_x, u32 tile_size_y, u32 bytes_per_pixel, |
| 27 | u32 bytes_per_pixel, u32 width, u32 height, u32 depth, | 27 | u32 width, u32 height, u32 depth, |
| 28 | u32 block_height = TICEntry::DefaultBlockHeight, | 28 | u32 block_height = TICEntry::DefaultBlockHeight, |
| 29 | u32 block_depth = TICEntry::DefaultBlockHeight, | 29 | u32 block_depth = TICEntry::DefaultBlockHeight, |
| 30 | u32 width_spacing = 0); | 30 | u32 width_spacing = 0); |
| @@ -44,12 +44,11 @@ std::size_t CalculateSize(bool tiled, u32 bytes_per_pixel, u32 width, u32 height | |||
| 44 | 44 | ||
| 45 | /// Copies an untiled subrectangle into a tiled surface. | 45 | /// Copies an untiled subrectangle into a tiled surface. |
| 46 | void SwizzleSubrect(u32 subrect_width, u32 subrect_height, u32 source_pitch, u32 swizzled_width, | 46 | void SwizzleSubrect(u32 subrect_width, u32 subrect_height, u32 source_pitch, u32 swizzled_width, |
| 47 | u32 bytes_per_pixel, VAddr swizzled_data, VAddr unswizzled_data, | 47 | u32 bytes_per_pixel, u8* swizzled_data, u8* unswizzled_data, u32 block_height); |
| 48 | u32 block_height); | ||
| 49 | 48 | ||
| 50 | /// Copies a tiled subrectangle into a linear surface. | 49 | /// Copies a tiled subrectangle into a linear surface. |
| 51 | void UnswizzleSubrect(u32 subrect_width, u32 subrect_height, u32 dest_pitch, u32 swizzled_width, | 50 | void UnswizzleSubrect(u32 subrect_width, u32 subrect_height, u32 dest_pitch, u32 swizzled_width, |
| 52 | u32 bytes_per_pixel, VAddr swizzled_data, VAddr unswizzled_data, | 51 | u32 bytes_per_pixel, u8* swizzled_data, u8* unswizzled_data, u32 block_height, |
| 53 | u32 block_height, u32 offset_x, u32 offset_y); | 52 | u32 offset_x, u32 offset_y); |
| 54 | 53 | ||
| 55 | } // namespace Tegra::Texture | 54 | } // namespace Tegra::Texture |