Name NV_gpu_program4 Name Strings GL_NV_gpu_program4 Contact Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com) Status Shipping for GeForce 8 Series (November 2006) Version Last Modified Date: 09/11/2014 NVIDIA Revision: 11 Number 322 Dependencies This extension is written against to OpenGL 2.0 specification. OpenGL 2.0 is not required, but we expect all implementations of this extension will also support OpenGL 2.0. This extension is also written against the ARB_vertex_program specification, which provides the basic mechanisms for the assembly programming model used by this extension. This extension serves as the basis for the NV_fragment_program4, NV_geometry_program4, and NV_vertex_program4, which all build on this extension to support fragment, geometry, and vertex programs, respectively. If "GL_NV_gpu_program4" is found in the extension string, all of these extensions are supported. NV_parameter_buffer_object affects the definition of this extension. ARB_texture_rectangle trivially affects the definition of this extension. EXT_gpu_program_parameters trivially affects the definition of this extension. EXT_texture_integer trivially affects the definition of this extension. EXT_texture_array trivially affects the definition of this extension. EXT_texture_buffer_object trivially affects the definition of this extension. NV_primitive_restart trivially affects the definition of this extension. Overview This specification documents the common instruction set and basic functionality provided by NVIDIA's 4th generation of assembly instruction sets supporting programmable graphics pipeline stages. The instruction set builds upon the basic framework provided by the ARB_vertex_program and ARB_fragment_program extensions to expose considerably more capable hardware. In addition to new capabilities for vertex and fragment programs, this extension provides a new program type (geometry programs) further described in the NV_geometry_program4 specification. NV_gpu_program4 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 fully capable signed and unsigned integer data types, along with a set of arithmetic, logical, and data type conversion instructions capable of operating on integers. It also provides a uniform set of structured branching constructs (if tests, loops, and subroutines) that fully support run-time condition testing. This extension provides several new texture mapping capabilities. Shadow cube maps are supported, where cube map faces can encode depth values. Texture lookup instructions can include an immediate texel offset, which can assist in advanced filtering. New instructions are provided to fetch a single texel by address in a texture map (TXF) and query the size of a specified texture level (TXQ). By and large, vertex and fragment programs written to ARB_vertex_program and ARB_fragment_program can be ported directly by simply changing the program header from "!!ARBvp1.0" or "!!ARBfp1.0" to "!!NVvp4.0" or "!!NVfp4.0", and then modifying the code to take advantage of the expanded feature set. There are a small number of areas where this extension is not a functional superset of previous vertex program extensions, which are documented in this specification. New Procedures and Functions void ProgramLocalParameterI4iNV(enum target, uint index, int x, int y, int z, int w); void ProgramLocalParameterI4ivNV(enum target, uint index, const int *params); void ProgramLocalParametersI4ivNV(enum target, uint index, sizei count, const int *params); void ProgramLocalParameterI4uiNV(enum target, uint index, uint x, uint y, uint z, uint w); void ProgramLocalParameterI4uivNV(enum target, uint index, const uint *params); void ProgramLocalParametersI4uivNV(enum target, uint index, sizei count, const uint *params); void ProgramEnvParameterI4iNV(enum target, uint index, int x, int y, int z, int w); void ProgramEnvParameterI4ivNV(enum target, uint index, const int *params); void ProgramEnvParametersI4ivNV(enum target, uint index, sizei count, const int *params); void ProgramEnvParameterI4uiNV(enum target, uint index, uint x, uint y, uint z, uint w); void ProgramEnvParameterI4uivNV(enum target, uint index, const uint *params); void ProgramEnvParametersI4uivNV(enum target, uint index, sizei count, const uint *params); void GetProgramLocalParameterIivNV(enum target, uint index, int *params); void GetProgramLocalParameterIuivNV(enum target, uint index, uint *params); void GetProgramEnvParameterIivNV(enum target, uint index, int *params); void GetProgramEnvParameterIuivNV(enum target, uint index, uint *params); New Tokens Accepted by the parameter of GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev: MIN_PROGRAM_TEXEL_OFFSET_EXT 0x8904 MAX_PROGRAM_TEXEL_OFFSET_EXT 0x8905 (note: these tokens are shared with the EXT_gpu_shader4 extension.) Accepted by the parameter of GetProgramivARB: PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 PROGRAM_RESULT_COMPONENTS_NV 0x8907 MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 Additions to Chapter 2 of the OpenGL 1.5 Specification (OpenGL Operation) (Modify "Section 2.14.1" of the ARB_vertex_program specification, describing program parameters.) Each program object has an associated array of program local parameters. Program local parameters are four-component vectors whose components can hold floating-point, signed integer, or unsigned integer values. The data type of each local parameter is established when the parameter's values are assigned. If a program attempts to read a local parameter using a data type other than the one used when the parameter is set, the values returned are undefined. ... The commands void ProgramLocalParameter4fARB(enum target, uint index, float x, float y, float z, float w); void ProgramLocalParameter4fvARB(enum target, uint index, const float *params); void ProgramLocalParameter4dARB(enum target, uint index, double x, double y, double z, double w); void ProgramLocalParameter4dvARB(enum target, uint index, const double *params); void ProgramLocalParameterI4iNV(enum target, uint index, int x, int y, int z, int w); void ProgramLocalParameterI4ivNV(enum target, uint index, const int *params); void ProgramLocalParameterI4uiNV(enum target, uint index, uint x, uint y, uint z, uint w); void ProgramLocalParameterI4uivNV(enum target, uint index, const uint *params); update the values of the program local parameter numbered belonging to the program object currently bound to . For the non-vector versions of these commands, the four components of the parameter are updated with the values of , , , and , respectively. For the vector versions, the components of the parameter are updated with the array of four values pointed to by . The error INVALID_VALUE is generated if is greater than or equal to the number of program local parameters supported by . The commands void ProgramLocalParameters4fvNV(enum target, uint index, sizei count, const float *params); void ProgramLocalParametersI4ivNV(enum target, uint index, sizei count, const int *params); void ProgramLocalParametersI4uivNV(enum target, uint index, sizei count, const uint *params); update the values of the program local parameters numbered through + - 1 with the array of 4 * values pointed to by . The error INVALID_VALUE is generated if the sum of and is greater than the number of program local parameters supported by . When a program local parameter is updated, the data type of its components is assigned according to the data type of the provided values. If values provided are of type "float" or "double", the components of the parameter are floating-point. If the values provided are of type "int", the components of the parameter are signed integers. If the values provided are of type "uint", the components of the parameter are unsigned integers. Additionally, each program target has an associated array of program environment parameters. Unlike program local parameters, program environment parameters are shared by all program objects of a given target. Program environment parameters are four-component vectors whose components can hold floating-point, signed integer, or unsigned integer values. The data type of each environment parameter is established when the parameter's values are assigned. If a program attempts to read an environment parameter using a data type other than the one used when the parameter is set, the values returned are undefined. ... The commands void ProgramEnvParameter4fARB(enum target, uint index, float x, float y, float z, float w); void ProgramEnvParameter4fvARB(enum target, uint index, const float *params); void ProgramEnvParameter4dARB(enum target, uint index, double x, double y, double z, double w); void ProgramEnvParameter4dvARB(enum target, uint index, const double *params); void ProgramEnvParameterI4iNV(enum target, uint index, int x, int y, int z, int w); void ProgramEnvParameterI4ivNV(enum target, uint index, const int *params); void ProgramEnvParameterI4uiNV(enum target, uint index, uint x, uint y, uint z, uint w); void ProgramEnvParameterI4uivNV(enum target, uint index, const uint *params); update the values of the program environment parameter numbered for the given program target . For the non-vector versions of these commands, the four components of the parameter are updated with the values of , , , and , respectively. For the vector versions, the four components of the parameter are updated with the array of four values pointed to by . The error INVALID_VALUE is generated if is greater than or equal to the number of program environment parameters supported by . The commands void ProgramEnvParameters4fvNV(enum target, uint index, sizei count, const float *params); void ProgramEnvParametersI4ivNV(enum target, uint index, sizei count, const int *params); void ProgramEnvParametersI4uivNV(enum target, uint index, sizei count, const uint *params); update the values of the program environment parameters numbered through + - 1 with the array of 4 * values pointed to by . The error INVALID_VALUE is generated if the sum of and is greater than the number of program local parameters supported by . When a program environment parameter is updated, the data type of its components is assigned according to the data type of the provided values. If values provided are of type "float" or "double", the components of the parameter are floating-point. If the values provided are of type "int", the components of the parameter are signed integers. If the values provided are of type "uint", the components of the parameter are unsigned integers. ... 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, providing both integer and floating-point operations. 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. 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. Note that this extension is not a standalone extension and a small number of grammar rules are left to be defined in the extensions defining the specific vertex, fragment, and geometry program types. ::= "END" ::=