diff options
author | bunnei <bunneidev@gmail.com> | 2018-07-18 18:55:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-18 18:55:37 -0700 |
commit | 89f0acfd36223976afd60fca5f30881fe0ecca7f (patch) | |
tree | 0a38b48388fd9f74256787178062f4551aafa562 /src | |
parent | d883d3b64f145cf6f2d047f43f7e256f66f4c433 (diff) | |
parent | b496a9eefe57f1b7a261546c8149f250288b9698 (diff) |
Merge pull request #680 from bunnei/fix-swizz
decoders: Fix calc of swizzle image_width_in_gobs.
Diffstat (limited to 'src')
-rw-r--r-- | src/video_core/textures/decoders.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index be18aa299..a3684a195 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <cmath> #include <cstring> #include "common/assert.h" #include "core/memory.h" @@ -17,7 +18,9 @@ namespace Texture { * Taken from the Tegra X1 TRM. */ static u32 GetSwizzleOffset(u32 x, u32 y, u32 image_width, u32 bytes_per_pixel, u32 block_height) { - u32 image_width_in_gobs = image_width * bytes_per_pixel / 64; + // Round up to the next gob + const u32 image_width_in_gobs{(image_width * bytes_per_pixel + 63) / 64}; + u32 GOB_address = 0 + (y / (8 * block_height)) * 512 * block_height * image_width_in_gobs + (x * bytes_per_pixel / 64) * 512 * block_height + (y % (8 * block_height) / 8) * 512; |