The Mesa 3D Graphics Library

Shading Language Support

This page describes the features and status of Mesa's support for the OpenGL Shading Language.

Contents

Environment Variables

The MESA_GLSL environment variable can be set to a comma-separated list of keywords to control some aspects of the GLSL compiler and shader execution. These are generally used for debugging.

Example: export MESA_GLSL=dump,nopt

Shaders can be dumped and replaced on runtime for debugging purposes. This feature is not currently supported by SCons build. This is controlled via following environment variables:

Note, path set must exist before running for dumping or replacing to work. When both are set, these paths should be different so the dumped shaders do not clobber the replacement shaders. Also, the filenames of the replacement shaders should match the filenames of the corresponding dumped shaders.

GLSL Version

The GLSL compiler currently supports version 3.30 of the shading language.

Several GLSL extensions are also supported:

Unsupported Features

XXX update this section

The following features of the shading language are not yet fully supported in Mesa:

All other major features of the shading language should function.

Implementation Notes

These issues will be addressed/resolved in the future.

Programming Hints

Stand-alone GLSL Compiler

The stand-alone GLSL compiler program can be used to compile GLSL shaders into low-level GPU code.

This tool is useful for:

After building Mesa, the compiler can be found at src/compiler/glsl/glsl_compiler

Here's an example of using the compiler to compile a vertex shader and emit GL_ARB_vertex_program-style instructions:

    src/compiler/glsl/glsl_compiler --version XXX --dump-ast myshader.vert
Options include

Compiler Implementation

The source code for Mesa's shading language compiler is in the src/compiler/glsl/ directory.

XXX provide some info about the compiler....

The final vertex and fragment programs may be interpreted in software (see prog_execute.c) or translated into a specific hardware architecture (see drivers/dri/i915/i915_fragprog.c for example).

Compiler Validation

Developers working on the GLSL compiler should test frequently to avoid regressions.

The Piglit project has many GLSL tests.

The Mesa demos repository also has some good GLSL tests.