3

I've read that a VBO (Vertex Buffer Object) essentially keeps a reference count, so that if the VBO's name is given to glDeleteBuffers(), it isn't truly dismissed if a living VAO (Vertex Array Object) still references it. This behavior is similar to "Smart Pointers" newer languages are increasingly adopting. But to what extent this is true and can be designed around, and if it applies to IBO (Index Buffer Object) as well, I haven't been able to find any information on.

If a VBO is kept alive by a VAO that references it and I don't intend to update it or use it beyond the VAO's death, I think the best play is to destroy my reference to it. Is it proper to do so? And can I do the same with an IBO?

Anne Quinn
  • 12,609
  • 8
  • 54
  • 101
  • Out of curiosity, where did you read this? I brief search on the Khronos site and didn't find anything. It could very well be true, but then it's probably an internal design choice, could change at any moment and should not be relied on. – Yun Sep 07 '21 at 13:55
  • 1
    @Yun - I'm only assuming it uses a reference count internally; I learned VAO will keep a VBO alive only from reading a very brief mention somewhere months ago. I couldn't find much info on it either. – Anne Quinn Sep 07 '21 at 13:59

1 Answers1

5

Objects can be attached to other objects. So long as an object is attached to another object, the attached object will not actually be destroyed by calling glDelete*. It will be destroyed only after it is either unattached or the object it is attached to is destroyed as well.

This isn't really something to worry about all that much. If you glDelete* an object, you should not directly use that name again.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • Thank you! A VAO can have 1 IBO and 16 VBO attached, so I take it the IBO is also kept alive. (Of course, please correct me if I'm mistaken) – Anne Quinn Sep 07 '21 at 13:53
  • I believe you, but do you happen to have a reference for this behavior? :) – Yun Sep 07 '21 at 14:18