head 1.2; access; symbols netbsd-8-3-RELEASE:1.1.1.6 netbsd-9-4-RELEASE:1.1.1.7 netbsd-9-3-RELEASE:1.1.1.7 netbsd-9-2-RELEASE:1.1.1.7 netbsd-9-1-RELEASE:1.1.1.7 netbsd-8-2-RELEASE:1.1.1.6 netbsd-9-0-RELEASE:1.1.1.7 netbsd-9-0-RC2:1.1.1.7 netbsd-9-0-RC1:1.1.1.7 mesalib-19-1-7:1.1.1.8 netbsd-9:1.1.1.7.0.2 netbsd-9-base:1.1.1.7 mesa-18-3-6:1.1.1.7 netbsd-8-1-RELEASE:1.1.1.6 netbsd-8-1-RC1:1.1.1.6 mesa-18-3-4:1.1.1.7 netbsd-7-2-RELEASE:1.1.1.5.2.1 netbsd-8-0-RELEASE:1.1.1.6 netbsd-8-0-RC2:1.1.1.6 netbsd-8-0-RC1:1.1.1.6 netbsd-7-1-2-RELEASE:1.1.1.5.2.1 netbsd-7-1-1-RELEASE:1.1.1.5.2.1 netbsd-8:1.1.1.6.0.2 netbsd-8-base:1.1.1.6 netbsd-7-1:1.1.1.5.2.1.0.4 netbsd-7-1-RELEASE:1.1.1.5.2.1 netbsd-7-1-RC2:1.1.1.5.2.1 netbsd-7-1-RC1:1.1.1.5.2.1 netbsd-7-0-2-RELEASE:1.1.1.5.2.1 netbsd-7-0-1-RELEASE:1.1.1.5.2.1 netbsd-7-0:1.1.1.5.2.1.0.2 netbsd-7-0-RELEASE:1.1.1.5.2.1 netbsd-7-0-RC3:1.1.1.5.2.1 netbsd-7-0-RC2:1.1.1.5.2.1 netbsd-7-0-RC1:1.1.1.5.2.1 MesaLib-10-3-5:1.1.1.6 netbsd-5-2-3-RELEASE:1.1.1.1.2.1 netbsd-5-1-5-RELEASE:1.1.1.1.2.1 netbsd-6-0-6-RELEASE:1.1.1.4 netbsd-6-1-5-RELEASE:1.1.1.4 netbsd-7:1.1.1.5.0.2 netbsd-7-base:1.1.1.5 MesaLib-7-11-2:1.1.1.5 netbsd-6-1-4-RELEASE:1.1.1.4 netbsd-6-0-5-RELEASE:1.1.1.4 riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.4 riastradh-drm2:1.1.1.4.0.8 riastradh-drm2-base:1.1.1.4 netbsd-6-1-3-RELEASE:1.1.1.4 netbsd-6-0-4-RELEASE:1.1.1.4 netbsd-5-2-2-RELEASE:1.1.1.1.2.1 netbsd-5-1-4-RELEASE:1.1.1.1.2.1 netbsd-6-1-2-RELEASE:1.1.1.4 netbsd-6-0-3-RELEASE:1.1.1.4 netbsd-5-2-1-RELEASE:1.1.1.1.2.1 netbsd-5-1-3-RELEASE:1.1.1.1.2.1 netbsd-6-1-1-RELEASE:1.1.1.4 netbsd-6-1:1.1.1.4.0.6 netbsd-6-0-2-RELEASE:1.1.1.4 netbsd-6-1-RELEASE:1.1.1.4 netbsd-6-1-RC4:1.1.1.4 netbsd-6-1-RC3:1.1.1.4 netbsd-6-1-RC2:1.1.1.4 netbsd-6-1-RC1:1.1.1.4 netbsd-5-2:1.1.1.1.2.1.0.4 netbsd-6-0-1-RELEASE:1.1.1.4 netbsd-5-2-RELEASE:1.1.1.1.2.1 netbsd-5-2-RC1:1.1.1.1.2.1 netbsd-6-0:1.1.1.4.0.4 netbsd-6-0-RELEASE:1.1.1.4 netbsd-6-0-RC2:1.1.1.4 netbsd-6-0-RC1:1.1.1.4 netbsd-6:1.1.1.4.0.2 netbsd-6-base:1.1.1.4 netbsd-5-1-2-RELEASE:1.1.1.1.2.1 netbsd-5-1-1-RELEASE:1.1.1.1.2.1 netbsd-5-1:1.1.1.1.2.1.0.2 netbsd-5-1-RELEASE:1.1.1.1.2.1 netbsd-5-1-RC4:1.1.1.1.2.1 MesaLib-7-8-2:1.1.1.4 netbsd-5-1-RC3:1.1.1.1.2.1 MesaLib-7-7-1:1.1.1.3 netbsd-5-1-RC2:1.1.1.1.2.1 netbsd-5-1-RC1:1.1.1.1.2.1 netbsd-5-0-2-RELEASE:1.1.1.1 MesaLib-7-4-4:1.1.1.2 netbsd-5-0-1-RELEASE:1.1.1.1 MesaLib-7-4-2:1.1.1.2 netbsd-5-0:1.1.1.1.0.4 netbsd-5-0-RELEASE:1.1.1.1 netbsd-5-0-RC4:1.1.1.1 netbsd-5-0-RC3:1.1.1.1 netbsd-5-0-RC2:1.1.1.1 netbsd-5-0-RC1:1.1.1.1 netbsd-5:1.1.1.1.0.2 netbsd-5-base:1.1.1.1 MesaLib-7-0-3:1.1.1.1 xorg:1.1.1; locks; strict; comment @# @; 1.2 date 2022.05.09.01.27.12; author mrg; state dead; branches; next 1.1; commitid vdvqJ71xlVGCRjDD; 1.1 date 2008.07.29.05.08.18; author mrg; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2008.07.29.05.08.18; author mrg; state Exp; branches 1.1.1.1.2.1; next 1.1.1.2; 1.1.1.2 date 2009.06.11.00.50.15; author mrg; state Exp; branches; next 1.1.1.3; 1.1.1.3 date 2010.05.23.21.22.15; author mrg; state Exp; branches; next 1.1.1.4; 1.1.1.4 date 2010.07.19.05.31.51; author mrg; state Exp; branches; next 1.1.1.5; 1.1.1.5 date 2014.07.09.19.38.34; author riastradh; state Exp; branches 1.1.1.5.2.1; next 1.1.1.6; commitid h96CLViPL8qdRJHx; 1.1.1.6 date 2014.12.18.06.02.09; author mrg; state Exp; branches; next 1.1.1.7; commitid tzEjkwzaREfP8u2y; 1.1.1.7 date 2019.03.10.03.42.48; author mrg; state Exp; branches; next 1.1.1.8; commitid r12jo1Nf3ebQKLeB; 1.1.1.8 date 2019.09.24.16.19.49; author maya; state Exp; branches; next ; commitid KJXusGl8fi9AAhEB; 1.1.1.1.2.1 date 2009.09.17.03.32.04; author snj; state Exp; branches; next ; 1.1.1.5.2.1 date 2015.01.05.20.58.25; author martin; state Exp; branches; next ; commitid 1yEFPaBBlEWKuS4y; desc @@ 1.2 log @merge mesa 21.3.7. @ text @
This page describes the features and status of Mesa's support for the OpenGL Shading Language.
Last updated on 28 March 2007.
Contents
The following features of the shading language are not yet supported in Mesa:
All other major features of the shading language should function.
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.
float x = 1.0 / sqrt(y);Write this:
float x = inversesqrt(y);
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.
This tool is useful for:
To build the glslcompiler program (this will be improved someday):
cd src/mesa make libmesa.a cd drivers/glslcompiler make
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
The output may look similar to this:
!!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.
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
src/mesa/shader/slang/
directory.
The compiler follows a fairly standard design and basically works as follows:
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).
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; };
A new Glean test has been create to exercise the GLSL compiler.
The glsl1 test runs over 150 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 regressions.
The test coverage is reasonably broad and complete but additional tests should be added.