From 50233f6ffb4ef0ba4cf5ffdd7bc75103bc93dd8a Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Thu, 15 Sep 2016 14:29:02 -0700 Subject: [PATCH] Don't re-report texture memory usage until the returned value changes --- libraries/gpu-gl/src/gpu/gl/GLTexture.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp b/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp index fc50c69538..3a45f55646 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp @@ -93,6 +93,7 @@ const std::vector& GLTexture::getFaceTargets(GLenum target) { } #define MIN_FREE_GPU_MEMORY_PERCENTAGE 0.25f + float GLTexture::getMemoryPressure() { // Check for an explicit memory limit auto availableTextureMemory = Texture::getAllowedGPUMemoryUsage(); @@ -107,8 +108,10 @@ float GLTexture::getMemoryPressure() { } else { // Check the global free GPU memory auto freeGpuMemory = getFreeDedicatedMemory(); - if (freeGpuMemory) { - auto freePercentage = (float)freeGpuMemory / (float)totalGpuMemory; + static gpu::Size lastFreeGpuMemory = 0; + auto freePercentage = (float)freeGpuMemory / (float)totalGpuMemory; + if (freeGpuMemory != lastFreeGpuMemory) { + lastFreeGpuMemory = freeGpuMemory; if (freePercentage < MIN_FREE_GPU_MEMORY_PERCENTAGE) { qDebug() << "Exceeded max GPU memory"; return 2.0;