18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-21 07:24:57 +01:00

fix(python): the old texture deleted under the lock the viewers bind under, a fence not made waited for with glFinish

From the review of #411:

- finish_upload() deleted the old texture before it took the lock of the render target, and the
  windows of python.displaywindows read the name under that lock but bound it after letting go of it.
  A window could bind a name already deleted, or already given to the next upload. In a compatibility
  context (the legacy renderer) that makes a new empty texture: a black frame and a texture never
  deleted. The commit and the publishing of the new name now go under the lock, and the viewer binds
  under it too. A name bound before the deletion stays alive in that window's context while bound.
- A glFenceSync that returns no fence was taken for a signalled one: the image went in place at once,
  with nothing ordering the contexts. The worker now waits for its upload with glFinish then, as
  without sync objects.
This commit is contained in:
maj00r
2026-11-19 18:00:22 +01:00
parent 61d195d9fc
commit 939514ea79
3 changed files with 9 additions and 9 deletions

View File

@@ -192,13 +192,11 @@ void python_screen_viewer::threadfunc()
void python_screen_viewer::bind_shared_texture() const
{
size_t texture;
{
std::scoped_lock guard(m_rt->mutex);
texture = m_rt->texture_id;
}
// bound each frame: each image uploaded by a worker comes in a texture of its own, and a name deleted comes back for
// a later one, so a name seen before may be another texture already
// a later one, so a name seen before may be another texture already. bound under the lock the drawing thread deletes
// the old texture under, so the name read here is never one already gone
std::scoped_lock guard(m_rt->mutex);
size_t const texture = m_rt->texture_id;
glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(texture != 0 ? texture : m_initialtexture));
}