ARB (GPU assembly language)
Encyclopedia
ARB - OpenGL Assembly Language is a low-level shading language
Shading language
A shading language is a special programming language adapted to map on shader programming. Those kind of languages usually have special data types like color and normal...

. It was created by the OpenGL ARB to standardize GPU instructions controlling the hardware graphics pipeline
Graphics pipeline
In 3D computer graphics, the terms graphics pipeline or rendering pipeline most commonly refers to the current state of the art method of rasterization-based rendering as supported by commodity graphics hardware. The graphics pipeline typically accepts some representation of a three-dimensional...

.

History

Texas Instruments
Texas Instruments
Texas Instruments Inc. , widely known as TI, is an American company based in Dallas, Texas, United States, which develops and commercializes semiconductor and computer technology...

 created the first programmable graphics processor in 1985: the TMS34010
TMS34010
The TMS34010 was the first programmable graphics processor integrated circuit . First silicon was working at Texas Instruments in Houston in December 1985, and first shipment was to IBM's workstation facility in Kingston, New York, in January 1986...

, which allowed developers to load and execute code on the processor to control pixel
Pixel
In digital imaging, a pixel, or pel, is a single point in a raster image, or the smallest addressable screen element in a display device; it is the smallest unit of picture that can be represented or controlled....

 output on a video display. This was followed by the TMS34020 and TMS34082 in 1989, providing programmable 3D graphics output.

NVIDIA
NVIDIA
Nvidia is an American global technology company based in Santa Clara, California. Nvidia is best known for its graphics processors . Nvidia and chief rival AMD Graphics Techonologies have dominated the high performance GPU market, pushing other manufacturers to smaller, niche roles...

 released its first video card NV1
NV1
Nvidia NV1, manufactured by SGS-THOMSON Microelectronics under the model name STG2000, was a multimedia PCI card released in 1995 and sold to retail as the Diamond Edge 3D. It featured a complete 2D/3D graphics core based upon quadratic texture mapping, VRAM or FPM DRAM memory, an integrated...

 in 1995, which supported quadratic texture mapping. This was followed by the Riva 128
RIVA 128
Released in late 1997 by Nvidia, the RIVA 128, or "NV3", was one of the first consumer graphics processing units to integrate 3D acceleration in addition to traditional 2D and video acceleration...

 (NV3) in 1997, providing the first hardware acceleration for Direct3D
Direct3D
Direct3D is part of Microsoft's DirectX application programming interface . Direct3D is available for Microsoft Windows operating systems , and for other platforms through the open source software Wine. It is the base for the graphics API on the Xbox and Xbox 360 console systems...

.

Various video card vendors released their own accelerated boards, each with their own instruction set for GPU operations. The OpenGL Architecture Review Board
OpenGL Architecture Review Board
The OpenGL Architecture Review Board is an industry consortium that governed the OpenGL specification.It was formed in 1992, and defined the conformance tests, approved the OpenGL specification and advanced the standard...

 (ARB) was formed in 1992, in part to establish standards for the GPU industry.

The ARB and NVIDIA
NVIDIA
Nvidia is an American global technology company based in Santa Clara, California. Nvidia is best known for its graphics processors . Nvidia and chief rival AMD Graphics Techonologies have dominated the high performance GPU market, pushing other manufacturers to smaller, niche roles...

 established a number of OpenGL
OpenGL
OpenGL is a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics. The interface consists of over 250 different function calls which can be used to draw complex three-dimensional scenes from simple primitives. OpenGL...

 extensions to standardize GPU programming:
  • EXT_texture_env_combine - provided a programmable method of combining textures.
  • NV_register_combiners - GeForce 256
  • NV_vertex_program - GeForce 3
  • NV_texture_shader - GeForce 3
  • NV_texture_shader3 - GeForce 4
  • NV_vertex_program2 - GeForce FX
  • NV_fragment_program - GeForce FX


This culminated with ARB
OpenGL Architecture Review Board
The OpenGL Architecture Review Board is an industry consortium that governed the OpenGL specification.It was formed in 1992, and defined the conformance tests, approved the OpenGL specification and advanced the standard...

's 2002 release of
  • ARB_vertex_program
  • ARB_fragment_program


These two extensions provided an industry standard for an assembly language that controlled the GPU pipeline for 3D vertex and interpolated pixel properties, respectively.

Subsequent high-level shading language
Shading language
A shading language is a special programming language adapted to map on shader programming. Those kind of languages usually have special data types like color and normal...

s sometimes compile to this ARB standard. While 3D developers are now more likely to use a C-like, high-level shading language for GPU programming, ARB assembly has the advantage of being supported on a wide range of hardware.

Note however that some features, such as loops and conditionals, are not available in ARB assembly, and using them requires to adopt either the NV_gpu_program4 extension, or the GLSL shading language.

Most non-nVidia OpenGL implementations do not provide the nVidia ARB assembly extension and do not offer any other way to access all the shader features directly in assembly, forcing the use of GLSL even for machine generated shaders where assembly would be more appropriate.

ARB_vertex_program

The ARB Vertex Program extension provides APIs to load ARBvp1.0 assembly instructions, enable selected programs, and to set various GPU parameters.

Vertex programs are used to modify vertex properties, such as position, normals and texture coordinates, that are passed to the next pipeline process: often a fragment shader; more recently, a geometry shader.

