This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // The native handle type holds resource handles and a coarse description. | |
| typedef union { | |
| // handle that is a texture | |
| struct { | |
| GLuint gl; | |
| GLuint gl_renderbuf; | |
| } tex; | |
| // handle that is a vertex buffer | |
| struct { | |
| GLuint base; | |
| GLuint indices; | |
| } vbuf; | |
| } GDrawNativeHandle; | |
| // ... | |
| static void eat_gl_err(void) | |
| { | |
| while (glGetError() != GL_NO_ERROR); | |
| } | |
| static void opengl_check(void) | |
| { | |
| GLint e = glGetError(); | |
| if (e != GL_NO_ERROR) { | |
| report_err(e); // prints a message and exits in my test | |
| eat_gl_err(); | |
| } | |
| } | |
| // ... | |
| static void api_free_resource(GDrawHandle *r) | |
| { | |
| if (!r->cache->is_vertex) { // <- is_vertex was not set for VBOs here | |
| // so VBOs went through here... | |
| glDeleteTextures(1, &r->handle.tex.gl); | |
| if (r->handle.tex.gl_renderbuf && r->handle.tex.gl_renderbuf != r->handle.tex.gl) | |
| glDeleteRenderbuffers(1, &r->handle.tex.gl_renderbuf); | |
| } else { | |
| // ...instead of through here, generating glDeleteTextures/glRenderbuffers for then-unassigned names. | |
| glDeleteBuffers(1, &r->handle.vbuf.base); | |
| glDeleteBuffers(1, &r->handle.vbuf.indices); | |
| } | |
| opengl_check(); // <- no error reported here, driver crashes in second thread a while later. | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment