X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=docs%2Fshading.html;h=839a61a0361380dd00ff829aafe23e9f97f53b42;hb=3bca0af25dbf6d6b162463138100abb20bc1a1cc;hp=28bd645c5d52e7fa2fde3981873cff6cfa3804dc;hpb=61d31ae10daf3a59ccbf9bcc4cda3ca4fdd195aa;p=mesa.git diff --git a/docs/shading.html b/docs/shading.html index 28bd645c5d5..839a61a0361 100644 --- a/docs/shading.html +++ b/docs/shading.html @@ -1,51 +1,131 @@ - + + + + + Shading Language + + + -Shading Language Support +
+ The Mesa 3D Graphics Library +
- + +
- - -

Shading Language Support

+

Shading Language

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

-

-Last updated on 17 Feb 2007. -

-

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 +

+ +

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: +

+ +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. + +

Capturing Shaders

+ +

+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 3.30 of the shading language. +

+ +

+Several GLSL extensions are also supported: +

+ - -

Unsupported Features

+

Unsupported Features

+ +

XXX update this section

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

@@ -53,8 +133,7 @@ All other major features of the shading language should function.

-
-

Implementation Notes

+

Implementation Notes

@@ -76,43 +156,9 @@ These issues will be addressed/resolved in the future.

-
-

Programming Hints

+

Programming Hints

-
-

Stand-alone Compiler

+

Stand-alone GLSL Compiler

-A unique stand-alone GLSL compiler driver has been added to Mesa. -

- -

-The stand-alone compiler (like a conventional command-line compiler) -is a tool that accepts Shading Language programs and emits low-level -GPU programs. +The stand-alone GLSL compiler program can be used to compile GLSL shaders +into low-level GPU code.

This tool is useful for: -

+

-(compiler build instructions TBD) +After building Mesa, the compiler can be found at src/compiler/glsl/glsl_compiler

@@ -156,33 +197,55 @@ Here's an example of using the compiler to compile a vertex shader and emit GL_ARB_vertex_program-style instructions:

-    glslcompiler --arb --linenumbers --vs vertshader.txt
+    src/compiler/glsl/glsl_compiler --version XXX --dump-ast myshader.vert
 
+ +Options include + + + +

Compiler Implementation

+

-The output may look similar to this: +The source code for Mesa's shading language compiler is in the +src/compiler/glsl/ directory. +

+ +

+XXX provide some info about the compiler....

-
-!!ARBvp1.0
-  0: MOV result.texcoord[0], vertex.texcoord[0];
-  1: DP4 temp0.x, state.matrix.mvp.row[0], vertex.position;
-  2: DP4 temp0.y, state.matrix.mvp.row[1], vertex.position;
-  3: DP4 temp0.z, state.matrix.mvp.row[2], vertex.position;
-  4: DP4 temp0.w, state.matrix.mvp.row[3], vertex.position;
-  5: MOV result.position, temp0;
-  6: END
-

-Note that some shading language constructs (such as uniform and varying -variables) aren't expressible in ARB or NV-style programs. -Therefore, the resulting output is not always legal by definition of -those program languages. +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. +

+

-Also note that this compiler driver is still under development. -Over time, the correctness of the GPU programs, with respect to the ARB -and NV languagues, should improve. +The Mesa demos repository also has some good GLSL tests.

- - +
+ +