Re: [PyOpenGL-Users] glReadPixels not working in thread
Brought to you by:
mcfletch
From: Ian M. <ia...@ge...> - 2018-01-23 21:10:27
|
It's not entirely clear to me your setup. It looks like you're trying to use a subprocess? A few things: - Threads in Python add parallelism, but not performance, due to the global interpreter lock. They may even be pure software threads. - OpenGL contexts are not threadsafe. It is usually considered an error to use OpenGL from multiple threads, although in-principle it can be done if the parallel executions correspond to a serial execution, with no overlaps (through, e.g., tons of mutexes). - Subprocesses definitely will suffer at least that problem. IDR exactly, but it may be an error to attempt to share a GL context across subprocesses, regardless of any synchronization. Recommendation: keep all GL calls in one thread, and don't use threads in Python anyway unless you need asynchronous operations. If profiling shows that OpenGL *command overhead* really is the bottleneck *and* this is worth investing effort fixing, move to C++. If you still don't have enough performance, move from OpenGL to Vulkan (which unlike GL will allow you to build and issue command lists in parallel). Ian |