Cg Toolkit Cg 3.1 Toolkit Documentation
Cg / Profiles / gp4vp

Name

gp4vp - OpenGL vertex profile for NVIDIA GeForce 8/9/100/200/300 Series, OpenGL 3.x Quadro

Synopsis

  gp4vp

Description

This OpenGL profile corresponds to the per-vertex functionality introduced by NVIDIA's 4th generation of assembly instruction sets.

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

Note that the NV_gpu_program4 extension has its vertex domain-specific aspects documented in the NV_vertex_program4 specification.

Data-dependent loops and branching are allowed.

Relative indexing of uniform arrays is supported.

Texture accesses are supported. While the prior vp40 profile has substantial limitations on vertex texturing, the gp4vp profile eliminates all the limitations.

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).

If the system supports the NV_explicit_multisample OpenGL extension, renderbuffers can be bound as textures, which allows texture access to individual samples stored in multi-sample renderbuffer.

3D Api Dependencies

Requires OpenGL support for the NV_gpu_program4 extension. This extension was introduced by the GeForce 8800 and other G8x-based GPUs. Renderbuffer sampler access requires NV_explicit_multisample extension.

Opengl Extension Specifications

Programmability:

 http://www.opengl.org/registry/specs/NV/gpu_program4.txt
 http://www.opengl.org/registry/specs/NV/vertex_program4.txt

New texture samplers:

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

New integer texture formats:

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

Optional renderbuffer textures:

 http://www.opengl.org/registry/specs/NV/explicit_multisample.txt

Profile Options

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.
samplerRBUF
Renderbuffer texture unit corresponding to OpenGL's GL_TEXTURE_RENDERBUFFER_NV target provided by the NV_explicit_multisample extension. Sampling returns float vectors.
isamplerRBUF
Renderbuffer texture unit corresponding to OpenGL's GL_TEXTURE_RENDERBUFFER_NV target provided by the NV_explicit_multisample extension. Sampling returns int vectors.
usamplerRBUF
Renderbuffer texture unit corresponding to OpenGL's GL_TEXTURE_RENDERBUFFER_NV target provided by the NV_explicit_multisample 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

Vertex Attribute Input Semantics

For geometry shader profiles such as gp4gp, varying parameters with vertex attribute input semantics must be declared with the AttribArray template-style syntax because a geometry shader accepts an attribute array of vertex attributes (rather than individual vertex attributes as a vertex shader does).

Example defining a varying parameter for the position vertex attribute:

  AttribArray<float4> position : POSITION

The set of binding semantics for varying input vertex attributes to gp4gp consists of POSITION, BLENDWEIGHT, NORMAL, COLOR0, COLOR1, TESSFACTOR, PSIZE, BLENDINDICES, and TEXCOORD0-TEXCOORD7. One can also use TANGENT and BINORMAL instead of TEXCOORD6 and TEXCOORD7.

Additionally, a set of binding semantics ATTR0-ATTR15 can be used. These binding semantics map to NV_gpu_program4 input attribute parameters as described in the NV_geometry_program4 document.

The two sets act as aliases to each other on NVIDIA GPUs excluding Apple Macs. ATI GPUs and NVIDIA Mac GPUs do not alias the conventional vertex attributes with the generic attributes.

Binding Semantics Name       Corresponding Data

POSITION, ATTR0              Input Vertex, Generic Attribute 0

BLENDWEIGHT, ATTR1           Input vertex weight, Generic Attribute 1

NORMAL, ATTR2                Input normal, Generic Attribute 2

DIFFUSE, COLOR0, ATTR3       Input primary color, Generic Attribute 3

SPECULAR, COLOR1, ATTR4      Input secondary color, Generic Attribute 4

TESSFACTOR, FOGCOORD, ATTR5  Input fog coordinate, Generic Attribute 5

PSIZE, ATTR6                 Input point size, Generic Attribute 6

BLENDINDICES, ATTR7          Generic Attribute 7

TEXCOORD0-TEXCOORD7,         Input texture coordinates (texcoord0-texcoord7)
ATTR8-ATTR15                 Generic Attributes 8-15

TANGENT, ATTR14              Generic Attribute 14

BINORMAL, ATTR15             Generic Attribute 15

VERTEXID                     Input vertex ID (integer)
                             Vertex index when using vertex arrays

INSTANCEID                   Integer instance ID of the primitive
                             within the current batch

These vertex attribute semantics should match with the semantics of the outputs of the vertex shader feeding the geometry shader.

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-TEXUNIT31  Texture image unit

Example:

  uniform sampler2DARRAY texArray : TEXUNIT7;

Output Semantics

These vertex attribute output semantics match the output semantics for gp4vp.

Binding Semantics Name        Corresponding Data

POSITION, HPOS                Output position

PSIZE, PSIZ                   Output point size

FOG, FOGC                     Output fog coordinate

COLOR0, COL0                  Output primary color

COLOR1, COL1                  Output secondary color

BCOL0                         Output backface primary color

BCOL1                         Output backface secondary color

TEXCOORD0-TEXCOORD7,          Output texture coordinates
TEX0-TEX7

CLP0-CL5                      Output Clip distances

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, 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, tex2DARRAYlod, tex2DARRAYproj

The dimensions of a texture array level can be determined.

tex2DARRAYsize

See Also

gp4, gp4gp, gp4fp, texBUF, texBUFsize, texRBUF, texRBUFsize, floatToRawIntBits, floatToIntBits, intBitsToFloat, tex1DARRAY, tex1DARRAYbias, tex1DARRAYcmpbias, tex1DARRAYlod, tex1DARRAYcmplod, tex1DARRAYproj, tex1DARRAYsize, tex2DARRAY, tex2DARRAYbias, tex2DARRAYlod, tex2DARRAYproj, tex2DARRAYsize


Cg Toolkit | Cg Toolkit | Download | Release Archive | Profiles | Reference | Books | Discussions |


Cg Profiles

arbfp1
arbvp1
ds_5_0
fp20
fp30
fp40
glslf
glslg
glsl
glslv
gp4fp
gp4gp
gp4
gp4vp
gp5fp
gp5gp
gp5
gp5tcp
gp5tep
gp5vp
gs_4_0
gs_5_0
hlsl10
hlsl11
hlslf
hlslv
hs_5_0
ps_1_1
ps_1_2
ps_1_3
ps_2_0
ps_2_sw
ps_2_x
ps_3_0
ps_4_0
ps_5_0
vp20
vp30
vp40
vs_1_1
vs_2_0
vs_2_sw
vs_2_x
vs_3_0
vs_4_0
vs_5_0