NAME

gp4fp - OpenGL fragment profile for G8x (GeForce 8xxx Series, G8x-based Quadro FX, etc.)

SYNOPSIS

  gp4fp

DESCRIPTION

This OpenGL profile corresponds to the per-fragment functionality introduced by the GeForce 8800 and other G8x-based NVIDIA GPUs.

The compiler output for this profile conforms to the assembly format defined by NV_gpu_program4 and ARB_fragment_program.

Note that the NV_gpu_program4 extension has its fragment domain-specific aspects documented in the NV_fragment_program4 specification.

Data-dependent loops and branching are allowed.

Relative indexing of uniform arrays is supported.

Parameter buffer objects (also known as "constant buffers" in DirectX 10 or "bindable uniform" in GLSL's EXT_bindable_uniform extension) provide a way to source uniform values from OpenGL buffer objects.

Texture accesses include support for texture arrays (see the EXT_texture_array OpenGL extension for more details) and texture buffer objects (see the EXT_texture_buffer_object extension for details). Texture results can be either conventional floating-point vectors or integer vectors (see the EXT_texture_integer extension for details).

3D API DEPENDENCIES

Requires OpenGL support for the NV_gpu_program4 extension. This extension was introduced by the GeForce 6800 and other G8x-based GPUs.

OpenGL Extension Specifications

Programmability:

 www.opengl.org/registry/specs/NV/gpu_program4.txt 
 www.opengl.org/registry/specs/NV/fragment_program4.txt 

New texture samplers:

 www.opengl.org/registry/specs/EXT/texture_array.txt 
 www.opengl.org/registry/specs/EXT/texture_buffer_object.txt 

New integer texture formats:

 www.opengl.org/registry/specs/EXT/texture_integer.txt 

Draw buffers:

  www.opengl.org/registry/specs/ARB/draw_buffers.txt
  www.opengl.org/registry/specs/ATI/draw_buffers.txt

PROFILE OPTIONS

Common GP4 Options

fastimul

Assume integer multiply inputs have at most 24 significant bits. Example: "-po fastimul"

Fragment Domain-specific GP4 Options

ARB_draw_buffers=val
ATI_draw_buffers=val

Indicates that the ARB_draw_buffers or ATI_draw_buffers OpenGL extension is supported and what the extension's implementation dependent value of GL_MAX_DRAW_BUFFERS_ARB or GL_MAX_DRAW_BUFFERS_ATI is.

When specified, the compiler generates the "OPTION ARB_draw_buffers;" or "OPTION ATI_draw_buffers;" in the compiled code to enable output to multiple draw buffers. Output to multiple draw buffers is done by specifying output parameters with the COLOR1, COLOR2, etc. semantics.

GPUs that support these extensions typically support up to 4 buffers.

These options are useful in the rare situation you want to control the specific OPTION name used. For example, Apple drivers support the ARB_draw_buffers extension but not the ATI_draw_buffers extension.

The CgGL runtime routine cgGLSetOptimalOptions will automatically add the appropriate option based on querying the current OpenGL context's extension support (prefering the ARB extension) and specify the proper limit.

DATA TYPES

Samplers

This profile has additional samplers for texture arrays (1D and 2D) and texture buffers.

Standard OpenGL textures formats (GL_RGBA8, etc.) return floating-point sampled results, but new signed and unsigned integer texture formats require samplers the return signed and unsigned integer vectors respectively. Sampler variants for fetching signed and unsigned integer vectors are prefixed by i and u respectively. Your application is required to make sure the bound textures have the appropriate texture format. So a 3D texture specified with the GL_RGBA32UI_EXT internal format (see the EXT_texture_integer OpenGL extension) must be used with a usampler3D sampler. Otherwise, texture sampling returns undefined results.

sampler1D

1D texture unit corresponding to OpenGL's GL_TEXTURE_1D target. Sampling returns float vectors.

isampler1D

1D texture unit corresponding to OpenGL's GL_TEXTURE_1D target. Sampling returns int vectors.

usampler1D

1D texture unit corresponding to OpenGL's GL_TEXTURE_1D target. Sampling returns unsigned int vectors.

sampler1DARRAY

1D array texture unit corresponding to OpenGL's GL_TEXTURE_1D_ARRAY_EXT target provided by the EXT_texture_array extension. Sampling returns float vectors.

isampler1DARRAY

1D array texture unit corresponding to OpenGL's GL_TEXTURE_1D_ARRAY_EXT target provided by the EXT_texture_array extension. Sampling returns int vectors.

usampler1DARRAY

1D array texture unit corresponding to OpenGL's GL_TEXTURE_1D_ARRAY_EXT target provided by the EXT_texture_array extension. Sampling returns unsigned int vectors.

sampler2D

2D texture unit corresponding to OpenGL's GL_TEXTURE_2D target. Sampling returns float vectors.

isampler2D

2D texture unit corresponding to OpenGL's GL_TEXTURE_2D target. Sampling returns int vectors.

usampler2D

2D texture unit corresponding to OpenGL's GL_TEXTURE_2D target. Sampling returns unsigned int vectors.

sampler2DARRAY

2D array texture unit corresponding to OpenGL's GL_TEXTURE_2D_ARRAY_EXT target provided by the EXT_texture_array extension. Sampling returns float vectors.

isampler2DARRAY

2D array texture unit corresponding to OpenGL's GL_TEXTURE_2D_ARRAY_EXT target provided by the EXT_texture_array extension. Sampling returns int vectors.

usampler2DARRAY

2D array texture unit corresponding to OpenGL's GL_TEXTURE_2D_ARRAY_EXT target provided by the EXT_texture_array extension. Sampling returns unsigned int vectors.

sampler3D

3D texture unit corresponding to OpenGL's GL_TEXTURE_3D target. Sampling returns float vectors.

isampler3D

3D texture unit corresponding to OpenGL's GL_TEXTURE_3D target. Sampling returns int vectors.

usampler3D

3D texture unit corresponding to OpenGL's GL_TEXTURE_3D target. Sampling returns unsigned int vectors.

samplerCUBE

Cube map texture unit corresponding to OpenGL's GL_TEXTURE_CUBE_MAP target. Sampling returns float vectors.

isamplerCUBE

Cube map texture unit corresponding to OpenGL's GL_TEXTURE_CUBE_MAP target. Sampling returns int vectors.

usamplerCUBE

Cube map texture unit corresponding to OpenGL's GL_TEXTURE_CUBE_MAP target. Sampling returns unsigned int vectors.

samplerRECT

Rectangle texture unit corresponding to OpenGL's GL_TEXTURE_RECTANGLE_ARB target. Sampling returns float vectors.

isamplerRECT

Rectangle texture unit corresponding to OpenGL's GL_TEXTURE_RECTANGLE_ARB target. Sampling returns int vectors.

isamplerRECT

Rectangle texture unit corresponding to OpenGL's GL_TEXTURE_RECTANGLE_ARB target. Sampling returns unsigned int vectors.

samplerBUF

Buffer texture unit corresponding to OpenGL's GL_TEXTURE_BUFFER_EXT target provided by the EXT_texture_buffer_object extension. Sampling returns float vectors.

isamplerBUF

Buffer texture unit corresponding to OpenGL's GL_TEXTURE_BUFFER_EXT target provided by the EXT_texture_buffer_object extension. Sampling returns int vectors.

usamplerBUF

Buffer texture unit corresponding to OpenGL's GL_TEXTURE_BUFFER_EXT target provided by the EXT_texture_buffer_object extension. Sampling returns unsigned int vectors.

Floating-point

float

32-bit IEEE floating-point

half

32-bit IEEE floating-point

double

32-bit IEEE floating-point

fixed

Floating-point restricted to [-2,2) range.

Integer

This profile supports "true" integer data types. Shifting and bitwise operators are supported for integer data types.

int

32-bit signed integer

unsigned int

32-bit unsigned integer

short

16-bit signed integer

unsigned short

16-bit unsigned integer

char

8-bit signed integer

unsigned char

8-bit unsigned integer

SEMANTICS

VARYING INPUT SEMANTICS

Interpolated Input Semantics

The varying input semantics in the gp4fp profile correspond to the respectively named varying output semantics of the gp4vp profile (or gp4gp if a geometry shader is present).

  Binding Semantics Name           Corresponding Data
  
  COLOR                            Input primary color
  COLOR0
  COL
  COL0
  
  COLOR1                           Input secondary color
  COL1   

  WPOS                             Window position (with lower-left origin)
  
  TEX0                             Input texture coordinate sets 0
  TEXCOORD0
 
  TEX1                             Input texture coordinate sets 1
  TEXCOORD1
 
  TEX2                             Input texture coordinate sets 2
  TEXCOORD2
 
  TEX3                             Input texture coordinate sets 3
  TEXCOORD3
  
  TEX4                             Input texture coordinate sets 4
  TEXCOORD4

  TEX5                             Input texture coordinate sets 5
  TEXCOORD5
  
  TEX6                             Input texture coordinate sets 6
  TEXCOORD6
 
  TEX7                             Input texture coordinate sets 7
  TEXCOORD7
  
  FOGP                             Input fog color (XYZ) and factor (W)
  FOG
 

Interpolation Semantic Modifiers

A number of interpolation semantic modifiers control how interpolation happens for the interpolated input semantics above. These modifiers are suffixed to the semantic name with a "." (period) seperator. Without a modifier, perspective-correct interpolation applies.

  Semantic Modifier Name           Meaning

  CENTROID                         Interpolate at the centroid of the covered samples
                                   (only applies when rendering to multisampled surface)
 
  FLAT                             Flat shading using provoking vertex's value
  
  NOPERSPECTIVE                    Interpolate without perspective correction

Examples:

  float4 a : TEXCOORD0
  float4 b : TEXCOORD1.CENTROID
  float4 c : TEXCOORD2.FLAT
  float4 d : TEXCOORD3.NOPERSPECTIVE

Per-primitive Input Semantics

  FACE                             Polygon facing.
                                   +1 for front-facing polygon or line or point
                                   -1 for back-facing polygon
 
  PRIMITIVEID                      Primitive ID (int)

If a geometry program is active, parameters given the PRIMITIVEID semantic obtained their integer value from the primitive ID value emitted by the geometry program for the provoking vertex. If no geometry program is active, the value is the number of primitives processed by the rasterizer since the last time glBegin was called (directly or indirectly via vertex array functions). The first primitive generated after a glBegin is numbered zero, and the primitive ID counter is incremented after every individual point, line, or polygon primitive is processed. For polygons drawn in point or line mode, the primitive ID counter is incremented only once, even though multiple points or lines may be drawn. For QUADS and QUAD_STRIP primitives that are decomposed into triangles, the primitive ID is incremented after each complete quad is processed. For POLYGON primitives, the primitive ID counter is zero. The primitive ID is zero for fragments generated by DrawPixels or Bitmap. Restarting a primitive topology using the primitive restart index has no effect on the primitive ID counter.

UNIFORM INPUT SEMANTICS

Buffer Semantics

gp4 profiles can specify that uniforms be specified to reside within binable buffers.

Example of automatic, compiler-determined specification of a uniform's location within a buffer:

  uniform float2 location   : BUFFER[3];  // compiler positions within buffer 3
  uniform float4 brickColor : BUFFER[3];  // compiler positions within buffer 3

Example of absolute byte offset specification of a uniform's locaiton within a buffer:

  uniform float4 mustBeHere : BUFFER[7][20];  // locate 20 bytes into buffer 7

Constant Register Semantics

  C0-C255           Constant register [0..255].
                    The aliases c0-c255 (lowercase) are also accepted.

If used with a variable that requires more than one constant register (e.g. a matrix), the semantic specifies the first register that is used.

Example:

  uniform float4 array[20] : C14;  // uses c14 through c33

Texture Unit Semantics

  TEXUNIT0-TEXUNIT15  Texture unit (but only 4 distinct texture units
                      are allowed)

Example:

  uniform sampler2DARRAY texArray : TEXUNIT7;

OUTPUT SEMANTICS

  COLOR                            Output color (float4 or int4)
  COL

  COLOR0-COLOR7                    Output color (float4 or int4) for draw buffers 0 to 7
  COL0-COL7
 
  DEPTH                            Output depth (float)
  DEPR

STANDARD LIBRARY ISSUES

Raw Cast from Floating-point to Integer Functions

It is possible to convert the raw bit patterns of IEEE single-precision floating-point to 32-bit unsigned integer.

floatToRawIntBits, floatToIntBits, intBitsToFloat

Texture Array Functions

New sampler data types for texture arrays and texture buffers lead to new standard library routines to access these samplers.

New standard library functions are used to access 1D texture array samplers (sampler1DARRAY).

tex1DARRAY, tex1DARRAYbias, tex1DARRAYcmpbias, tex1DARRAYlod, tex1DARRAYcmplod, and tex1DARRAYproj

The dimensions of a texture array level can be determined.

tex1DARRAYsize

New standard library functions are used to access 2D texture array samplers (sampler2DARRAY).

tex2DARRAY, tex2DARRAYbias, tex2DARRAYcmpbias, tex2DARRAYlod, tex2DARRAYcmplod, and tex2DARRAYproj

The dimensions of a texture array level can be determined.

tex2DARRAYsize

SEE ALSO

gp4fp, gp4vp, texBUF, texBUFsize, floatToRawIntBits, floatToIntBits, intBitsToFloat

tex1DARRAY, tex1DARRAYbias, tex1DARRAYcmpbias, tex1DARRAYlod, tex1DARRAYcmplod, tex1DARRAYproj, tex1DARRAYsize

tex2DARRAY, tex2DARRAYbias, tex2DARRAYcmpbias, tex2DARRAYlod, tex2DARRAYcmplod, tex2DARRAYproj, tex2DARRAYsize