Don't leak GL fences

This commit is contained in:
Lionel Flandrin 2016-09-17 22:23:27 +02:00
parent b911183d22
commit 6cfd34ab30
3 changed files with 22 additions and 1 deletions

View File

@ -1851,6 +1851,18 @@ void *rglFenceSync(GLenum condition, GLbitfield flags)
#endif
}
/*
*
* Core in:
* OpenGL : 3.2
* OpenGLES : 3.0
*/
void rglDeleteSync(GLsync sync) {
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3)
glDeleteSync(sync);
#endif
}
/*
*
* Core in:

View File

@ -161,6 +161,7 @@ RETRO_BEGIN_DECLS
#define glClearBufferfi rglClearBufferfi
#define glWaitSync rglWaitSync
#define glFenceSync rglFenceSync
#define glDeleteSync rglDeleteSync
#define glBufferStorage rglBufferStorage
#define glFlushMappedBufferRange rglFlushMappedBufferRange
#define glClientWaitSync rglClientWaitSync
@ -400,6 +401,7 @@ void rglTexSubImage2D( GLenum target,
const GLvoid * pixels);
void rglDeleteVertexArrays(GLsizei n, const GLuint *arrays);
void *rglFenceSync(GLenum condition, GLbitfield flags);
void rglDeleteSync(GLsync sync);
void rglWaitSync(void *sync, GLbitfield flags, uint64_t timeout);
void rglBufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data, GLbitfield flags);
void rglFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length);

View File

@ -33,12 +33,19 @@ struct Storage {
{
}
~Storage() {
if (this->fence) {
glDeleteSync(this->fence);
}
}
// Wait for the buffer to be ready for reuse
void sync() {
if (this->fence) {
glWaitSync(this->fence, 0, GL_TIMEOUT_IGNORED);
get_error();
glDeleteSync(this->fence);
this->fence = NULL;
get_error();
}
}