PDA

View Full Version : OpenGL and OpenMP



Dee.cz
10-03-2007, 04:36 AM
Hello, has anyone tried to run other jobs in parallel to rendering?

#pragma omp parallel sections
{
#pragma omp section
{
OpenGL rendering
}
#pragma omp section
{
unrelated CPU number crunching
}
}I tried it with GF8 and VC+2005 and OpenGL code gets broken on many different places..e.g. uniform location is sometimes not found, although the same location in the same shader was found in previous frame.

knackered
10-03-2007, 04:42 AM
no idea, but what i do know is that an opengl context can only be current to one thread at a time. So if OpenMP is forking multiple threads to execute the opengl functions you're in trouble.

Dee.cz
10-03-2007, 06:24 AM
"omp section" and gl rendering in it is always executed only by one thread, but thread is selected randomly from pool. It works when rendering is assigned to master thread, thanks for help!

skynet
10-04-2007, 04:56 AM
but thread is selected randomly from pool.This means, you have to make the OpenGL rendering context current in that thread before issuing any GL commands.

RGHP
10-04-2007, 09:39 PM
Also you have to consider that if you want to render in the same scene, all the OpenGL states must be encapsulated in Mutexs.