Skip to content

Commit 113223c

Browse files
authored
Merge pull request vircadia#1475 from ksuprynowicz/auto_texture_fix
Fix automatic texture memory bug.
2 parents 92af537 + 65576ba commit 113223c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void GLBackend::init() {
155155
#if defined(Q_OS_ANDROID) || defined(USE_GLES) || defined(Q_OS_DARWIN)
156156
qCDebug(gpugllogging) << "Automatic texture memory not supported in this configuration";
157157
_videoCard = Unknown;
158-
_dedicatedMemory = gpu->getMemory() * BYTES_PER_MIB;
158+
_dedicatedMemory = (size_t)(gpu->getMemory()) * BYTES_PER_MIB;
159159
_totalMemory = _dedicatedMemory;
160160
#endif
161161

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

174-
_totalMemory = GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX * BYTES_PER_KIB;
175-
_dedicatedMemory = GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX * BYTES_PER_KIB;
174+
_totalMemory = (size_t)(GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX) * BYTES_PER_KIB;
175+
_dedicatedMemory = (size_t)(GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX) * BYTES_PER_KIB;
176176
_videoCard = NVIDIA;
177177

178178

@@ -182,20 +182,20 @@ void GLBackend::init() {
182182
GL_GET_INTEGER(TEXTURE_FREE_MEMORY_ATI);
183183

184184
// We are actually getting free memory instead of total memory
185-
_totalMemory = TEXTURE_FREE_MEMORY_ATI * BYTES_PER_KIB;
185+
_totalMemory = (size_t)(TEXTURE_FREE_MEMORY_ATI) * BYTES_PER_KIB;
186186
_dedicatedMemory = _totalMemory;
187187
_videoCard = ATI;
188188
} else if ( ::gl::queryCurrentRendererIntegerMESA(GLX_RENDERER_VIDEO_MEMORY_MESA, &mem) ) {
189189
// This works only on Linux. queryCurrentRendererIntegerMESA will return false if the
190190
// function is not supported because we're not on Linux, or for any other reason.
191191
qCDebug(gpugllogging) << "MESA card detected";
192-
_totalMemory = mem * BYTES_PER_MIB;
192+
_totalMemory = (size_t)(mem) * BYTES_PER_MIB;
193193
_dedicatedMemory = _totalMemory;
194194
_videoCard = MESA;
195195
} else {
196196
qCCritical(gpugllogging) << "Don't know how to get memory for OpenGL vendor " << vendor << "; renderer " << renderer << ", trying fallback";
197197
_videoCard = Unknown;
198-
_dedicatedMemory = gpu->getMemory() * BYTES_PER_MIB;
198+
_dedicatedMemory = (size_t)(gpu->getMemory()) * BYTES_PER_MIB;
199199
_totalMemory = _dedicatedMemory;
200200
}
201201
#endif
@@ -237,12 +237,12 @@ size_t GLBackend::getAvailableMemory() {
237237
#if !defined(Q_OS_ANDROID) && !defined(USE_GLES)
238238
glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &mem[0]);
239239
#endif
240-
return mem[0] * BYTES_PER_KIB;
240+
return (size_t)(mem[0]) * BYTES_PER_KIB;
241241
case ATI:
242242
#if !defined(Q_OS_ANDROID) && !defined(USE_GLES)
243243
glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, &mem[0]);
244244
#endif
245-
return mem[0] * BYTES_PER_KIB;
245+
return (size_t)(mem[0]) * BYTES_PER_KIB;
246246
case MESA:
247247
return 0; // Don't know the current value
248248
case Unknown:

0 commit comments

Comments
 (0)