mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-21 07:24:57 +01:00
fix(python): a screen uploaded by the worker goes into a texture of its own, put in place after a fence
With python.threadedupload (the default) the worker wrote the image into the texture the drawing thread draws from, with glTexImage2D and glGenerateMipmap from its own context, and only a glFlush after. Nothing ordered the two contexts: the drawing one could sample the texture while its storage was being made anew, its level 0 half written or its mipmaps not made yet, and on a change of size the worker deleted the texture and wrote a new name into `id` with no synchronisation. The worker now uploads each image into a new texture, sets a fence after it and flushes. The drawing thread, once per frame in python_taskqueue::update(), waits for that fence on the gpu (glWaitSync, the cpu goes on), deletes the old texture and puts the new one in place. The worker no longer touches the texture drawn from, nor `id`. An image the drawing thread didn't take yet is dropped by the next one. Without sync objects the worker waits for the upload with glFinish. The windows of python.displaywindows with python.sharectx bound the texture once; they now bind the name of the last image put in place, which python_rt keeps for them. Uploads on the drawing thread (python.threadedupload no, the Lua and WebAssembly screens, the editor) are as they were.
This commit is contained in:
@@ -67,6 +67,9 @@ struct python_rt
|
||||
int width;
|
||||
int height;
|
||||
std::string image;
|
||||
// gl name of the texture with the last image put in place, for the windows of python.displaywindows (0: none yet). the image
|
||||
// uploaded by a worker gets a texture of its own, so the name changes with each one
|
||||
size_t texture_id{0};
|
||||
|
||||
std::chrono::high_resolution_clock::time_point timestamp;
|
||||
};
|
||||
@@ -80,7 +83,12 @@ class render_task
|
||||
render_task(PyObject *Renderer, std::shared_ptr<dictionary_source> Input, std::shared_ptr<python_rt> Target) : m_renderer(Renderer), m_input(Input), m_target(Target) {}
|
||||
// methods
|
||||
void run();
|
||||
// uploads the image on the drawing thread
|
||||
void upload() const;
|
||||
// uploads the image on a worker with a gl context of its own (python.threadedupload); commit_upload() puts it in place
|
||||
void upload_from_thread() const;
|
||||
// puts the image of upload_from_thread() in place, on the drawing thread
|
||||
void commit_upload() const;
|
||||
void cancel() const;
|
||||
auto target() const -> std::shared_ptr<python_rt>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user