Page MenuHome

Estimate a slightly better value of gpu memory used for GPU_textures.
ClosedPublic

Authored by Germano Cavalcante (mano-wii) on Jul 20 2018, 7:17 PM.

Details

Summary

This patch adds a mipmaps member to the GPUTexture struct and also computes to the memory used by these mipmaps and the memory used for textures that are created from an external bindcode.

So it solves the following inconsistencies:

  • The memory value for mipmaps was not being computed.
  • As GPU_texture_from_bindcode didn't call gpu_texture_memory_footprint_add, it brought inconsistencies to the value of the used memory, especially when the texture is freed.

Notes:

  • The bytesize member has been removed from the GPUTexture struct, as I don't think it is a good idea to increase the size of that struct with the new member mipmaps, and also because the value of bitesize is easy to obtain.
  • There are around 12 other places in the blender code that creates gl textures without going through the gpu. Therefore the computed memory value is not the actual gpu memory value.

Diff Detail

Repository
rB Blender

Event Timeline

Clément Foucault (fclem) requested changes to this revision.Mar 12 2020, 10:51 PM

I would like to have this updated to latest master. This is not really important but nice to have.

@Germano Cavalcante (mano-wii) Feel free to abandon revision if you don't have the time to do that.

This revision now requires changes to proceed.Mar 12 2020, 10:51 PM

I'll take a look at this Monday.

Very few style comments but the patch looks good to me.

source/blender/gpu/intern/gpu_texture.c
383

typo: bits *

1400

Prefer testing miplvl > tex->mipmaps.

1518

Prefer testing miplvl <= tex->mipmaps

1572

why uint?

This revision is now accepted and ready to land.Mar 17 2020, 1:51 AM
Germano Cavalcante (mano-wii) marked 4 inline comments as done.
  • Adjust according to the review
  • Fix asserts in test files
Clément Foucault (fclem) requested changes to this revision.Mar 17 2020, 11:02 PM
Clément Foucault (fclem) added inline comments.
source/blender/gpu/intern/gpu_texture.c
417

change function name to gpu_format_to_gl_internalformat

419

I don't really like this. Keep the switch case and duplicate for gl_internalformat_to_gpu_format.
We could use macros to avoid too much duplication.

511

change function name to gl_internalformat_to_gpu_format

This revision now requires changes to proceed.Mar 17 2020, 11:02 PM
Germano Cavalcante (mano-wii) marked 3 inline comments as done.
  • Rename functions
  • use switch
This revision is now accepted and ready to land.Mar 23 2020, 6:16 PM