glsl: make static constant variables "static const"

This allows them to be moved to .rodata, and allow us to be sure that they
will not be modified.

Signed-off-by: Chia-I Wu <olv@lunarg.com>
glsl: protect locale_t with a mutex

There may be two contexts compiling shaders at the same time.  locale_t needs
to be protected.

Signed-off-by: Chia-I Wu <olv@lunarg.com>
glsl: protect anonymous struct id with a mutex

There may be two contexts compiling shaders at the same time, and we want the
anonymous struct id to be globally unique.

Signed-off-by: Chia-I Wu <olv@lunarg.com>
glsl: protect glsl_type with a mutex

glsl_type has several static hash tables and a static ralloc context.  They
need to be protected by a mutex as they are not thread-safe.

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>
mail
glsl: constify gl_context for link_shaders

_mesa_reference_shader
DeleteShader
NewShader
glsl: constify gl_context for _mesa_glsl_compile_shader
mesa: