From 2ebba56758cfafe9b6d92f91e6aa175cfed379c0 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 1 Apr 2017 20:36:05 +0200 Subject: [PATCH] Fix crash in LocoRoco with D3D11 when hitting a spiky (a broken texture gets created with too many mipmaps for its size) --- GPU/D3D11/TextureCacheD3D11.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/GPU/D3D11/TextureCacheD3D11.cpp b/GPU/D3D11/TextureCacheD3D11.cpp index ac3643e99e..248d6abb96 100644 --- a/GPU/D3D11/TextureCacheD3D11.cpp +++ b/GPU/D3D11/TextureCacheD3D11.cpp @@ -474,9 +474,15 @@ void TextureCacheD3D11::BuildTexture(TexCacheEntry *const entry, bool replaceIma break; } + // If size reaches 1, stop, and override maxlevel. + int tw = gstate.getTextureWidth(i); + int th = gstate.getTextureHeight(i); + if (tw == 1 || th == 1) { + maxLevel = i; + break; + } + if (i > 0 && gstate_c.Supports(GPU_SUPPORTS_TEXTURE_LOD_CONTROL)) { - int tw = gstate.getTextureWidth(i); - int th = gstate.getTextureHeight(i); if (tw != 1 && tw != (gstate.getTextureWidth(i - 1) >> 1)) badMipSizes = true; else if (th != 1 && th != (gstate.getTextureHeight(i - 1) >> 1))