From b42170c7b651695f9d4fecf67a5707010c07b006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Gro=C3=9F?= Date: Sun, 10 Oct 2021 15:01:35 +0200 Subject: [PATCH] Disable automatic texture memory on unsupported platforms. Fix automatic texture memory fallback. --- .../gpu-gl-common/src/gpu/gl/GLBackend.cpp | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp index dd30727523..b907021399 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp @@ -151,13 +151,21 @@ void GLBackend::init() { GPUIdent* gpu = GPUIdent::getInstance(vendor, renderer); unsigned int mem; +// Do not try to get texture memory information on unsupported systems. +#if defined(Q_OS_ANDROID) || defined(USE_GLES) || defined(Q_OS_DARWIN) + qCDebug(gpugllogging) << "Automatic texture memory not supported in this configuration"; + _videoCard = Unknown; + _dedicatedMemory = gpu->getMemory() * BYTES_PER_MIB; + _totalMemory = _dedicatedMemory; +#endif + +#if !defined(Q_OS_ANDROID) && !defined(USE_GLES) && !defined(Q_OS_DARWIN) if (vendor.contains("NVIDIA") ) { qCDebug(gpugllogging) << "NVIDIA card detected"; -#if !defined(Q_OS_ANDROID) && !defined(USE_GLES) + GL_GET_INTEGER(GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX); GL_GET_INTEGER(GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX); GL_GET_INTEGER(GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX); -#endif qCDebug(gpugllogging) << "GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX: " << GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX; qCDebug(gpugllogging) << "GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX: " << GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX; @@ -170,10 +178,10 @@ void GLBackend::init() { } else if (vendor.contains("ATI")) { qCDebug(gpugllogging) << "ATI card detected"; -#if !defined(Q_OS_ANDROID) && !defined(USE_GLES) - GL_GET_INTEGER(TEXTURE_FREE_MEMORY_ATI); -#endif + GL_GET_INTEGER(TEXTURE_FREE_MEMORY_ATI); + + // We are actually getting free memory instead of total memory _totalMemory = TEXTURE_FREE_MEMORY_ATI * BYTES_PER_KIB; _dedicatedMemory = _totalMemory; _videoCard = ATI; @@ -187,9 +195,10 @@ void GLBackend::init() { } else { qCCritical(gpugllogging) << "Don't know how to get memory for OpenGL vendor " << vendor << "; renderer " << renderer << ", trying fallback"; _videoCard = Unknown; - _dedicatedMemory = gpu->getMemory(); + _dedicatedMemory = gpu->getMemory() * BYTES_PER_MIB; _totalMemory = _dedicatedMemory; } +#endif qCDebug(gpugllogging) << "dedicated: " << _dedicatedMemory; qCDebug(gpugllogging) << "total: " << _totalMemory;