Name MESA_gpu_program3 Name Strings GL_MESA_vertex_program3 GL_MESA_fragment_program3 Contact Ian Romanick, Intel Corporation (ian.d.romanick 'at' intel.com) IP Status NVIDIA claims to own intellectual property related to ARB_vertex_program, and has signed an ARB Contributor License agreement licensing this intellectual property. Microsoft claims to own intellectual property related to ARB_vertex_program. Large portions of the text of this extension were extracted from the ARB_vertex_program, ARB_fragment_program, NV_vertex_program2_option, NV_gpu_program4, NV_vertex_program4, and NV_fragment_program4 extension specifications. Status Incomplete. DO NOT SHIP! Version October 19, 2009 (version 2) Number TBD Dependencies This extension is written against the OpenGL 2.0 specification. OpenGL 2.0 is not required, but we expect all implementations of this extension will also support OpenGL 2.0. ARB_vertex_program and ARB_fragment_program are required. This extension interacts with ARB_fragment_program_shadow. This extension interacts with ARB_draw_buffers and ATI_draw_buffers. ARB_texture_rectangle trivially affects the definition of this extension. ARB_texture_cube_map trivially affects the definition of this extension. Overview This specification documents the common instruction set and basic functionality provided by so-called Shader Model 3.0 GPUs. Such GPUs provide a variety of capabilities beyond those exposed by ARB_vertex_program and ARB_fragment_program. The instruction set document here builds on the basic framework provided by the ARB_vertex_program and ARB_fragment_program extensions. MESA_gpu_program3 provides a unified instruction set -- all instruction set features are available for all program types, except for a small number of features that make sense only for a specific program type. It provides a variety of new instructions and conditional write masking. It also provides a uniform set of structured branching constructs (if tests, loops, and subroutines) that fully support run-time condition testing. This extension exposes the following capabilities: * structured branching support, including: - data-dependent if-statements - loops supporting a fixed number of iterations - a data-dependent loop exit instruction * subroutine calls * data-dependent conditional write masks * address registers with four components (instead of just one) * address register-relative addressing for attribute and result arrays * absolute value operator on scalar and swizzled operand loads * SIN and COS trigonometry instructions in vertex programs * optional texture fetching in vertex programs * fully orthogonal "set on" instructions * instructions to compute partial derivatives and perform texture lookups using specified partial derivatives in fragment programs * result clamping to the range [0, 1] in vertex programs * centroid, constant, and non-perspective interpolation of fragment program attributes For the most part, vertex and fragment programs writing for ARB_vertex_program and ARB_fragment_program wishing to use this added functionality need only add: OPTION MESA_gpu_program3; to the beginning of their programs. New Procedures and Functions None New Tokens Accepted by the parameter of GetProgramivARB: MAX_PROGRAM_EXEC_INSTRUCTIONS_MESA 0x88F4 MAX_PROGRAM_CALL_DEPTH_MESA 0x88F5 MAX_PROGRAM_IF_DEPTH_MESA 0x88F6 MAX_PROGRAM_LOOP_DEPTH_MESA 0x88F7 MAX_PROGRAM_LOOP_COUNT_MESA 0x88F8 (note: These tokens share values with tokens of the NV_fragment_program2 extension.) MAX_PROGRAM_PREDICATE_REGISTERS_MESA 0x???? Accepted by the parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev: MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C Additions to Chapter 2 of the OpenGL 2.0 Specification (OpenGL Operation) Insert New Section 2.X between Sections 2.Y and 2.Z: Section 2.X, GPU Programs The GL provides a number of different program targets that allow an application to either replace certain fixed-function pipeline stages with a fully programmable model or use a program to control aspects of the GL pipeline that previously had only hard-wired behavior. A common base instruction set is available for all program types. Structured branching operations and subroutine calls are available. Texture mapping (loading data from external images) is supported for all program types. The main differences between the different program types are the set of available inputs and outputs, which are program type- specific, and a few instructions that are meaningful for only a subset of program types. Vertex Programs Vertex programs are used to compute the transformed attributes of a vertex, in lieu of the set of fixed-function operations described in sections 2.10 through 2.13. Vertex programs are run on a single vertex at a time, and the state of neighboring vertices is not available. The inputs available to a vertex program are the vertex attributes described in section 2.7. The results of the program are the attributes of a transformed vertex, which include (among other things) a transformed position, colors, and texture coordinates. The vertices transformed by a vertex program are then processed normally by the remainder of the GL pipeline. Fragment Programs Fragment programs are used to compute the transformed attributes of a fragment, in lieu of the set of fixed-function operations described in sections 3.8 through 3.10. Fragment programs are run on a single fragment at a time, and the state of neighboring fragments is not explicitly available. (In practice, fragment programs may be run on a block of fragments, and neighboring fragments' attributes may be used for texture LOD calculations or partial derivative approximation.) The inputs available to a fragment program are the interpolated attributes of a fragment, which include (among other things) window-space position, primary and secondary colors, and texture coordinates. The results of the program are one (or more) colors and possibly a new window Z coordinate. A fragment program can not modify the (X,Y) location of the fragment. Section 2.X.2, Program Grammar GPU program strings are specified as an array of ASCII characters containing the program text. When a GPU program is loaded by a call to ProgramStringARB, the program string is parsed into a set of tokens possibly separated by whitespace. Spaces, tabs, newlines, carriage returns, and comments are considered whitespace. Comments begin with the character "#" and are terminated by a newline, a carriage return, or the end of the program array. The Backus-Naur Form (BNF) grammar below specifies the syntactically valid sequences for GPU programs. The set of valid tokens can be inferred from the grammar. A line containing "/* empty */" represents an empty string and is used to indicate optional rules. A program is invalid if it contains any tokens or characters not defined in this specification. ::= "END" ::=