mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-21 07:24:57 +01:00
fix(python): the image of the worker goes in place once its fence is signalled, the viewer binds it each frame
From the review of 8811ee5a:
- glWaitSync ordered only the context of the main window. The extra viewports and the windows of
python.displaywindows draw in contexts of their own and could bind the new texture before the upload
was done. commit_thread_upload() now asks the fence without waiting (glClientWaitSync, timeout 0) and
puts the image in place only once it is signalled, so every context binding it afterwards has it whole.
Until then the task stays in the upload queue and is asked again the next frame.
- The drawing thread chose between upload and commit by python.threadedupload, the worker by whether it
got a context. With python.threadedupload on and no context made for the worker, the screens were no
longer updated. The task now records that a worker uploaded it.
- The viewer of python.displaywindows told a new image by its texture name, but a deleted name comes back
for a later texture. It binds the name of the last image each frame, read under the lock of the render
target, and the name it starts with is read on the drawing thread when it is made.
This commit is contained in:
@@ -232,22 +232,31 @@ void render_task::upload() const
|
||||
}
|
||||
}
|
||||
|
||||
void render_task::upload_from_thread() const
|
||||
void render_task::upload_from_thread()
|
||||
{
|
||||
m_uploadedbyworker = true;
|
||||
if (Global.python_uploadmain && m_target && m_target->shared_tex)
|
||||
{
|
||||
m_target->shared_tex->upload_from_thread(m_target->width, m_target->height, reinterpret_cast<const uint8_t *>(m_target->image.data()));
|
||||
}
|
||||
}
|
||||
|
||||
void render_task::commit_upload() const
|
||||
bool render_task::finish_upload() const
|
||||
{
|
||||
if (Global.python_uploadmain && m_target && m_target->shared_tex)
|
||||
if (false == Global.python_uploadmain || nullptr == m_target || nullptr == m_target->shared_tex)
|
||||
return true;
|
||||
if (m_uploadedbyworker)
|
||||
{
|
||||
m_target->shared_tex->commit_thread_upload();
|
||||
std::scoped_lock lock(m_target->mutex);
|
||||
m_target->texture_id = m_target->shared_tex->get_id();
|
||||
if (false == m_target->shared_tex->commit_thread_upload())
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
upload();
|
||||
}
|
||||
std::scoped_lock lock(m_target->mutex);
|
||||
m_target->texture_id = m_target->shared_tex->get_id();
|
||||
return true;
|
||||
}
|
||||
|
||||
void render_task::cancel() const { /* nothing to do */ }
|
||||
@@ -629,15 +638,8 @@ void python_taskqueue::update()
|
||||
{
|
||||
std::scoped_lock lock(m_uploadtasks.mutex);
|
||||
|
||||
for (auto const &task : m_uploadtasks.data)
|
||||
{
|
||||
if (Global.python_threadedupload)
|
||||
task->commit_upload();
|
||||
else
|
||||
task->upload();
|
||||
}
|
||||
|
||||
m_uploadtasks.data.clear();
|
||||
// a task whose image a worker uploaded stays until the gpu has the image
|
||||
std::erase_if(m_uploadtasks.data, [](std::shared_ptr<render_task> const &Task) { return Task->finish_upload(); });
|
||||
}
|
||||
|
||||
void python_taskqueue::error()
|
||||
|
||||
Reference in New Issue
Block a user