15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci NV_fragment_program2 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_NV_fragment_program2 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com) 125bd8deadSopenharmony_ci Eric Werness, NVIDIA Corporation (ewerness 'at' nvidia.com) 135bd8deadSopenharmony_ci 145bd8deadSopenharmony_ciStatus 155bd8deadSopenharmony_ci 165bd8deadSopenharmony_ci Shipping. 175bd8deadSopenharmony_ci 185bd8deadSopenharmony_ciVersion 195bd8deadSopenharmony_ci 205bd8deadSopenharmony_ci Last Modified: 08/04/2004 215bd8deadSopenharmony_ci NVIDIA Revision: 8 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ciNumber 245bd8deadSopenharmony_ci 255bd8deadSopenharmony_ci 304 265bd8deadSopenharmony_ci 275bd8deadSopenharmony_ci 285bd8deadSopenharmony_ciDependencies 295bd8deadSopenharmony_ci 305bd8deadSopenharmony_ci ARB_fragment_program is required. 315bd8deadSopenharmony_ci NV_fragment_program_option is required. 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ciOverview 345bd8deadSopenharmony_ci 355bd8deadSopenharmony_ci This extension, like the NV_fragment_program_option extension, provides 365bd8deadSopenharmony_ci additional fragment program functionality to extend the standard 375bd8deadSopenharmony_ci ARB_fragment_program language and execution environment. ARB programs 385bd8deadSopenharmony_ci wishing to use this added functionality need only add: 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ci OPTION NV_fragment_program2; 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ci to the beginning of their fragment programs. 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ci New functionality provided by this extension, above and beyond that 455bd8deadSopenharmony_ci already provided by the NV_fragment_program_option extension, includes: 465bd8deadSopenharmony_ci 475bd8deadSopenharmony_ci 485bd8deadSopenharmony_ci * structured branching support, including data-dependent IF tests, loops 495bd8deadSopenharmony_ci supporting a fixed number of iterations, and a data-dependent loop 505bd8deadSopenharmony_ci exit instruction (BRK), 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ci * subroutine calls, 535bd8deadSopenharmony_ci 545bd8deadSopenharmony_ci * instructions to perform vector normalization, divide vector components 555bd8deadSopenharmony_ci by a scalar, and perform two-component dot products (with or without a 565bd8deadSopenharmony_ci scalar add), 575bd8deadSopenharmony_ci 585bd8deadSopenharmony_ci * an instruction to perform a texture lookup with an explicit LOD, 595bd8deadSopenharmony_ci 605bd8deadSopenharmony_ci * a loop index register for indirect access into the texture coordinate 615bd8deadSopenharmony_ci attribute array, and 625bd8deadSopenharmony_ci 635bd8deadSopenharmony_ci * a facing attribute that indicates whether the fragment is generated 645bd8deadSopenharmony_ci from a front- or back-facing primitive. 655bd8deadSopenharmony_ci 665bd8deadSopenharmony_ci 675bd8deadSopenharmony_ciIssues 685bd8deadSopenharmony_ci 695bd8deadSopenharmony_ci * Should this extension expose projective forms of the LOD-modifying 705bd8deadSopenharmony_ci texture instructions? 715bd8deadSopenharmony_ci 725bd8deadSopenharmony_ci RESOLVED: No. The user can manually add a DIV instruction to achieve 735bd8deadSopenharmony_ci the same effect. 745bd8deadSopenharmony_ci 755bd8deadSopenharmony_ci * Should this extension expose precision explicitly? 765bd8deadSopenharmony_ci 775bd8deadSopenharmony_ci RESOLVED: Only for storage using the SHORT TEMP and LONG TEMP syntax 785bd8deadSopenharmony_ci (similar to NV_fragment_program_option). 795bd8deadSopenharmony_ci 805bd8deadSopenharmony_ci * How are resources (such as registers and condition codes) scoped? 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ci RESOLVED: All resources are globally scoped. This means that if, for 835bd8deadSopenharmony_ci instance, a subroutine modifies a condition code, that modification 845bd8deadSopenharmony_ci effects both the caller and the callee. 855bd8deadSopenharmony_ci 865bd8deadSopenharmony_ci * How is the scope determined for instructions required to be within a 875bd8deadSopenharmony_ci specific loop construct? 885bd8deadSopenharmony_ci 895bd8deadSopenharmony_ci RESOLVED: The scope is determined statically at compile time. This means 905bd8deadSopenharmony_ci that calling BRK and using A0 from a subroutine called within a loop is 915bd8deadSopenharmony_ci a compile error. 925bd8deadSopenharmony_ci 935bd8deadSopenharmony_ci 945bd8deadSopenharmony_ciNew Procedures and Functions 955bd8deadSopenharmony_ci 965bd8deadSopenharmony_ci None. 975bd8deadSopenharmony_ci 985bd8deadSopenharmony_ciNew Tokens 995bd8deadSopenharmony_ci 1005bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetProgramivARB: 1015bd8deadSopenharmony_ci 1025bd8deadSopenharmony_ci MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 1035bd8deadSopenharmony_ci MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 1045bd8deadSopenharmony_ci MAX_PROGRAM_IF_DEPTH_NV 0x88F6 1055bd8deadSopenharmony_ci MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 1065bd8deadSopenharmony_ci MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 1075bd8deadSopenharmony_ci 1085bd8deadSopenharmony_ci 1095bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 1.2.1 Specification (OpenGL Operation) 1105bd8deadSopenharmony_ci 1115bd8deadSopenharmony_ci None. 1125bd8deadSopenharmony_ci 1135bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 1.2.1 Specification (Rasterization) 1145bd8deadSopenharmony_ci 1155bd8deadSopenharmony_ci Modify Section 3.11 of ARB_fragment_program (Fragment Program): 1165bd8deadSopenharmony_ci 1175bd8deadSopenharmony_ci Delete the sentence referring to the lack of branching or looping. 1185bd8deadSopenharmony_ci 1195bd8deadSopenharmony_ci Modify Section 3.11.2 of ARB_fragment_program (Fragment Program Grammar 1205bd8deadSopenharmony_ci and Restrictions): 1215bd8deadSopenharmony_ci 1225bd8deadSopenharmony_ci (mostly add to existing grammar rules, as extended by 1235bd8deadSopenharmony_ci NV_fragment_program_option) 1245bd8deadSopenharmony_ci 1255bd8deadSopenharmony_ci <optionName> ::= "NV_fragment_program2" 1265bd8deadSopenharmony_ci 1275bd8deadSopenharmony_ci <statement> ::= <branchLabel> ":" 1285bd8deadSopenharmony_ci 1295bd8deadSopenharmony_ci <instruction> ::= <FlowInstruction> 1305bd8deadSopenharmony_ci 1315bd8deadSopenharmony_ci <ALUInstruction> ::= <VECSCAop_instruction> 1325bd8deadSopenharmony_ci 1335bd8deadSopenharmony_ci <FlowInstruction> ::= <BRAop_instruction> 1345bd8deadSopenharmony_ci | <FLOWCCop_instruction> 1355bd8deadSopenharmony_ci | <IFop_instruction> 1365bd8deadSopenharmony_ci | <LOOPop_instruction> 1375bd8deadSopenharmony_ci | <ENDFLOWop_instruction> 1385bd8deadSopenharmony_ci 1395bd8deadSopenharmony_ci <VECTORop> ::= "NRM" 1405bd8deadSopenharmony_ci 1415bd8deadSopenharmony_ci <VECSCAop_instruction> ::= <VECSCAop> <instResult> "," <instOperandV> "," 1425bd8deadSopenharmony_ci <instOperandS> 1435bd8deadSopenharmony_ci 1445bd8deadSopenharmony_ci <VECSCAop> ::= "DIV" 1455bd8deadSopenharmony_ci 1465bd8deadSopenharmony_ci <BINop> ::= "DP2" 1475bd8deadSopenharmony_ci 1485bd8deadSopenharmony_ci <TRIop> ::= "DP2A" 1495bd8deadSopenharmony_ci 1505bd8deadSopenharmony_ci <TEXop> ::= "TXL" 1515bd8deadSopenharmony_ci 1525bd8deadSopenharmony_ci <BRAop_instruction> ::= <BRAop> <branchLabel> <optBranchCond> 1535bd8deadSopenharmony_ci 1545bd8deadSopenharmony_ci <BRAop> ::= "CAL" 1555bd8deadSopenharmony_ci 1565bd8deadSopenharmony_ci <FLOWCCop_instruction> ::= <FLOWCCop> <optBranchCond> 1575bd8deadSopenharmony_ci 1585bd8deadSopenharmony_ci <FLOWCCop> ::= "RET" 1595bd8deadSopenharmony_ci | "BRK" 1605bd8deadSopenharmony_ci 1615bd8deadSopenharmony_ci <IFop_instruction> ::= <IFop> <ccTest> 1625bd8deadSopenharmony_ci 1635bd8deadSopenharmony_ci <IFop> ::= "IF" 1645bd8deadSopenharmony_ci 1655bd8deadSopenharmony_ci <LOOPop_instruction> ::= <LOOPop> <instOperandV> 1665bd8deadSopenharmony_ci 1675bd8deadSopenharmony_ci <LOOPop> ::= "LOOP" 1685bd8deadSopenharmony_ci | "REP" 1695bd8deadSopenharmony_ci 1705bd8deadSopenharmony_ci <ENDFLOWop_instruction> ::= <ENDFLOWop> 1715bd8deadSopenharmony_ci 1725bd8deadSopenharmony_ci <ENDFLOWop> ::= "ELSE" 1735bd8deadSopenharmony_ci | "ENDIF" 1745bd8deadSopenharmony_ci | "ENDLOOP" 1755bd8deadSopenharmony_ci | "ENDREP" 1765bd8deadSopenharmony_ci 1775bd8deadSopenharmony_ci <optBranchCond> ::= /* empty */ 1785bd8deadSopenharmony_ci | <ccMask> 1795bd8deadSopenharmony_ci 1805bd8deadSopenharmony_ci <branchLabel> ::= <identifier> 1815bd8deadSopenharmony_ci 1825bd8deadSopenharmony_ci <attribFragBasic> ::= "texcoord" "[" <arrayMemRel> "]" 1835bd8deadSopenharmony_ci | "facing" 1845bd8deadSopenharmony_ci 1855bd8deadSopenharmony_ci <arrayMemRel> ::= <addrUseS> <arrayMemRelOffset> 1865bd8deadSopenharmony_ci 1875bd8deadSopenharmony_ci <arrayMemRelOffset> ::= /* empty */ 1885bd8deadSopenharmony_ci | "+" <addrRegPosOffset> 1895bd8deadSopenharmony_ci 1905bd8deadSopenharmony_ci <addrRegPosOffset> ::= <integer> from 0 to 9 1915bd8deadSopenharmony_ci 1925bd8deadSopenharmony_ci <addrUseS> ::= <addrVarName> <scalarAddrSuffix> 1935bd8deadSopenharmony_ci 1945bd8deadSopenharmony_ci <scalarAddrSuffix> ::= "." <addrComponent> 1955bd8deadSopenharmony_ci 1965bd8deadSopenharmony_ci <addrComponent> ::= "x" 1975bd8deadSopenharmony_ci 1985bd8deadSopenharmony_ci Note: This extension provides a pre-defined address register (A0) that 1995bd8deadSopenharmony_ci matches the <addrVarName> grammar rule and can be used as a loop counter 2005bd8deadSopenharmony_ci (Section 3.11.3.Y). It is not possible to declare additional address 2015bd8deadSopenharmony_ci register variables. 2025bd8deadSopenharmony_ci 2035bd8deadSopenharmony_ci 2045bd8deadSopenharmony_ci Modify Section 3.11.3.1, Fragment Attributes 2055bd8deadSopenharmony_ci 2065bd8deadSopenharmony_ci (add new bindings to binding table) 2075bd8deadSopenharmony_ci 2085bd8deadSopenharmony_ci Fragment Attribute Binding Components Underlying State 2095bd8deadSopenharmony_ci -------------------------- ---------- ---------------------------- 2105bd8deadSopenharmony_ci ... 2115bd8deadSopenharmony_ci fragment.texcoord[A0.x+n] (s,t,r,q) indexed texture coordinate 2125bd8deadSopenharmony_ci fragment.facing (f,0,0,1) fragment facing 2135bd8deadSopenharmony_ci 2145bd8deadSopenharmony_ci If a fragment attribute binding matches "fragment.texcoord[A0.x+n]", a 2155bd8deadSopenharmony_ci texture coordinate number <c> is computed by adding the current value of 2165bd8deadSopenharmony_ci the "A0.x" address register (the loop index -- Section 3.11.3.Y) and <n>. 2175bd8deadSopenharmony_ci The "x", "y", "z", and "w" components of the fragment attribute variable 2185bd8deadSopenharmony_ci are filled with the "s", "t", "r", and "q" components, respectively, of 2195bd8deadSopenharmony_ci the fragment texture coordinates for texture coordinate set <c>. If <c> 2205bd8deadSopenharmony_ci is negative or greater than or equal to MAX_TEXTURE_COORDS_ARB, the 2215bd8deadSopenharmony_ci fragment attribute variable is undefined. 2225bd8deadSopenharmony_ci 2235bd8deadSopenharmony_ci If a fragment attribute binding matches "fragment.facing", the "x" 2245bd8deadSopenharmony_ci component of the fragment attribute variable is filled with +1.0 or -1.0, 2255bd8deadSopenharmony_ci depending on the orientation of the primitive producing the fragment. If 2265bd8deadSopenharmony_ci the fragment is generated by a back-facing polygon (including point- and 2275bd8deadSopenharmony_ci line-mode polygons), the facing is -1.0; otherwise, the facing is +1.0. 2285bd8deadSopenharmony_ci The "y", "z", and "w" coordinates are filled with 0, 0, and 1, 2295bd8deadSopenharmony_ci respectively. 2305bd8deadSopenharmony_ci 2315bd8deadSopenharmony_ci 2325bd8deadSopenharmony_ci Add New Section 3.11.3.Y, Fragment Program Address Register (insert after 2335bd8deadSopenharmony_ci Section 3.11.3.X, Condition Code Register) 2345bd8deadSopenharmony_ci 2355bd8deadSopenharmony_ci Fragment program address register variables are a set of four-component 2365bd8deadSopenharmony_ci signed integer vectors where only the "x" component of the address 2375bd8deadSopenharmony_ci registers is currently accessible. Address registers are used as indices 2385bd8deadSopenharmony_ci when performing relative addressing in the "fragment.texcoord" attribute 2395bd8deadSopenharmony_ci array (section 3.11.3.1). 2405bd8deadSopenharmony_ci 2415bd8deadSopenharmony_ci Fragment program address registers can not be declared in a fragment 2425bd8deadSopenharmony_ci program. There is only a single built-in address register, "A0.x" (loop 2435bd8deadSopenharmony_ci index), which is available inside LOOP/ENDLOOP blocks. A fragment program 2445bd8deadSopenharmony_ci that accesses A0.x outside a LOOP/ENDLOOP block will fail to load. 2455bd8deadSopenharmony_ci 2465bd8deadSopenharmony_ci A0.x is initialized in by the LOOP instruction and updated by the ENDLOOP 2475bd8deadSopenharmony_ci instruction. When LOOP blocks are nested, each block has its own value 2485bd8deadSopenharmony_ci for A0.x, but only the A0.x value for the innermost block can be used. The 2495bd8deadSopenharmony_ci value of A0.x is clamped to be greater than or equal to 0. 2505bd8deadSopenharmony_ci 2515bd8deadSopenharmony_ci 2525bd8deadSopenharmony_ci Modify Section 3.11.4, Fragment Program Execution Environment 2535bd8deadSopenharmony_ci 2545bd8deadSopenharmony_ci (modify instruction table) There are sixty-seven fragment program 2555bd8deadSopenharmony_ci instructions.... 2565bd8deadSopenharmony_ci 2575bd8deadSopenharmony_ci Modifiers 2585bd8deadSopenharmony_ci Instr. R H X C S Inputs Output Description 2595bd8deadSopenharmony_ci ------- - - - - - ------ ------ -------------------------------- 2605bd8deadSopenharmony_ci ABS X X X X X v v absolute value 2615bd8deadSopenharmony_ci ADD X X X X X v,v v add 2625bd8deadSopenharmony_ci BRK - - - - - c - break out of loop instruction 2635bd8deadSopenharmony_ci CAL - - - - - c - subroutine call 2645bd8deadSopenharmony_ci CMP - - - X X v,v,v v compare 2655bd8deadSopenharmony_ci COS X X - X X s ssss cosine with reduction to [-PI,PI] 2665bd8deadSopenharmony_ci DDX X X - X X v v partial derivative relative to X 2675bd8deadSopenharmony_ci DDY X X - X X v v partial derivative relative to Y 2685bd8deadSopenharmony_ci DIV X X - X X v,s v divide vector components by scalar 2695bd8deadSopenharmony_ci DP2 X X X X X v,v ssss 2-component dot product 2705bd8deadSopenharmony_ci DP2A X X X X X v,v,v ssss 2-comp. dot product w/scalar add 2715bd8deadSopenharmony_ci DP3 X X X X X v,v ssss 3-component dot product 2725bd8deadSopenharmony_ci DP4 X X X X X v,v ssss 4-component dot product 2735bd8deadSopenharmony_ci DPH X X X X X v,v ssss homogeneous dot product 2745bd8deadSopenharmony_ci DST X X - X X v,v v distance vector 2755bd8deadSopenharmony_ci ELSE - - - - - - - start if test else block 2765bd8deadSopenharmony_ci ENDIF - - - - - - - end if test block 2775bd8deadSopenharmony_ci ENDLOOP - - - - - - - end of loop block 2785bd8deadSopenharmony_ci ENDREP - - - - - - - end of repeat block 2795bd8deadSopenharmony_ci EX2 X X - X X s ssss exponential base 2 2805bd8deadSopenharmony_ci FLR X X X X X v v floor 2815bd8deadSopenharmony_ci FRC X X X X X v v fraction 2825bd8deadSopenharmony_ci IF - - - - - c - start of if test block 2835bd8deadSopenharmony_ci KIL - - - - - v or c - kill fragment 2845bd8deadSopenharmony_ci LG2 X X - X X s ssss logarithm base 2 2855bd8deadSopenharmony_ci LIT X X - X X v v compute light coefficients 2865bd8deadSopenharmony_ci LOOP - - - - - v - start of loop block 2875bd8deadSopenharmony_ci LRP X X X X X v,v,v v linear interpolation 2885bd8deadSopenharmony_ci MAD X X X X X v,v,v v multiply and add 2895bd8deadSopenharmony_ci MAX X X X X X v,v v maximum 2905bd8deadSopenharmony_ci MIN X X X X X v,v v minimum 2915bd8deadSopenharmony_ci MOV X X X X X v v move 2925bd8deadSopenharmony_ci MUL X X X X X v,v v multiply 2935bd8deadSopenharmony_ci NRM X X - X X v v normalize 3-component vector 2945bd8deadSopenharmony_ci PK2H - - - - - v ssss pack two 16-bit floats 2955bd8deadSopenharmony_ci PK2US - - - - - v ssss pack two unsigned 16-bit scalars 2965bd8deadSopenharmony_ci PK4B - - - - - v ssss pack four signed 8-bit scalars 2975bd8deadSopenharmony_ci PK4UB - - - - - v ssss pack four unsigned 8-bit scalars 2985bd8deadSopenharmony_ci POW X X - X X s,s ssss exponentiate 2995bd8deadSopenharmony_ci RCP X X - X X s ssss reciprocal 3005bd8deadSopenharmony_ci REP - - - - - v - start of repeat block 3015bd8deadSopenharmony_ci RET - - - - - c - subroutine return 3025bd8deadSopenharmony_ci RFL X X - X X v,v v reflection vector 3035bd8deadSopenharmony_ci RSQ X X - X X s ssss reciprocal square root 3045bd8deadSopenharmony_ci SCS X X - X X s ss-- sine/cosine without reduction 3055bd8deadSopenharmony_ci SEQ X X X X X v,v v set on equal 3065bd8deadSopenharmony_ci SFL X X X X X v,v v set on false 3075bd8deadSopenharmony_ci SGE X X X X X v,v v set on greater than or equal 3085bd8deadSopenharmony_ci SGT X X X X X v,v v set on greater than 3095bd8deadSopenharmony_ci SIN X X - X X s ssss sine with reduction to [-PI,PI] 3105bd8deadSopenharmony_ci SLE X X X X X v,v v set on less than or equal 3115bd8deadSopenharmony_ci SLT X X X X X v,v v set on less than 3125bd8deadSopenharmony_ci SNE X X X X X v,v v set on not equal 3135bd8deadSopenharmony_ci STR X X X X X v,v v set on true 3145bd8deadSopenharmony_ci SUB X X X X X v,v v subtract 3155bd8deadSopenharmony_ci SWZ X X - X X v v extended swizzle 3165bd8deadSopenharmony_ci TEX - - - X X v v texture sample 3175bd8deadSopenharmony_ci TXB - - - X X v v texture sample with bias 3185bd8deadSopenharmony_ci TXD - - - X X v,v,v v texture sample w/partials 3195bd8deadSopenharmony_ci TXL - - - X X v v texture same w/explicit LOD 3205bd8deadSopenharmony_ci TXP - - - X X v v texture sample with projection 3215bd8deadSopenharmony_ci UP2H - - - X X s v unpack two 16-bit floats 3225bd8deadSopenharmony_ci UP2US - - - X X s v unpack two unsigned 16-bit scalars 3235bd8deadSopenharmony_ci UP4B - - - X X s v unpack four signed 8-bit scalars 3245bd8deadSopenharmony_ci UP4UB - - - X X s v unpack four unsigned 8-bit scalars 3255bd8deadSopenharmony_ci X2D X X - X X v,v,v v 2D coordinate transformation 3265bd8deadSopenharmony_ci XPD X X - X X v,v v cross product 3275bd8deadSopenharmony_ci 3285bd8deadSopenharmony_ci Table X.5: Summary of fragment program instructions. The columns "R", 3295bd8deadSopenharmony_ci "H", "X", "C", and "S" indicate whether the "R", "H", or "X" precision 3305bd8deadSopenharmony_ci modifiers, the C condition code update modifier, and the "_SAT"/"_SSAT" 3315bd8deadSopenharmony_ci saturation modifiers, respectively, are supported for the opcode. In 3325bd8deadSopenharmony_ci the input/output columns, "v" indicates a floating-point vector input or 3335bd8deadSopenharmony_ci output, "s" indicates a floating-point scalar input, "ssss" indicates a 3345bd8deadSopenharmony_ci scalar output replicated across a 4-component result vector, "ss--" 3355bd8deadSopenharmony_ci indicates two scalar outputs in the first two components, and "c" 3365bd8deadSopenharmony_ci indicates a condition code test. Instructions describe as "texture 3375bd8deadSopenharmony_ci sample" also specify a texture image unit identifier and a texture 3385bd8deadSopenharmony_ci target. 3395bd8deadSopenharmony_ci 3405bd8deadSopenharmony_ci 3415bd8deadSopenharmony_ci Modify Section 3.11.4.3, Fragment Program Destination Register Update 3425bd8deadSopenharmony_ci 3435bd8deadSopenharmony_ci (modify saturation discussion) If the instruction opcode has the "_SAT" 3445bd8deadSopenharmony_ci suffix, requesting saturated result vectors, each component of the result 3455bd8deadSopenharmony_ci vector is clamped to the range [0,1] before updating the destination 3465bd8deadSopenharmony_ci register. If the instruction opcode has the "_SSAT" suffix, requesting 3475bd8deadSopenharmony_ci signed saturation, each component of the result vector is clamped to the 3485bd8deadSopenharmony_ci range [-1,1] before updating the destination register. 3495bd8deadSopenharmony_ci 3505bd8deadSopenharmony_ci 3515bd8deadSopenharmony_ci Add Section 3.11.4.X, Fragment Program Branching (before Section 3.11.4.4, 3525bd8deadSopenharmony_ci Fragment Program Result Processing) 3535bd8deadSopenharmony_ci 3545bd8deadSopenharmony_ci Fragment programs support a limited model of branching. Fragment programs 3555bd8deadSopenharmony_ci can specify one of several types of instruction blocks: IF/ELSE/ENDIF 3565bd8deadSopenharmony_ci blocks, LOOP/ENDLOOP blocks, and REP/ENDREP blocks. Examples include the 3575bd8deadSopenharmony_ci following: 3585bd8deadSopenharmony_ci 3595bd8deadSopenharmony_ci LOOP {5, 0, 1}; # 5 iterations with loop index at 0,1,2,3,4 3605bd8deadSopenharmony_ci ADD R0, R0, R1; 3615bd8deadSopenharmony_ci ENDLOOP; 3625bd8deadSopenharmony_ci 3635bd8deadSopenharmony_ci REP repCount; 3645bd8deadSopenharmony_ci ADD R0, R0, R1; 3655bd8deadSopenharmony_ci ENDREP; 3665bd8deadSopenharmony_ci 3675bd8deadSopenharmony_ci MOVC CC, R0; 3685bd8deadSopenharmony_ci IF GT.x; 3695bd8deadSopenharmony_ci MOV R0, R1; # executes if R0.x > 0 3705bd8deadSopenharmony_ci ELSE; 3715bd8deadSopenharmony_ci MOV R0, R2; # executes if R0.x <= 0 3725bd8deadSopenharmony_ci ENDIF; 3735bd8deadSopenharmony_ci 3745bd8deadSopenharmony_ci Instruction blocks may be nested -- for example, a LOOP block may be 3755bd8deadSopenharmony_ci contained inside an IF/ELSE/ENDIF block. In all cases, each instruction 3765bd8deadSopenharmony_ci block must be terminated with the appropriate instruction (ENDIF for IF, 3775bd8deadSopenharmony_ci ENDLOOP for LOOP, ENDREP for REP). Nested instruction blocks must be 3785bd8deadSopenharmony_ci wholly contained within a block -- if a LOOP instruction is found between 3795bd8deadSopenharmony_ci an IF and ELSE instruction, the ENDLOOP must also be present between the 3805bd8deadSopenharmony_ci IF and ELSE. A fragment program will fail to load if any instruction 3815bd8deadSopenharmony_ci block is terminated by an incorrect instruction or is not terminated 3825bd8deadSopenharmony_ci before the block containing it. 3835bd8deadSopenharmony_ci 3845bd8deadSopenharmony_ci IF/ELSE/ENDIF blocks evaluate a condition to determine which instructions 3855bd8deadSopenharmony_ci to execute. If the condition is true, all instructions between the IF and 3865bd8deadSopenharmony_ci ELSE are executed. If the condition is false, all instructions between 3875bd8deadSopenharmony_ci the ELSE and ENDIF are executed. The ELSE instruction is optional. If 3885bd8deadSopenharmony_ci the ELSE is omitted, all instructions between the IF and ENDIF are 3895bd8deadSopenharmony_ci executed if the condition is true, or skipped if the condition is false. 3905bd8deadSopenharmony_ci A limited amount of nesting is supported -- a fragment program will fail 3915bd8deadSopenharmony_ci to load if an IF instruction is nested inside MAX_PROGRAM_IF_DEPTH_NV or 3925bd8deadSopenharmony_ci more IF/ELSE/ENDIF blocks. 3935bd8deadSopenharmony_ci 3945bd8deadSopenharmony_ci The condition of an IF test is specified by the <ccTest> grammar rule and 3955bd8deadSopenharmony_ci may depend on the contents of the condition code register. Branch 3965bd8deadSopenharmony_ci conditions are evaluated by evaluating a condition code write mask in 3975bd8deadSopenharmony_ci exactly the same manner as done for register writes (section 2.14.2.2). 3985bd8deadSopenharmony_ci If any of the four components of the condition code write mask are 3995bd8deadSopenharmony_ci enabled, the branch is taken and execution continues with the instruction 4005bd8deadSopenharmony_ci following the label specified in the instruction. Otherwise, the 4015bd8deadSopenharmony_ci instruction is ignored and fragment program execution continues with the 4025bd8deadSopenharmony_ci next instruction. In the following example code, 4035bd8deadSopenharmony_ci 4045bd8deadSopenharmony_ci MOVC CC, c[0]; # c[0]=(-2, 0, 2, NaN), CC gets (LT,EQ,GT,UN) 4055bd8deadSopenharmony_ci CAL label1 (LT.xyzw); # call taken 4065bd8deadSopenharmony_ci CAL label2 (LT.wyzw); # call not taken 4075bd8deadSopenharmony_ci 4085bd8deadSopenharmony_ci the first CAL instruction loads a condition code of (LT,EQ,GT,UN) while 4095bd8deadSopenharmony_ci the second CAL instruction loads a condition code of (UN,EQ,GT,UN). The 4105bd8deadSopenharmony_ci first call will be made because the "x" component evaluates to LT; the 4115bd8deadSopenharmony_ci second call will not be made because no component evaluates to LT. 4125bd8deadSopenharmony_ci 4135bd8deadSopenharmony_ci LOOP/ENDLOOP and REP/ENDREP blocks involve a loop counter that indicates 4145bd8deadSopenharmony_ci the number of times the instructions between the LOOP/REP and 4155bd8deadSopenharmony_ci ENDLOOP/ENDREP are executed. Looping blocks have a number of significant 4165bd8deadSopenharmony_ci limitations. First, the loop counter can not be computed at run time; it 4175bd8deadSopenharmony_ci must be specified as a program parameter. Second, the number of loop 4185bd8deadSopenharmony_ci iterations is limited to the value MAX_PROGRAM_LOOP_COUNT_NV, which must 4195bd8deadSopenharmony_ci be at least 255. Third, only a limited amount of nesting is supported -- 4205bd8deadSopenharmony_ci a fragment program will fail to load if a LOOP or REP instruction is 4215bd8deadSopenharmony_ci nested inside MAX_PROGRAM_LOOP_DEPTH_NV or more LOOP/ENDLOOP or REP/ENDREP 4225bd8deadSopenharmony_ci blocks. 4235bd8deadSopenharmony_ci 4245bd8deadSopenharmony_ci The BRK instruction is available to terminate a loop block early. A BRK 4255bd8deadSopenharmony_ci instruction can be conditional; the condition is evaluated in the same 4265bd8deadSopenharmony_ci manner as the condition of an IF instruction, and the loop is terminated 4275bd8deadSopenharmony_ci if the condition is true. A fragment program will fail to load if it 4285bd8deadSopenharmony_ci contains a BRK instruction that is not nested inside a LOOP/ENDLOOP or 4295bd8deadSopenharmony_ci REP/ENDREP block. 4305bd8deadSopenharmony_ci 4315bd8deadSopenharmony_ci Fragment programs can contain one or more instruction labels, matching the 4325bd8deadSopenharmony_ci grammar rule <branchLabel>. An instruction label can be referred to 4335bd8deadSopenharmony_ci explicitly in subroutine call (CAL) instructions. Instruction labels can 4345bd8deadSopenharmony_ci be used at any point in the body of a program, and can be used in 4355bd8deadSopenharmony_ci instructions before being defined in the program string. Instruction 4365bd8deadSopenharmony_ci labels can be defined anywhere in the program, except inside an 4375bd8deadSopenharmony_ci IF/ELSE/ENDIF, LOOP/ENDLOOP, or REP/ENDREP instruction block. A fragment 4385bd8deadSopenharmony_ci program will fail to load if it contains an instruction label inside an 4395bd8deadSopenharmony_ci instruction block. 4405bd8deadSopenharmony_ci 4415bd8deadSopenharmony_ci Fragment programs can also specify subroutine calls. When a subroutine 4425bd8deadSopenharmony_ci call (CAL) instruction is executed, a reference to the instruction 4435bd8deadSopenharmony_ci immediately following the CAL instruction is pushed onto the call stack. 4445bd8deadSopenharmony_ci When a subroutine return (RET) instruction is executed, an instruction 4455bd8deadSopenharmony_ci reference is popped off the call stack and program execution continues 4465bd8deadSopenharmony_ci with the popped instruction. A fragment program will terminate if a CAL 4475bd8deadSopenharmony_ci instruction is executed with MAX_PROGRAM_CALL_DEPTH_NV entries already in 4485bd8deadSopenharmony_ci the call stack or if a RET instruction is executed with an empty call 4495bd8deadSopenharmony_ci stack. Subroutine calls may be conditional; the condition is specified by 4505bd8deadSopenharmony_ci the <optBranchCond> grammar rule and evaluated in the same way as the 4515bd8deadSopenharmony_ci condition of the IF instruction. If no condition is specified, it is as 4525bd8deadSopenharmony_ci though "(TR)" were specified -- the branch is unconditional. 4535bd8deadSopenharmony_ci 4545bd8deadSopenharmony_ci If a fragment program has an instruction label "main", program execution 4555bd8deadSopenharmony_ci begins with the instruction immediately following the instruction label. 4565bd8deadSopenharmony_ci Otherwise, program execution begins with the first instruction of the 4575bd8deadSopenharmony_ci program. Instructions will be executed sequentially in the order 4585bd8deadSopenharmony_ci specified in the program, although branch instructions will affect the 4595bd8deadSopenharmony_ci instruction execution order, as described above. A fragment program will 4605bd8deadSopenharmony_ci terminate after executing a RET instruction with an empty call stack. A 4615bd8deadSopenharmony_ci fragment program will also terminate after executing the last instruction 4625bd8deadSopenharmony_ci in the program, unless that instruction was a taken branch. 4635bd8deadSopenharmony_ci 4645bd8deadSopenharmony_ci A fragment program will fail to load if an instruction refers to a label 4655bd8deadSopenharmony_ci that is not defined in the program string. 4665bd8deadSopenharmony_ci 4675bd8deadSopenharmony_ci A fragment program will terminate abnormally if a subroutine call 4685bd8deadSopenharmony_ci instruction produces a call stack overflow. Additionally, a fragment 4695bd8deadSopenharmony_ci program will terminate abnormally after executing 4705bd8deadSopenharmony_ci MAX_PROGRAM_EXEC_INSTRUCTIONS instructions to prevent hangs caused by 4715bd8deadSopenharmony_ci infinite loops in the program. 4725bd8deadSopenharmony_ci 4735bd8deadSopenharmony_ci When a fragment program terminates, normally or abnormally, it will emit a 4745bd8deadSopenharmony_ci fragment whose attributes are taken from the final values of the fragment 4755bd8deadSopenharmony_ci program result variables (section 3.11.3.4). 4765bd8deadSopenharmony_ci 4775bd8deadSopenharmony_ci 4785bd8deadSopenharmony_ci Add to Section 3.11.4.5 of ARB_fragment_program (Fragment Program 4795bd8deadSopenharmony_ci Options): 4805bd8deadSopenharmony_ci 4815bd8deadSopenharmony_ci Section 3.11.4.5.3, NV_fragment_program2 Option 4825bd8deadSopenharmony_ci 4835bd8deadSopenharmony_ci If a fragment program specifies the "NV_fragment_program2" option, the 4845bd8deadSopenharmony_ci ARB_fragment_program grammar and execution environment are extended to 4855bd8deadSopenharmony_ci take advantage of all the features of the "NV_fragment_program" option, 4865bd8deadSopenharmony_ci plus the following features: 4875bd8deadSopenharmony_ci 4885bd8deadSopenharmony_ci * structured branching support, including data-dependent IF tests, loops 4895bd8deadSopenharmony_ci supporting a fixed number of iterations, and a data-dependent loop 4905bd8deadSopenharmony_ci exit instruction (BRK), 4915bd8deadSopenharmony_ci 4925bd8deadSopenharmony_ci * subroutine calls, 4935bd8deadSopenharmony_ci 4945bd8deadSopenharmony_ci * several new instructions: 4955bd8deadSopenharmony_ci 4965bd8deadSopenharmony_ci * NRM -- vector normalization 4975bd8deadSopenharmony_ci * DIV -- divide vector components by a scalar 4985bd8deadSopenharmony_ci * DP2 -- two-component dot product 4995bd8deadSopenharmony_ci * DP2A -- two-component dot product with scalar add 5005bd8deadSopenharmony_ci * TXL -- texture lookup with explicit LOD specified 5015bd8deadSopenharmony_ci * IF/ELSE/ENDIF -- conditional execution blocks 5025bd8deadSopenharmony_ci * REP/ENDREP -- loop block 5035bd8deadSopenharmony_ci * LOOP/ENDLOOP -- loop block using index register 5045bd8deadSopenharmony_ci * BRK -- break out of loop block 5055bd8deadSopenharmony_ci * CAL -- subroutine call 5065bd8deadSopenharmony_ci * RET -- subroutine return 5075bd8deadSopenharmony_ci 5085bd8deadSopenharmony_ci * a loop index register inside LOOP/ENDLOOP blocks that can be used for 5095bd8deadSopenharmony_ci indirect access into the texture coordinate attribute array, and 5105bd8deadSopenharmony_ci 5115bd8deadSopenharmony_ci * a facing attribute that indicates whether the fragment is generated 5125bd8deadSopenharmony_ci from a front- or back-facing primitive. 5135bd8deadSopenharmony_ci 5145bd8deadSopenharmony_ci 5155bd8deadSopenharmony_ci Modify Section 3.11.5, Fragment Program ALU Instruction Set 5165bd8deadSopenharmony_ci 5175bd8deadSopenharmony_ci Section 3.11.5.48, DIV: Divide (Vector Components by Scalar) 5185bd8deadSopenharmony_ci 5195bd8deadSopenharmony_ci The DIV instruction divides each component of the first vector operand by 5205bd8deadSopenharmony_ci the second scalar operand to produce a 4-component result vector. 5215bd8deadSopenharmony_ci 5225bd8deadSopenharmony_ci tmp0 = VectorLoad(op0); 5235bd8deadSopenharmony_ci tmp1 = ScalarLoad(op1); 5245bd8deadSopenharmony_ci result.x = tmp0.x / tmp1; 5255bd8deadSopenharmony_ci result.y = tmp0.y / tmp1; 5265bd8deadSopenharmony_ci result.z = tmp0.z / tmp1; 5275bd8deadSopenharmony_ci result.w = tmp0.w / tmp1; 5285bd8deadSopenharmony_ci 5295bd8deadSopenharmony_ci This instruction may not produce results identical to a RCP/MUL 5305bd8deadSopenharmony_ci instruction sequence. 5315bd8deadSopenharmony_ci 5325bd8deadSopenharmony_ci 5335bd8deadSopenharmony_ci Section 3.11.5.49, DP2: 2-Component Dot Product 5345bd8deadSopenharmony_ci 5355bd8deadSopenharmony_ci The DP2 instruction computes a two-component dot product of the two 5365bd8deadSopenharmony_ci operands (using the first two components) and replicates the dot product 5375bd8deadSopenharmony_ci to all four components of the result vector. 5385bd8deadSopenharmony_ci 5395bd8deadSopenharmony_ci tmp0 = VectorLoad(op0); 5405bd8deadSopenharmony_ci tmp1 = VectorLoad(op1); 5415bd8deadSopenharmony_ci dot = (tmp0.x * tmp1.x) + (tmp0.y * tmp1.y); 5425bd8deadSopenharmony_ci result.x = dot; 5435bd8deadSopenharmony_ci result.y = dot; 5445bd8deadSopenharmony_ci result.z = dot; 5455bd8deadSopenharmony_ci result.w = dot; 5465bd8deadSopenharmony_ci 5475bd8deadSopenharmony_ci Section 3.11.5.50, DP2A: 2-Component Dot Product w/Scalar Add 5485bd8deadSopenharmony_ci 5495bd8deadSopenharmony_ci The DP2 instruction computes a two-component dot product of the two 5505bd8deadSopenharmony_ci operands (using the first two components), adds the x component of the 5515bd8deadSopenharmony_ci third operand, and replicates the result to all four components of the 5525bd8deadSopenharmony_ci result vector. 5535bd8deadSopenharmony_ci 5545bd8deadSopenharmony_ci tmp0 = VectorLoad(op0); 5555bd8deadSopenharmony_ci tmp1 = VectorLoad(op1); 5565bd8deadSopenharmony_ci tmp2 = VectorLoad(op2); 5575bd8deadSopenharmony_ci dot = (tmp0.x * tmp1.x) + (tmp0.y * tmp1.y) + tmp2.x; 5585bd8deadSopenharmony_ci result.x = dot; 5595bd8deadSopenharmony_ci result.y = dot; 5605bd8deadSopenharmony_ci result.z = dot; 5615bd8deadSopenharmony_ci result.w = dot; 5625bd8deadSopenharmony_ci 5635bd8deadSopenharmony_ci 5645bd8deadSopenharmony_ci Section 3.11.5.51, NRM: 3-Component Vector Normalize 5655bd8deadSopenharmony_ci 5665bd8deadSopenharmony_ci The NRM instruction normalizes the vector given by the x, y, and z 5675bd8deadSopenharmony_ci components of the vector operand to produce the x, y, and z components of 5685bd8deadSopenharmony_ci the result vector. The w component of the result is undefined. 5695bd8deadSopenharmony_ci 5705bd8deadSopenharmony_ci tmp = VectorLoad(op0); 5715bd8deadSopenharmony_ci scale = ApproxRSQ(tmp.x * tmp.x + tmp.y * tmp.y + tmp.z * tmp.z); 5725bd8deadSopenharmony_ci result.x = tmp.x * scale; 5735bd8deadSopenharmony_ci result.y = tmp.y * scale; 5745bd8deadSopenharmony_ci result.z = tmp.z * scale; 5755bd8deadSopenharmony_ci result.w = undefined; 5765bd8deadSopenharmony_ci 5775bd8deadSopenharmony_ci Note that the normalization uses an approximate scale and may be carried 5785bd8deadSopenharmony_ci at lower precision than a corresponding sequence of DP3, RSQ, and MUL 5795bd8deadSopenharmony_ci instructions. 5805bd8deadSopenharmony_ci 5815bd8deadSopenharmony_ci 5825bd8deadSopenharmony_ci Add Section 3.11.6.6, TXL: Texture Lookup with Explicit LOD 5835bd8deadSopenharmony_ci 5845bd8deadSopenharmony_ci The TXL instruction takes the x, y, and z components of the vector operand 5855bd8deadSopenharmony_ci and maps them to s, t, and r, respectively. These coordinates are used to 5865bd8deadSopenharmony_ci sample from the specified texture target on the specified texture image 5875bd8deadSopenharmony_ci unit in a manner consistent with its parameters. 5885bd8deadSopenharmony_ci 5895bd8deadSopenharmony_ci The level of detail is computed as specified in section 3.8.8, except that 5905bd8deadSopenharmony_ci rho(x,y) is given by 2^w, where w is the w component of the vector 5915bd8deadSopenharmony_ci operand. 5925bd8deadSopenharmony_ci 5935bd8deadSopenharmony_ci The resulting sample is mapped to RGBA as described in table 3.21 5945bd8deadSopenharmony_ci and written to the result vector. 5955bd8deadSopenharmony_ci 5965bd8deadSopenharmony_ci tmp = VectorLoad(op0); 5975bd8deadSopenharmony_ci result = TextureSample(tmp.x, tmp.y, tmp.z, 0.0, op1, op2); 5985bd8deadSopenharmony_ci 5995bd8deadSopenharmony_ci 6005bd8deadSopenharmony_ci Add Section 3.11.X, Fragment Program Flow Control Instruction Set 6015bd8deadSopenharmony_ci (immediately after Section 3.11.6, Fragment Program Texture Instruction 6025bd8deadSopenharmony_ci Set) 6035bd8deadSopenharmony_ci 6045bd8deadSopenharmony_ci 3.11.X.1, BRK: Break 6055bd8deadSopenharmony_ci 6065bd8deadSopenharmony_ci The BRK instruction conditionally transfers control to the instruction 6075bd8deadSopenharmony_ci immediately following the next ENDLOOP or ENDREP instruction. A BRK 6085bd8deadSopenharmony_ci instruction has no effect if the condition code test evaluates to FALSE. 6095bd8deadSopenharmony_ci 6105bd8deadSopenharmony_ci The following pseudocode describes the operation of the instruction: 6115bd8deadSopenharmony_ci 6125bd8deadSopenharmony_ci if (TestCC(cc.c***) || TestCC(cc.*c**) || 6135bd8deadSopenharmony_ci TestCC(cc.**c*) || TestCC(cc.***c)) { 6145bd8deadSopenharmony_ci continue execution at instruction following the next ENDLOOP or 6155bd8deadSopenharmony_ci ENDREP; 6165bd8deadSopenharmony_ci } 6175bd8deadSopenharmony_ci 6185bd8deadSopenharmony_ci 6195bd8deadSopenharmony_ci 3.11.X.2, CAL: Subroutine Call 6205bd8deadSopenharmony_ci 6215bd8deadSopenharmony_ci The CAL instruction conditionally transfers control to the instruction 6225bd8deadSopenharmony_ci following the label specified in the instruction. A CAL instruction has 6235bd8deadSopenharmony_ci no effect if the condition code test evaluates to FALSE. 6245bd8deadSopenharmony_ci 6255bd8deadSopenharmony_ci When executed, the CAL instruction pushes a reference to the instruction 6265bd8deadSopenharmony_ci immediately following the CAL instruction onto the call stack. When a 6275bd8deadSopenharmony_ci matching RET instruction is executed, execution will continue at that 6285bd8deadSopenharmony_ci instruction after executing the matching RET instruction. 6295bd8deadSopenharmony_ci 6305bd8deadSopenharmony_ci Implementations may have a limited call stack. If the number of CAL 6315bd8deadSopenharmony_ci instructions that have been performed without returning is 6325bd8deadSopenharmony_ci MAX_PROGRAM_CALL_DEPTH_NV, a CAL instruction will cause the call stack to 6335bd8deadSopenharmony_ci overflow and the fragment program to terminate. 6345bd8deadSopenharmony_ci 6355bd8deadSopenharmony_ci The following pseudocode describes the operation of the instruction: 6365bd8deadSopenharmony_ci 6375bd8deadSopenharmony_ci if (TestCC(cc.c***) || TestCC(cc.*c**) || 6385bd8deadSopenharmony_ci TestCC(cc.**c*) || TestCC(cc.***c)) { 6395bd8deadSopenharmony_ci 6405bd8deadSopenharmony_ci // Check for call stack overflow. 6415bd8deadSopenharmony_ci if (callStackDepth >= MAX_PROGRAM_CALL_DEPTH_NV) { 6425bd8deadSopenharmony_ci terminate fragment program; 6435bd8deadSopenharmony_ci } 6445bd8deadSopenharmony_ci 6455bd8deadSopenharmony_ci push instruction following the CAL instruction on the call stack; 6465bd8deadSopenharmony_ci continue execution at instruction following <branchLabel>; 6475bd8deadSopenharmony_ci } 6485bd8deadSopenharmony_ci 6495bd8deadSopenharmony_ci 6505bd8deadSopenharmony_ci 3.11.X.3, ELSE: Beginning of ELSE Block 6515bd8deadSopenharmony_ci 6525bd8deadSopenharmony_ci The ELSE instruction signifies the end of the "execute if true" portion of 6535bd8deadSopenharmony_ci an IF/ELSE/ENDIF block. 6545bd8deadSopenharmony_ci 6555bd8deadSopenharmony_ci If the condition evaluated at the IF statement was TRUE, when a program 6565bd8deadSopenharmony_ci reaches the ELSE statement, it has completed the entire "execute if true" 6575bd8deadSopenharmony_ci portion of the IF/ELSE/ENDIF block. Execution will continue at the 6585bd8deadSopenharmony_ci corresponding ENDIF instruction. 6595bd8deadSopenharmony_ci 6605bd8deadSopenharmony_ci If the condition evaluated at the IF statement was FALSE, program 6615bd8deadSopenharmony_ci execution would skip over the entire "execute if true" portion of the 6625bd8deadSopenharmony_ci IF/ELSE/ENDIF block, including the ELSE instruction. 6635bd8deadSopenharmony_ci 6645bd8deadSopenharmony_ci 6655bd8deadSopenharmony_ci 3.11.X.4, ENDIF: End of IF/ELSE Block 6665bd8deadSopenharmony_ci 6675bd8deadSopenharmony_ci The ENDIF instruction signifies the end of an IF/ELSE/ENDIF block. It has 6685bd8deadSopenharmony_ci no other effect on program execution. 6695bd8deadSopenharmony_ci 6705bd8deadSopenharmony_ci 6715bd8deadSopenharmony_ci 3.11.X.5, ENDLOOP: End of LOOP Block 6725bd8deadSopenharmony_ci 6735bd8deadSopenharmony_ci The ENDLOOP instruction specifies the end of a LOOP block. When an 6745bd8deadSopenharmony_ci ENDLOOP instruction executes, the loop count is decremented and the loop 6755bd8deadSopenharmony_ci index increment value is added to the loop index (A0.x). If the 6765bd8deadSopenharmony_ci decremented loop count is greater than zero, execution continues at the 6775bd8deadSopenharmony_ci top of the LOOP block. 6785bd8deadSopenharmony_ci 6795bd8deadSopenharmony_ci LoopCount--; 6805bd8deadSopenharmony_ci LoopIndex += LoopIncr; 6815bd8deadSopenharmony_ci if (LoopCount > 0) { 6825bd8deadSopenharmony_ci continue execution at instruction following corresponding LOOP 6835bd8deadSopenharmony_ci instruction; 6845bd8deadSopenharmony_ci } 6855bd8deadSopenharmony_ci 6865bd8deadSopenharmony_ci 3.11.X.6, ENDREP: End of REP Block 6875bd8deadSopenharmony_ci 6885bd8deadSopenharmony_ci The ENDREP instruction specifies the end of a REP block. When an ENDREP 6895bd8deadSopenharmony_ci instruction executes, the loop count is decremented. If the decremented 6905bd8deadSopenharmony_ci loop count is greater than zero, execution continues at the top of the REP 6915bd8deadSopenharmony_ci block. 6925bd8deadSopenharmony_ci 6935bd8deadSopenharmony_ci LoopCount--; 6945bd8deadSopenharmony_ci if (LoopCount > 0) { 6955bd8deadSopenharmony_ci continue execution at instruction following corresponding LOOP 6965bd8deadSopenharmony_ci instruction; 6975bd8deadSopenharmony_ci } 6985bd8deadSopenharmony_ci 6995bd8deadSopenharmony_ci 7005bd8deadSopenharmony_ci 3.11.X.7, IF: Beginning of IF Block 7015bd8deadSopenharmony_ci 7025bd8deadSopenharmony_ci The IF instruction conditionally transfers control to the instruction 7035bd8deadSopenharmony_ci immediately following the corresponding ELSE instruction (if present) or 7045bd8deadSopenharmony_ci ENDIF instruction (if no ELSE is present). 7055bd8deadSopenharmony_ci 7065bd8deadSopenharmony_ci Implementations may have a limited ability to nest IF blocks at run time. 7075bd8deadSopenharmony_ci If the number of IF/ENDIF blocks that are currently active is 7085bd8deadSopenharmony_ci MAX_PROGRAM_IF_DEPTH_NV, an IF instruction will cause the fragment program 7095bd8deadSopenharmony_ci to terminate. If an IF instruction is executed inside a subroutine, any 7105bd8deadSopenharmony_ci active IF/ENDIF blocks in the calling code count against this limit. 7115bd8deadSopenharmony_ci 7125bd8deadSopenharmony_ci if (IF block nested too deeply) { 7135bd8deadSopenharmony_ci terminate fragment program; 7145bd8deadSopenharmony_ci } 7155bd8deadSopenharmony_ci 7165bd8deadSopenharmony_ci // Evaluate the condition. If the condition is true, continue at the 7175bd8deadSopenharmony_ci // next instruction. Otherwise, continue at the 7185bd8deadSopenharmony_ci if (TestCC(cc.c***) || TestCC(cc.*c**) || 7195bd8deadSopenharmony_ci TestCC(cc.**c*) || TestCC(cc.***c)) { 7205bd8deadSopenharmony_ci continue execution at the next instruction; 7215bd8deadSopenharmony_ci } else if (IF block contains an ELSE statement) { 7225bd8deadSopenharmony_ci continue execution at instruction following corresponding ELSE; 7235bd8deadSopenharmony_ci } else { 7245bd8deadSopenharmony_ci continue execution at instruction following corresponding ENDIF; 7255bd8deadSopenharmony_ci } 7265bd8deadSopenharmony_ci 7275bd8deadSopenharmony_ci 7285bd8deadSopenharmony_ci 3.11.X.8, LOOP: Beginning of LOOP Block 7295bd8deadSopenharmony_ci 7305bd8deadSopenharmony_ci The LOOP instruction begins a LOOP block. The x, y, and z components of 7315bd8deadSopenharmony_ci the single vector operand specify the initial values for the loop count, 7325bd8deadSopenharmony_ci loop index, and loop index increment, respectively. 7335bd8deadSopenharmony_ci 7345bd8deadSopenharmony_ci The loop count indicates the number of times the instructions between the 7355bd8deadSopenharmony_ci LOOP and corresponding ENDLOOP instruction will be executed. If the 7365bd8deadSopenharmony_ci initial value of the loop count is not positive, the entire block is 7375bd8deadSopenharmony_ci skipped and execution continues at the corresponding ENDLOOP instruction. 7385bd8deadSopenharmony_ci 7395bd8deadSopenharmony_ci The loop index (A0.x) can be used for indirect addressing in the set of 7405bd8deadSopenharmony_ci texture coordinate fragment attributes. A fragment program can only use 7415bd8deadSopenharmony_ci the loop index of the current LOOP block; loop indices for containing LOOP 7425bd8deadSopenharmony_ci blocks are not available. 7435bd8deadSopenharmony_ci 7445bd8deadSopenharmony_ci Implementations may have a limited ability to nest LOOP and REP blocks at 7455bd8deadSopenharmony_ci run time. If the number of LOOP/ENDLOOP and REP/ENDREP blocks that have 7465bd8deadSopenharmony_ci not completed is MAX_PROGRAM_LOOP_DEPTH_NV, a LOOP instruction will cause 7475bd8deadSopenharmony_ci the fragment program to terminate. If a LOOP instruction is executed 7485bd8deadSopenharmony_ci inside a subroutine, any active LOOP/ENDLOOP or REP/ENDREP blocks in the 7495bd8deadSopenharmony_ci calling code count against this limit. 7505bd8deadSopenharmony_ci 7515bd8deadSopenharmony_ci if (LOOP block nested too deeply) { 7525bd8deadSopenharmony_ci terminate fragment program; 7535bd8deadSopenharmony_ci } 7545bd8deadSopenharmony_ci 7555bd8deadSopenharmony_ci // Set up loop information for the new nesting level. 7565bd8deadSopenharmony_ci tmp = VectorLoad(op0); 7575bd8deadSopenharmony_ci LoopCount = floor(op0.x); 7585bd8deadSopenharmony_ci LoopIndex = floor(op0.y); 7595bd8deadSopenharmony_ci LoopIncr = floor(op0.z); 7605bd8deadSopenharmony_ci if (LoopCount <= 0) { 7615bd8deadSopenharmony_ci continue execution at the corresponding ENDLOOP; 7625bd8deadSopenharmony_ci } 7635bd8deadSopenharmony_ci 7645bd8deadSopenharmony_ci LOOP blocks do not support fully general branching -- a fragment program 7655bd8deadSopenharmony_ci will fail to load if the vector operand is not a program parameter. 7665bd8deadSopenharmony_ci 7675bd8deadSopenharmony_ci 7685bd8deadSopenharmony_ci 3.11.X.9, REP: Beginning of REP Block 7695bd8deadSopenharmony_ci 7705bd8deadSopenharmony_ci The REP instruction begins a REP block. The x component of the single 7715bd8deadSopenharmony_ci vector operand specifies the initial value for the loop count. REP blocks 7725bd8deadSopenharmony_ci are completely identical to LOOP blocks except that they don't use the 7735bd8deadSopenharmony_ci loop index at all. 7745bd8deadSopenharmony_ci 7755bd8deadSopenharmony_ci The loop count indicates the number of times the instructions between the 7765bd8deadSopenharmony_ci REP and corresponding ENDREP instruction will be executed. If the initial 7775bd8deadSopenharmony_ci value of the loop count is not positive, the entire block is skipped and 7785bd8deadSopenharmony_ci execution continues at the instruction following the corresponding ENDREP 7795bd8deadSopenharmony_ci instruction. 7805bd8deadSopenharmony_ci 7815bd8deadSopenharmony_ci Implementations may have a limited ability to nest LOOP and REP blocks at 7825bd8deadSopenharmony_ci run time. If the number of LOOP/ENDLOOP and REP/ENDREP blocks that have 7835bd8deadSopenharmony_ci not completed is MAX_PROGRAM_LOOP_DEPTH_NV, a REP instruction will cause 7845bd8deadSopenharmony_ci the fragment program to terminate. If a REP instruction is executed 7855bd8deadSopenharmony_ci inside a subroutine, any active LOOP/ENDLOOP or REP/ENDREP blocks in the 7865bd8deadSopenharmony_ci calling code count against this limit. 7875bd8deadSopenharmony_ci 7885bd8deadSopenharmony_ci if (REP block nested too deeply) { 7895bd8deadSopenharmony_ci terminate fragment program; 7905bd8deadSopenharmony_ci } 7915bd8deadSopenharmony_ci 7925bd8deadSopenharmony_ci // Set up loop information for the new nesting level. 7935bd8deadSopenharmony_ci tmp = VectorLoad(op0); 7945bd8deadSopenharmony_ci LoopCount = floor(op0.x); 7955bd8deadSopenharmony_ci if (LoopCount <= 0) { 7965bd8deadSopenharmony_ci continue execution at the corresponding ENDREP; 7975bd8deadSopenharmony_ci } 7985bd8deadSopenharmony_ci 7995bd8deadSopenharmony_ci REP blocks do not support fully general branching -- a fragment program 8005bd8deadSopenharmony_ci will fail to load if the vector operand is not a program parameter. 8015bd8deadSopenharmony_ci 8025bd8deadSopenharmony_ci 8035bd8deadSopenharmony_ci 3.11.X.10, RET: Subroutine Return 8045bd8deadSopenharmony_ci 8055bd8deadSopenharmony_ci The RET instruction conditionally returns from a subroutine initiated by a 8065bd8deadSopenharmony_ci CAL instruction. A RET instruction has no effect if the condition code 8075bd8deadSopenharmony_ci test evaluates to FALSE. 8085bd8deadSopenharmony_ci 8095bd8deadSopenharmony_ci When executed, the RET instruction pops a reference to the instruction 8105bd8deadSopenharmony_ci immediately following the corresponding CAL instruction onto the call 8115bd8deadSopenharmony_ci stack and continues execution at that instruction. 8125bd8deadSopenharmony_ci 8135bd8deadSopenharmony_ci If a RET instruction is issued when the call stack is empty, the fragment 8145bd8deadSopenharmony_ci program is terminated. 8155bd8deadSopenharmony_ci 8165bd8deadSopenharmony_ci if (TestCC(cc.c***) || TestCC(cc.*c**) || 8175bd8deadSopenharmony_ci TestCC(cc.**c*) || TestCC(cc.***c)) { 8185bd8deadSopenharmony_ci 8195bd8deadSopenharmony_ci if (callStackDepth <= 0) { 8205bd8deadSopenharmony_ci terminate fragment program; 8215bd8deadSopenharmony_ci } 8225bd8deadSopenharmony_ci 8235bd8deadSopenharmony_ci pop instruction following the CAL instruction off the call stack; 8245bd8deadSopenharmony_ci continue execution at that instruction; 8255bd8deadSopenharmony_ci } 8265bd8deadSopenharmony_ci 8275bd8deadSopenharmony_ci 8285bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 1.4 Specification (Per-Fragment 8295bd8deadSopenharmony_ciOperations and the Frame Buffer) 8305bd8deadSopenharmony_ci 8315bd8deadSopenharmony_ci None. 8325bd8deadSopenharmony_ci 8335bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 1.4 Specification (Special Functions) 8345bd8deadSopenharmony_ci 8355bd8deadSopenharmony_ci None. 8365bd8deadSopenharmony_ci 8375bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 1.4 Specification (State and 8385bd8deadSopenharmony_ciState Requests) 8395bd8deadSopenharmony_ci 8405bd8deadSopenharmony_ci None. 8415bd8deadSopenharmony_ci 8425bd8deadSopenharmony_ciAdditions to Appendix A of the OpenGL 1.4 Specification (Invariance) 8435bd8deadSopenharmony_ci 8445bd8deadSopenharmony_ci None. 8455bd8deadSopenharmony_ci 8465bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications 8475bd8deadSopenharmony_ci 8485bd8deadSopenharmony_ci None. 8495bd8deadSopenharmony_ci 8505bd8deadSopenharmony_ciDependencies on ARB_fragment_program 8515bd8deadSopenharmony_ci 8525bd8deadSopenharmony_ci ARB_fragment_program is required. 8535bd8deadSopenharmony_ci 8545bd8deadSopenharmony_ci This specification and NV_fragment_program_option are based on a modified 8555bd8deadSopenharmony_ci version of the grammar published in the ARB_fragment_program 8565bd8deadSopenharmony_ci specification. This modified grammar includes a few structural changes to 8575bd8deadSopenharmony_ci better accommodate new functionality from this and other extensions, but 8585bd8deadSopenharmony_ci should be functionally equivalent to the ARB_fragment_program grammar. 8595bd8deadSopenharmony_ci See NV_fragment_program_option for details on the base grammar. 8605bd8deadSopenharmony_ci 8615bd8deadSopenharmony_ciDependencies on NV_fragment_program2_option 8625bd8deadSopenharmony_ci 8635bd8deadSopenharmony_ci NV_fragment_program_option is required. 8645bd8deadSopenharmony_ci 8655bd8deadSopenharmony_ci If the NV_fragment_program2 program option is specified, all the 8665bd8deadSopenharmony_ci functionality described in both this extension and the 8675bd8deadSopenharmony_ci NV_fragment_program_option specification is available. 8685bd8deadSopenharmony_ci 8695bd8deadSopenharmony_ciGLX Protocol 8705bd8deadSopenharmony_ci 8715bd8deadSopenharmony_ci None. 8725bd8deadSopenharmony_ci 8735bd8deadSopenharmony_ciErrors 8745bd8deadSopenharmony_ci 8755bd8deadSopenharmony_ci None. 8765bd8deadSopenharmony_ci 8775bd8deadSopenharmony_ciNew State 8785bd8deadSopenharmony_ci 8795bd8deadSopenharmony_ci None. 8805bd8deadSopenharmony_ci 8815bd8deadSopenharmony_ciNew Implementation Dependent State 8825bd8deadSopenharmony_ci Min 8835bd8deadSopenharmony_ci Get Value Type Get Command Value Description Sec Attrib 8845bd8deadSopenharmony_ci ----------------------------------- ---- --------------- ------ ----------------- -------- ------ 8855bd8deadSopenharmony_ci MAX_PROGRAM_EXEC_INSTRUCTIONS_NV Z+ GetProgramivARB 65536 maximum program 3.11.4.X - 8865bd8deadSopenharmony_ci execution inst- 8875bd8deadSopenharmony_ci ruction count 8885bd8deadSopenharmony_ci MAX_PROGRAM_CALL_DEPTH_NV Z+ GetProgramivARB 4 maximum program 3.11.4.X - 8895bd8deadSopenharmony_ci call stack depth 8905bd8deadSopenharmony_ci MAX_PROGRAM_IF_DEPTH_NV Z+ GetProgramivARB 48 maximum program 3.11.4.X - 8915bd8deadSopenharmony_ci if nesting 8925bd8deadSopenharmony_ci MAX_PROGRAM_LOOP_DEPTH_NV Z+ GetProgramivARB 4 maximum program 3.11.4.X - 8935bd8deadSopenharmony_ci loop nesting 8945bd8deadSopenharmony_ci MAX_PROGRAM_LOOP_COUNT_NV Z+ GetProgramivARB 255 maximum program 3.11.4.X - 8955bd8deadSopenharmony_ci initial loop count 8965bd8deadSopenharmony_ci 8975bd8deadSopenharmony_ci (add to Table X.10. New Implementation-Dependent Values Introduced by 8985bd8deadSopenharmony_ci ARB_fragment_program. Values queried by GetProgramivARB require a <pname> 8995bd8deadSopenharmony_ci of FRAGMENT_PROGRAM_ARB.) 9005bd8deadSopenharmony_ci 9015bd8deadSopenharmony_ciRevision History 9025bd8deadSopenharmony_ci 9035bd8deadSopenharmony_ci Rev. Date Author Changes 9045bd8deadSopenharmony_ci ---- -------- ------- -------------------------------------------- 9055bd8deadSopenharmony_ci 8 08/04/04 pbrown Fixed two typos in the TXL instruction. 9065bd8deadSopenharmony_ci 9075bd8deadSopenharmony_ci 7 07/08/04 pbrown Fixed entries for KIL and RFL in the opcode 9085bd8deadSopenharmony_ci table. 9095bd8deadSopenharmony_ci 9105bd8deadSopenharmony_ci 6 05/16/04 pbrown Documented that "A0" is a pre-defined address 9115bd8deadSopenharmony_ci register variable for the purposes of the 9125bd8deadSopenharmony_ci grammar, and that no other address register 9135bd8deadSopenharmony_ci variables can be declared. 9145bd8deadSopenharmony_ci 9155bd8deadSopenharmony_ci 5 -------- pbrown Internal pre-release revisions. 916