diff --git a/client/renderers/EGL/texture_buffer.c b/client/renderers/EGL/texture_buffer.c index 77500e8f..768b330a 100644 --- a/client/renderers/EGL/texture_buffer.c +++ b/client/renderers/EGL/texture_buffer.c @@ -40,6 +40,12 @@ static void eglTexBuffer_cleanup(TextureBuffer * this) if (this->sampler) glDeleteSamplers(1, &this->sampler); + + if (this->sync) + { + glDeleteSync(this->sync); + this->sync = 0; + } } // common functions @@ -186,7 +192,7 @@ EGL_TexStatus eglTexBuffer_stream_process(EGL_Texture * texture_) GLuint tex = this->tex[this->bufIndex]; EGL_TexBuffer * buffer = &this->buf[this->bufIndex]; - if (buffer->updated && buffer->sync == 0) + if (buffer->updated && this->sync == 0) { this->rIndex = this->bufIndex; if (++this->bufIndex == this->texCount) @@ -212,7 +218,7 @@ EGL_TexStatus eglTexBuffer_stream_process(EGL_Texture * texture_) glBindTexture(GL_TEXTURE_2D, 0); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); - buffer->sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + this->sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); glFlush(); } @@ -226,15 +232,14 @@ EGL_TexStatus eglTexBuffer_stream_bind(EGL_Texture * texture_) if (this->rIndex == -1) return EGL_TEX_STATUS_NOTREADY; - EGL_TexBuffer * buffer = &this->buf[this->rIndex]; - if (buffer->sync) + if (this->sync) { - switch(glClientWaitSync(buffer->sync, 0, 20000000)) // 20ms + switch(glClientWaitSync(this->sync, 0, 20000000)) // 20ms { case GL_ALREADY_SIGNALED: case GL_CONDITION_SATISFIED: - glDeleteSync(buffer->sync); - buffer->sync = 0; + glDeleteSync(this->sync); + this->sync = 0; break; case GL_TIMEOUT_EXPIRED: @@ -242,8 +247,8 @@ EGL_TexStatus eglTexBuffer_stream_bind(EGL_Texture * texture_) case GL_WAIT_FAILED: case GL_INVALID_VALUE: - glDeleteSync(buffer->sync); - buffer->sync = 0; + glDeleteSync(this->sync); + this->sync = 0; DEBUG_GL_ERROR("glClientWaitSync failed"); return EGL_TEX_STATUS_ERROR; } diff --git a/client/renderers/EGL/texture_buffer.h b/client/renderers/EGL/texture_buffer.h index 681e0465..7651f7ca 100644 --- a/client/renderers/EGL/texture_buffer.h +++ b/client/renderers/EGL/texture_buffer.h @@ -34,6 +34,8 @@ typedef struct TextureBuffer GLuint tex[2]; GLuint sampler; EGL_TexBuffer buf[2]; + int bufFree; + GLsync sync; LG_Lock copyLock; int bufIndex; int rIndex; diff --git a/client/renderers/EGL/texture_util.c b/client/renderers/EGL/texture_util.c index 0177fcb5..d7ae901a 100644 --- a/client/renderers/EGL/texture_util.c +++ b/client/renderers/EGL/texture_util.c @@ -124,12 +124,6 @@ void eglTexUtilFreeBuffers(EGL_TexBuffer * buffers, int count) eglTexUtilUnmapBuffer(buffer); glDeleteBuffers(1, &buffer->pbo); - if (buffer->sync) - { - glDeleteSync(buffer->sync); - buffer->sync = 0; - } - buffer->pbo = 0; } } diff --git a/client/renderers/EGL/texture_util.h b/client/renderers/EGL/texture_util.h index 17cc5abc..6a3a45cc 100644 --- a/client/renderers/EGL/texture_util.h +++ b/client/renderers/EGL/texture_util.h @@ -41,7 +41,6 @@ typedef struct EGL_TexBuffer size_t size; GLuint pbo; void * map; - GLsync sync; bool updated; } EGL_TexBuffer;