Shading Language Support
+Shading Language Support
This page describes the features and status of Mesa's support for the - + OpenGL Shading Language.
@@ -19,7 +27,7 @@ Contents- Environment variables -
- GLSL 1.20 support +
- GLSL 1.40 support
- Unsupported Features
- Implementation Notes
- Programming Hints @@ -29,9 +37,7 @@ Contents
Environment Variables
+Environment Variables
The MESA_GLSL environment variable can be set to a comma-separated @@ -43,8 +49,9 @@ execution. These are generally used for debugging.
Experimenting with Shader Replacements
++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: +
-
+
- MESA_SHADER_DUMP_PATH - path where shader sources are dumped +
- MESA_SHADER_READ_PATH - path where replacement shaders are read +
Capturing Shaders
- -GLSL Version
++Setting MESA_SHADER_CAPTURE_PATH to a directory will cause the compiler +to write .shader_test files for use with +shader-db, a tool +which compiler developers can use to gather statistics about shaders +(instructions, cycles, memory accesses, and so on). +
++Notably, this captures linked GLSL shaders - with all stages together - +as well as ARB programs. +
+ +GLSL Version
-The GLSL compiler currently supports version 1.20 of the shading language. +The GLSL compiler currently supports version 3.30 of the shading language.
@@ -70,14 +105,12 @@ Several GLSL extensions are also supported:
- GL_ARB_draw_buffers -
- GL_ARB_texture_rectangle
- GL_ARB_fragment_coord_conventions -
- GL_EXT_texture_array +
- GL_ARB_shader_bit_encoding
Unsupported Features
+Unsupported Features
XXX update this section
@@ -90,7 +123,6 @@ in Mesa:Implementation Notes
+Implementation Notes
- Shading language programs are compiled into low-level programs
@@ -124,8 +155,7 @@ These issues will be addressed/resolved in the future.
-
-
Programming Hints
+Programming Hints
- Use the built-in library functions whenever possible. @@ -141,8 +171,7 @@ These issues will be addressed/resolved in the future.
Stand-alone GLSL Compiler
+Stand-alone GLSL Compiler
The stand-alone GLSL compiler program can be used to compile GLSL shaders @@ -151,7 +180,7 @@ into low-level GPU code.
This tool is useful for: -
+
- Inspecting GPU code to gain insight into compilation
- Generating initial GPU code for subsequent hand-tuning @@ -159,7 +188,7 @@ This tool is useful for:
-After building Mesa, the compiler can be found at src/glsl/glsl_compiler +After building Mesa, the compiler can be found at src/compiler/glsl/glsl_compiler
@@ -167,7 +196,7 @@ Here's an example of using the compiler to compile a vertex shader and emit GL_ARB_vertex_program-style instructions:
- src/glsl/glsl_compiler --dump-ast myshader.vert + src/compiler/glsl/glsl_compiler --version XXX --dump-ast myshader.vert
Options include @@ -175,18 +204,19 @@ Options include- --dump-ast - dump GPU code
- --dump-hir - dump high-level IR code
- --dump-lir - dump low-level IR code -
- --link - ??? +
- --dump-builder - dump GLSL IR code +
- --link - link shaders +
- --just-log - display only shader / linker info if exist, +without any header or separator +
- --version - [Mandatory] define the GLSL version to use
Compiler Implementation
+Compiler Implementation
The source code for Mesa's shading language compiler is in the
-src/glsl/
directory.
+src/compiler/glsl/
directory.
@@ -199,54 +229,7 @@ The final vertex and fragment programs may be interpreted in software (see drivers/dri/i915/i915_fragprog.c for example).
-Code Generation Options
- --Internally, there are several options that control the compiler's code -generation and instruction selection. -These options are seen in the gl_shader_state struct and may be set -by the device driver to indicate its preferences: - -
-struct gl_shader_state -{ - ... - /** Driver-selectable options: */ - GLboolean EmitHighLevelInstructions; - GLboolean EmitCondCodes; - GLboolean EmitComments; -}; -- -
-
-
- EmitHighLevelInstructions
-
-This option controls instruction selection for loops and conditionals. -If the option is set high-level IF/ELSE/ENDIF, LOOP/ENDLOOP, CONT/BRK -instructions will be emitted. -Otherwise, those constructs will be implemented with BRA instructions. -
-
- - EmitCondCodes
-
-If set, condition codes (ala GL_NV_fragment_program) will be used for -branching and looping. -Otherwise, ordinary registers will be used (the IF instruction will -examine the first operand's X component and do the if-part if non-zero). -This option is only relevant if EmitHighLevelInstructions is set. -
-
- - EmitComments
-
-If set, instructions will be annoted with comments to help with debugging. -Extra NOP instructions will also be inserted. - - -
Compiler Validation
+Compiler Validation
Developers working on the GLSL compiler should test frequently to avoid @@ -254,15 +237,14 @@ regressions.
-The Piglit project -has many GLSL tests and the -Glean glsl1 test -tests GLSL features. +The Piglit project +has many GLSL tests.
The Mesa demos repository also has some good GLSL tests.
- - +