mesa: protect the debug state with a mutex

When GL_DEBUG_OUTPUT_SYNCHRONOUS is GL_TRUE, drivers are allowed to log debug
messages from other threads.  The debug state needs to be protected.  We are
about to change mesa to spawn threads for deferred glCompileShader calls and
we will need this groundwork.

Signed-off-by: Chia-I Wu <olv@lunarg.com>
glsl: add a generic thread pool data structure

It will be used to implement threaded glCompileShader.

Signed-off-by: Chia-I Wu <olv@lunarg.com>
mesa: add support for threaded glCompileShader

Threaded glCompileShader can be enabled for a context by calling
_mesa_enable_glsl_threadpool.  It will initialize the singleton GLSL thread
pool and defer glCompileShader calls to the thread pool.

For applications to benefit from threaded glCompileShader, they have to
compile shaders in this fashion

 for (i = 0; i < num_shaders; i++)
   glCompileShader(shaders[i]);
 for (i = 0; i < num_shaders; i++)
   glGetShaderiv(shaders[i], GL_COMPILE_STATUS, &val);

As each glGetShaderiv call will force mesa to wait for the deferred
glCompileShader to complete, compiling shaders in the traditional way will
defeat this feature.  This is also why the feature needs to be explicitly
enabled with _mesa_enable_glsl_threadpool.

Signed-off-by: Chia-I Wu <olv@lunarg.com>
i965: add drirc option multithread_glsl_compiler

Setting it to a non-zero value N will cause glCompileShader to be deferred to
a thread pool.  When N is greater than 1, it indicates the maximum number of
threads in the pool.  When N is 1, the number of threads is up to the driver.

Signed-off-by: Chia-I Wu <olv@lunarg.com>