If I call
glDeleteTextures, will it release memory immediately? And what is the performance? I know that
glGenTexture is quite cheap, because it only alocated id, but I have nor found anything about deleting.
If I call glDeleteTextures, will it release memory immediately?
After a texture is deleted, it has no contents or dimensionality, and its name is free for reuse.
This says absolutely nothing about the backing storage for a texture, i.e the memory used for it. From that we can infer that behaviour is entirely up to the GL implementation. Typically one of three things might happen:
- Memory is released immediately.
- Memory is not released immediately but will be released at some point in time shortly after you call glDeleteTextures; a scenario where this might make sense is if releasing the memory immediately (and not returning until done) is an expensive operation - if so, queueing-up the release for later on might help with performance right now.
- Memory is not released at all. Where this might make sense is if the memory can be re-used to satisfy a future allocation requirement and where this re-use is faster than a full release and reallocate cycle.
Because OpenGL doesn't specify which, any of these three, or something else entirely different, may happen.
Otherwise the only things you can rely on after calling glDeleteTextures are:
- The texture name can be reused by a future call to glGenTextures, and,
- glGet calls against the contents or dimensionality will return NULL or 0.
And what is the performance?
OpenGL specifies functionality, not performance. As always with performance-related questions, you should know your target platforms and benchmark/profile your code on them so that you are satisfied that the performance you get is within acceptable tolerances.