mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 13:37:22 +00:00
[client] egl: revert glsync changes
`process` and `bind` are called from the same thread in order, there is no need for atomic usage here. This reverts commit3d7dbd6371
. This reverts commitb3db1ba10b
.
This commit is contained in:
parent
e949f2f8d2
commit
037b76750a
@ -41,9 +41,11 @@ static void eglTexBuffer_cleanup(TextureBuffer * this)
|
|||||||
if (this->sampler)
|
if (this->sampler)
|
||||||
glDeleteSamplers(1, &this->sampler);
|
glDeleteSamplers(1, &this->sampler);
|
||||||
|
|
||||||
GLsync sync = atomic_exchange(&this->sync, 0);
|
if (this->sync)
|
||||||
if (sync)
|
{
|
||||||
glDeleteSync(sync);
|
glDeleteSync(this->sync);
|
||||||
|
this->sync = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// common functions
|
// common functions
|
||||||
@ -66,7 +68,6 @@ bool eglTexBuffer_init(EGL_Texture ** texture, EGLDisplay * display)
|
|||||||
this = UPCAST(TextureBuffer, *texture);
|
this = UPCAST(TextureBuffer, *texture);
|
||||||
|
|
||||||
this->texCount = 1;
|
this->texCount = 1;
|
||||||
atomic_init(&this->sync, 0);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +200,7 @@ EGL_TexStatus eglTexBuffer_stream_process(EGL_Texture * texture)
|
|||||||
GLuint tex = this->tex[this->bufIndex];
|
GLuint tex = this->tex[this->bufIndex];
|
||||||
EGL_TexBuffer * buffer = &this->buf[this->bufIndex];
|
EGL_TexBuffer * buffer = &this->buf[this->bufIndex];
|
||||||
|
|
||||||
if (buffer->updated && atomic_load(&this->sync) == 0)
|
if (buffer->updated && this->sync == 0)
|
||||||
{
|
{
|
||||||
this->rIndex = this->bufIndex;
|
this->rIndex = this->bufIndex;
|
||||||
if (++this->bufIndex == this->texCount)
|
if (++this->bufIndex == this->texCount)
|
||||||
@ -225,8 +226,7 @@ EGL_TexStatus eglTexBuffer_stream_process(EGL_Texture * texture)
|
|||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||||
|
|
||||||
GLsync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
this->sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||||
glDeleteSync(atomic_exchange(&this->sync, sync));
|
|
||||||
glFlush();
|
glFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,14 +240,14 @@ EGL_TexStatus eglTexBuffer_stream_bind(EGL_Texture * texture)
|
|||||||
if (this->rIndex == -1)
|
if (this->rIndex == -1)
|
||||||
return EGL_TEX_STATUS_NOTREADY;
|
return EGL_TEX_STATUS_NOTREADY;
|
||||||
|
|
||||||
GLsync sync = atomic_exchange(&this->sync, 0);
|
if (this->sync)
|
||||||
if (sync)
|
|
||||||
{
|
{
|
||||||
switch(glClientWaitSync(sync, 0, 20000000)) // 20ms
|
switch(glClientWaitSync(this->sync, 0, 20000000)) // 20ms
|
||||||
{
|
{
|
||||||
case GL_ALREADY_SIGNALED:
|
case GL_ALREADY_SIGNALED:
|
||||||
case GL_CONDITION_SATISFIED:
|
case GL_CONDITION_SATISFIED:
|
||||||
glDeleteSync(sync);
|
glDeleteSync(this->sync);
|
||||||
|
this->sync = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_TIMEOUT_EXPIRED:
|
case GL_TIMEOUT_EXPIRED:
|
||||||
@ -255,7 +255,8 @@ EGL_TexStatus eglTexBuffer_stream_bind(EGL_Texture * texture)
|
|||||||
|
|
||||||
case GL_WAIT_FAILED:
|
case GL_WAIT_FAILED:
|
||||||
case GL_INVALID_VALUE:
|
case GL_INVALID_VALUE:
|
||||||
glDeleteSync(sync);
|
glDeleteSync(this->sync);
|
||||||
|
this->sync = 0;
|
||||||
DEBUG_GL_ERROR("glClientWaitSync failed");
|
DEBUG_GL_ERROR("glClientWaitSync failed");
|
||||||
return EGL_TEX_STATUS_ERROR;
|
return EGL_TEX_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ typedef struct TextureBuffer
|
|||||||
GLuint sampler;
|
GLuint sampler;
|
||||||
EGL_TexBuffer buf[EGL_TEX_BUFFER_MAX];
|
EGL_TexBuffer buf[EGL_TEX_BUFFER_MAX];
|
||||||
int bufFree;
|
int bufFree;
|
||||||
_Atomic(GLsync) sync;
|
GLsync sync;
|
||||||
LG_Lock copyLock;
|
LG_Lock copyLock;
|
||||||
int bufIndex;
|
int bufIndex;
|
||||||
int rIndex;
|
int rIndex;
|
||||||
|
Loading…
Reference in New Issue
Block a user