admin管理员组文章数量:1289620
I am wondering when a VAO ID gets 'erased' from VRAM (and whether the corresponding vertex data is also removed). Is there any way to get a notification from the GPU when it discards a VAO and its associated vertex data?
If that's not possible, I plan to maintain a map of active VAOs in the GPU. For each new VAO creation, I will check whether the newly created VAO is already in the map and remove it if necessary.
I am wondering when a VAO ID gets 'erased' from VRAM (and whether the corresponding vertex data is also removed). Is there any way to get a notification from the GPU when it discards a VAO and its associated vertex data?
If that's not possible, I plan to maintain a map of active VAOs in the GPU. For each new VAO creation, I will check whether the newly created VAO is already in the map and remove it if necessary.
Share Improve this question edited Feb 20 at 16:54 Rabbid76 211k30 gold badges156 silver badges199 bronze badges asked Feb 20 at 16:39 Benzait SofianeBenzait Sofiane 1572 silver badges12 bronze badges 4 |1 Answer
Reset to default 1There is only one way to determine if a name corresponds to a vertex array object.
glIsVertexArray
returns GL_TRUE if array is currently the name of a vertex array object
...
If array is a name returned by glGenVertexArrays, by that has not yet been bound through a call to glBindVertexArray, then the name is not a vertex array object and glIsVertexArray returns GL_FALSE.
I don't know what you mean by "erasing" a vertex array object (from VRAM) but i assume you mean deleting it (glDeleteVertexArrays). I mean it is straightforward, generate a name, create the object (bind), do something with it and when done, delete it. OpenGL is a state machine, there is no event mechanism that informs the user when a state has been modified, but you can set and query the current state, like to query if a name is associated with an object.
But you could do something like this (since gl functions are loaded at run-time):
//function pointer, set by gl loader
PFNGLBINDVERTEXARRAYPROC gl_bind_vertex_array_proc;
static inline void glBindVertexArray(GLuint array)
{
//test if current bound array equals array
if (current_array == array) {
return;
}
//invoke the 'real' gl function
gl_bind_vertex_array_proc(array);
//test for error
GLenum err = glGetError();
if (err == GL_NO_ERROR) {
//notify about new binding, e.g. invoke some global handler
//store current array
current_array = array;
} else {
//invoke error handler
}
}
See also: https://www.khronos./opengl/wiki/Load_OpenGL_Functions
本文标签: Does OpenGL provide a way to know if a VAO was quoterasedquot from the GPUStack Overflow
版权声明:本文标题:Does OpenGL provide a way to know if a VAO was "erased" from the GPU? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741420870a2377796.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
glDelete*
method is used, so you should know when it gets deleted. – BDL Commented Feb 21 at 8:32