summaryrefslogtreecommitdiffstats
path: root/src/video_core/textures/decoders.cpp
diff options
context:
space:
mode:
authorFernandoS27 <fsahmkow27@gmail.com>2018-10-12 20:21:53 +0200
committerFernandoS27 <fsahmkow27@gmail.com>2018-10-12 20:21:53 +0200
commit97b6405a17276b7497788ef924466cc24bda9f8e (patch)
treefdf1b513a12733e4093afa987b9ba62b7b28191c /src/video_core/textures/decoders.cpp
parentMerge pull request #1467 from ogniK5377/svcbreak-type-fix (diff)
downloadyuzu-97b6405a17276b7497788ef924466cc24bda9f8e.tar
yuzu-97b6405a17276b7497788ef924466cc24bda9f8e.tar.gz
yuzu-97b6405a17276b7497788ef924466cc24bda9f8e.tar.bz2
yuzu-97b6405a17276b7497788ef924466cc24bda9f8e.tar.lz
yuzu-97b6405a17276b7497788ef924466cc24bda9f8e.tar.xz
yuzu-97b6405a17276b7497788ef924466cc24bda9f8e.tar.zst
yuzu-97b6405a17276b7497788ef924466cc24bda9f8e.zip
Diffstat (limited to 'src/video_core/textures/decoders.cpp')
-rw-r--r--src/video_core/textures/decoders.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp
index 3d5476e5d..0d2456b56 100644
--- a/src/video_core/textures/decoders.cpp
+++ b/src/video_core/textures/decoders.cpp
@@ -4,6 +4,7 @@
#include <cmath>
#include <cstring>
+#include "common/alignment.h"
#include "common/assert.h"
#include "core/memory.h"
#include "video_core/gpu.h"
@@ -199,4 +200,19 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat
return rgba_data;
}
+std::size_t CalculateSize(bool tiled, u32 bytes_per_pixel, u32 width, u32 height, u32 depth,
+ u32 block_height, u32 block_depth) {
+ if (tiled) {
+ const u32 gobs_in_x = 64 / bytes_per_pixel;
+ const u32 gobs_in_y = 8;
+ const u32 gobs_in_z = 1;
+ const u32 aligned_width = Common::AlignUp(width, gobs_in_x);
+ const u32 aligned_height = Common::AlignUp(height, gobs_in_y * block_height);
+ const u32 aligned_depth = Common::AlignUp(depth, gobs_in_z * block_depth);
+ return aligned_width * aligned_height * aligned_depth * bytes_per_pixel;
+ } else {
+ return width * height * depth * bytes_per_pixel;
+ }
+}
+
} // namespace Tegra::Texture