diff options
| author | 2018-11-25 00:12:09 -0300 | |
|---|---|---|
| committer | 2018-11-25 00:38:53 -0300 | |
| commit | 7ff2131cf99f470d0c52520e5fd7bfde2a91c0a5 (patch) | |
| tree | 438fc05a7a5b278087dba2b9855dfd4a2f5a784b /src | |
| parent | video_core: Move morton functions to their own file (diff) | |
| download | yuzu-7ff2131cf99f470d0c52520e5fd7bfde2a91c0a5.tar.gz yuzu-7ff2131cf99f470d0c52520e5fd7bfde2a91c0a5.tar.xz yuzu-7ff2131cf99f470d0c52520e5fd7bfde2a91c0a5.zip | |
morton: Style changes
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/morton.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/video_core/morton.cpp b/src/video_core/morton.cpp index 3dd0e4754..f14abba7d 100644 --- a/src/video_core/morton.cpp +++ b/src/video_core/morton.cpp | |||
| @@ -29,7 +29,7 @@ static void MortonCopy(u32 stride, u32 block_height, u32 height, u32 block_depth | |||
| 29 | const u32 tile_size_x{GetDefaultBlockWidth(format)}; | 29 | const u32 tile_size_x{GetDefaultBlockWidth(format)}; |
| 30 | const u32 tile_size_y{GetDefaultBlockHeight(format)}; | 30 | const u32 tile_size_y{GetDefaultBlockHeight(format)}; |
| 31 | 31 | ||
| 32 | if (morton_to_linear) { | 32 | if constexpr (morton_to_linear) { |
| 33 | Tegra::Texture::UnswizzleTexture(buffer, addr, tile_size_x, tile_size_y, bytes_per_pixel, | 33 | Tegra::Texture::UnswizzleTexture(buffer, addr, tile_size_x, tile_size_y, bytes_per_pixel, |
| 34 | stride, height, depth, block_height, block_depth); | 34 | stride, height, depth, block_height, block_depth); |
| 35 | } else { | 35 | } else { |
| @@ -314,12 +314,12 @@ static u32 GetMortonOffset128(u32 x, u32 y, u32 bytes_per_pixel) { | |||
| 314 | // Calculates the offset of the position of the pixel in Morton order | 314 | // Calculates the offset of the position of the pixel in Morton order |
| 315 | // Framebuffer images are split into 128x128 tiles. | 315 | // Framebuffer images are split into 128x128 tiles. |
| 316 | 316 | ||
| 317 | const unsigned int block_height = 128; | 317 | constexpr u32 block_height = 128; |
| 318 | const unsigned int coarse_x = x & ~127; | 318 | const u32 coarse_x = x & ~127; |
| 319 | 319 | ||
| 320 | u32 i = MortonInterleave128(x, y); | 320 | const u32 i = MortonInterleave128(x, y); |
| 321 | 321 | ||
| 322 | const unsigned int offset = coarse_x * block_height; | 322 | const u32 offset = coarse_x * block_height; |
| 323 | 323 | ||
| 324 | return (i + offset) * bytes_per_pixel; | 324 | return (i + offset) * bytes_per_pixel; |
| 325 | } | 325 | } |
| @@ -335,17 +335,17 @@ void MortonSwizzle(MortonSwizzleMode mode, Surface::PixelFormat format, u32 stri | |||
| 335 | void MortonCopyPixels128(u32 width, u32 height, u32 bytes_per_pixel, u32 linear_bytes_per_pixel, | 335 | void MortonCopyPixels128(u32 width, u32 height, u32 bytes_per_pixel, u32 linear_bytes_per_pixel, |
| 336 | u8* morton_data, u8* linear_data, bool morton_to_linear) { | 336 | u8* morton_data, u8* linear_data, bool morton_to_linear) { |
| 337 | u8* data_ptrs[2]; | 337 | u8* data_ptrs[2]; |
| 338 | for (unsigned y = 0; y < height; ++y) { | 338 | for (u32 y = 0; y < height; ++y) { |
| 339 | for (unsigned x = 0; x < width; ++x) { | 339 | for (u32 x = 0; x < width; ++x) { |
| 340 | const u32 coarse_y = y & ~127; | 340 | const u32 coarse_y = y & ~127; |
| 341 | u32 morton_offset = | 341 | const u32 morton_offset = |
| 342 | GetMortonOffset128(x, y, bytes_per_pixel) + coarse_y * width * bytes_per_pixel; | 342 | GetMortonOffset128(x, y, bytes_per_pixel) + coarse_y * width * bytes_per_pixel; |
| 343 | u32 gl_pixel_index = (x + y * width) * linear_bytes_per_pixel; | 343 | const u32 linear_pixel_index = (x + y * width) * linear_bytes_per_pixel; |
| 344 | 344 | ||
| 345 | data_ptrs[morton_to_linear] = morton_data + morton_offset; | 345 | data_ptrs[morton_to_linear ? 1 : 0] = morton_data + morton_offset; |
| 346 | data_ptrs[!morton_to_linear] = &linear_data[gl_pixel_index]; | 346 | data_ptrs[morton_to_linear ? 0 : 1] = &linear_data[linear_pixel_index]; |
| 347 | 347 | ||
| 348 | memcpy(data_ptrs[0], data_ptrs[1], bytes_per_pixel); | 348 | std::memcpy(data_ptrs[0], data_ptrs[1], bytes_per_pixel); |
| 349 | } | 349 | } |
| 350 | } | 350 | } |
| 351 | } | 351 | } |