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:
authorMitchell Stokes <mogurijin@gmail.com>2010-11-17 08:28:25 +0300
committerMitchell Stokes <mogurijin@gmail.com>2010-11-17 08:28:25 +0300
commit1bb98b41944dadf69645cf3b99bcabd9834f9240 (patch)
tree5c700ba234517211190bf7865c0ee7a353475b94 /source/blender/gpu/intern/gpu_extensions.c
parentf791d74f102dcfed69a95d605e3c634f76a070ab (diff)
Adding monitoring for (approximate) VRAM used by textures. The information is currently only used in the profiling data of the BGE.
Here is a image of it in action: http://www.pasteall.org/pic/show.php?id=6351 What it monitors: * VRAM used by textures created via bf_gpu and BL_Textures What it does not monitor: * VRAM used by the Blender ui * VRAM used by 2d filters * VRAM allocated by the user via KX_Scene.pre_draw and KX_Scene.pre_draw
Diffstat (limited to 'source/blender/gpu/intern/gpu_extensions.c')
-rw-r--r--source/blender/gpu/intern/gpu_extensions.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index 70a74aafead..4298ec8d44d 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -66,11 +66,12 @@ static struct GPUGlobal {
GLuint currentfb;
int glslsupport;
int extdisabled;
+ unsigned int texturevram; // An approximation of how much vram is being used for textures
int colordepth;
GPUDeviceType device;
GPUOSType os;
GPUDriverType driver;
-} GG = {1, 0, 0, 0};
+} GG = {1, 0, 0, 0, 0};
/* GPU Types */
@@ -185,6 +186,21 @@ int GPU_color_depth()
return GG.colordepth;
}
+unsigned int GPU_texture_vram_usage()
+{
+ return GG.texturevram;
+}
+
+void GPU_texture_vram_add(unsigned int amount)
+{
+ GG.texturevram += amount;
+}
+
+void GPU_texture_vram_subtract(unsigned int amount)
+{
+ GG.texturevram -= amount;
+}
+
int GPU_print_error(char *str)
{
GLenum errCode;
@@ -343,6 +359,8 @@ static GPUTexture *GPU_texture_create_nD(int w, int h, int n, float *fpixels, in
if (tex->target == GL_TEXTURE_1D) {
glTexImage1D(tex->target, 0, internalformat, tex->w, 0, format, type, 0);
+ GPU_texture_vram_add(tex->w*4);
+
if (fpixels) {
glTexSubImage1D(tex->target, 0, 0, w, format, type,
pixels? pixels: fpixels);
@@ -356,6 +374,8 @@ static GPUTexture *GPU_texture_create_nD(int w, int h, int n, float *fpixels, in
glTexImage2D(tex->target, 0, internalformat, tex->w, tex->h, 0,
format, type, 0);
+ GPU_texture_vram_add(tex->w*tex->h*4);
+
if (fpixels) {
glTexSubImage2D(tex->target, 0, 0, 0, w, h,
format, type, pixels? pixels: fpixels);
@@ -620,8 +640,15 @@ void GPU_texture_free(GPUTexture *tex)
if (tex->fb)
GPU_framebuffer_texture_detach(tex->fb, tex);
if (tex->bindcode && !tex->fromblender)
+ {
glDeleteTextures(1, &tex->bindcode);
+ if (tex->target == GL_TEXTURE_2D)
+ GPU_texture_vram_subtract(tex->w*tex->h*4);
+ else
+ GPU_texture_vram_subtract(tex->w*4);
+ }
+
MEM_freeN(tex);
}
}