Re: glReadPixels not working in thread

Shir Gur <[email protected]> Tue, 23 Jan 2018 21:17:38 +0000
Newsgroups gmane.comp.python.opengl.user
Message-ID <CADt4nj+5fQNrRPU_FJO=LUM1pMyq1T7epQVETQMmC-DUn3iTEw@mail.gmail.com>
--===============5026538751690984352==
Content-Type: multipart/alternative; boundary="94eb2c031db027f4eb05637814eb"

--94eb2c031db027f4eb05637814eb
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

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 <[email protected]> wrote:

> =E2=80=8BIt's not entirely clear to me your setup. It looks like you're t=
rying 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 t=
o
> use OpenGL from multiple threads, although in-principle it can be done if
> the parallel executions correspond to a serial execution, with no overlap=
s
> (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 enoug=
h
> performance, move from OpenGL to Vulkan (which unlike GL will allow you t=
o
> build and issue command lists in parallel).
>
> Ian
>

--94eb2c031db027f4eb05637814eb
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Thanks a lot!<br><br>Actually my goal is to generate data for learning in p=
arallel to the actual learning process.<br>So I thought of doing so in anot=
her thread.<br><div class=3D"gmail_quote"><div dir=3D"ltr">On Tue, 23 Jan 2=
018 at 23:10 Ian Mallett &lt;<a href=3D"mailto:[email protected]">ian@geom=
etrian.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=
=3D"ltr"><div style=3D"font-family:times new roman,serif" class=3D"gmail_de=
fault">=E2=80=8BIt&#39;s not entirely clear to me your setup. It looks like=
 you&#39;re trying to use a subprocess? A few things:</div><div style=3D"fo=
nt-family:times new roman,serif" class=3D"gmail_default"><br></div><div sty=
le=3D"font-family:times new roman,serif" class=3D"gmail_default">- Threads =
in Python add parallelism, but not performance, due to the global interpret=
er lock. They may even be pure software threads.</div><div style=3D"font-fa=
mily:times new roman,serif" class=3D"gmail_default">- OpenGL contexts are n=
ot threadsafe. It is usually considered an error to use OpenGL from multipl=
e 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).</div><div style=3D"font-family:times new roman,serif" class=3D"gm=
ail_default">- Subprocesses definitely will suffer at least that problem. I=
DR exactly, but it may be an error to attempt to share a GL context across =
subprocesses, regardless of any synchronization.</div><div style=3D"font-fa=
mily:times new roman,serif" class=3D"gmail_default"><br></div><div style=3D=
"font-family:times new roman,serif" class=3D"gmail_default">Recommendation:=
 keep all GL calls in one thread, and don&#39;t use threads in Python anywa=
y unless you need asynchronous operations. If profiling shows that OpenGL <=
i>command overhead</i> really is the bottleneck <i>and</i> this is worth in=
vesting effort fixing, move to C++. If you still don&#39;t have enough perf=
ormance, move from OpenGL to Vulkan (which unlike GL will allow you to buil=
d and issue command lists in parallel).<br></div></div><div dir=3D"ltr"><di=
v style=3D"font-family:times new roman,serif" class=3D"gmail_default"><br><=
/div><div style=3D"font-family:times new roman,serif" class=3D"gmail_defaul=
t">Ian<br></div></div></blockquote></div>

--94eb2c031db027f4eb05637814eb--


--===============5026538751690984352==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--===============5026538751690984352==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
_______________________________________________
PyOpenGL-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyopengl-users

--===============5026538751690984352==--