diff options
author | Lioncash <mathew1800@gmail.com> | 2020-09-22 23:31:53 +0200 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2020-09-22 23:32:33 +0200 |
commit | ff45c3957858cdf189b73e11550da06fe4337b8e (patch) | |
tree | 288ff1cc4677d6511ed8cc7e1b0db20ce2d2590f /src/video_core/texture_cache | |
parent | Merge pull request #4697 from lioncash/copy5 (diff) | |
download | yuzu-ff45c3957858cdf189b73e11550da06fe4337b8e.tar yuzu-ff45c3957858cdf189b73e11550da06fe4337b8e.tar.gz yuzu-ff45c3957858cdf189b73e11550da06fe4337b8e.tar.bz2 yuzu-ff45c3957858cdf189b73e11550da06fe4337b8e.tar.lz yuzu-ff45c3957858cdf189b73e11550da06fe4337b8e.tar.xz yuzu-ff45c3957858cdf189b73e11550da06fe4337b8e.tar.zst yuzu-ff45c3957858cdf189b73e11550da06fe4337b8e.zip |
Diffstat (limited to 'src/video_core/texture_cache')
-rw-r--r-- | src/video_core/texture_cache/surface_base.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/video_core/texture_cache/surface_base.cpp b/src/video_core/texture_cache/surface_base.cpp index dfcf36e0b..b44c09d71 100644 --- a/src/video_core/texture_cache/surface_base.cpp +++ b/src/video_core/texture_cache/surface_base.cpp @@ -115,20 +115,24 @@ std::optional<std::pair<u32, u32>> SurfaceBaseImpl::GetLayerMipmap( if (gpu_addr == candidate_gpu_addr) { return {{0, 0}}; } + if (candidate_gpu_addr < gpu_addr) { - return {}; + return std::nullopt; } + const auto relative_address{static_cast<GPUVAddr>(candidate_gpu_addr - gpu_addr)}; const auto layer{static_cast<u32>(relative_address / layer_size)}; if (layer >= params.depth) { - return {}; + return std::nullopt; } + const GPUVAddr mipmap_address = relative_address - layer_size * layer; const auto mipmap_it = Common::BinaryFind(mipmap_offsets.begin(), mipmap_offsets.end(), mipmap_address); if (mipmap_it == mipmap_offsets.end()) { - return {}; + return std::nullopt; } + const auto level{static_cast<u32>(std::distance(mipmap_offsets.begin(), mipmap_it))}; return std::make_pair(layer, level); } |