summaryrefslogtreecommitdiff
path: root/src/video_core/texture_cache
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2019-05-10 22:12:35 -0400
committerGravatar ReinUsesLisp2019-06-20 21:36:12 -0300
commit94f2be5473182789ec3f6388b43fcd708a505500 (patch)
tree449c07c6f2ca05db69b720543bac5124e6ba7940 /src/video_core/texture_cache
parenttexture_cache: Implement L1_Inner_cache (diff)
downloadyuzu-94f2be5473182789ec3f6388b43fcd708a505500.tar.gz
yuzu-94f2be5473182789ec3f6388b43fcd708a505500.tar.xz
yuzu-94f2be5473182789ec3f6388b43fcd708a505500.zip
texture_cache: Optimize GetMipBlockHeight and GetMipBlockDepth
Diffstat (limited to 'src/video_core/texture_cache')
-rw-r--r--src/video_core/texture_cache/surface_params.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/video_core/texture_cache/surface_params.cpp b/src/video_core/texture_cache/surface_params.cpp
index 3a47f404d..e7e671d8c 100644
--- a/src/video_core/texture_cache/surface_params.cpp
+++ b/src/video_core/texture_cache/surface_params.cpp
@@ -5,6 +5,7 @@
5#include <map> 5#include <map>
6 6
7#include "common/alignment.h" 7#include "common/alignment.h"
8#include "common/bit_util.h"
8#include "common/cityhash.h" 9#include "common/cityhash.h"
9#include "core/core.h" 10#include "core/core.h"
10#include "video_core/engines/shader_bytecode.h" 11#include "video_core/engines/shader_bytecode.h"
@@ -190,11 +191,8 @@ u32 SurfaceParams::GetMipBlockHeight(u32 level) const {
190 const u32 height{GetMipHeight(level)}; 191 const u32 height{GetMipHeight(level)};
191 const u32 default_block_height{GetDefaultBlockHeight()}; 192 const u32 default_block_height{GetDefaultBlockHeight()};
192 const u32 blocks_in_y{(height + default_block_height - 1) / default_block_height}; 193 const u32 blocks_in_y{(height + default_block_height - 1) / default_block_height};
193 u32 block_height = 4; 194 const u32 block_height = Common::Log2Ceil32(blocks_in_y);
194 while (block_height > 0 && blocks_in_y <= (1U << block_height) * 4) { 195 return std::clamp(block_height, 3U, 8U) - 3U;
195 --block_height;
196 }
197 return block_height;
198} 196}
199 197
200u32 SurfaceParams::GetMipBlockDepth(u32 level) const { 198u32 SurfaceParams::GetMipBlockDepth(u32 level) const {
@@ -206,15 +204,10 @@ u32 SurfaceParams::GetMipBlockDepth(u32 level) const {
206 } 204 }
207 205
208 const u32 depth{GetMipDepth(level)}; 206 const u32 depth{GetMipDepth(level)};
209 u32 block_depth = 5; 207 const u32 block_depth = Common::Log2Ceil32(depth);
210 while (block_depth > 0 && depth * 2 <= (1U << block_depth)) { 208 if (block_depth > 4) {
211 --block_depth; 209 return 5 - (GetMipBlockHeight(level) >= 2);
212 }
213
214 if (block_depth == 5 && GetMipBlockHeight(level) >= 2) {
215 return 4;
216 } 210 }
217
218 return block_depth; 211 return block_depth;
219} 212}
220 213