Skip to content

Commit

Permalink
Merge pull request #887 from daleglass/fix-ati-auto-vram
Browse files Browse the repository at this point in the history
Fix getting the free VRAM on ATI cards
  • Loading branch information
two-one-five authored Nov 28, 2020
2 parents 4e1b683 + 182302c commit 0157d5f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,19 +219,21 @@ void GLBackend::init() {
}

size_t GLBackend::getAvailableMemory() {
GLint mem;
// GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX returns 1 value
// GL_TEXTURE_FREE_MEMORY_ATI returns 4 values, we only need the first
GLint mem[4] = {0,0,0,0};

switch( _videoCard ) {
case NVIDIA:
#if !defined(Q_OS_ANDROID)
glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &mem);
glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &mem[0]);
#endif
return mem * BYTES_PER_KIB;
return mem[0] * BYTES_PER_KIB;
case ATI:
#if !defined(Q_OS_ANDROID)
glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, &mem);
glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, &mem[0]);
#endif
return mem * BYTES_PER_KIB;
return mem[0] * BYTES_PER_KIB;
case MESA:
return 0; // Don't know the current value
case Unknown:
Expand Down Expand Up @@ -1002,4 +1004,4 @@ void GLBackend::setCameraCorrection(const Mat4& correction, const Mat4& prevRend

void GLBackend::syncProgram(const gpu::ShaderPointer& program) {
gpu::gl::GLShader::sync(*this, *program);
}
}

0 comments on commit 0157d5f

Please sign in to comment.