https://bugs.winehq.org/show_bug.cgi?id=47380
--- Comment #12 from Henri Verbeet hverbeet@gmail.com --- (In reply to Tim Schumacher from comment #11)
(In reply to Henri Verbeet from comment #10)
(In reply to Tim Schumacher from comment #9)
It seems like the finish method is constantly called from the wrong thread (thead 9 seems to be the main thread), causing the thread to constantly stall instead of calling the singlethread finish function.
That's pretty much expected when csmt is enabled.
From what I read in the code, wouldn't it at least require one call to finish() from the correct thread to actually do the finish action? The code looks like the following to me:
if (we are on the thread that was started with run_thread) finish the queue else stall until queue is empty
Am I misunderstanding something here?
Mostly just what the "correct" thread is.
In case wined3d_cs_mt_finish() gets called from wined3d_cs_run(), wined3d_cs_mt_finish() can't just wait for the queue to become empty, because it wouldn't be making any progress. Fortunately, the fact that it gets called at all means all previous commands have already finished, so we can just return.
The *normal* situation is that wined3d_cs_mt_finish() gets called from the application thread, and waits for wined3d_cs_run() to catch up. In particular, in wined3d_cs_map(), it waits for the WINED3D_CS_OP_MAP to get executed, so that "map_desc" contains valid information.
It currently wait by just spinning. That's straightforward, but not always optimal. It may be better to sleep depending on e.g. the distance between the head and the tail. The larger problem is still likely that we're calling wined3d_cs_map() at all.