From 8c632ca0adcd085c2888bc77479ae0ece7316441 Mon Sep 17 00:00:00 2001 From: Logan McNaughton Date: Mon, 6 Jun 2016 22:58:09 -0600 Subject: [PATCH] Fix Texture Cache on Raspberry Pi The Raspberry Pi only supports 32768 GPU memory allocations see https://github.com/raspberrypi/firmware/issues/611 Each texture takes 2 allocs, so the max is around 16000, I've set it to 15000 to be safe --- src/Textures.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Textures.cpp b/src/Textures.cpp index 5af07062..5ed969ff 100644 --- a/src/Textures.cpp +++ b/src/Textures.cpp @@ -522,6 +522,16 @@ void TextureCache::destroy() void TextureCache::_checkCacheSize() { +#ifdef VC + if (m_textures.size() > 15000) { + CachedTexture& piTex = m_textures.back(); + m_cachedBytes -= piTex.textureBytes; + glDeleteTextures(1, &piTex.glName); + m_lruTextureLocations.erase(piTex.crc); + m_textures.pop_back(); + } +#endif + if (m_cachedBytes <= m_maxBytes) return;