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:
@@ -245,6 +245,9 @@ bool render_task::finish_upload() const
|
||||
{
|
||||
if (false == Global.python_uploadmain || nullptr == m_target || nullptr == m_target->shared_tex)
|
||||
return true;
|
||||
// the old texture is deleted and the new name published under the lock the windows of python.displaywindows bind under,
|
||||
// so none of them binds the old name once it is gone: a name bound before stays alive in its context while bound there
|
||||
std::scoped_lock lock(m_target->mutex);
|
||||
if (m_uploadedbyworker)
|
||||
{
|
||||
if (false == m_target->shared_tex->commit_thread_upload())
|
||||
@@ -254,7 +257,6 @@ bool render_task::finish_upload() const
|
||||
{
|
||||
upload();
|
||||
}
|
||||
std::scoped_lock lock(m_target->mutex);
|
||||
m_target->texture_id = m_target->shared_tex->get_id();
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user