From 544b15e8e415d56b415189717805a88b2e5dc06f Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Mon, 22 Jun 2020 11:29:55 -0400 Subject: [PATCH] TextureCache: Fix case where layer goes off bound. The returned layer is expected to be between 0 and the depth of the surface, anything larger is off bounds. --- src/video_core/texture_cache/surface_base.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/video_core/texture_cache/surface_base.cpp b/src/video_core/texture_cache/surface_base.cpp index 94d3a6ae53..0caf3b4f05 100644 --- a/src/video_core/texture_cache/surface_base.cpp +++ b/src/video_core/texture_cache/surface_base.cpp @@ -120,6 +120,9 @@ std::optional> SurfaceBaseImpl::GetLayerMipmap( } const auto relative_address{static_cast(candidate_gpu_addr - gpu_addr)}; const auto layer{static_cast(relative_address / layer_size)}; + if (layer >= params.depth) { + return {}; + } const GPUVAddr mipmap_address = relative_address - layer_size * layer; const auto mipmap_it = Common::BinaryFind(mipmap_offsets.begin(), mipmap_offsets.end(), mipmap_address);