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.
This commit is contained in:
parent
c541f3abef
commit
70d38a996e
Notes:
blender-bot
2023-02-14 08:45:12 +01:00
Referenced by issue #59344, Blender 2.8 - Knife cut - pressing Z at a fast speed doesnt register all of the toggles (keymap 2.7x) Referenced by issue #59273, Text object disappears when Fill Mode set to None Referenced by issue #59222, Blender 2.8 - Editing objects with modifiers enabled for edit mode crashes blender Referenced by issue #59231, Blender 2.8 - Shape Key editor - Tab doesnt go to the next value, but instead edits the name of the next shape key
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue