From: Brian Paul
Example: export MESA_GLSL=dump,nopt
@@ -59,30 +59,28 @@ Example: export MESA_GLSL=dump,nopt
-
-GLSL version 1.20 is supported in Mesa 7.3 and later.
-Among the features/differences of GLSL 1.20 are:
+The GLSL compiler currently supports version 1.20 of the shading language.
+
+Several GLSL extensions are also supported:
+ XXX update this section
The following features of the shading language are not yet fully supported
in Mesa:
@@ -130,39 +128,6 @@ These issues will be addressed/resolved in the future.
-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.
@@ -201,59 +159,25 @@ This tool is useful for:
-After building Mesa, the glslcompiler can be built by manually running:
+After building Mesa, the compiler can be found at src/glsl/glsl_compiler
Here's an example of using the compiler to compile a vertex shader and
emit GL_ARB_vertex_program-style instructions:
-results in:
-
-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.
-
-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 source code for Mesa's shading language compiler is in the
-
-The compiler follows a fairly standard design and basically works as follows:
+XXX provide some info about the compiler....
The final vertex and fragment programs may be interpreted in software
@@ -351,20 +249,20 @@ Extra NOP instructions will also be inserted.
-A Glean test has
-been create to exercise the GLSL compiler.
-
-The glsl1 test runs over 170 sub-tests to check that the language
-features and built-in functions work properly.
-This test should be run frequently while working on the compiler to catch
+Developers working on the GLSL compiler should test frequently to avoid
regressions.
-The test coverage is reasonably broad and complete but additional tests
-should be added.
+The Piglit project
+has many GLSL tests and the
+Glean glsl1 test
+tests GLSL features.
+The Mesa demos repository also has some good GLSL tests.
+GLSL 1.20 support
+GLSL Version
-
-
mat2x3, mat2x4
, etc. types and functions
-transpose(), outerProduct(), matrixCompMult()
functions
-(but untested)
-invariant
qualifier
-array.length()
method
-float[5] a;
array syntax
-centroid
qualifier
-Unsupported Features
+Programming Hints
-
@@ -182,13 +145,8 @@ These issues will be addressed/resolved in the future.
-
- void main()
- {
- vec4 a1, a2, b1, b2;
- gl_Position = expression using a1, a2.
- gl_Color = expression using b1, b2;
- }
-
- Can be rewritten as follows to use half as many registers:
-
- void main()
- {
- {
- vec4 a1, a2;
- gl_Position = expression using a1, a2.
- }
- {
- vec4 b1, b2;
- gl_Color = expression using b1, b2;
- }
- }
-
- Alternately, rather than using several float variables, use
- a vec4 instead. Use swizzling and writemasks to access the
- components of the vec4 as floats.
-
@@ -172,8 +137,6 @@ These issues will be addressed/resolved in the future.
float x = inversesqrt(y);
-Stand-alone GLSL Compiler
- make realclean
- make linux
- cd src/mesa/drivers/glslcompiler
- make
-
-
- bin/glslcompiler --debug --numbers --fs progs/glsl/CH06-brick.frag.txt
-
-
-# Fragment Program/Shader
- 0: RCP TEMP[4].x, UNIFORM[2].xxxx;
- 1: RCP TEMP[4].y, UNIFORM[2].yyyy;
- 2: MUL TEMP[3].xy, VARYING[0], TEMP[4];
- 3: MOV TEMP[1], TEMP[3];
- 4: MUL TEMP[0].w, TEMP[1].yyyy, CONST[4].xxxx;
- 5: FRC TEMP[1].z, TEMP[0].wwww;
- 6: SGT.C TEMP[0].w, TEMP[1].zzzz, CONST[4].xxxx;
- 7: IF (NE.wwww); # (if false, goto 9);
- 8: ADD TEMP[1].x, TEMP[1].xxxx, CONST[4].xxxx;
- 9: ENDIF;
- 10: FRC TEMP[1].xy, TEMP[1];
- 11: SGT TEMP[2].xy, UNIFORM[3], TEMP[1];
- 12: MUL TEMP[1].z, TEMP[2].xxxx, TEMP[2].yyyy;
- 13: LRP TEMP[0], TEMP[1].zzzz, UNIFORM[0], UNIFORM[1];
- 14: MUL TEMP[0].xyz, TEMP[0], VARYING[1].xxxx;
- 15: MOV OUTPUT[0].xyz, TEMP[0];
- 16: MOV OUTPUT[0].w, CONST[4].yyyy;
- 17: END
+ src/glsl/glslcompiler --dump-ast myshader.vert
-
+
+
@@ -262,38 +186,12 @@ and NV languagues, should improve.
src/mesa/shader/slang/
directory.
+src/glsl/
directory.
-
Compiler Validation