From 1e7dd7db6408fa9f2020f239e9ea28ebd8022334 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Mon, 10 Oct 2016 12:57:58 -0700 Subject: [PATCH] Fix GPU texture counter, better logging for memory pressure --- libraries/gpu-gl/src/gpu/gl/GLBackend.cpp | 1 - libraries/gpu-gl/src/gpu/gl/GLTexture.cpp | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libraries/gpu-gl/src/gpu/gl/GLBackend.cpp b/libraries/gpu-gl/src/gpu/gl/GLBackend.cpp index c082c00609..3c34765011 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLBackend.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLBackend.cpp @@ -666,7 +666,6 @@ void GLBackend::recycle() const { for (auto pair : externalTexturesTrash) { auto fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); pair.second(pair.first, fence); - decrementTextureGPUCount(); } } diff --git a/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp b/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp index 649065ab84..25c92b513a 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp @@ -115,7 +115,7 @@ float GLTexture::getMemoryPressure() { if (freeGpuMemory != lastFreeGpuMemory) { lastFreeGpuMemory = freeGpuMemory; if (freePercentage < MIN_FREE_GPU_MEMORY_PERCENTAGE) { - qDebug() << "Exceeded max GPU memory"; + qCDebug(gpugllogging) << "Exceeded min free GPU memory " << freePercentage; return OVER_MEMORY_PRESSURE; } } @@ -129,7 +129,13 @@ float GLTexture::getMemoryPressure() { // Return the consumed texture memory divided by the available texture memory. auto consumedGpuMemory = Context::getTextureGPUMemoryUsage(); - return (float)consumedGpuMemory / (float)availableTextureMemory; + float memoryPressure = (float)consumedGpuMemory / (float)availableTextureMemory; + static Context::Size lastConsumedGpuMemory = 0; + if (memoryPressure > 1.0f && lastConsumedGpuMemory != consumedGpuMemory) { + lastConsumedGpuMemory = consumedGpuMemory; + qCDebug(gpugllogging) << "Exceeded max allowed texture memory: " << consumedGpuMemory << " / " << availableTextureMemory; + } + return memoryPressure; }