diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/contents.html | 1 | ||||
-rw-r--r-- | docs/relnotes-6.5.3.html | 16 | ||||
-rw-r--r-- | docs/shading.html | 242 |
3 files changed, 254 insertions, 5 deletions
diff --git a/docs/contents.html b/docs/contents.html index 693145c2e3c..21eca4df871 100644 --- a/docs/contents.html +++ b/docs/contents.html @@ -64,6 +64,7 @@ a:visited { <ul> <li><a href="http://sourceforge.net/projects/mesa3d" target="_parent">SourceForge homepage</a> <li><a href="repository.html" target="MainFrame">Source Code Repository</a> +<li><a href="shading.html" target="MainFrame">Shading Language</a> <li><a href="utilities.html" target="MainFrame">Utilities</a> <li><a href="helpwanted.html" target="MainFrame">Help Wanted</a> <li><a href="devinfo.html" target="MainFrame">Development Notes</a> diff --git a/docs/relnotes-6.5.3.html b/docs/relnotes-6.5.3.html index b3d2fe64556..27053c071b8 100644 --- a/docs/relnotes-6.5.3.html +++ b/docs/relnotes-6.5.3.html @@ -11,8 +11,7 @@ <H1>Mesa 6.5.3 Release Notes / (in progress)</H1> <p> -Mesa 6.5.3 is a 6.5 follow-on development release mostly consisting of -bug fixes</a>. +Mesa 6.5.3 is a 6.5 follow-on development release with many internal changes. </p> @@ -24,8 +23,14 @@ TBD <h2>New features</h2> <ul> +<li>OpenGL 2.0 support. +<li>Entirely new Shading Language code generator. +<li>Much faster software execution of vertex, fragment shaders. +<li>New vertex buffer object infrastructure (replaces old array_cache code). <li>Updated glext.h file (version 39) <li>Updated glxext.h file (version 18) +<li>GL_MAX_DRAWBUFFERS is now 4 (software rendering) so + "multiple render targets" are really supported. </ul> <h2>Bug fixes</h2> @@ -33,6 +38,7 @@ TBD <li>Fog was errantly applied when a fragment shader was enabled (bug 9346) <li>glPush/PopClientAttrib didn't handle VBO bindings correctly (bug 9445) <li>With 32-bit Z buffer, the fragment Z of lines and points was sometimes wrong. +<li>GL_POST_CONVOLUTION_ALPHA_BIAS/SCALE was broken. <li>1D convolution state could effect 2D image transfers </ul> @@ -40,6 +46,7 @@ TBD <h2>Internal code changes</h2> <ul> +<li>Massive changes to the Shading Language compiler. <li>The _MaintainTnlProgram, _MaintainTexEnvProgram, _TexEnvProgram and _TnlProgram fields have been moved. <li>The ctx->FragmentProgram._Active field has been removed. @@ -53,7 +60,6 @@ fixed-function program. <h2>To Do (someday) items</h2> <ul> <li>Switch to freeglut -<li>Increase MAX_DRAWBUFFERS <li>Fix linux-glide target/driver. <li>Improved lambda and derivative calculation for frag progs. </ul> @@ -65,8 +71,8 @@ fixed-function program. Driver Status ---------------------- ---------------------- DRI drivers varies with the driver -XMesa/GLX (on Xlib) implements OpenGL 1.5 -OSMesa (off-screen) implements OpenGL 1.5 +XMesa/GLX (on Xlib) implements OpenGL 2.0 +OSMesa (off-screen) implements OpenGL 2.0 Glide (3dfx Voodoo1/2) implements OpenGL 1.3 SVGA implements OpenGL 1.3 Wind River UGL implements OpenGL 1.3 diff --git a/docs/shading.html b/docs/shading.html new file mode 100644 index 00000000000..cb2c1c3209b --- /dev/null +++ b/docs/shading.html @@ -0,0 +1,242 @@ +<HTML> + +<TITLE>Shading Language Support</TITLE> + +<link rel="stylesheet" type="text/css" href="mesa.css"></head> + +<BODY> + +<H1>Shading Language Support</H1> + +<p> +This page describes the features and status of Mesa's support for the +<a href="http://opengl.org/documentation/glsl/" target="_parent"> +OpenGL Shading Language</a>. +</p> + +<p> +Last updated on 17 Feb 2007. +</p> + +<p> +Contents +</p> +<ul> +<li><a href="#unsup">Unsupported Features</a> +<li><a href="#notes">Implementation Notes</a> +<li><a href="#hints">Programming Hints</a> +<li><a href="#standalone">Stand-alone Compiler</a> +<li><a href="#implementation">Compiler Implementation</a> +</ul> + + +<a name="unsup"> +<h2>Unsupported Features</h2> + +<p> +The following features of the shading language are not yet supported +in Mesa: +</p> + +<ul> +<li>Dereferencing arrays with non-constant indexes +<li>User-defined structs +<li>Linking of multiple shaders is not supported +<li>Integer operations are not fully implemented (most are implemented + as floating point). +<li>gl_ClipVertex +</ul> + +<p> +All other major features of the shading language should function. +</p> + + +<a name="notes"> +<h2>Implementation Notes</h2> + +<ul> +<li>Shading language programs are compiled into low-level programs + very similar to those of GL_ARB_vertex/fragment_program. +<li>All vector types (vec2, vec3, vec4, bvec2, etc) currently occupy full + float[4] registers. +<li>Float constants and variables are packed so that up to four floats + can occupy one program parameter/register. +<li>All function calls are inlined. +<li>Shaders which use too many registers will not compile. +<li>The quality of generated code is pretty good, register usage is fair. +<li>Shader error detection and reporting of errors (InfoLog) is not + very good yet. +<li>There are massive memory leaks in the compiler. +</ul> + +<p> +These issues will be addressed/resolved in the future. +</p> + + +<a name="hints"> +<h2>Programming Hints</h2> + +<ul> +<li>Declare <em>in</em> function parameters as <em>const</em> whenever possible. + This improves the efficiency of function inlining. +</li> +<br> +<li>To reduce register usage, declare variables within smaller scopes. + For example, the following code: +<pre> + void main() + { + vec4 a1, a2, b1, b2; + gl_Position = expression using a1, a2. + gl_Color = expression using b1, b2; + } +</pre> + Can be rewritten as follows to use half as many registers: +<pre> + void main() + { + { + vec4 a1, a2; + gl_Position = expression using a1, a2. + } + { + vec4 b1, b2; + gl_Color = expression using b1, b2; + } + } +</pre> + Alternately, rather than using several float variables, use + a vec4 instead. Use swizzling and writemasks to access the + components of the vec4 as floats. +</li> +<br> +<li>Use the built-in library functions whenever possible. + For example, instead of writing this: +<pre> + float x = 1.0 / sqrt(y); +</pre> + Write this: +<pre> + float x = inversesqrt(y); +</pre> +</ul> + + +<a name="standalone"> +<h2>Stand-alone Compiler</h2> + +<p> +A unique stand-alone GLSL compiler driver has been added to Mesa. +<p> + +<p> +The stand-alone compiler (like a conventional command-line compiler) +is a tool that accepts Shading Language programs and emits low-level +GPU programs. +</p> + +<p> +This tool is useful for: +<p> +<ul> +<li>Inspecting GPU code to gain insight into compilation +<li>Generating initial GPU code for subsequent hand-tuning +<li>Debugging the GLSL compiler itself +</ul> + +<p> +To build the glslcompiler program (this will be improved someday): +</p> +<pre> + cd src/mesa + make libmesa.a + cd drivers/glslcompiler + make +</pre> + + +<p> +Here's an example of using the compiler to compile a vertex shader and +emit GL_ARB_vertex_program-style instructions: +</p> +<pre> + glslcompiler --arb --linenumbers --vs vertshader.txt +</pre> +<p> +The output may look similar to this: +</p> +<pre> +!!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 +</pre> + +<p> +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. +</p> +<p> +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. +</p> + + + +<a name="implementation"> +<h2>Compiler Implementation</h2> + +<p> +The source code for Mesa's shading language compiler is in the +<code>src/mesa/shader/slang/</code> directory. +</p> + +<p> +The compiler follows a fairly standard design and basically works as follows: +</p> +<ul> +<li>The input string is tokenized (see grammar.c) and parsed +(see slang_compiler_*.c) to produce an Abstract Syntax Tree (AST). +The nodes in this tree are slang_operation structures +(see slang_compile_operation.h). +The nodes are decorated with symbol table, scoping and datatype information. +<li>The AST is converted into an Intermediate representation (IR) tree +(see the slang_codegen.c file). +The IR nodes represent basic GPU instructions, like add, dot product, +move, etc. +The IR tree is mostly a binary tree, but a few nodes have three or four +children. +In principle, the IR tree could be executed by doing an in-order traversal. +<li>The IR tree is traversed in-order to emit code (see slang_emit.c). +This is also when registers are allocated to store variables and temps. +<li>In the future, a pattern-matching code generator-generator may be +used for code generation. +Programs such as L-BURG (Bottom-Up Rewrite Generator) and Twig look for +patterns in IR trees, compute weights for subtrees and use the weights +to select the best instructions to represent the sub-tree. +<li>The emitted GPU instructions (see prog_instruction.h) are stored in a +gl_program object (see mtypes.h). +<li>When a fragment shader and vertex shader are linked (see slang_link.c) +the varying vars are matched up, uniforms are merged, and vertex +attributes are resolved (rewriting instructions as needed). +</ul> + +<p> +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). +</p> + + + +</BODY> +</HTML> |