Skip to content

Commit

Permalink
Merge pull request #1475 from ksuprynowicz/auto_texture_fix
Browse files Browse the repository at this point in the history
Fix automatic texture memory bug.
  • Loading branch information
daleglass authored Nov 25, 2021
2 parents 92af537 + 65576ba commit 113223c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void GLBackend::init() {
#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;
_dedicatedMemory = (size_t)(gpu->getMemory()) * BYTES_PER_MIB;
_totalMemory = _dedicatedMemory;
#endif

Expand All @@ -171,8 +171,8 @@ void GLBackend::init() {
qCDebug(gpugllogging) << "GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX: " << GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX;
qCDebug(gpugllogging) << "GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX: " << GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX;

_totalMemory = GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX * BYTES_PER_KIB;
_dedicatedMemory = GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX * BYTES_PER_KIB;
_totalMemory = (size_t)(GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX) * BYTES_PER_KIB;
_dedicatedMemory = (size_t)(GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX) * BYTES_PER_KIB;
_videoCard = NVIDIA;


Expand All @@ -182,20 +182,20 @@ void GLBackend::init() {
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;
_totalMemory = (size_t)(TEXTURE_FREE_MEMORY_ATI) * BYTES_PER_KIB;
_dedicatedMemory = _totalMemory;
_videoCard = ATI;
} else if ( ::gl::queryCurrentRendererIntegerMESA(GLX_RENDERER_VIDEO_MEMORY_MESA, &mem) ) {
// This works only on Linux. queryCurrentRendererIntegerMESA will return false if the
// function is not supported because we're not on Linux, or for any other reason.
qCDebug(gpugllogging) << "MESA card detected";
_totalMemory = mem * BYTES_PER_MIB;
_totalMemory = (size_t)(mem) * BYTES_PER_MIB;
_dedicatedMemory = _totalMemory;
_videoCard = MESA;
} else {
qCCritical(gpugllogging) << "Don't know how to get memory for OpenGL vendor " << vendor << "; renderer " << renderer << ", trying fallback";
_videoCard = Unknown;
_dedicatedMemory = gpu->getMemory() * BYTES_PER_MIB;
_dedicatedMemory = (size_t)(gpu->getMemory()) * BYTES_PER_MIB;
_totalMemory = _dedicatedMemory;
}
#endif
Expand Down Expand Up @@ -237,12 +237,12 @@ size_t GLBackend::getAvailableMemory() {
#if !defined(Q_OS_ANDROID) && !defined(USE_GLES)
glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &mem[0]);
#endif
return mem[0] * BYTES_PER_KIB;
return (size_t)(mem[0]) * BYTES_PER_KIB;
case ATI:
#if !defined(Q_OS_ANDROID) && !defined(USE_GLES)
glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, &mem[0]);
#endif
return mem[0] * BYTES_PER_KIB;
return (size_t)(mem[0]) * BYTES_PER_KIB;
case MESA:
return 0; // Don't know the current value
case Unknown:
Expand Down

0 comments on commit 113223c

Please sign in to comment.