3 <TITLE>Shading Language Support
</TITLE>
5 <link rel=
"stylesheet" type=
"text/css" href=
"mesa.css"></head>
9 <H1>Shading Language Support
</H1>
12 This page describes the features and status of Mesa's support for the
13 <a href=
"http://opengl.org/documentation/glsl/" target=
"_parent">
14 OpenGL Shading Language
</a>.
18 Last updated on
20 Jan
2007.
21 <h2>Unsupported Features
</h2>
24 The following features of the shading language are not yet supported
31 <li>Linking of multiple shaders is not supported
33 <li>Not all built-in OpenGL state variables are supported yet.
34 Common variables such as gl_ModelViewMatrix and gl_NormalMatrix
36 <li>Integer operations are not fully implemented (most are implemented
41 All other major features of the shading language should function.
45 <h2>Implementation Notes
</h2>
48 <li>Shading language programs are compiled into low-level programs
49 very similar to those of GL_ARB_vertex/fragment_program.
50 <li>All vector types (vec2, vec3, vec4, bvec2, etc) currently occupy full
52 <li>Float constants and variables are packed so that up to four floats
53 can occupy one program parameter/register.
54 <li>All function calls are inlined.
55 <li>Shaders which use too many registers will not compile.
56 <li>The quality of generated code is pretty good, register usage is fair.
57 <li>Shader error detection and reporting of errors (InfoLog) is not
59 <li>There are massive memory leaks in the compiler.
63 These issues will be addressed/resolved in the future.
67 <h2>Programming Hints
</h2>
70 <li>Declare
<em>in
</em> function parameters as
<em>const
</em> whenever possible.
71 This improves the efficiency of function inlining.
74 <li>To reduce register usage, declare variables within smaller scopes.
75 For example, the following code:
80 gl_Position = expression using a1, a2.
81 gl_Color = expression using b1, b2;
84 Can be rewritten as follows to use half as many registers:
90 gl_Position = expression using a1, a2.
94 gl_Color = expression using b1, b2;
98 Alternately, rather than using several float variables, use
99 a vec4 instead. Use swizzling and writemasks to access the
100 components of the vec4 as floats.
103 <li>Use the built-in library functions whenever possible.
104 For example, instead of writing this:
106 float x =
1.0 / sqrt(y);
110 float x = inversesqrt(y);