mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 21:47:23 +00:00
[client] egl: don't map the texture until it's needed
The texture buffer may still be in use if we try to re-map it immediately, instead only map when we need it mapped, and unmap immediately after advancing the offset allowing the render thread to continue while the unmap operation occurs
This commit is contained in:
parent
67dec216d2
commit
ede96fa486
@ -300,9 +300,6 @@ bool egl_texture_setup(EGL_Texture * texture, enum EGL_PixelFormat pixFmt, size_
|
|||||||
NULL,
|
NULL,
|
||||||
GL_MAP_WRITE_BIT
|
GL_MAP_WRITE_BIT
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!egl_texture_map(texture, i))
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -335,12 +332,15 @@ bool egl_texture_update(EGL_Texture * texture, const uint8_t * buffer)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!egl_texture_map(texture, s.w))
|
||||||
|
return EGL_TEX_STATUS_ERROR;
|
||||||
|
|
||||||
memcpy(texture->tex[s.w].map, buffer, texture->pboBufferSize);
|
memcpy(texture->tex[s.w].map, buffer, texture->pboBufferSize);
|
||||||
atomic_store_explicit(&texture->state.w, next, memory_order_release);
|
atomic_store_explicit(&texture->state.w, next, memory_order_release);
|
||||||
|
egl_texture_unmap(texture, s.w);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Non streaming, this is NOT thread safe */
|
|
||||||
for(int p = 0; p < texture->planeCount; ++p)
|
for(int p = 0; p < texture->planeCount; ++p)
|
||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D, texture->tex[0].t[p]);
|
glBindTexture(GL_TEXTURE_2D, texture->tex[0].t[p]);
|
||||||
@ -368,6 +368,9 @@ bool egl_texture_update_from_frame(EGL_Texture * texture, const FrameBuffer * fr
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!egl_texture_map(texture, s.w))
|
||||||
|
return EGL_TEX_STATUS_ERROR;
|
||||||
|
|
||||||
framebuffer_read(
|
framebuffer_read(
|
||||||
frame,
|
frame,
|
||||||
texture->tex[s.w].map,
|
texture->tex[s.w].map,
|
||||||
@ -379,6 +382,8 @@ bool egl_texture_update_from_frame(EGL_Texture * texture, const FrameBuffer * fr
|
|||||||
);
|
);
|
||||||
|
|
||||||
atomic_store_explicit(&texture->state.w, next, memory_order_release);
|
atomic_store_explicit(&texture->state.w, next, memory_order_release);
|
||||||
|
egl_texture_unmap(texture, s.w);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,7 +400,6 @@ enum EGL_TexStatus egl_texture_process(EGL_Texture * texture)
|
|||||||
return texture->ready ? EGL_TEX_STATUS_OK : EGL_TEX_STATUS_NOTREADY;
|
return texture->ready ? EGL_TEX_STATUS_OK : EGL_TEX_STATUS_NOTREADY;
|
||||||
|
|
||||||
/* update the texture */
|
/* update the texture */
|
||||||
egl_texture_unmap(texture, s.u);
|
|
||||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, texture->tex[s.u].pbo);
|
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, texture->tex[s.u].pbo);
|
||||||
for(int p = 0; p < texture->planeCount; ++p)
|
for(int p = 0; p < texture->planeCount; ++p)
|
||||||
{
|
{
|
||||||
@ -417,9 +421,6 @@ enum EGL_TexStatus egl_texture_process(EGL_Texture * texture)
|
|||||||
texture->ready = true;
|
texture->ready = true;
|
||||||
atomic_store_explicit(&texture->state.u, nextu, memory_order_release);
|
atomic_store_explicit(&texture->state.u, nextu, memory_order_release);
|
||||||
|
|
||||||
if (!egl_texture_map(texture, s.u))
|
|
||||||
return EGL_TEX_STATUS_ERROR;
|
|
||||||
|
|
||||||
return EGL_TEX_STATUS_OK;
|
return EGL_TEX_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user