15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci NV_fragment_program4 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci (none) 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciStatus 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Shipping for GeForce 8 Series (November 2006) 165bd8deadSopenharmony_ci 175bd8deadSopenharmony_ciVersion 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ci Last Modified Date: 05/26/09 205bd8deadSopenharmony_ci NVIDIA Revision: 6 215bd8deadSopenharmony_ci 225bd8deadSopenharmony_ciNumber 235bd8deadSopenharmony_ci 245bd8deadSopenharmony_ci 335 255bd8deadSopenharmony_ci 265bd8deadSopenharmony_ciDependencies 275bd8deadSopenharmony_ci 285bd8deadSopenharmony_ci OpenGL 1.1 is required. 295bd8deadSopenharmony_ci 305bd8deadSopenharmony_ci NV_gpu_program4 is required. This extension is supported if 315bd8deadSopenharmony_ci "GL_NV_gpu_program4" is found in the extension string. 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ci ATI_draw_buffers and ARB_draw_buffers trivially affects the definition of 345bd8deadSopenharmony_ci this specification. 355bd8deadSopenharmony_ci 365bd8deadSopenharmony_ci ARB_fragment_program_shadow trivially affects the definition of this 375bd8deadSopenharmony_ci specification. 385bd8deadSopenharmony_ci 395bd8deadSopenharmony_ci NV_primitive_restart trivially affects the definition of this extension. 405bd8deadSopenharmony_ci 415bd8deadSopenharmony_ci This extension is written against the OpenGL 2.0 specification. 425bd8deadSopenharmony_ci 435bd8deadSopenharmony_ciOverview 445bd8deadSopenharmony_ci 455bd8deadSopenharmony_ci This extension builds on the common assembly instruction set 465bd8deadSopenharmony_ci infrastructure provided by NV_gpu_program4, adding fragment 475bd8deadSopenharmony_ci program-specific features. 485bd8deadSopenharmony_ci 495bd8deadSopenharmony_ci This extension provides interpolation modifiers to fragment program 505bd8deadSopenharmony_ci attributes allowing programs to specify that specified attributes be 515bd8deadSopenharmony_ci flat-shaded (constant over a primitive), centroid-sampled (multisample 525bd8deadSopenharmony_ci rendering), or interpolated linearly in screen space. The set of input 535bd8deadSopenharmony_ci and output bindings provided includes all bindings supported by 545bd8deadSopenharmony_ci ARB_fragment_program. Additional input bindings are provided to determine 555bd8deadSopenharmony_ci whether fragments were generated by front- or back-facing primitives 565bd8deadSopenharmony_ci ("fragment.facing"), to identify the individual primitive used to generate 575bd8deadSopenharmony_ci the fragment ("primitive.id"), and to determine distances to user clip 585bd8deadSopenharmony_ci planes ("fragment.clip[n]"). Additionally generic input attributes allow 595bd8deadSopenharmony_ci a fragment program to receive a greater number of attributes from previous 605bd8deadSopenharmony_ci pipeline stages than possible using only the pre-defined fixed-function 615bd8deadSopenharmony_ci attributes. 625bd8deadSopenharmony_ci 635bd8deadSopenharmony_ci By and large, programs written to ARB_fragment_program can be ported 645bd8deadSopenharmony_ci directly by simply changing the program header from "!!ARBfp1.0" to 655bd8deadSopenharmony_ci "!!NVfp4.0", and then modifying instructions to take advantage of the 665bd8deadSopenharmony_ci expanded feature set. There are a small number of areas where this 675bd8deadSopenharmony_ci extension is not a functional superset of previous fragment program 685bd8deadSopenharmony_ci extensions, which are documented in the NV_gpu_program4 specification. 695bd8deadSopenharmony_ci 705bd8deadSopenharmony_ciNew Procedures and Functions 715bd8deadSopenharmony_ci 725bd8deadSopenharmony_ci None. 735bd8deadSopenharmony_ci 745bd8deadSopenharmony_ciNew Tokens 755bd8deadSopenharmony_ci 765bd8deadSopenharmony_ci None. 775bd8deadSopenharmony_ci 785bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 2.0 Specification (OpenGL Operation) 795bd8deadSopenharmony_ci 805bd8deadSopenharmony_ci Modify Section 2.X, GPU Programs 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ci (insert after second paragraph) 835bd8deadSopenharmony_ci 845bd8deadSopenharmony_ci Fragment Programs 855bd8deadSopenharmony_ci 865bd8deadSopenharmony_ci Fragment programs are used to compute the transformed attributes of a 875bd8deadSopenharmony_ci fragment, in lieu of the set of fixed-function operations described in 885bd8deadSopenharmony_ci sections 3.8 through 3.10. Fragment programs are run on a single fragment 895bd8deadSopenharmony_ci at a time, and the state of neighboring fragments is not explicitly 905bd8deadSopenharmony_ci available. (In practice, fragment programs may be run on a block of 915bd8deadSopenharmony_ci fragments, and neighboring fragments' attributes may be used for texture 925bd8deadSopenharmony_ci LOD calculations or partial derivative approximation.) The inputs 935bd8deadSopenharmony_ci available to a fragment program are the interpolated attributes of a 945bd8deadSopenharmony_ci fragment, which include (among other things) window-space position, 955bd8deadSopenharmony_ci primary and secondary colors, and texture coordinates. The results of the 965bd8deadSopenharmony_ci program are one (or more) colors and possibly a new window Z coordinate. 975bd8deadSopenharmony_ci A fragment program can not modify the (X,Y) location of the fragment. 985bd8deadSopenharmony_ci 995bd8deadSopenharmony_ci Modify Section 2.X.2, Program Grammar 1005bd8deadSopenharmony_ci 1015bd8deadSopenharmony_ci (replace third paragraph) 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ci Fragment programs are required to begin with the header string 1045bd8deadSopenharmony_ci "!!NVfp4.0". This header string identifies the subsequent program body as 1055bd8deadSopenharmony_ci being a fragment program and indicates that it should be parsed according 1065bd8deadSopenharmony_ci to the base NV_gpu_program4 grammar plus the additions below. Program 1075bd8deadSopenharmony_ci string parsing begins with the character immediately following the header 1085bd8deadSopenharmony_ci string. 1095bd8deadSopenharmony_ci 1105bd8deadSopenharmony_ci (add the following grammar rules to the NV_gpu_program4 base grammar) 1115bd8deadSopenharmony_ci 1125bd8deadSopenharmony_ci <instruction> ::= <SpecialInstruction> 1135bd8deadSopenharmony_ci 1145bd8deadSopenharmony_ci <varModifier> ::= <interpModifier> 1155bd8deadSopenharmony_ci 1165bd8deadSopenharmony_ci <SpecialInstruction> ::= "KIL" <opModifiers> <killCond> 1175bd8deadSopenharmony_ci | "DDX" <opModifiers> <instResult> "," 1185bd8deadSopenharmony_ci <instOperandV> 1195bd8deadSopenharmony_ci | "DDY" <opModifiers> <instResult> "," 1205bd8deadSopenharmony_ci <instOperandV> 1215bd8deadSopenharmony_ci 1225bd8deadSopenharmony_ci <killCond> ::= <instOperandV> 1235bd8deadSopenharmony_ci 1245bd8deadSopenharmony_ci <interpModifier> ::= "FLAT" 1255bd8deadSopenharmony_ci | "CENTROID" 1265bd8deadSopenharmony_ci | "NOPERSPECTIVE" 1275bd8deadSopenharmony_ci 1285bd8deadSopenharmony_ci <attribBasic> ::= <fragPrefix> "fogcoord" 1295bd8deadSopenharmony_ci | <fragPrefix> "position" 1305bd8deadSopenharmony_ci | <fragPrefix> "facing" 1315bd8deadSopenharmony_ci | <attribTexCoord> <optArrayMemAbs> 1325bd8deadSopenharmony_ci | <attribClip> <arrayMemAbs> 1335bd8deadSopenharmony_ci | <attribGeneric> <arrayMemAbs> 1345bd8deadSopenharmony_ci | "primitive" "." "id" 1355bd8deadSopenharmony_ci 1365bd8deadSopenharmony_ci <attribColor> ::= <fragPrefix> "color" 1375bd8deadSopenharmony_ci 1385bd8deadSopenharmony_ci <attribMulti> ::= <attribTexCoord> <arrayRange> 1395bd8deadSopenharmony_ci | <attribClip> <arrayRange> 1405bd8deadSopenharmony_ci | <attribGeneric> <arrayRange> 1415bd8deadSopenharmony_ci 1425bd8deadSopenharmony_ci <attribTexCoord> ::= <fragPrefix> "texcoord" 1435bd8deadSopenharmony_ci 1445bd8deadSopenharmony_ci <attribClip> ::= <fragPrefix> "clip" 1455bd8deadSopenharmony_ci 1465bd8deadSopenharmony_ci <attribGeneric> ::= <fragPrefix> "attrib" 1475bd8deadSopenharmony_ci 1485bd8deadSopenharmony_ci <fragPrefix> ::= "fragment" "." 1495bd8deadSopenharmony_ci 1505bd8deadSopenharmony_ci <resultBasic> ::= <resPrefix> "color" <resultOptColorNum> 1515bd8deadSopenharmony_ci | <resPrefix> "depth" 1525bd8deadSopenharmony_ci 1535bd8deadSopenharmony_ci <resultOptColorNum> ::= /* empty */ 1545bd8deadSopenharmony_ci 1555bd8deadSopenharmony_ci <resPrefix> ::= "result" "." 1565bd8deadSopenharmony_ci 1575bd8deadSopenharmony_ci (add the following subsection to section 2.X.3.1, Program Variable Types) 1585bd8deadSopenharmony_ci 1595bd8deadSopenharmony_ci Explicitly declared fragment program attribute variables may have one or 1605bd8deadSopenharmony_ci more interpolation modifiers that control how per-fragment values are 1615bd8deadSopenharmony_ci computed. 1625bd8deadSopenharmony_ci 1635bd8deadSopenharmony_ci An attribute variable declared as "FLAT" will be flat-shaded. For such 1645bd8deadSopenharmony_ci variables, the value of the attribute will be constant over an entire 1655bd8deadSopenharmony_ci primitive and will taken from the provoking vertex of the primitive, as 1665bd8deadSopenharmony_ci described in Section 2.14.7. If "FLAT" is not specified, attributes will 1675bd8deadSopenharmony_ci be interpolated as described in Chapter 3, with the exception that 1685bd8deadSopenharmony_ci attribute variables bound to colors will still be flat-shaded if the shade 1695bd8deadSopenharmony_ci model (section 2.14.7) is FLAT. If an attribute variable declared as 1705bd8deadSopenharmony_ci "FLAT" corresponds to a texture coordinate replaced by a point sprite 1715bd8deadSopenharmony_ci (s,t) value (section 3.3.1), the value of the attribute is undefined. 1725bd8deadSopenharmony_ci 1735bd8deadSopenharmony_ci An attribute variable declared as "CENTROID" will be interpolated using a 1745bd8deadSopenharmony_ci point on or inside the primitive, if possible, when doing multisample line 1755bd8deadSopenharmony_ci or polygon rasterization (sections 3.4.4 and 3.5.6). This method can 1765bd8deadSopenharmony_ci avoid artifacts during multisample rasterization when some samples of a 1775bd8deadSopenharmony_ci pixel are covered, but the sample location used is outside the primitive. 1785bd8deadSopenharmony_ci Note that when centroid sampling, the sample points used to generate 1795bd8deadSopenharmony_ci attribute values for adjacent pixels may not be evenly spaced, which can 1805bd8deadSopenharmony_ci lead to artifacts when evaluating partial derivatives or performing 1815bd8deadSopenharmony_ci texture LOD calculations needed for mipmapping. If "CENTROID" is not 1825bd8deadSopenharmony_ci specified, attributes may be sampled anywhere inside the pixel as 1835bd8deadSopenharmony_ci permitted by the specification, including at points outside the primitive. 1845bd8deadSopenharmony_ci 1855bd8deadSopenharmony_ci An attribute variable declared as "NOPERSPECTIVE" will be interpolated 1865bd8deadSopenharmony_ci using a method that is linear in screen space, as described in equation 1875bd8deadSopenharmony_ci 3.7 and the appoximation that follows equation 3.8. If "NOPERSPECTIVE" is 1885bd8deadSopenharmony_ci not specified, attributes must be interpolated with perspective 1895bd8deadSopenharmony_ci correction, as described in equations 3.6 and 3.8. When clipping lines or 1905bd8deadSopenharmony_ci polygons, an alternate method is used to compute the attributes of 1915bd8deadSopenharmony_ci vertices introduced by clipping when they are specified as "NOPERSPECTIVE" 1925bd8deadSopenharmony_ci (section 2.14.8). 1935bd8deadSopenharmony_ci 1945bd8deadSopenharmony_ci Implicitly declared attribute variables (bindings used directly in a 1955bd8deadSopenharmony_ci program instruction) will inherit the interpolation modifiers of any 1965bd8deadSopenharmony_ci explicitly declared attribute variable using the same binding. If no such 1975bd8deadSopenharmony_ci variable exists, default interpolation modes will be used. 1985bd8deadSopenharmony_ci 1995bd8deadSopenharmony_ci For fragments generated by point primitives, DrawPixels, and Bitmap, 2005bd8deadSopenharmony_ci interpolation modifiers have no effect. 2015bd8deadSopenharmony_ci 2025bd8deadSopenharmony_ci Implementations are not required to support arithmetic interpolation of 2035bd8deadSopenharmony_ci integer values written by a previous pipeline stage. Integer fragment 2045bd8deadSopenharmony_ci program attribute variables must be flat-shaded; a program will fail to 2055bd8deadSopenharmony_ci load if it declares a variable with the "INT" or "UINT" data type 2065bd8deadSopenharmony_ci modifiers without the "FLAT" interpolation modifier. 2075bd8deadSopenharmony_ci 2085bd8deadSopenharmony_ci There are several additional limitations on the use of interpolation 2095bd8deadSopenharmony_ci modifiers. A fragment program will fail to load: 2105bd8deadSopenharmony_ci 2115bd8deadSopenharmony_ci * if an interpolation modifier is specified when declaring a 2125bd8deadSopenharmony_ci non-attribute variable, 2135bd8deadSopenharmony_ci 2145bd8deadSopenharmony_ci * if the same interpolation modifier is specified more than once in a 2155bd8deadSopenharmony_ci single declaration (e.g., "CENTROID CENTROID ATTRIB"), 2165bd8deadSopenharmony_ci 2175bd8deadSopenharmony_ci * if the "FLAT" modifier is used together with either "CENTROID" or 2185bd8deadSopenharmony_ci "NOPERSPECTIVE" in a single declaration, 2195bd8deadSopenharmony_ci 2205bd8deadSopenharmony_ci * if any interpolation modifier is specified when declaring a variable 2215bd8deadSopenharmony_ci bound to a fragment's position, face direction, fog coordinate, or any 2225bd8deadSopenharmony_ci interpolated clip distance, 2235bd8deadSopenharmony_ci 2245bd8deadSopenharmony_ci * if multiple attribute variables with different interpolation modifiers 2255bd8deadSopenharmony_ci are bound to the same fragment attribute, or 2265bd8deadSopenharmony_ci 2275bd8deadSopenharmony_ci * if one variable is bound to the fragment's primary color and a second 2285bd8deadSopenharmony_ci variable with different interpolation modifiers is bound the the 2295bd8deadSopenharmony_ci fragment's secondary color. 2305bd8deadSopenharmony_ci 2315bd8deadSopenharmony_ci (add the following subsection to section 2.X.3.2, Program Attribute 2325bd8deadSopenharmony_ci Variables) 2335bd8deadSopenharmony_ci 2345bd8deadSopenharmony_ci Fragment program attribute variables describe the attributes of a fragment 2355bd8deadSopenharmony_ci produced during rasterization. The set of available bindings is 2365bd8deadSopenharmony_ci enumerated in Table X.X. 2375bd8deadSopenharmony_ci 2385bd8deadSopenharmony_ci Most attributes correspond to per-vertex attributes that are interpolated 2395bd8deadSopenharmony_ci over a primitive; such attributes are subject to the interpolation 2405bd8deadSopenharmony_ci modifiers described in section 2.X.3.1. The fragment's position, facing, 2415bd8deadSopenharmony_ci and primitive IDs are the exceptions, and are generated specially during 2425bd8deadSopenharmony_ci rasterization. Since two-sided color selection occurs prior to 2435bd8deadSopenharmony_ci rasterization, there are no distinct "front" or "back" colors available to 2445bd8deadSopenharmony_ci fragment programs. A single set of colors is available, which corresponds 2455bd8deadSopenharmony_ci to interpolated front or back vertex colors. 2465bd8deadSopenharmony_ci 2475bd8deadSopenharmony_ci If geometry programs are enabled, attributes will be obtained by 2485bd8deadSopenharmony_ci interpolating per-vertex outputs written by the geometry program. If 2495bd8deadSopenharmony_ci geometry programs are disabled, but vertex programs are enabled, 2505bd8deadSopenharmony_ci attributes will be obtained by interpolating per-vertex outputs written by 2515bd8deadSopenharmony_ci the vertex program. In either case, the fragment program attributes 2525bd8deadSopenharmony_ci should be read using the same component data type used to write the vertex 2535bd8deadSopenharmony_ci output attributes in the geometry or vertex program. The value of any 2545bd8deadSopenharmony_ci attribute corresponding to a vertex output not written by the geometry or 2555bd8deadSopenharmony_ci vertex program is undefined. 2565bd8deadSopenharmony_ci 2575bd8deadSopenharmony_ci If neither geometry nor vertex programs are used, attributes will be 2585bd8deadSopenharmony_ci obtained by interpolating per-vertex values computed by fixed-function 2595bd8deadSopenharmony_ci vertex processing. All interpolated fragment attributes should be read as 2605bd8deadSopenharmony_ci floating-point values. 2615bd8deadSopenharmony_ci 2625bd8deadSopenharmony_ci Fragment Attribute Binding Components Underlying State 2635bd8deadSopenharmony_ci -------------------------- ---------- ---------------------------- 2645bd8deadSopenharmony_ci fragment.color (r,g,b,a) primary color 2655bd8deadSopenharmony_ci fragment.color.primary (r,g,b,a) primary color 2665bd8deadSopenharmony_ci fragment.color.secondary (r,g,b,a) secondary color 2675bd8deadSopenharmony_ci fragment.texcoord (s,t,r,q) texture coordinate, unit 0 2685bd8deadSopenharmony_ci fragment.texcoord[n] (s,t,r,q) texture coordinate, unit n 2695bd8deadSopenharmony_ci fragment.fogcoord (f,-,-,-) fog distance/coordinate 2705bd8deadSopenharmony_ci * fragment.clip[n] (c,-,-,-) interpolated clip distance n 2715bd8deadSopenharmony_ci fragment.attrib[n] (x,y,z,w) generic interpolant n 2725bd8deadSopenharmony_ci fragment.texcoord[n..o] (s,t,r,q) texture coordinates n thru o 2735bd8deadSopenharmony_ci * fragment.clip[n..o] (c,-,-,-) clip distances n thru o 2745bd8deadSopenharmony_ci fragment.attrib[n..o] (x,y,z,w) generic interpolants n thru o 2755bd8deadSopenharmony_ci * fragment.position (x,y,z,1/w) window position 2765bd8deadSopenharmony_ci * fragment.facing (f,-,-,-) fragment facing 2775bd8deadSopenharmony_ci * primitive.id (id,-,-,-) primitive number 2785bd8deadSopenharmony_ci 2795bd8deadSopenharmony_ci Table X.X: Fragment Attribute Bindings. The "Components" column 2805bd8deadSopenharmony_ci indicates the mapping of the state in the "Underlying State" column. 2815bd8deadSopenharmony_ci Bindings containing "[n]" require an integer value of <n> to select an 2825bd8deadSopenharmony_ci individual item. Interpolation modifiers are not supported on variables 2835bd8deadSopenharmony_ci that use bindings labeled with "*". 2845bd8deadSopenharmony_ci 2855bd8deadSopenharmony_ci If a fragment attribute binding matches "fragment.color" or 2865bd8deadSopenharmony_ci "fragment.color.primary", the "x", "y", "z", and "w" components of the 2875bd8deadSopenharmony_ci fragment attribute variable are filled with the "r", "g", "b", and "a" 2885bd8deadSopenharmony_ci components, respectively, of the fragment's primary color. 2895bd8deadSopenharmony_ci 2905bd8deadSopenharmony_ci If a fragment attribute binding matches "fragment.color.secondary", the 2915bd8deadSopenharmony_ci "x", "y", "z", and "w" components of the fragment attribute variable are 2925bd8deadSopenharmony_ci filled with the "r", "g", "b", and "a" components, respectively, of the 2935bd8deadSopenharmony_ci fragment's secondary color. 2945bd8deadSopenharmony_ci 2955bd8deadSopenharmony_ci If a fragment attribute binding matches "fragment.texcoord" or 2965bd8deadSopenharmony_ci "fragment.texcoord[n]", the "x", "y", "z", and "w" components of the 2975bd8deadSopenharmony_ci fragment attribute variable are filled with the "s", "t", "r", and "q" 2985bd8deadSopenharmony_ci components, respectively, of the fragment texture coordinates for texture 2995bd8deadSopenharmony_ci unit <n>. If "[n]" is omitted, texture unit zero is used. 3005bd8deadSopenharmony_ci 3015bd8deadSopenharmony_ci If a fragment attribute binding matches "fragment.fogcoord", the "x" 3025bd8deadSopenharmony_ci component of the fragment attribute variable is filled with either the 3035bd8deadSopenharmony_ci fragment eye distance or the fog coordinate, depending on whether the fog 3045bd8deadSopenharmony_ci source is set to FRAGMENT_DEPTH_EXT or FOG_COORDINATE_EXT, respectively. 3055bd8deadSopenharmony_ci The "y", "z", and "w" coordinates are undefined. 3065bd8deadSopenharmony_ci 3075bd8deadSopenharmony_ci If a fragment attribute binding matches "fragment.clip[n]", the "x" 3085bd8deadSopenharmony_ci component of the fragment attribute variable is filled with the 3095bd8deadSopenharmony_ci interpolated value of clip distance <n>, as written by the vertex or 3105bd8deadSopenharmony_ci geometry program. The "y", "z", and "w" components of the variable are 3115bd8deadSopenharmony_ci undefined. If fixed-function vertex processing or position-invariant 3125bd8deadSopenharmony_ci vertex programs are used with geometry programs disabled, clip distances 3135bd8deadSopenharmony_ci are obtained by interpolating the per-clip plane dot product: 3145bd8deadSopenharmony_ci 3155bd8deadSopenharmony_ci (p_1' p_2' p_3' p_4') dot (x_e y_e z_e w_e), 3165bd8deadSopenharmony_ci 3175bd8deadSopenharmony_ci for clip plane <n> as described in section 2.12. The clip distance for 3185bd8deadSopenharmony_ci clip plane <n> is undefined if clip plane <n> is disabled. 3195bd8deadSopenharmony_ci 3205bd8deadSopenharmony_ci If a fragment attribute binding matches "fragment.attrib[n]", the "x", 3215bd8deadSopenharmony_ci "y", "z", and "w" components of the fragment attribute variable are filled 3225bd8deadSopenharmony_ci with the "x", "y", "z", and "w" components of generic interpolant <n>. 3235bd8deadSopenharmony_ci All generic interpolants will be undefined when used with fixed-function 3245bd8deadSopenharmony_ci vertex processing with no geometry program enabled. 3255bd8deadSopenharmony_ci 3265bd8deadSopenharmony_ci If a fragment attribute binding matches "fragment.texcoord[n..o]", 3275bd8deadSopenharmony_ci "fragment.clip[n..o]", or "fragment.attrib[n..o]", a sequence of 1+<o>-<n> 3285bd8deadSopenharmony_ci bindings is created. For texture coordinate bindings, it is as though the 3295bd8deadSopenharmony_ci sequence "fragment.texcoord[n], fragment.texcoord[n+1], 3305bd8deadSopenharmony_ci ... fragment.texcoord[o]" were specfied. These bindings are available 3315bd8deadSopenharmony_ci only in explicit declarations of array variables. A program will fail to 3325bd8deadSopenharmony_ci load if <n> is greater than <o>. 3335bd8deadSopenharmony_ci 3345bd8deadSopenharmony_ci If a fragment attribute binding matches "fragment.position", the "x" and 3355bd8deadSopenharmony_ci "y" components of the fragment attribute variable are filled with the 3365bd8deadSopenharmony_ci floating-point (x,y) window coordinates of the fragment center, relative 3375bd8deadSopenharmony_ci to the lower left corner of the window. The "z" component is filled with 3385bd8deadSopenharmony_ci the fragment's z window coordinate. If z window coordinates are 3395bd8deadSopenharmony_ci represented internally by the GL as fixed-point values, the z window 3405bd8deadSopenharmony_ci coordinate undergoes an implied conversion to floating point. This 3415bd8deadSopenharmony_ci conversion must leave the values 0 and 1 invariant. The "w" component is 3425bd8deadSopenharmony_ci filled with the reciprocal of the fragment's clip w coordinate. 3435bd8deadSopenharmony_ci 3445bd8deadSopenharmony_ci If a fragment attribute binding matches "fragment.facing", the "x" 3455bd8deadSopenharmony_ci component of the fragment attribute variable is filled with +1.0 or -1.0, 3465bd8deadSopenharmony_ci depending on the orientation of the primitive producing the fragment. If 3475bd8deadSopenharmony_ci the fragment is generated by a back-facing polygon (including point- and 3485bd8deadSopenharmony_ci line-mode polygons), the facing is -1.0; otherwise, the facing is +1.0. 3495bd8deadSopenharmony_ci The "y", "z", and "w" coordinates are undefined. 3505bd8deadSopenharmony_ci 3515bd8deadSopenharmony_ci If a fragment attribute binding matches "primitive.id", the "x" component 3525bd8deadSopenharmony_ci of the fragment attribute variable is filled with a single integer. If a 3535bd8deadSopenharmony_ci geometry program is active, this value is obtained by taking the primitive 3545bd8deadSopenharmony_ci ID value emitted by the geometry program for the provoking vertex. If no 3555bd8deadSopenharmony_ci geometry program is active, the value is the number of primitives 3565bd8deadSopenharmony_ci processed by the rasterizer since the last time Begin was called (directly 3575bd8deadSopenharmony_ci or indirectly via vertex array functions). The first primitive generated 3585bd8deadSopenharmony_ci after a Begin is numbered zero, and the primitive ID counter is 3595bd8deadSopenharmony_ci incremented after every individual point, line, or polygon primitive is 3605bd8deadSopenharmony_ci processed. For polygons drawn in point or line mode, the primitive ID 3615bd8deadSopenharmony_ci counter is incremented only once, even though multiple points or lines may 3625bd8deadSopenharmony_ci be drawn. For QUADS and QUAD_STRIP primitives that are decomposed into 3635bd8deadSopenharmony_ci triangles, the primitive ID is incremented after each complete quad is 3645bd8deadSopenharmony_ci processed. For POLYGON primitives, the primitive ID counter is zero. The 3655bd8deadSopenharmony_ci primitive ID is zero for fragments generated by DrawPixels or Bitmap. 3665bd8deadSopenharmony_ci Restarting a primitive topology using the primitive restart index has no 3675bd8deadSopenharmony_ci effect on the primitive ID counter. The "y", "z", and "w" components of 3685bd8deadSopenharmony_ci the variable are always undefined. 3695bd8deadSopenharmony_ci 3705bd8deadSopenharmony_ci (add the following subsection to section 2.X.3.5, Program Results.) 3715bd8deadSopenharmony_ci 3725bd8deadSopenharmony_ci Fragment programs produce final fragment values, and the set of result 3735bd8deadSopenharmony_ci variables available to such programs correspond to the final attributes of 3745bd8deadSopenharmony_ci a fragment. Fragment program result variables may not be declared as 3755bd8deadSopenharmony_ci arrays. 3765bd8deadSopenharmony_ci 3775bd8deadSopenharmony_ci The set of allowable result variable bindings is given in Table X.X. 3785bd8deadSopenharmony_ci 3795bd8deadSopenharmony_ci Binding Components Description 3805bd8deadSopenharmony_ci ----------------------------- ---------- ---------------------------- 3815bd8deadSopenharmony_ci result.color (r,g,b,a) color 3825bd8deadSopenharmony_ci result.color[n] (r,g,b,a) color output n 3835bd8deadSopenharmony_ci result.depth (*,*,d,*) depth coordinate 3845bd8deadSopenharmony_ci 3855bd8deadSopenharmony_ci Table X.X: Fragment Result Variable Bindings. 3865bd8deadSopenharmony_ci Components labeled "*" are unused. 3875bd8deadSopenharmony_ci 3885bd8deadSopenharmony_ci If a result variable binding matches "result.color", updates to the "x", 3895bd8deadSopenharmony_ci "y", "z", and "w" components of the result variable modify the "r", "g", 3905bd8deadSopenharmony_ci "b", and "a" components, respectively, of the fragment's output color. 3915bd8deadSopenharmony_ci 3925bd8deadSopenharmony_ci If a result variable binding matches "result.color[n]" and the 3935bd8deadSopenharmony_ci ARB_draw_buffers program option is specified, updates to the "x", "y", 3945bd8deadSopenharmony_ci "z", and "w" components of the color result variable modify the "r", "g", 3955bd8deadSopenharmony_ci "b", and "a" components, respectively, of the fragment output color 3965bd8deadSopenharmony_ci numbered <n>. If the ARB_draw_buffers program option is not specified, 3975bd8deadSopenharmony_ci the "result.color[n]" binding is unavailable. 3985bd8deadSopenharmony_ci 3995bd8deadSopenharmony_ci If a result variable binding matches "result.depth", updates to the "z" 4005bd8deadSopenharmony_ci component of the result variable modify the fragment's output depth value. 4015bd8deadSopenharmony_ci If the "result.depth" binding is not in used in a variable written to by 4025bd8deadSopenharmony_ci any instruction in the fragment program, the interpolated depth value 4035bd8deadSopenharmony_ci produced by rasterization is used as if fragment program mode is not 4045bd8deadSopenharmony_ci enabled. Otherwise, the value written by the fragment program is used, 4055bd8deadSopenharmony_ci and the fragment's final depth value is undefined if the program did not 4065bd8deadSopenharmony_ci end up writing a depth value due to flow control or write masks. Writes 4075bd8deadSopenharmony_ci to any component of depth other than the "z" component have no effect. 4085bd8deadSopenharmony_ci 4095bd8deadSopenharmony_ci (modify Table X.13 in section 2.X.4, Program Instructions, to include the 4105bd8deadSopenharmony_ci following.) 4115bd8deadSopenharmony_ci 4125bd8deadSopenharmony_ci Modifiers 4135bd8deadSopenharmony_ci Instruction F I C S H D Inputs Out Description 4145bd8deadSopenharmony_ci ----------- - - - - - - ---------- --- -------------------------------- 4155bd8deadSopenharmony_ci DDX X - X X X F v v partial derivative relative to X 4165bd8deadSopenharmony_ci DDY X - X X X F v v partial derivative relative to Y 4175bd8deadSopenharmony_ci KIL X X - - X F vc - kill fragment 4185bd8deadSopenharmony_ci 4195bd8deadSopenharmony_ci (add the following subsection to section 2.X.6, Program Options.) 4205bd8deadSopenharmony_ci 4215bd8deadSopenharmony_ci Section 2.X.6.Y, Fragment Program Options 4225bd8deadSopenharmony_ci 4235bd8deadSopenharmony_ci + Fixed-Function Fog Emulation (ARB_fog_exp, ARB_fog_exp2, ARB_fog_linear) 4245bd8deadSopenharmony_ci 4255bd8deadSopenharmony_ci If a fragment program specifies one of the options "ARB_fog_exp", 4265bd8deadSopenharmony_ci "ARB_fog_exp2", or "ARB_fog_linear", the program will apply fog to the 4275bd8deadSopenharmony_ci program's final color using a fog mode of EXP, EXP2, or LINEAR, 4285bd8deadSopenharmony_ci respectively, as described in section 3.10. 4295bd8deadSopenharmony_ci 4305bd8deadSopenharmony_ci When a fog option is specified in a fragment program, semantic 4315bd8deadSopenharmony_ci restrictions are added to indicate that a fragment program will fail to 4325bd8deadSopenharmony_ci load if the number of temporaries it contains exceeds the 4335bd8deadSopenharmony_ci implementation-dependent limit minus 1, if the number of attributes it 4345bd8deadSopenharmony_ci contains exceeds the implementation-dependent limit minus 1, or if the 4355bd8deadSopenharmony_ci number of parameters it contains exceeds the implementation-dependent 4365bd8deadSopenharmony_ci limit minus 2. 4375bd8deadSopenharmony_ci 4385bd8deadSopenharmony_ci Additionally, when the ARB_fog_exp option is specified in a fragment 4395bd8deadSopenharmony_ci program, a semantic restriction is added to indicate that a fragment 4405bd8deadSopenharmony_ci program will fail to load if the number of instructions or ALU 4415bd8deadSopenharmony_ci instructions it contains exceeds the implementation-dependent limit minus 4425bd8deadSopenharmony_ci 3. When the ARB_fog_exp2 option is specified in a fragment program, a 4435bd8deadSopenharmony_ci semantic restriction is added to indicate that a fragment program will 4445bd8deadSopenharmony_ci fail to load if the number of instructions or ALU instructions it contains 4455bd8deadSopenharmony_ci exceeds the implementation-dependent limit minus 4. When the 4465bd8deadSopenharmony_ci ARB_fog_linear option is specified in a fragment program, a semantic 4475bd8deadSopenharmony_ci restriction is added to indicate that a fragment program will fail to load 4485bd8deadSopenharmony_ci if the number of instructions or ALU instructions it contains exceeds the 4495bd8deadSopenharmony_ci implementation-dependent limit minus 2. 4505bd8deadSopenharmony_ci 4515bd8deadSopenharmony_ci Only one fog application option may be specified by any given fragment 4525bd8deadSopenharmony_ci program. A fragment program that specifies more than one of the program 4535bd8deadSopenharmony_ci options "ARB_fog_exp", "ARB_fog_exp2", and "ARB_fog_linear", will fail to 4545bd8deadSopenharmony_ci load. 4555bd8deadSopenharmony_ci 4565bd8deadSopenharmony_ci + Precision Hints (ARB_precision_hint_fastest, ARB_precision_hint_nicest) 4575bd8deadSopenharmony_ci 4585bd8deadSopenharmony_ci Fragment program computations are carried out at an implementation- 4595bd8deadSopenharmony_ci dependent precision. However, some implementations may be able to perform 4605bd8deadSopenharmony_ci fragment program computations at more than one precision, and may be able 4615bd8deadSopenharmony_ci to trade off computation precision for performance. 4625bd8deadSopenharmony_ci 4635bd8deadSopenharmony_ci If a fragment program specifies the "ARB_precision_hint_fastest" program 4645bd8deadSopenharmony_ci option, implementations should select precision to minimize program 4655bd8deadSopenharmony_ci execution time, with possibly reduced precision. If a fragment program 4665bd8deadSopenharmony_ci specifies the "ARB_precision_hint_nicest" program option, implementations 4675bd8deadSopenharmony_ci should maximize the precision, with possibly increased execution time. 4685bd8deadSopenharmony_ci 4695bd8deadSopenharmony_ci Only one precision control option may be specified by any given fragment 4705bd8deadSopenharmony_ci program. A fragment program that specifies both the 4715bd8deadSopenharmony_ci "ARB_precision_hint_fastest" and "ARB_precision_hint_nicest" program 4725bd8deadSopenharmony_ci options will fail to load. 4735bd8deadSopenharmony_ci 4745bd8deadSopenharmony_ci + Multiple Color Outputs (ARB_draw_buffers, ATI_draw_buffers) 4755bd8deadSopenharmony_ci 4765bd8deadSopenharmony_ci If a fragment program specifies the "ARB_draw_buffers" or 4775bd8deadSopenharmony_ci "ATI_draw_buffers" option, it will generate multiple output colors, and 4785bd8deadSopenharmony_ci the result binding "result.color[n]" is allowed, as described in section 4795bd8deadSopenharmony_ci 2.X.3.5. If this option is not specified, a fragment program that 4805bd8deadSopenharmony_ci attempts to bind "result.color[n]" will fail to load, and only 4815bd8deadSopenharmony_ci "result.color" will be allowed. 4825bd8deadSopenharmony_ci 4835bd8deadSopenharmony_ci The multiple color outputs will typically be written to an ordered list of 4845bd8deadSopenharmony_ci draw buffers in the manner described in the ARB_draw_buffers extension 4855bd8deadSopenharmony_ci specification. 4865bd8deadSopenharmony_ci 4875bd8deadSopenharmony_ci + Fragment Program Shadows (ARB_fragment_program_shadow) 4885bd8deadSopenharmony_ci 4895bd8deadSopenharmony_ci The ARB_fragment_program_shadow option introduced a set of "SHADOW" 4905bd8deadSopenharmony_ci texture targets and made the results of depth texture lookups undefined 4915bd8deadSopenharmony_ci unless the texture format and compare mode were consistent with the target 4925bd8deadSopenharmony_ci provided in the fragment program instruction. This behavior is enabled by 4935bd8deadSopenharmony_ci default in NV_gpu_program4; specifying the option is not illegal but has 4945bd8deadSopenharmony_ci no additional effect. 4955bd8deadSopenharmony_ci 4965bd8deadSopenharmony_ci (add the following subsection to section 2.X.7, Program Declarations.) 4975bd8deadSopenharmony_ci 4985bd8deadSopenharmony_ci Section 2.X.7.Y, Fragment Program Declarations 4995bd8deadSopenharmony_ci 5005bd8deadSopenharmony_ci No declarations are supported at present for fragment programs. 5015bd8deadSopenharmony_ci 5025bd8deadSopenharmony_ci 5035bd8deadSopenharmony_ci (add the following subsection to section 2.X.8, Program Instruction Set.) 5045bd8deadSopenharmony_ci 5055bd8deadSopenharmony_ci Section 2.X.8.Z, DDX: Partial Derivative Relative to X 5065bd8deadSopenharmony_ci 5075bd8deadSopenharmony_ci The DDX instruction computes approximate partial derivatives of the four 5085bd8deadSopenharmony_ci components of the single floating-point vector operand with respect to the 5095bd8deadSopenharmony_ci X window coordinate to yield a result vector. The partial derivatives are 5105bd8deadSopenharmony_ci evaluated at the sample location of the pixel. 5115bd8deadSopenharmony_ci 5125bd8deadSopenharmony_ci f = VectorLoad(op0); 5135bd8deadSopenharmony_ci result = ComputePartialX(f); 5145bd8deadSopenharmony_ci 5155bd8deadSopenharmony_ci Note that the partial derivates obtained by this instruction are 5165bd8deadSopenharmony_ci approximate, and derivative-of-derivate instruction sequences may not 5175bd8deadSopenharmony_ci yield accurate second derivatives. Note also that the sample locations 5185bd8deadSopenharmony_ci for attributes declared with the CENTROID interpolation modifier may not 5195bd8deadSopenharmony_ci be evenly spaced, which can lead to artifacts in derivative calculations. 5205bd8deadSopenharmony_ci 5215bd8deadSopenharmony_ci DDX supports only floating-point data type modifiers and is available only 5225bd8deadSopenharmony_ci to fragment programs. 5235bd8deadSopenharmony_ci 5245bd8deadSopenharmony_ci Section 2.X.8.Z, DDY: Partial Derivative Relative to Y 5255bd8deadSopenharmony_ci 5265bd8deadSopenharmony_ci The DDY instruction computes approximate partial derivatives of the four 5275bd8deadSopenharmony_ci components of the single operand with respect to the Y window coordinate 5285bd8deadSopenharmony_ci to yield a result vector. The partial derivatives are evaluated at the 5295bd8deadSopenharmony_ci center of the pixel. 5305bd8deadSopenharmony_ci 5315bd8deadSopenharmony_ci f = VectorLoad(op0); 5325bd8deadSopenharmony_ci result = ComputePartialY(f); 5335bd8deadSopenharmony_ci 5345bd8deadSopenharmony_ci Note that the partial derivates obtained by this instruction are 5355bd8deadSopenharmony_ci approximate, and derivative-of-derivate instruction sequences may not 5365bd8deadSopenharmony_ci yield accurate second derivatives. Note also that the sample locations 5375bd8deadSopenharmony_ci for attributes declared with the CENTROID interpolation modifier may not 5385bd8deadSopenharmony_ci be evenly spaced, which can lead to artifacts in derivative calculations. 5395bd8deadSopenharmony_ci 5405bd8deadSopenharmony_ci DDY supports only floating-point data type modifiers and is available only 5415bd8deadSopenharmony_ci to fragment programs. 5425bd8deadSopenharmony_ci 5435bd8deadSopenharmony_ci Section 2.X.8.Z, KIL: Kill Fragment 5445bd8deadSopenharmony_ci 5455bd8deadSopenharmony_ci The KIL instruction evaluates a condition and kills a fragment if the test 5465bd8deadSopenharmony_ci passes. A fragment killed by the KIL instruction is discarded, and will 5475bd8deadSopenharmony_ci not be seen by subsequent stages of the pipeline. 5485bd8deadSopenharmony_ci 5495bd8deadSopenharmony_ci A KIL instruction may be specified using either a floating-point or 5505bd8deadSopenharmony_ci integer vector operand or a condition code test. 5515bd8deadSopenharmony_ci 5525bd8deadSopenharmony_ci If a floating-point or integer vector is provided, the fragment is 5535bd8deadSopenharmony_ci discarded if any of its components are negative: 5545bd8deadSopenharmony_ci 5555bd8deadSopenharmony_ci tmp = VectorLoad(op0); 5565bd8deadSopenharmony_ci if ((tmp.x < 0) || (tmp.y < 0) || 5575bd8deadSopenharmony_ci (tmp.z < 0) || (tmp.w < 0)) 5585bd8deadSopenharmony_ci { 5595bd8deadSopenharmony_ci exit; 5605bd8deadSopenharmony_ci } 5615bd8deadSopenharmony_ci 5625bd8deadSopenharmony_ci Unsigned integer vector operands are permitted; however, KIL.U will have 5635bd8deadSopenharmony_ci no effect as no component is negative by definition. 5645bd8deadSopenharmony_ci 5655bd8deadSopenharmony_ci If a condition code test is provided, the fragment is discarded if any 5665bd8deadSopenharmony_ci component of the test passes: 5675bd8deadSopenharmony_ci 5685bd8deadSopenharmony_ci if (TestCC(rc.c***) || TestCC(rc.*c**) || 5695bd8deadSopenharmony_ci TestCC(rc.**c*) || TestCC(rc.***c)) 5705bd8deadSopenharmony_ci { 5715bd8deadSopenharmony_ci exit; 5725bd8deadSopenharmony_ci } 5735bd8deadSopenharmony_ci 5745bd8deadSopenharmony_ci KIL supports all three data type modifiers. 5755bd8deadSopenharmony_ci 5765bd8deadSopenharmony_ci KIL is available only to fragment programs. 5775bd8deadSopenharmony_ci 5785bd8deadSopenharmony_ci Replace Section 2.14.8, and rename it to "Vertex Attribute Clipping" 5795bd8deadSopenharmony_ci (p. 70). 5805bd8deadSopenharmony_ci 5815bd8deadSopenharmony_ci After lighting, clamping or masking and possible flatshading, vertex 5825bd8deadSopenharmony_ci attributes, including colors, texture and fog coordinates, shader varying 5835bd8deadSopenharmony_ci variables, and point sizes computed on a per vertex basis, are clipped. 5845bd8deadSopenharmony_ci Those attributes associated with a vertex that lies within the clip volume 5855bd8deadSopenharmony_ci are unaffected by clipping. If a primitive is clipped, however, the 5865bd8deadSopenharmony_ci attributes assigned to vertices produced by clipping are produced by 5875bd8deadSopenharmony_ci interpolating attributes along the clipped edge. 5885bd8deadSopenharmony_ci 5895bd8deadSopenharmony_ci Let the attributes assigned to the two vertices P_1 and P_2 of an 5905bd8deadSopenharmony_ci unclipped edge be a_1 and a_2. The value of t (section 2.12) for a 5915bd8deadSopenharmony_ci clipped point P is used to obtain the attribute associated with P as 5925bd8deadSopenharmony_ci 5935bd8deadSopenharmony_ci a = t * a_1 + (1-t) * a_2 5945bd8deadSopenharmony_ci 5955bd8deadSopenharmony_ci unless the attribute is specified to be interpolated without perspective 5965bd8deadSopenharmony_ci correction in a fragment program. In that case, the attribute associated 5975bd8deadSopenharmony_ci with P is 5985bd8deadSopenharmony_ci 5995bd8deadSopenharmony_ci a = t' * a_1 + (1-t') * a_2 6005bd8deadSopenharmony_ci 6015bd8deadSopenharmony_ci where 6025bd8deadSopenharmony_ci 6035bd8deadSopenharmony_ci t' = (t * w_1) / (t * w_1 + (1-t) * w_2) 6045bd8deadSopenharmony_ci 6055bd8deadSopenharmony_ci and w_1 and w_2 are the w clip coordinates of P_1 and P_2, 6065bd8deadSopenharmony_ci respectively. If w_1 or w_2 is either zero or negative, the value of the 6075bd8deadSopenharmony_ci associated attribute is undefined. 6085bd8deadSopenharmony_ci 6095bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 2.0 Specification (Rasterization) 6105bd8deadSopenharmony_ci 6115bd8deadSopenharmony_ci None 6125bd8deadSopenharmony_ci 6135bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 2.0 Specification (Per-Fragment 6145bd8deadSopenharmony_ciOperations and the Frame Buffer) 6155bd8deadSopenharmony_ci 6165bd8deadSopenharmony_ci None 6175bd8deadSopenharmony_ci 6185bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 2.0 Specification (Special Functions) 6195bd8deadSopenharmony_ci 6205bd8deadSopenharmony_ci None 6215bd8deadSopenharmony_ci 6225bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 2.0 Specification (State and 6235bd8deadSopenharmony_ciState Requests) 6245bd8deadSopenharmony_ci 6255bd8deadSopenharmony_ci None 6265bd8deadSopenharmony_ci 6275bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications 6285bd8deadSopenharmony_ci 6295bd8deadSopenharmony_ci None 6305bd8deadSopenharmony_ci 6315bd8deadSopenharmony_ciDependencies on ARB_draw_buffers and ATI_draw_buffers 6325bd8deadSopenharmony_ci 6335bd8deadSopenharmony_ci If neither ARB_draw_buffers nor ATI_draw_buffers is supported, then the 6345bd8deadSopenharmony_ci discussion of the ARB_draw_buffers option in section 2.X.6.Y should be 6355bd8deadSopenharmony_ci removed, as well as the result bindings of the form "result.color[n]" and 6365bd8deadSopenharmony_ci "result.color[n..o]". 6375bd8deadSopenharmony_ci 6385bd8deadSopenharmony_ciDependencies on ARB_fragment_program_shadow 6395bd8deadSopenharmony_ci 6405bd8deadSopenharmony_ci If ARB_fragment_program_shadow is not supported, then the discussion of 6415bd8deadSopenharmony_ci the ARB_fragment_program_shadow option in section 2.X.6.Y should be 6425bd8deadSopenharmony_ci removed. 6435bd8deadSopenharmony_ci 6445bd8deadSopenharmony_ciDependencies on NV_primitive_restart 6455bd8deadSopenharmony_ci 6465bd8deadSopenharmony_ci The spec describes the behavior that primitive restart does not affect the 6475bd8deadSopenharmony_ci primitive ID counter, including for POLYGON primitives (where one could 6485bd8deadSopenharmony_ci argue that the restart index starts a new primitive without a new Begin to 6495bd8deadSopenharmony_ci reset the count. If NV_primitive_restart is not supported, references to 6505bd8deadSopenharmony_ci that extension in the discussion of the "primitive.id" attribute should be 6515bd8deadSopenharmony_ci removed. 6525bd8deadSopenharmony_ci 6535bd8deadSopenharmony_ciErrors 6545bd8deadSopenharmony_ci 6555bd8deadSopenharmony_ci None 6565bd8deadSopenharmony_ci 6575bd8deadSopenharmony_ciNew State 6585bd8deadSopenharmony_ci 6595bd8deadSopenharmony_ci None 6605bd8deadSopenharmony_ci 6615bd8deadSopenharmony_ciNew Implementation Dependent State 6625bd8deadSopenharmony_ci 6635bd8deadSopenharmony_ci None 6645bd8deadSopenharmony_ci 6655bd8deadSopenharmony_ciIssues 6665bd8deadSopenharmony_ci 6675bd8deadSopenharmony_ci (1) How should special interpolation controls be specified? 6685bd8deadSopenharmony_ci 6695bd8deadSopenharmony_ci RESOLVED: As a special modifier to fragment program attribute variable 6705bd8deadSopenharmony_ci declarations. It was decided that the fragment program was the most 6715bd8deadSopenharmony_ci natural place to put the control. This wouldn't require making a large 6725bd8deadSopenharmony_ci number of related state changes controlling interpolation whenever the 6735bd8deadSopenharmony_ci fragment program used. The final mechanism using special interpolation 6745bd8deadSopenharmony_ci modifiers was chosen because it fit well with the other variable 6755bd8deadSopenharmony_ci modifiers (for data storage size and data type) provided by 6765bd8deadSopenharmony_ci NV_gpu_program4. Examples: 6775bd8deadSopenharmony_ci 6785bd8deadSopenharmony_ci FLAT ATTRIB texcoords[4] = { fragment.texcoord[0..3] }; 6795bd8deadSopenharmony_ci CENTROID ATTRIB texcoord4 = fragment.texcoord[4]; 6805bd8deadSopenharmony_ci CENTROID NOPERSPECTIVE ATTRIB 6815bd8deadSopenharmony_ci attribs[3] = { fragment.attrib[0..2] }; 6825bd8deadSopenharmony_ci 6835bd8deadSopenharmony_ci There were a variety of options considered, including: 6845bd8deadSopenharmony_ci 6855bd8deadSopenharmony_ci * special declarations in vertex or geometry programs to specify the 6865bd8deadSopenharmony_ci interpolation type, 6875bd8deadSopenharmony_ci 6885bd8deadSopenharmony_ci * special declarations in the fragment program to specify one or more 6895bd8deadSopenharmony_ci interpolation type modifiers per binding, such as: 6905bd8deadSopenharmony_ci 6915bd8deadSopenharmony_ci INTERPOLATE fragment.texcoord[0..3], FLAT; 6925bd8deadSopenharmony_ci INTERPOLATE fragment.texcoord[4], CENTROID; 6935bd8deadSopenharmony_ci INTERPOLATE fragment.attrib[0..2], CENTROID, NOPERSPECTIVE; 6945bd8deadSopenharmony_ci 6955bd8deadSopenharmony_ci * fixed-function state specifying the interpolation mode 6965bd8deadSopenharmony_ci 6975bd8deadSopenharmony_ci glInterpolateAttribNV(GL_TEXTURE0, GL_FLAT); 6985bd8deadSopenharmony_ci glInterpolateAttribNV(GL_GENERIC_ATTRIB0, GL_CENTROID_NV); 6995bd8deadSopenharmony_ci 7005bd8deadSopenharmony_ci Recent updates to GLSL provide similar functionality (for centroid) with 7015bd8deadSopenharmony_ci a similar approach, using a modifier on varying variable declarations. 7025bd8deadSopenharmony_ci 7035bd8deadSopenharmony_ci (2) How should perspective-incorrect interpolation (linear in screen 7045bd8deadSopenharmony_ci space) and clipping interact? 7055bd8deadSopenharmony_ci 7065bd8deadSopenharmony_ci RESOLVED: Primitives with attributes specified to be 7075bd8deadSopenharmony_ci perspective-incorrect should be clipped so that the vertices introduced 7085bd8deadSopenharmony_ci by clipping should have attribute values consistent with the 7095bd8deadSopenharmony_ci interpolation mode. We do not want to have large color shifts 7105bd8deadSopenharmony_ci introduced by clipping a perspective-incorrect attribute. For example, 7115bd8deadSopenharmony_ci a primitive that approaches, but doesn't cross, a frustum clip plane 7125bd8deadSopenharmony_ci should look pretty much identical to a similar primitive that just 7135bd8deadSopenharmony_ci barely crosses the clip plane. 7145bd8deadSopenharmony_ci 7155bd8deadSopenharmony_ci Clipping perspective-incorrect interpolants that cross the W==0 plane is 7165bd8deadSopenharmony_ci very challenging. The attribute clipping equation provided in the spec 7175bd8deadSopenharmony_ci effectively projects all the original vertices to screen space while 7185bd8deadSopenharmony_ci ignoring the X and Y frustum clip plane. As W approaches zero, the 7195bd8deadSopenharmony_ci projected X/Y window coordinates become extremely large. When clipping 7205bd8deadSopenharmony_ci an edge with one vertex inside the frustum and the other out near 7215bd8deadSopenharmony_ci infinity (after projection, due to W approaching zero), the interpolated 7225bd8deadSopenharmony_ci attribute for the entire visible portion of the edge should almost 7235bd8deadSopenharmony_ci exactly match the attribute value of the visible vertex. 7245bd8deadSopenharmony_ci 7255bd8deadSopenharmony_ci If an outlying vertex approaches and then goes past W==0, it can be said 7265bd8deadSopenharmony_ci to go "to infinity and beyond" in screen space. The correct answer for 7275bd8deadSopenharmony_ci screen-linear interpolation is no longer obvious, at least to the author 7285bd8deadSopenharmony_ci of this specification. Rather than trying to figure out what the 7295bd8deadSopenharmony_ci "right" answer is or if one even exists, the results of clipping such 7305bd8deadSopenharmony_ci edges is specified as undefined. 7315bd8deadSopenharmony_ci 7325bd8deadSopenharmony_ci (3) If a shader wants to use interpolation modifiers without using 7335bd8deadSopenharmony_ci declared variables, is that possible? 7345bd8deadSopenharmony_ci 7355bd8deadSopenharmony_ci RESOLVED: Yes. If "dummy" variables are declared, all interpolants 7365bd8deadSopenharmony_ci bound to that variable will get the variable's interpolation modifiers. 7375bd8deadSopenharmony_ci In the following program: 7385bd8deadSopenharmony_ci 7395bd8deadSopenharmony_ci FLAT ATTRIB tc02[3] = { fragment.texcoord[0..2] }; 7405bd8deadSopenharmony_ci MOV R0, fragment.texcoord[1]; 7415bd8deadSopenharmony_ci MOV R1, fragment.texcoord[3]; 7425bd8deadSopenharmony_ci 7435bd8deadSopenharmony_ci The variable R0 will get texture coordinate set 1, which will be 7445bd8deadSopenharmony_ci flat-shaded due to the declaration of "tc02". The variable R1 will get 7455bd8deadSopenharmony_ci texture coordinate set 3, which will be smooth shaded (default). 7465bd8deadSopenharmony_ci 7475bd8deadSopenharmony_ci (4) Is it possible to read the same attribute with different interpolation 7485bd8deadSopenharmony_ci modifiers? 7495bd8deadSopenharmony_ci 7505bd8deadSopenharmony_ci RESOLVED: No. A program that tries to do that will fail to compile. 7515bd8deadSopenharmony_ci 7525bd8deadSopenharmony_ci (5) Why can't fragment program results be declared as arrays? 7535bd8deadSopenharmony_ci 7545bd8deadSopenharmony_ci RESOLVED: This is a limitation of the programming model. If an 7555bd8deadSopenharmony_ci implementation needs to do run-time indexing of fragment program result 7565bd8deadSopenharmony_ci variables (effectively writing to "result.color[A0.x]"), code such as 7575bd8deadSopenharmony_ci the following can be used: 7585bd8deadSopenharmony_ci 7595bd8deadSopenharmony_ci TEMP colors[4]; 7605bd8deadSopenharmony_ci ... 7615bd8deadSopenharmony_ci MOV colors[A0.x], R1; 7625bd8deadSopenharmony_ci MOV colors[3], 12.3; 7635bd8deadSopenharmony_ci ... 7645bd8deadSopenharmony_ci # end of the program 7655bd8deadSopenharmony_ci MOV result.color[0], colors[0]; 7665bd8deadSopenharmony_ci MOV result.color[1], colors[1]; 7675bd8deadSopenharmony_ci MOV result.color[2], colors[2]; 7685bd8deadSopenharmony_ci MOV result.color[3], colors[3]; 7695bd8deadSopenharmony_ci 7705bd8deadSopenharmony_ci (6) Do clip distances require that the corresponding clip planes be 7715bd8deadSopenharmony_ci enabled to be read by a fragment program? 7725bd8deadSopenharmony_ci 7735bd8deadSopenharmony_ci RESOLVED: No. 7745bd8deadSopenharmony_ci 7755bd8deadSopenharmony_ci (7) How do primitive IDs work with fragment programs? 7765bd8deadSopenharmony_ci 7775bd8deadSopenharmony_ci RESOLVED: If a geometry program is enabled, the primitive ID is 7785bd8deadSopenharmony_ci consumed by the geometry program and is not automatically available to 7795bd8deadSopenharmony_ci the fragment program. If the fragment program needs a primitive ID in 7805bd8deadSopenharmony_ci this case, the geometry program can write out a primitive ID using the 7815bd8deadSopenharmony_ci "result.primid" binding, and the fragment program will see the primitive 7825bd8deadSopenharmony_ci ID written for the provoking vertex. 7835bd8deadSopenharmony_ci 7845bd8deadSopenharmony_ci If no geometry program is enabled, the primitive ID is automatically 7855bd8deadSopenharmony_ci available, and specifies the number of primitives (points, lines, or 7865bd8deadSopenharmony_ci triangles) processed by since the last explicit or implicit Begin call. 7875bd8deadSopenharmony_ci 7885bd8deadSopenharmony_ci (8) What is the primitive ID for non-geometry commands that generate 7895bd8deadSopenharmony_ci fragments, such as DrawPixels, Bitmap, and CopyPixels. 7905bd8deadSopenharmony_ci 7915bd8deadSopenharmony_ci RESOLVED: Zero. 7925bd8deadSopenharmony_ci 7935bd8deadSopenharmony_ci (9) How does the FLAT interpolation modifier interact with point sprite 7945bd8deadSopenharmony_ci coordinate replacement? 7955bd8deadSopenharmony_ci 7965bd8deadSopenharmony_ci RESOLVED: The value of such attributes are undefined. Specifying these 7975bd8deadSopenharmony_ci two operations together is self-contradictory -- FLAT asks for an 7985bd8deadSopenharmony_ci interpolant that is constant over a primitive, and point sprite 7995bd8deadSopenharmony_ci coordinate interpolation asks for an interpolant that is non-constant 8005bd8deadSopenharmony_ci over a point sprite. 8015bd8deadSopenharmony_ci 8025bd8deadSopenharmony_ci 8035bd8deadSopenharmony_ciRevision History 8045bd8deadSopenharmony_ci 8055bd8deadSopenharmony_ci Rev. Date Author Changes 8065bd8deadSopenharmony_ci ---- -------- -------- -------------------------------------------- 8075bd8deadSopenharmony_ci 6 05/26/09 pbrown Fix documentation of KIL to support integer 8085bd8deadSopenharmony_ci operands, as indicated in the opcodes table 8095bd8deadSopenharmony_ci in NV_gpu_program4. 8105bd8deadSopenharmony_ci 8115bd8deadSopenharmony_ci 5 03/11/09 pbrown Fix section numbers for option/declaration 8125bd8deadSopenharmony_ci sections. 8135bd8deadSopenharmony_ci 8145bd8deadSopenharmony_ci 4 11/06/07 pbrown Documented interaction between the FLAT 8155bd8deadSopenharmony_ci interpolation modifier and point sprite 8165bd8deadSopenharmony_ci coordinate replacement. 8175bd8deadSopenharmony_ci 8185bd8deadSopenharmony_ci 1-3 pbrown Internal spec development. 819