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:
authorClément Foucault <foucault.clem@gmail.com>2018-12-12 00:10:16 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-12-12 00:10:16 +0300
commit70d38a996eb507dd9e35c265153934191ccba855 (patch)
treee67f3234197611834772a8869dd61213b8270958
parentc541f3abef105e7a1f3a35c0a070464472d443d7 (diff)
GPUTexture: Fix memory statistics not working for Multisamples textures
and also output the vram footprint of the texture at the creation. Also output the full texture memory usage if alloc fails.
-rw-r--r--source/blender/gpu/intern/gpu_texture.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index 052674e7090..75eb17546ac 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -99,7 +99,7 @@ static uint memory_usage;
static uint gpu_texture_memory_footprint_compute(GPUTexture *tex)
{
int samp = max_ii(tex->samples, 1);
- switch (tex->target) {
+ switch (tex->target_base) {
case GL_TEXTURE_1D:
return tex->bytesize * tex->w * samp;
case GL_TEXTURE_1D_ARRAY:
@@ -607,8 +607,6 @@ GPUTexture *GPU_texture_create_nD(
GLenum data_format = gpu_get_gl_dataformat(tex_format, &tex->format_flag);
GLenum data_type = gpu_get_gl_datatype(gpu_data_format);
- gpu_texture_memory_footprint_add(tex);
-
/* Generate Texture object */
tex->bindcode = GPU_tex_alloc();
@@ -645,9 +643,10 @@ GPUTexture *GPU_texture_create_nD(
pixels, &rescaled_pixels);
if (G.debug & G_DEBUG_GPU || !valid) {
-
- printf("GPUTexture: create : %s, %s, w : %d, h : %d, d : %d, comp : %d\n",
- gl_enum_to_str(tex->target), gl_enum_to_str(internalformat), w, h, d, tex->components);
+ printf("GPUTexture: create : %s, %s, w : %d, h : %d, d : %d, comp : %d, size : %.2f MiB\n",
+ gl_enum_to_str(tex->target), gl_enum_to_str(internalformat),
+ w, h, d, tex->components,
+ gpu_texture_memory_footprint_compute(tex) / 1048576.0f);
}
if (!valid) {
@@ -656,11 +655,15 @@ GPUTexture *GPU_texture_create_nD(
}
else {
fprintf(stderr, "GPUTexture: texture alloc failed. Likely not enough Video Memory.\n");
+ fprintf(stderr, "Current texture memory usage : %.2f MiB.\n",
+ gpu_texture_memory_footprint_compute(tex) / 1048576.0f);
}
GPU_texture_free(tex);
return NULL;
}
+ gpu_texture_memory_footprint_add(tex);
+
/* Upload Texture */
const float *pix = (rescaled_pixels) ? rescaled_pixels : pixels;
@@ -749,8 +752,6 @@ static GPUTexture *GPU_texture_cube_create(
GLenum data_format = gpu_get_gl_dataformat(tex_format, &tex->format_flag);
GLenum data_type = gpu_get_gl_datatype(gpu_data_format);
- gpu_texture_memory_footprint_add(tex);
-
/* Generate Texture object */
tex->bindcode = GPU_tex_alloc();
@@ -763,6 +764,8 @@ static GPUTexture *GPU_texture_cube_create(
return NULL;
}
+ gpu_texture_memory_footprint_add(tex);
+
glBindTexture(tex->target, tex->bindcode);
/* Upload Texture */