Re: [PyOpenGL-Users] glReadPixels not working in thread
Brought to you by:
mcfletch
From: Shir G. <shi...@gm...> - 2018-01-23 21:17:55
|
Thanks a lot! Actually my goal is to generate data for learning in parallel to the actual learning process. So I thought of doing so in another thread. On Tue, 23 Jan 2018 at 23:10 Ian Mallett <ia...@ge...> wrote: > 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 > |