From f8059eae430cb8f39a0b49a1c1144de99fdc7947 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 27 Nov 2016 18:13:54 +1000 Subject: [PATCH] OGL: Fix render-target texture mipmap allocation The loop was allocating one-too-many levels, as well as incorrect sizes for each level. Probably not an issue as mipmapped render targets aren't used, but the logic should be correct anyway. --- Source/Core/VideoBackends/OGL/TextureCache.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Core/VideoBackends/OGL/TextureCache.cpp b/Source/Core/VideoBackends/OGL/TextureCache.cpp index 2cf0623939..3226dfdefa 100644 --- a/Source/Core/VideoBackends/OGL/TextureCache.cpp +++ b/Source/Core/VideoBackends/OGL/TextureCache.cpp @@ -121,10 +121,11 @@ TextureCache::TCacheEntryBase* TextureCache::CreateTexture(const TCacheEntryConf if (config.rendertarget) { - for (u32 level = 0; level <= config.levels; level++) + for (u32 level = 0; level < config.levels; level++) { - glTexImage3D(GL_TEXTURE_2D_ARRAY, level, GL_RGBA, config.width, config.height, config.layers, - 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); + glTexImage3D(GL_TEXTURE_2D_ARRAY, level, GL_RGBA, std::max(config.width >> level, 1u), + std::max(config.height >> level, 1u), config.layers, 0, GL_RGBA, + GL_UNSIGNED_BYTE, nullptr); } glGenFramebuffers(1, &entry->framebuffer); FramebufferManager::SetFramebuffer(entry->framebuffer);