ARB_fragment_program

The ARB Fragment Program extension provides APIs to load ARBfp1.0 assembly instructions, enable selected programs, and to set various GPU parameters.

OpenGL
OpenGL
OpenGL is a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics. The interface consists of over 250 different function calls which can be used to draw complex three-dimensional scenes from simple primitives. OpenGL...

 fragments are interpolated pixel definitions. The GPU's vertex processor calculates all the pixels controlled by a set of vertices, interpolates their position and other properties and passes them onto its fragment process. Fragment programs allow developers to modify these pixel properties before they are rendered to a frame buffer for display.

OpenGL Parameters

  • Attrib parameters are per-vertex attributes such as vertex normals.

  • Local parameters are applied across a program's entire data set for a given shader pass.

  • Env parameters are applied across all programs.

ARB Variables

All ARB assembly variables are float4 vectors, which may be addressed by xyzw or rgba suffixes.

ARB registers are scalar variables where only one element may be addressed.
  • ADDRESS variables are registers.

  • ATTRIB are per-vertex attributes.

  • PARAM are uniform properties - constants, Env or Local.

  • TEMP temporary variables.

  • ALIAS provides alternate names for variables.

  • OUTPUT designates variables that are passed back to the pipeline.

Vertex Attributes

ARB assembly supports the following suffixes for vertex attributes:
  • position
  • weight
  • normal
  • color
  • fogcoord
  • texcoord
  • matrixindex
  • attrib

State Matrices

ARB assembly supports the following state matrices:
  • modelview
  • projection
  • texture
  • palette
  • program


The following modifiers may be used:
  • inverse
  • transpose
  • invtrans

ARB Assembly Instructions

ARB supports the following instructions:
  • ABS - absolute value
  • ADD - add
  • ARL - address register load
  • DP3 - 3-component dot product
    Dot product
    In mathematics, the dot product or scalar product is an algebraic operation that takes two equal-length sequences of numbers and returns a single number obtained by multiplying corresponding entries and then summing those products...

  • DP4 - 4-component dot product
    Dot product
    In mathematics, the dot product or scalar product is an algebraic operation that takes two equal-length sequences of numbers and returns a single number obtained by multiplying corresponding entries and then summing those products...

  • DPH - homogeneous dot product
    Dot product
    In mathematics, the dot product or scalar product is an algebraic operation that takes two equal-length sequences of numbers and returns a single number obtained by multiplying corresponding entries and then summing those products...

  • DST - distance vector
  • EX2 - exponential base 2
  • EXP - exponential base 2 (approximate)
  • FLR - floor
  • FRC - fraction
  • LG2 - logarithm base 2
  • LIT - compute light coefficients
  • LOG - logarithm base 2 (approximate)
  • MAD - multiply and add
  • MAX - maximum
  • MIN - minimum
  • MOV - move
  • MUL - multiply
  • POW - exponentiate
  • RCP - reciprocal
  • RSQ - reciprocal square root
  • SGE - set on greater than or equal
  • SLT - set on less than
  • SUB - subtract
  • SWZ - extended swizzle
  • XPD - cross product
    Cross product
    In mathematics, the cross product, vector product, or Gibbs vector product is a binary operation on two vectors in three-dimensional space. It results in a vector which is perpendicular to both of the vectors being multiplied and normal to the plane containing them...



This is only a partial list of assembly instructions ; a reference can be found here : Shader Assembly Language (ARB/NV) Quick Reference Guide for OpenGL.

ARB assembly provides no instructions for flow control or branching. SGE and SLT may be used to conditionally set or clear vectors or registers.

ARB interfaces provide no compiling step for assembly language.

GL_NV_fragment_program_option extends the ARB_fragment_program language with additional instructions.
GL_NV_fragment_program2, GL_NV_vertex_program2_option and GL_NV_vertex_program3 extend it further.

A sample trivial ARB Vertex Shader


!!ARBvp1.0
TEMP vertexClip;
DP4 vertexClip.x, state.matrix.mvp.row[0], vertex.position;
DP4 vertexClip.y, state.matrix.mvp.row[1], vertex.position;
DP4 vertexClip.z, state.matrix.mvp.row[2], vertex.position;
DP4 vertexClip.w, state.matrix.mvp.row[3], vertex.position;
MOV result.position, vertexClip;
MOV result.color, vertex.color;
MOV result.texcoord[0], vertex.texcoord;
END

A sample trivial ARB Fragment Shader


!!ARBfp1.0
TEMP color;
MUL color, fragment.texcoord[0].y, 2.0;
ADD color, 1.0, -color;
ABS color, color;
ADD result.color, 1.0, -color;
MOV result.color.a, 1.0;
END

See also

  • OpenGL
    OpenGL
    OpenGL is a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics. The interface consists of over 250 different function calls which can be used to draw complex three-dimensional scenes from simple primitives. OpenGL...

  • OpenGL Architecture Review Board
    OpenGL Architecture Review Board
    The OpenGL Architecture Review Board is an industry consortium that governed the OpenGL specification.It was formed in 1992, and defined the conformance tests, approved the OpenGL specification and advanced the standard...

  • Shader Languages
    Shading language
    A shading language is a special programming language adapted to map on shader programming. Those kind of languages usually have special data types like color and normal...

  • Assembly Languages
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK