Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2015-04-24 15:11:05 +0300
committerAntony Riakiotakis <kalast@gmail.com>2015-04-24 15:11:21 +0300
commit80d75cb3e45fe10904b887e04481761dc458c876 (patch)
tree67fc62e0efcfa4049a66a3f63162eff3354e0ae8 /source/blender/gpu
parentc2f861453e3eb9e3cbb7840066fc074e015dfc87 (diff)
Add debug option --debug-gpumem to show GPU memory used in status bar.
Only used in ATIs and NVIDIAs. Used extensions are: https://www.opengl.org/registry/specs/ATI/meminfo.txt http://developer.download.nvidia.com/opengl/specs/ If you read the documentation, the numbers are not supposed to be exact and also depend on the time when the call is made. The numbers can also change quite quickly. It's only meant to give a rough measure of what is going on.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_extensions.h3
-rw-r--r--source/blender/gpu/intern/gpu_extensions.c28
2 files changed, 31 insertions, 0 deletions
diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h
index 27a4396e5d8..f3927ba960b 100644
--- a/source/blender/gpu/GPU_extensions.h
+++ b/source/blender/gpu/GPU_extensions.h
@@ -71,6 +71,9 @@ int GPU_max_texture_size(void);
int GPU_color_depth(void);
void GPU_get_dfdy_factors(float fac[2]);
+bool GPU_mem_stats_supported(void);
+void GPU_mem_stats_get(int *totalmem, int *freemem);
+
void GPU_code_generate_glsl_lib(void);
/* GPU Types */
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index b095eab6952..54e3339eb29 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -2084,6 +2084,34 @@ void GPU_shader_free_builtin_shaders(void)
}
}
+bool GPU_mem_stats_supported(void)
+{
+ return (GLEW_NVX_gpu_memory_info || (GLEW_ATI_meminfo)) && (G.debug & G_DEBUG_GPU_MEM);
+}
+
+
+void GPU_mem_stats_get(int *totalmem, int *freemem)
+{
+ if (GLEW_NVX_gpu_memory_info) {
+ /* returned value in Kb */
+ glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, totalmem);
+
+ glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, freemem);
+ }
+ else if (GLEW_ATI_meminfo) {
+ int stats[4];
+
+ glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, stats);
+ *freemem = stats[0];
+ *totalmem = 0;
+ }
+ else {
+ *totalmem = 0;
+ *freemem = 0;
+ }
+}
+
+
#if 0 /* unused */
/* GPUPixelBuffer */