[Nouveau] OpenGL context switching with Noveau

Sampsa Riikonen sampsa.riikonen at iki.fi
Wed Feb 8 18:38:29 UTC 2017


Dear Devs,

(I hope this question is not that much OT for this list..)

My question is about fast OpenGL context switching, i.e. when there are 
several processes using the same nvidia card, each one with their own 
OpenGL context.  In my specific case, I am trying to dump 720p video 
simultaneously to multiple windows using OpenGL textures.

So, to begin with, I have a process that spans child processes (*not* 
threads, i.e. using the fork system call)

Each one of these (multi)processes has a video decoder that produces 
bitmaps at 25 fps rate.  I am dumping the bitmaps to openGL using pixel 
buffer objects (PBOs) and textures.

Each time when uploading a PBO and later on, when showing the texture, 
each (multi)process needs to change to its own context by performing the 
GLX call

glXMakeCurrent(display_id, window_id, context_id)

So there is quite a bit of context switching going on..!  If there are 
30 windows, that's > 750 context switches per second.  I am able to pull 
this off with intel and ati graphics cards, but not with any nvidia card 
(tried a few of them), neither with the proprietary driver nor with noveau.

Are there any specific tricks to achieve this?  Or should I just use one 
context from one process, i.e. use multithreading instead of 
multiprocessing and avoid context switching alltogether?  (is there 
something fundamentally wrong in my approach of multiprocesses and 
context switching?)

Interestingly, when using N>2 multiprocesses (spanned with fork), only 
one of the textures is updating - the others freeze.  However, when 
using the same code as independently launched programs, I can achieve 
N=10+.  However, this seems not to be always stable (whole X server 
freezes sometimes).

On the other hand, I can also use, say, several vlc clients to create a 
same kind of situation and it seems to work.

Ay insight highly appreciated..

Regards,

Sampsa Riikonen



More information about the Nouveau mailing list