gp4fp - OpenGL fragment profile for NVIDIA GeForce 8/9/100/200/300 Series, OpenGL 3.x Quadro gp4fp This OpenGL profile corresponds to the per-fragment 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_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). 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: http://www.opengl.org/registry/specs/NV/gpu_program4.txt http://www.opengl.org/registry/specs/NV/fragment_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 Draw buffers: http://www.opengl.org/registry/specs/ARB/draw_buffers.txt http://www.opengl.org/registry/specs/ATI/draw_buffers.txt

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

Fragment Domain-specific GP4 Options
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.

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. 1D texture unit corresponding to OpenGL's GL_TEXTURE_1D target. Sampling returns float vectors. 1D texture unit corresponding to OpenGL's GL_TEXTURE_1D target. Sampling returns int vectors. 1D texture unit corresponding to OpenGL's GL_TEXTURE_1D target. Sampling returns unsigned int vectors. 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. 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. 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. 2D texture unit corresponding to OpenGL's GL_TEXTURE_2D target. Sampling returns float vectors. 2D texture unit corresponding to OpenGL's GL_TEXTURE_2D target. Sampling returns int vectors. 2D texture unit corresponding to OpenGL's GL_TEXTURE_2D target. Sampling returns unsigned int vectors. 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. 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. 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. 3D texture unit corresponding to OpenGL's GL_TEXTURE_3D target. Sampling returns float vectors. 3D texture unit corresponding to OpenGL's GL_TEXTURE_3D target. Sampling returns int vectors. 3D texture unit corresponding to OpenGL's GL_TEXTURE_3D target. Sampling returns unsigned int vectors. Cube map texture unit corresponding to OpenGL's GL_TEXTURE_CUBE_MAP target. Sampling returns float vectors. Cube map texture unit corresponding to OpenGL's GL_TEXTURE_CUBE_MAP target. Sampling returns int vectors. Cube map texture unit corresponding to OpenGL's GL_TEXTURE_CUBE_MAP target. Sampling returns unsigned int vectors. Rectangle texture unit corresponding to OpenGL's GL_TEXTURE_RECTANGLE_ARB target. Sampling returns float vectors. Rectangle texture unit corresponding to OpenGL's GL_TEXTURE_RECTANGLE_ARB target. Sampling returns int vectors. Rectangle texture unit corresponding to OpenGL's GL_TEXTURE_RECTANGLE_ARB target. Sampling returns unsigned int vectors. Buffer texture unit corresponding to OpenGL's GL_TEXTURE_BUFFER_EXT target provided by the EXT_texture_buffer_object extension. Sampling returns float vectors. Buffer texture unit corresponding to OpenGL's GL_TEXTURE_BUFFER_EXT target provided by the EXT_texture_buffer_object extension. Sampling returns int vectors. 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
32-bit IEEE floating-point 32-bit IEEE floating-point 32-bit IEEE floating-point 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. 32-bit signed integer 32-bit unsigned integer 16-bit signed integer 16-bit unsigned integer 8-bit signed integer 8-bit unsigned integer

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

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 gp4, gp4vp, gp4gp, gp4vp, texBUF, texBUFsize, floatToRawIntBits, floatToIntBits, intBitsToFloat, tex1DARRAY, tex1DARRAYbias, tex1DARRAYcmpbias, tex1DARRAYlod, tex1DARRAYcmplod, tex1DARRAYproj, tex1DARRAYsize, tex2DARRAY, tex2DARRAYbias, tex2DARRAYlod, tex2DARRAYproj, tex2DARRAYsize