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
32 <li>Not all built-in OpenGL state variables are supported yet.
33 Common variables such as gl_ModelViewMatrix and gl_NormalMatrix
35 <li>Integer operations are not fully implemented (most are implemented
40 All other major features of the shading language should function.
44 <h2>Implementation Notes
</h2>
47 <li>Shading language programs are compiled into low-level programs
48 very similar to those of GL_ARB_vertex/fragment_program.
49 <li>All vector types (vec2, vec3, vec4, bvec2, etc) currently occupy full
51 <li>Float constants and variables are packed so that up to four floats
52 can occupy one program parameter/register.
53 <li>All function calls are inlined.
54 <li>Shaders which use too many registers will not compile.
55 <li>The quality of generated code is pretty good, register usage is fair.
56 <li>Shader error detection and reporting of errors (InfoLog) is not
58 <li>There are massive memory leaks in the compiler.
62 These issues will be addressed/resolved in the future.
66 <h2>Programming Hints
</h2>
69 <li>Declare
<em>in
</em> function parameters as
<em>const
</em> whenever possible.
70 This improves the efficiency of function inlining.
73 <li>To reduce register usage, declare variables within smaller scopes.
74 For example, the following code:
79 gl_Position = expression using a1, a2.
80 gl_Color = expression using b1, b2;
83 Can be rewritten as follows to use half as many registers:
89 gl_Position = expression using a1, a2.
93 gl_Color = expression using b1, b2;
97 Alternately, rather than using several float variables, use
98 a vec4 instead. Use swizzling and writemasks to access the
99 components of the vec4 as floats.
102 <li>Use the built-in library functions whenever possible.
103 For example, instead of writing this:
105 float x =
1.0 / sqrt(y);
109 float x = inversesqrt(y);