diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-09-07 20:53:48 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-09-07 21:17:45 +0300 |
commit | 58353834f441b8b4ca91dcd4ec94ac49bbbf5ab0 (patch) | |
tree | 86d507e7ea388fde34cdc4ae7d874cc1c6f99d46 /source/blender/gpu/opengl/gl_context.cc | |
parent | c5c6b5ddb31c8a79667d6dcd689808efd3dadd8a (diff) |
GPUCapabilities: Isolate GL memory statistics
This is part of the Vulkan task T68990
This is a simple cleanup.
Diffstat (limited to 'source/blender/gpu/opengl/gl_context.cc')
-rw-r--r-- | source/blender/gpu/opengl/gl_context.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/gpu/opengl/gl_context.cc b/source/blender/gpu/opengl/gl_context.cc index ec6cc9e6159..ecf74a1993d 100644 --- a/source/blender/gpu/opengl/gl_context.cc +++ b/source/blender/gpu/opengl/gl_context.cc @@ -277,3 +277,30 @@ void GLContext::vao_cache_unregister(GLVaoCache *cache) } /** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Memory statistics + * \{ */ + +void GLContext::memory_statistics_get(int *r_total_mem, int *r_free_mem) +{ + /* TODO(merwin): use Apple's platform API to get this info. */ + if (GLEW_NVX_gpu_memory_info) { + /* Teturned value in Kb. */ + glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, r_total_mem); + glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, r_free_mem); + } + else if (GLEW_ATI_meminfo) { + int stats[4]; + glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, stats); + + *r_total_mem = 0; + *r_free_mem = stats[0]; /* Total memory free in the pool. */ + } + else { + *r_total_mem = 0; + *r_free_mem = 0; + } +} + +/** \} */ |