1Name 2 3 NV_vertex_program2_option 4 5Name Strings 6 7 GL_NV_vertex_program2_option 8 9Contact 10 11 Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com) 12 13Status 14 15 Shipping. 16 17Version 18 19 Last Modified: 06/23/2004 20 NVIDIA Revision: 3 21 22Number 23 24 305 25 26Dependencies 27 28 ARB_vertex_program is required. 29 30Overview 31 32 This extension provides additional vertex program functionality 33 to extend the standard ARB_vertex_program language and execution 34 environment. ARB programs wishing to use this added functionality 35 need only add: 36 37 OPTION NV_vertex_program2; 38 39 to the beginning of their vertex programs. 40 41 The functionality provided by this extension, which is roughly 42 equivalent to that provided by the NV_vertex_program2 extension, 43 includes: 44 45 * general purpose dynamic branching, 46 47 * subroutine calls, 48 49 * data-dependent conditional write masks, 50 51 * programmable user clip distances, 52 53 * address registers with four components (instead of just one), 54 55 * absolute value operator on scalar and swizzled operand loads, 56 57 * rudimentary address register math, 58 59 * SIN and COS trigonometry instructions, and 60 61 * fully orthogonal "set on" instructions, including a "set sign" 62 instruction. 63 64Issues 65 66 Why is this a separate extension, rather than just an additional 67 feature of NV_vertex_program2? 68 69 RESOLVED: The NV_vertex_program2 specification was completed 70 (with a published implementation) prior to the completion of 71 ARB_vertex_program. Future NVIDIA vertex program extensions should 72 contain extensions to the ARB_vertex_program execution environment 73 as a standard feature. 74 75 NV_vertex_program1_1 contains one feature not found in 76 ARB_vertex_program: the "RCC" (reciprocal clamped) instruction. 77 Should a "NV_vertex_program1_1" program option be provided to expose 78 this small amount of missing functionality? 79 80 RESOLVED: No. By itself, that functionality is not all that 81 interesting. 82 83 Should this extension provide a mechanism to specify an "ARB" 84 version of NV_vertex_program state programs (!!VSP1.0)? 85 86 RESOLVED: No. 87 88 Should a similar option be provided to expose ARB_vertex_program 89 features not found in NV_vertex_program (e.g., local parameters, state 90 bindings, certain "macro" instructions) under the NV_vertex_program 91 interface? 92 93 RESOLVED: No. Why not just write an ARB program in that case? 94 95 The ARB_vertex_program spec has a minor grammar bug that requires 96 that inline scalar constants used as scalar operands include a 97 component selector. In other words, you have to say "11.0.x" to 98 use the constant "11.0". What should we do here? 99 100 RESOLVED: The NV_vertex_program2_option grammar will correct 101 this problem, which should be fixed in future revisions to the 102 ARB language. 103 104New Procedures and Functions 105 106 None. 107 108New Tokens 109 110 Accepted by the <pname> parameter of GetProgramivARB: 111 112 MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 113 MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 114 115Additions to Chapter 2 of the OpenGL 1.4 Specification (OpenGL Operation) 116 117 Modify Section 2.11, Clipping (p. 42) 118 119 (insert before the second paragraph, p. 43) In vertex program mode, 120 conventional user clipping is performed if the vertex program is 121 position-invariant (section 2.14.4.5.1). When the vertex program 122 is not position-invariant, it can write a single floating-point clip 123 distance for each supported clip plane. The half-space corresponding 124 to clip plane <n> is given by the set of points that satisfy the 125 inequality 126 127 c_n(P) >=0, 128 129 where c_n(P) is the value of clip distance <n> at point P. For point 130 primitives, c_n(P) is simply the clip distance for the vertex in 131 question. For line and triangle primitives, per-vertex clip distances 132 are interpolated using a weighted mean, with weights derived according 133 to the algorithms described in sections 3.4 and 3.5. 134 135 Modify Section 2.14.2, Vertex Program Grammar and Restrictions 136 137 (mostly add to existing grammar rules, modify a few existing grammar 138 rules -- changes marked with "***") 139 140 <optionName> ::= "NV_vertex_program2" 141 142 <statement> ::= <branchLabel> ":" 143 144 <instruction> ::= <FlowInstruction> 145 146 <ALUInstruction> ::= <ARAop_instruction> 147 148 <FlowInstruction> ::= <BRAop_instruction> 149 | <FLOWCCop_instruction> 150 151 <VECTORop> ::= "SSG" 152 153 <SCALARop> ::= "COS" 154 | "RCC" 155 | "SIN" 156 157 <BINop> ::= "SEQ" 158 | "SFL" 159 | "SGT" 160 | "SLE" 161 | "SNE" 162 | "STR" 163 164 <ARLop> ::= "ARR" 165 166 <ARLop_src> ::= <instOperandV> 167 (*** instead of <instOperandS>) 168 169 <ARAop_instruction> ::= <ARAop> <instResultAddr> "," 170 <instOperandAddrVNS> 171 172 <ARAop> ::= "ARA" 173 174 <BRAop_instruction> ::= <BRAop> <branchLabel> <optBranchCond> 175 176 <BRAop> ::= "BRA" 177 | "CAL" 178 179 <FLOWCCop_instruction> ::= <FLOWCCop> <optBranchCond> 180 181 <FLOWCCop> ::= "RET" 182 183 <optBranchCond> ::= /* empty */ 184 | <ccMask> 185 186 <instOperandV> ::= <instOperandAbsV> 187 188 <instOperandAbsV> ::= <optSign> "|" <instOperandBaseV> "|" 189 190 <instOperandS> ::= <instOperandAbsS> 191 192 <instOperandAbsS> ::= <optSign> "|" <instOperandBaseS> "|" 193 194 195 <instOperandAddrVNS> ::= <addrUseVNS> 196 197 <instResult> ::= <instResultCC> 198 199 <instResultCC> ::= <instResultBase> <ccMask> 200 201 <instResultAddr> ::= <instResultAddrCC> 202 203 <instResultAddrCC> ::= <instResultAddrBase> <ccMask> 204 205 <branchLabel> ::= <identifier> 206 207 <paramUseV> ::= <constantScalar> 208 (*** instead of <constantScalar> 209 <swizzleSuffix>) 210 211 <paramUseS> ::= <constantScalar> 212 (*** instead of <constantScalar> 213 <scalarSuffix>) 214 215 <resultVtxBasic> ::= "clip" "[" <clipPlaneNum> "]" 216 217 <addrUseVNS> ::= <addrVarName> 218 219 <addrUseW> ::= <addrVarName> <optAddrWriteMask> 220 (*** instead of <addrVarName> 221 <addrWriteMask>) 222 223 <ccMask> ::= "(" <ccTest> ")" 224 225 <ccTest> ::= <ccMaskRule> <swizzleSuffix> 226 227 <ccMaskRule> ::= "EQ" 228 | "GE" 229 | "GT" 230 | "LE" 231 | "LT" 232 | "NE" 233 | "TR" 234 | "FL" 235 236 <optAddrWriteMask> ::= <optWriteMask> 237 (*** instead of "." "x") 238 239 <addrComponent> ::= <xyzwComponent> 240 (*** instead of "x") 241 242 (modify description of reserved identifiers) 243 244 ... The following strings are reserved keywords and may not be used 245 as identifiers: 246 247 ABS, ADD, ADDRESS, ALIAS, ARA, ARL, ARR, ATTRIB, BRA, CAL, COS, 248 DP3, DP4, DPH, DST, END, EX2, EXP, FLR, FRC, LG2, LIT, LOG, MAD, 249 MAX, MIN, MOV, MUL, OPTION, OUTPUT, PARAM, POW, RCC, RCP, RET, 250 RSQ, SEQ, SFL, SGE, SGT, SIN, SLE, SLT, SNE, SUB, SSG, STR, SWZ, 251 TEMP, XPD, program, result, state, and vertex. 252 253 Add to Section 2.14.3.4, Vertex Program Results 254 255 (add to binding table) 256 257 Binding Components Description 258 ----------------------------- ---------- ---------------------------- 259 result.clip[n] (d,*,*,*) clip plane distance 260 261 (add a paragraph before the last one) If a result variable binding 262 matches "result.clip[n]", updates to the "x" component of the result 263 variable set the clip distance for clip plane <n>. 264 265 (modify last paragraph) When in vertex program mode, all attributes 266 of a transformed vertex, except for clip distances, are undefined 267 at each vertex program invocation. Any results, or even individual 268 components of results, that are not written to during vertex program 269 execution remain undefined. All clip distances are initially zero, 270 and remain zero if not written by the vertex program. 271 272 Modify Section 2.14.3.5, Vertex Program Address Registers 273 274 (modify first paragraph) Vertex program address register variables are 275 a set of four-component signed integer vectors. Address registers 276 are used as indices when performing relative addressing in program 277 parameter arrays (section 2.14.4.2). 278 279 (modify third paragraph) Vertex program address register variables are 280 undefined at each vertex program invocation. Address registers can 281 be written by the ARA, ARL, and ARL instructions (section 2.14.5), 282 and will be read by the ARA instruction and when a program uses 283 relative addressing in program parameter arrays. 284 285 Add New Section 2.14.3.X, Condition Code Register (insert after 286 Section 2.14.3.5, Vertex Program Address Registers) 287 288 The vertex program condition code register is a single four-component 289 vector. Each component of this register is one of four enumerated 290 values: GT (greater than), EQ (equal), LT (less than), or UN 291 (unordered). The condition code register can be used to mask writes 292 to registers and to evaluate conditional branches. 293 294 Most vertex program instructions can optionally update the condition 295 code register. When a vertex program instruction updates the 296 condition code register, a condition code component is set to LT if 297 the corresponding component of the result is less than zero, EQ if it 298 is equal to zero, GT if it is greater than zero, and UN if it is NaN 299 (not a number). 300 301 The condition code register is initialized to a vector of EQ values 302 each time a vertex program executes. 303 304 Modify Section 2.14.4, Vertex Program Execution Environment 305 306 (modify 3rd paragraph) Vertex programs execute a sequence of 307 instructions, with support for conditional and unconditional branches, 308 subroutine calls, and returns. Vertex programs begin by executing 309 the instruction following the label "main". If no label "main" is 310 defined, execution begins at the first instruction in the program. 311 Instructions are executed in the order specified in the program, 312 jumping when specified in branch instructions, until the end of the 313 program is reached. 314 315 (modify instruction table) There are forty-two vertex program 316 instructions. Vertex program instructions may have an optional 317 suffix of "C" to allow an update of the condition code register 318 (section 2.14.3.X). For example, there are two instructions to 319 perform vector addition, "ADD" and "ADDC". The instructions and their 320 respective input and output parameters are summarized in Table X.5. 321 322 Instruction Inputs Output Description 323 ----------- ------ ------ -------------------------------- 324 ABS[C] v v absolute value 325 ADD[C] v,v v add 326 ARA[C] a a address register add 327 ARL[C] s a address register load 328 ARR[C] v a address register load (round) 329 BRA c - branch 330 CAL c - subroutine call 331 COS[C] s ssss cosine 332 DP3[C] v,v ssss 3-component dot product 333 DP4[C] v,v ssss 4-component dot product 334 DPH[C] v,v ssss homogeneous dot product 335 DST[C] v,v v distance vector 336 EX2[C] s ssss exponential base 2 337 EXP[C] s v exponential base 2 (approximate) 338 FLR[C] v v floor 339 FRC[C] v v fraction 340 LG2[C] s ssss logarithm base 2 341 LIT[C] v v compute light coefficients 342 LOG[C] s v logarithm base 2 (approximate) 343 MAD[C] v,v,v v multiply and add 344 MAX[C] v,v v maximum 345 MIN[C] v,v v minimum 346 MOV[C] v v move 347 MUL[C] v,v v multiply 348 POW[C] s,s ssss exponentiate 349 RCC[C] s ssss reciprocal (clamped) 350 RCP[C] s ssss reciprocal 351 RET c - subroutine return 352 RSQ[C] s ssss reciprocal square root 353 SEQ[C] v,v v set on equal 354 SFL[C] v,v v set on false 355 SGE[C] v,v v set on greater than or equal 356 SGT[C] v,v v set on greater than 357 SIN[C] s ssss sine 358 SLE[C] v,v v set on less than or equal 359 SLT[C] v,v v set on less than 360 SNE[C] v,v v set on not equal 361 SSG[C] v v set sign 362 STR[C] v,v v set on true 363 SUB[C] v,v v subtract 364 SWZ[C] v v extended swizzle 365 XPD[C] v,v v cross product 366 367 Table X.5: Summary of vertex program instructions. "[C]" indicates 368 that the opcode supports the condition code update modifier. "v" 369 indicates a floating-point vector input or output, "s" indicates 370 a floating-point scalar input, "ssss" indicates a scalar output 371 replicated across a 4-component result vector, "a" indicates a 372 vector address register, and "c" indicates a condition code test. 373 374 Modify Section 2.14.4.1, Vertex Program Operands 375 376 (add prior to the discussion of negation) A component-wise absolute 377 value operation can optionally performed on the operand if the operand 378 is surrounded with two "|" characters. For example, "|src|" indicates 379 that a component-wise absolute value operation should be performed on 380 the variable named "src". In terms of the grammar, this operation 381 is performed if the <instOperandV> or <instOperandS> grammar rules 382 match <instOperandAbsV> or <instOperandAbsS>, respectively. 383 384 (modify operand load pseudo-code) The following pseudo-code spells 385 out the operand generation process. In the example, "float" is a 386 floating-point scalar type, while "floatVec" is a four-component 387 vector. "source" refers to the register used for the operand, 388 matching the <srcReg> rule. "abs" is TRUE if an absolute value 389 operation should be performed on the operand (<instOperandAbsV> or 390 <instOperandAbsS> rules) "negate" is TRUE if the <optionalSign> rule 391 in <scalarSrcReg> or <swizzleSrcReg> matches "-" and FALSE otherwise. 392 The ".c***", ".*c**", ".**c*", ".***c" modifiers refer to the x, 393 y, z, and w components obtained by the swizzle operation; the ".c" 394 modifier refers to the single component selected for a scalar load. 395 396 floatVec VectorLoad(floatVec source) 397 { 398 floatVec operand; 399 400 operand.x = source.c***; 401 operand.y = source.*c**; 402 operand.z = source.**c*; 403 operand.w = source.***c; 404 if (abs) { 405 operand.x = abs(operand.x); 406 operand.y = abs(operand.y); 407 operand.z = abs(operand.z); 408 operand.w = abs(operand.w); 409 } 410 if (negate) { 411 operand.x = -operand.x; 412 operand.y = -operand.y; 413 operand.z = -operand.z; 414 operand.w = -operand.w; 415 } 416 417 return operand; 418 } 419 420 float ScalarLoad(floatVec source) 421 { 422 float operand; 423 424 operand = source.c; 425 if (abs) { 426 operand = abs(operand); 427 if (negate) { 428 operand = -operand; 429 } 430 431 return operand; 432 } 433 434 Rewrite Section 2.14.4.3, Vertex Program Destination Register Update 435 436 Most vertex program instructions write a 4-component result vector to 437 a single temporary or vertex result register. Writes to individual 438 components of the destination register are controlled by individual 439 component write masks specified as part of the instruction. 440 441 The component write mask is specified by the <optionalMask> rule 442 found in the <maskedDstReg> rule. If the optional mask is "", 443 all components are enabled. Otherwise, the optional mask names 444 the individual components to enable. The characters "x", "y", 445 "z", and "w" match the x, y, z, and w components respectively. 446 For example, an optional mask of ".xzw" indicates that the x, z, 447 and w components should be enabled for writing but the y component 448 should not. The grammar requires that the destination register mask 449 components must be listed in "xyzw" order. 450 451 The condition code write mask is specified by the <ccMask> rule found 452 in the <instResultCC> and <instResultAddrCC> rules. The condition 453 code register is loaded and swizzled according to the swizzle 454 codes specified by <swizzleSuffix>. Each component of the swizzled 455 condition code is tested according to the rule given by <ccMaskRule>. 456 <ccMaskRule> may have the values "EQ", "NE", "LT", "GE", LE", or "GT", 457 which mean to enable writes if the corresponding condition code field 458 evaluates to equal, not equal, less than, greater than or equal, less 459 than or equal, or greater than, respectively. Comparisons involving 460 condition codes of "UN" (unordered) evaluate to true for "NE" and 461 false otherwise. For example, if the condition code is (GT,LT,EQ,GT) 462 and the condition code mask is "(NE.zyxw)", the swizzle operation 463 will load (EQ,LT,GT,GT) and the mask will thus will enable writes on 464 the y, z, and w components. In addition, "TR" always enables writes 465 and "FL" always disables writes, regardless of the condition code. 466 If the condition code mask is empty, it is treated as "(TR)". 467 468 Each component of the destination register is updated with the result 469 of the vertex program instruction if and only if the component is 470 enabled for writes by both the component write mask and the condition 471 code write mask. Otherwise, the component of the destination register 472 remains unchanged. 473 474 A vertex program instruction can also optionally update the condition 475 code register. The condition code is updated if the condition 476 code register update suffix "C" is present in the instruction. 477 The instruction "ADDC" will update the condition code; the otherwise 478 equivalent instruction "ADD" will not. If condition code updates 479 are enabled, each component of the destination register enabled 480 for writes is compared to zero. The corresponding component of 481 the condition code is set to "LT", "EQ", or "GT", if the written 482 component is less than, equal to, or greater than zero, respectively. 483 Condition code components are set to "UN" if the written component is 484 NaN (not a number). Values of -0.0 and +0.0 both evaluate to "EQ". 485 If a component of the destination register is not enabled for writes, 486 the corresponding condition code component is also unchanged. 487 488 In the following example code, 489 490 # R1=(-2, 0, 2, NaN) R0 CC 491 MOVC R0, R1; # ( -2, 0, 2, NaN) (LT,EQ,GT,UN) 492 MOVC R0.xyz, R1.yzwx; # ( 0, 2, NaN, NaN) (EQ,GT,UN,UN) 493 MOVC R0 (NE), R1.zywx; # ( 0, 0, NaN, -2) (EQ,EQ,UN,LT) 494 495 the first instruction writes (-2,0,2,NaN) to R0 and updates the 496 condition code to (LT,EQ,GT,UN). The second instruction, only the 497 "x", "y", and "z" components of R0 and the condition code are updated, 498 so R0 ends up with (0,2,NaN,NaN) and the condition code ends up with 499 (EQ,GT,UN,UN). In the third instruction, the condition code mask 500 disables writes to the x component (its condition code field is "EQ"), 501 so R0 ends up with (0,0,NaN,-2) and the condition code ends up with 502 (EQ,EQ,UN,LT). 503 504 The following pseudocode illustrates the process of writing a result 505 vector to the destination register. In the pseudocode, "instrmask" 506 refers to the component write mask given by the <optWriteMask> 507 rule. "ccMaskRule" refers to the condition code mask rule given 508 by <ccMask> and "updatecc" is TRUE if and only if condition code 509 updates are enabled. "result", "destination", and "cc" refer to 510 the result vector, the register selected by <dstRegister> and the 511 condition code, respectively. Condition codes do not exist in the 512 VP1 execution environment. 513 514 boolean TestCC(CondCode field) { 515 switch (ccMaskRule) { 516 case "EQ": return (field == "EQ"); 517 case "NE": return (field != "EQ"); 518 case "LT": return (field == "LT"); 519 case "GE": return (field == "GT" || field == "EQ"); 520 case "LE": return (field == "LT" || field == "EQ"); 521 case "GT": return (field == "GT"); 522 case "TR": return TRUE; 523 case "FL": return FALSE; 524 case "": return TRUE; 525 } 526 } 527 528 enum GenerateCC(float value) { 529 if (value == NaN) { 530 return UN; 531 } else if (value < 0) { 532 return LT; 533 } else if (value == 0) { 534 return EQ; 535 } else { 536 return GT; 537 } 538 } 539 540 void UpdateDestination(floatVec destination, floatVec result) 541 { 542 floatVec merged; 543 ccVec mergedCC; 544 545 // Merge the converted result into the destination register, under 546 // control of the compile- and run-time write masks. 547 merged = destination; 548 mergedCC = cc; 549 if (instrMask.x && TestCC(cc.c***)) { 550 merged.x = result.x; 551 if (updatecc) mergedCC.x = GenerateCC(result.x); 552 } 553 if (instrMask.y && TestCC(cc.*c**)) { 554 merged.y = result.y; 555 if (updatecc) mergedCC.y = GenerateCC(result.y); 556 } 557 if (instrMask.z && TestCC(cc.**c*)) { 558 merged.z = result.z; 559 if (updatecc) mergedCC.z = GenerateCC(result.z); 560 } 561 if (instrMask.w && TestCC(cc.***c)) { 562 merged.w = result.w; 563 if (updatecc) mergedCC.w = GenerateCC(result.w); 564 } 565 566 // Write out the new destination register and condition code. 567 destination = merged; 568 cc = mergedCC; 569 } 570 571 While this rule describes floating-point results, the same logic 572 applies to the integer results generated by the ARA, ARL, and ARR 573 instructions. 574 575 Add Section 2.14.4.X, Vertex Program Branching (before Section 576 2.14.4.4, Vertex Program Result Processing) 577 578 Vertex programs can contain one or more instruction labels, matching 579 the grammar rule <branchLabel>. An instruction label can be referred 580 to explicitly in branch (BRA) or subroutine call (CAL) instructions. 581 Instruction labels can be defined or used at any point in the body 582 of a program, and can be used in instructions before being defined 583 in the program string. 584 585 Branching instructions can be conditional. The branch condition 586 is specified by the <optBranchCond> grammar rule and may depend on 587 the contents of the condition code register. Branch conditions are 588 evaluated by evaluating a condition code write mask in exactly the 589 same manner as done for register writes (section 2.14.2.2). If any 590 of the four components of the condition code write mask are enabled, 591 the branch is taken and execution continues with the instruction 592 following the label specified in the instruction. Otherwise, the 593 instruction is ignored and vertex program execution continues with 594 the next instruction. In the following example code, 595 596 MOVC CC, c[0]; # c[0]=(-2, 0, 2, NaN), CC gets (LT,EQ,GT,UN) 597 BRA label1 (LT.xyzw); 598 MOV R0,R1; # not executed 599 label1: 600 BRA label2 (LT.wyzw); 601 MOV R0,R2; # executed 602 label2: 603 604 the first BRA instruction loads a condition code of (LT,EQ,GT,UN) 605 while the second BRA instruction loads a condition code of 606 (UN,EQ,GT,UN). The first branch will be taken because the "x" 607 component evaluates to LT; the second branch will not be taken 608 because no component evaluates to LT. 609 610 Vertex programs can specify subroutine calls. When a subroutine 611 call (CAL) instruction is executed, a reference to the instruction 612 immediately following the CAL instruction is pushed onto the 613 call stack. When a subroutine return (RET) instruction is 614 executed, an instruction reference is popped off the call stack 615 and program execution continues with the popped instruction. 616 A vertex program will terminate if a CAL instruction is executed 617 with MAX_PROGRAM_CALL_DEPTH_NV entries already in the call stack or 618 if a RET instruction is executed with an empty call stack. 619 620 If a vertex program has an instruction label "main", program 621 execution begins with the instruction immediately following the 622 instruction label. Otherwise, program execution begins with the 623 first instruction of the program. Instructions will be executed 624 sequentially in the order specified in the program, although 625 branch instructions will affect the instruction execution order, 626 as described above. A vertex program will terminate after executing 627 a RET instruction with an empty call stack. A vertex program will 628 also terminate after executing the last instruction in the program, 629 unless that instruction was a taken branch. 630 631 A vertex program will fail to load if an instruction refers to a 632 label that is not defined in the program string. 633 634 A vertex program will terminate abnormally if a subroutine call 635 instruction produces a call stack overflow. Additionally, 636 a vertex program will terminate abnormally after executing 637 MAX_PROGRAM_EXEC_INSTRUCTIONS instructions to prevent hangs caused 638 by infinite loops in the program. 639 640 When a vertex program terminates, normally or abnormally, it will 641 emit a vertex whose attributes are taken from the final values of 642 the vertex result registers (section 2.14.1.5). 643 644 Modify Section 2.14.4.4, Vertex Program Result Processing 645 646 (modify 3rd paragraph) Transformed vertices are then assembled into 647 primitives and clipped as described in section 2.11. Clip distance 648 results are used to control user clip planes. 649 650 Add to Section 2.14.4.5, Vertex Program Options: 651 652 Section 2.14.4.5.2, NV_vertex_program2 Option 653 654 If a vertex program specifies the "NV_vertex_program2" program option, 655 the grammar will be extended to support the features found in the 656 NV_vertex_program2 extension not present in the ARB_vertex_program 657 extension, including: 658 659 * the availability of the following instructions: 660 661 - ARA (address register add, useful for looping), 662 - ARR (address register load with round), 663 - BRA (branch), 664 - CAL (subroutine call), 665 - COS (cosine), 666 - RET (subroutine return), 667 - SEQ (set on equal), 668 - SFL (set on false), 669 - SGT (set on greater than), 670 - SIN (sine), 671 - SLE (set on less than or equal), 672 - SNE (set on not equal), 673 - SSG (set sign), and 674 - STR (set on true). 675 676 * up to MAX_CALL_DEPTH_NV levels of subroutine calls/returns, 677 678 * a four-component condition code register to hold the sign of 679 result vector components (useful for comparisons), 680 681 * a condition code update opcode suffix "C", where the results of 682 the instruction are used to update the condition code register, 683 684 * a condition code write mask operator, where the condition code 685 register is swizzled and tested, and the test results are used 686 to mask register writes, 687 688 * six clip distance result bindings that can be used to perform 689 more complicated user clipping operations than those provided 690 with the position invariant program option, 691 692 * four-component address registers (instead of one-component 693 registers in ARB_vertex_program), with the "ARL" instruction 694 extended to produce a vector result, 695 696 * an absolute value operator on scalar and swizzled operands. 697 698 The added functionality is identical to that provided by 699 NV_vertex_program2 extension specification. 700 701 Modify Section 2.14.5.3, ARL: Address Register Load 702 703 The ARL instruction loads a single vector operand and performs a 704 component-wise floor operation to generate a signed integer result 705 vector. 706 707 tmp = VectorLoad(op0); 708 iresult.x = floor(tmp.x); 709 iresult.y = floor(tmp.y); 710 iresult.z = floor(tmp.z); 711 iresult.w = floor(tmp.w); 712 713 The floor operation returns the largest integer less than or equal 714 to the operand. For example floor(-1.7) = -2.0, floor(+1.0) = +1.0, 715 and floor(+3.7) = +3.0. 716 717 Note that in the unextended ARB_vertex_program specification, the ARL 718 instruction loads a scalar operand and generates a scalar result. 719 720 Add to Section 2.14.5, Vertex Program Instruction Set 721 722 Section 2.14.5.28, ARA: Address Register Add 723 724 The ARA instruction adds two pairs of components of a vector address 725 register operand to produce an integer result vector. The "x" and "z" 726 components of the result vector contain the sum of the "x" and "z" 727 components of the operand; the "y" and "w" components of the result 728 vector contain the sum of the "y" and "w" components of the operand. 729 730 itmp = AddrVectorLoad(op0); 731 iresult.x = itmp.x + itmp.z; 732 iresult.y = itmp.y + itmp.w; 733 iresult.z = itmp.x + itmp.z; 734 iresult.w = itmp.y + itmp.w; 735 736 Component swizzling is not supported when the operand is loaded. 737 738 Section 2.14.5.29, ARR: Address Register Load (with round) 739 740 The ARR instruction loads a single vector operand and performs a 741 component-wise round operation to generate a signed integer result 742 vector. 743 744 tmp = VectorLoad(op0); 745 iresult.x = round(tmp.x); 746 iresult.y = round(tmp.y); 747 iresult.z = round(tmp.z); 748 iresult.w = round(tmp.w); 749 750 The round operation returns the nearest integer to the operand. If the 751 fractional portion of the operand is 0.5, round() selects the nearest even 752 integer. For example round(-1.7) = -2.0, round(+1.0) = +1.0, and 753 round(+3.7) = +4.0. 754 755 Section 2.14.5.30, BRA: Branch 756 757 The BRA instruction conditionally transfers control to the instruction 758 following the label specified in the instruction. The following 759 pseudocode describes the operation of the instruction: 760 761 if (TestCC(cc.c***) || TestCC(cc.*c**) || 762 TestCC(cc.**c*) || TestCC(cc.***c)) { 763 // continue execution at instruction following <branchLabel> 764 } else { 765 // do nothing 766 } 767 768 In the pseudocode, <branchLabel> is the label specified in the 769 instruction according to the <branchLabel> grammar rule. 770 771 Section 2.14.5.31, CAL: Subroutine Call 772 773 The CAL instruction conditionally transfers control to the instruction 774 following the label specified in the instruction. It also pushes a 775 reference to the instruction immediately following the CAL instruction 776 onto the call stack, where execution will continue after executing 777 the matching RET instruction. The following pseudocode describes 778 the operation of the instruction: 779 780 if (TestCC(cc.c***) || TestCC(cc.*c**) || 781 TestCC(cc.**c*) || TestCC(cc.***c)) { 782 if (callStackDepth >= MAX_PROGRAM_CALL_DEPTH_NV) { 783 // terminate vertex program 784 } else { 785 callStack[callStackDepth] = nextInstruction; 786 callStackDepth++; 787 } 788 // continue execution at instruction following <branchLabel> 789 } else { 790 // do nothing 791 } 792 793 In the pseudocode, <branchLabel> is the label specified in the 794 instruction matching the <branchLabel> grammar rule, <callStackDepth> 795 is the current depth of the call stack, <callStack> is an array 796 holding the call stack, and <nextInstruction> is a reference to the 797 instruction immediately following the present one in the program 798 string. 799 800 If the call stack overflows, the vertex program terminates abnormally and 801 all vertex program results are undefined. 802 803 Section 2.14.5.32, COS: Cosine 804 805 The COS instruction approximates the cosine of the angle specified 806 by the scalar operand and replicates the approximation to all four 807 components of the result vector. The angle is specified in radians 808 and does not have to be in the range [0,2*PI]. 809 810 tmp = ScalarLoad(op0); 811 result.x = ApproxCosine(tmp); 812 result.y = ApproxCosine(tmp); 813 result.z = ApproxCosine(tmp); 814 result.w = ApproxCosine(tmp); 815 816 Section 2.14.5.33, RCC: Reciprocal (Clamped) 817 818 The RCC instruction approximates the reciprocal of the scalar operand, 819 clamps the result to one of two ranges, and replicates the clamped 820 result to all four components of the result vector. 821 822 If the approximated reciprocal is greater than 0.0, the result is 823 clamped to the range [2^-64, 2^+64]. If the approximate reciprocal 824 is not greater than zero, the result is clamped to the range [-2^+64, 825 -2^-64]. 826 827 tmp = ScalarLoad(op0); 828 result.x = ClampApproxReciprocal(tmp); 829 result.y = ClampApproxReciprocal(tmp); 830 result.z = ClampApproxReciprocal(tmp); 831 result.w = ClampApproxReciprocal(tmp); 832 833 The following rule applies to reciprocation: 834 835 1. ApproxReciprocal(+1.0) = +1.0. 836 837 Section 2.14.5.34, RET: Subroutine Call Return 838 839 The RET instruction conditionally returns from a subroutine initiated 840 by a CAL instruction by popping an instruction reference off the 841 top of the call stack and transferring control to the referenced 842 instruction. The following pseudocode describes the operation of 843 the instruction: 844 845 if (TestCC(cc.c***) || TestCC(cc.*c**) || 846 TestCC(cc.**c*) || TestCC(cc.***c)) { 847 if (callStackDepth <= 0) { 848 // terminate vertex program 849 } else { 850 callStackDepth--; 851 instruction = callStack[callStackDepth]; 852 } 853 854 // continue execution at <instruction> 855 } else { 856 // do nothing 857 } 858 859 In the pseudocode, <callStackDepth> is the depth of the call stack, 860 <callStack> is an array holding the call stack, and <instruction> is 861 a reference to an instruction previously pushed onto the call stack. 862 863 If the call stack is empty when RET executes, the vertex program 864 terminates normally. 865 866 Section 2.14.5.35, SEQ: Set on Equal 867 868 The SEQ instruction performs a component-wise comparison of the 869 two operands. Each component of the result vector is 1.0 if the 870 corresponding component of the first operand is equal to that of 871 the second, and 0.0 otherwise. 872 873 tmp0 = VectorLoad(op0); 874 tmp1 = VectorLoad(op1); 875 result.x = (tmp0.x == tmp1.x) ? 1.0 : 0.0; 876 result.y = (tmp0.y == tmp1.y) ? 1.0 : 0.0; 877 result.z = (tmp0.z == tmp1.z) ? 1.0 : 0.0; 878 result.w = (tmp0.w == tmp1.w) ? 1.0 : 0.0; 879 880 Section 2.14.5.36, SFL: Set on False 881 882 The SFL instruction is a degenerate case of the other "Set on" 883 instructions that sets all components of the result vector to 0.0. 884 885 result.x = 0.0; 886 result.y = 0.0; 887 result.z = 0.0; 888 result.w = 0.0; 889 890 Section 2.14.5.37, SGT: Set on Greater Than 891 892 The SGT instruction performs a component-wise comparison of the 893 two operands. Each component of the result vector is 1.0 if the 894 corresponding component of the first operands is greater than that 895 of the second, and 0.0 otherwise. 896 897 tmp0 = VectorLoad(op0); 898 tmp1 = VectorLoad(op1); 899 result.x = (tmp0.x > tmp1.x) ? 1.0 : 0.0; 900 result.y = (tmp0.y > tmp1.y) ? 1.0 : 0.0; 901 result.z = (tmp0.z > tmp1.z) ? 1.0 : 0.0; 902 result.w = (tmp0.w > tmp1.w) ? 1.0 : 0.0; 903 904 Section 2.14.5.38, SIN: Sine 905 906 The SIN instruction approximates the sine of the angle specified by 907 the scalar operand and replicates it to all four components of the 908 result vector. The angle is specified in radians and does not have 909 to be in the range [0,2*PI]. 910 911 tmp = ScalarLoad(op0); 912 result.x = ApproxSine(tmp); 913 result.y = ApproxSine(tmp); 914 result.z = ApproxSine(tmp); 915 result.w = ApproxSine(tmp); 916 917 Section 2.14.5.39, SLE: Set on Less Than or Equal 918 919 The SLE instruction performs a component-wise comparison of the 920 two operands. Each component of the result vector is 1.0 if the 921 corresponding component of the first operand is less than or equal 922 to that of the second, and 0.0 otherwise. 923 924 tmp0 = VectorLoad(op0); 925 tmp1 = VectorLoad(op1); 926 result.x = (tmp0.x <= tmp1.x) ? 1.0 : 0.0; 927 result.y = (tmp0.y <= tmp1.y) ? 1.0 : 0.0; 928 result.z = (tmp0.z <= tmp1.z) ? 1.0 : 0.0; 929 result.w = (tmp0.w <= tmp1.w) ? 1.0 : 0.0; 930 931 Section 2.14.5.40, SNE: Set on Not Equal 932 933 The SNE instruction performs a component-wise comparison of the 934 two operands. Each component of the result vector is 1.0 if the 935 corresponding component of the first operand is not equal to that 936 of the second, and 0.0 otherwise. 937 938 tmp0 = VectorLoad(op0); 939 tmp1 = VectorLoad(op1); 940 result.x = (tmp0.x != tmp1.x) ? 1.0 : 0.0; 941 result.y = (tmp0.y != tmp1.y) ? 1.0 : 0.0; 942 result.z = (tmp0.z != tmp1.z) ? 1.0 : 0.0; 943 result.w = (tmp0.w != tmp1.w) ? 1.0 : 0.0; 944 945 Section 2.14.5.41, SSG: Set Sign 946 947 The SSG instruction generates a result vector containing the signs of 948 each component of the single vector operand. Each component of the 949 result vector is 1.0 if the corresponding component of the operand 950 is greater than zero, 0.0 if the corresponding component of the 951 operand is equal to zero, and -1.0 if the corresponding component 952 of the operand is less than zero. 953 954 tmp = VectorLoad(op0); 955 result.x = SetSign(tmp.x); 956 result.y = SetSign(tmp.y); 957 result.z = SetSign(tmp.z); 958 result.w = SetSign(tmp.w); 959 960 Section 2.14.5.42, STR: Set on True 961 962 The STR instruction is a degenerate case of the other "Set on" 963 instructions that sets all components of the result vector to 1.0. 964 965 result.x = 1.0; 966 result.y = 1.0; 967 result.z = 1.0; 968 result.w = 1.0; 969 970Additions to Chapter 3 of the OpenGL 1.4 Specification (Rasterization) 971 972 None. 973 974Additions to Chapter 4 of the OpenGL 1.4 Specification (Per-Fragment 975Operations and the Frame Buffer) 976 977 None. 978 979Additions to Chapter 5 of the OpenGL 1.4 Specification (Special Functions) 980 981 None. 982 983Additions to Chapter 6 of the OpenGL 1.4 Specification (State and State 984Requests) 985 986 None. 987 988Additions to Appendix A of the OpenGL 1.4 Specification (Invariance) 989 990 None. 991 992Additions to the AGL/GLX/WGL Specifications 993 994 None. 995 996Dependencies on ARB_vertex_program 997 998 This specification is based on a modified version of the grammar 999 published in the ARB_vertex_program specification. This modified 1000 grammar (see below) includes a few structural changes to better 1001 accommodate new functionality from this and other extensions, but 1002 should be functionally equivalent to the ARB_vertex_program grammar. 1003 1004 <program> ::= <optionSequence> <statementSequence> "END" 1005 1006 <optionSequence> ::= <optionSequence> <option> 1007 | /* empty */ 1008 1009 <option> ::= "OPTION" <optionName> ";" 1010 1011 <optionName> ::= "ARB_position_invariant" 1012 1013 <statementSequence> ::= <statement> <statementSequence> 1014 | /* empty */ 1015 1016 <statement> ::= <instruction> ";" 1017 | <namingStatement> ";" 1018 1019 <instruction> ::= <ALUInstruction> 1020 1021 <ALUInstruction> ::= <VECTORop_instruction> 1022 | <SCALARop_instruction> 1023 | <BINSCop_instruction> 1024 | <BINop_instruction> 1025 | <TRIop_instruction> 1026 | <SWZop_instruction> 1027 | <ARLop_instruction> 1028 1029 <VECTORop_instruction> ::= <VECTORop> <instResult> "," <instOperandV> 1030 1031 <VECTORop> ::= "ABS" 1032 | "FLR" 1033 | "FRC" 1034 | "LIT" 1035 | "MOV" 1036 1037 <SCALARop_instruction> ::= <SCALARop> <instResult> "," <instOperandS> 1038 1039 <SCALARop> ::= "EX2" 1040 | "EXP" 1041 | "LG2" 1042 | "LOG" 1043 | "RCP" 1044 | "RSQ" 1045 1046 <BINSCop_instruction> ::= <BINSCop> <instResult> "," <instOperandS> "," 1047 <instOperandS> 1048 1049 <BINSCop> ::= "POW" 1050 1051 <BINop_instruction> ::= <BINop> <instResult> "," <instOperandV> "," 1052 <instOperandV> 1053 1054 <BINop> ::= "ADD" 1055 | "DP3" 1056 | "DP4" 1057 | "DPH" 1058 | "DST" 1059 | "MAX" 1060 | "MIN" 1061 | "MUL" 1062 | "SGE" 1063 | "SLT" 1064 | "SUB" 1065 | "XPD" 1066 1067 <TRIop_instruction> ::= <TRIop> <instResult> "," <instOperandV> "," 1068 <instOperandV> "," <instOperandV> 1069 1070 <TRIop> ::= "MAD" 1071 1072 <SWZop_instruction> ::= <SWZop> <instResult> "," <instOperandVNS> "," 1073 <extendedSwizzle> 1074 1075 <SWZop> ::= "SWZ" 1076 1077 <ARLop_instruction> ::= <ARLop> <instResultAddr> "," <ARLop_src> 1078 1079 <ARLop> ::= "ARL" 1080 1081 <ARLop_src> ::= <instOperandS> 1082 1083 <instOperandV> ::= <instOperandBaseV> 1084 1085 <instOperandBaseV> ::= <optSign> <attribUseV> 1086 | <optSign> <tempUseV> 1087 | <optSign> <paramUseV> 1088 1089 <instOperandS> ::= <instOperandBaseS> 1090 1091 <instOperandBaseS> ::= <optSign> <attribUseS> 1092 | <optSign> <tempUseS> 1093 | <optSign> <paramUseS> 1094 1095 <instOperandVNS> ::= <attribUseVNS> 1096 | <tempUseVNS> 1097 | <paramUseVNS> 1098 1099 <instResult> ::= <instResultBase> 1100 1101 <instResultBase> ::= <tempUseW> 1102 | <resultUseW> 1103 1104 <instResultAddr> ::= <instResultAddrBase> 1105 1106 <instResultAddrBase> ::= <addrUseW> 1107 1108 <namingStatement> ::= <ATTRIB_statement> 1109 | <PARAM_statement> 1110 | <TEMP_statement> 1111 | <OUTPUT_statement> 1112 | <ALIAS_statement> 1113 | <ADDRESS_statement> 1114 1115 <ATTRIB_statement> ::= "ATTRIB" <establishName> "=" <attribUseD> 1116 1117 <PARAM_statement> ::= <PARAM_singleStmt> 1118 | <PARAM_multipleStmt> 1119 1120 <PARAM_singleStmt> ::= "PARAM" <establishName> <paramSingleInit> 1121 1122 <PARAM_multipleStmt> ::= "PARAM" <establishName> "[" <optArraySize> "]" 1123 <paramMultipleInit> 1124 1125 <optArraySize> ::= /* empty */ 1126 | <integer> /* [1,MAX_PROGRAM_PARAMETERS_ARB]*/ 1127 1128 <paramSingleInit> ::= "=" <paramUseDB> 1129 1130 <paramMultipleInit> ::= "=" "{" <paramMultInitList> "}" 1131 1132 <paramMultInitList> ::= <paramUseDM> 1133 | <paramUseDM> "," <paramMultInitList> 1134 1135 <TEMP_statement> ::= "TEMP" <varNameList> 1136 1137 <OUTPUT_statement> ::= "OUTPUT" <establishName> "=" <resultUseD> 1138 1139 <ALIAS_statement> ::= "ALIAS" <establishName> "=" <establishedName> 1140 1141 <establishedName> ::= <tempVarName> 1142 | <addrVarName> 1143 | <attribVarName> 1144 | <paramArrayVarName> 1145 | <paramSingleVarName> 1146 | <resultVarName> 1147 1148 <ADDRESS_statement> ::= "ADDRESS" <varNameList> 1149 1150 <varNameList> ::= <establishName> 1151 | <establishName> "," <varNameList> 1152 1153 <establishName> ::= <identifier> 1154 1155 <attribUseV> ::= <attribBasic> <swizzleSuffix> 1156 | <attribVarName> <swizzleSuffix> 1157 | <attribColor> <swizzleSuffix> 1158 | <attribColor> "." <colorType> <swizzleSuffix> 1159 1160 <attribUseS> ::= <attribBasic> <scalarSuffix> 1161 | <attribVarName> <scalarSuffix> 1162 | <attribColor> <scalarSuffix> 1163 | <attribColor> "." <colorType> <scalarSuffix> 1164 1165 <attribUseVNS> ::= <attribBasic> 1166 | <attribVarName> 1167 | <attribColor> 1168 | <attribColor> "." <colorType> 1169 1170 <attribUseD> ::= <attribBasic> 1171 | <attribColor> 1172 | <attribColor> "." <colorType> 1173 1174 <attribBasic> ::= "vertex" "." <attribVtxBasic> 1175 1176 <attribVtxBasic> ::= "position" 1177 | "weight" <vtxOptWeightNum> 1178 | "normal" 1179 | "fogcoord" 1180 | "texcoord" <optTexCoordNum> 1181 | "matrixindex" "[" <vtxWeightNum> "]" 1182 | "attrib" "[" <vtxAttribNum> "]" 1183 1184 <attribColor> ::= "vertex" "." "color" 1185 1186 <paramUseV> ::= <paramSingleVarName> <swizzleSuffix> 1187 | <paramArrayVarName> "[" <arrayMem> "]" 1188 <swizzleSuffix> 1189 | <stateSingleItem> <swizzleSuffix> 1190 | <programSingleItem> <swizzleSuffix> 1191 | <constantVector> <swizzleSuffix> 1192 | <constantScalar> <swizzleSuffix> 1193 1194 <paramUseS> ::= <paramSingleVarName> <scalarSuffix> 1195 | <paramArrayVarName> "[" <arrayMem> "]" 1196 <scalarSuffix> 1197 | <stateSingleItem> <scalarSuffix> 1198 | <programSingleItem> <scalarSuffix> 1199 | <constantVector> <scalarSuffix> 1200 | <constantScalar> <scalarSuffix> 1201 1202 <paramUseVNS> ::= <paramSingleVarName> 1203 | <paramArrayVarName> "[" <arrayMem> "]" 1204 | <stateSingleItem> 1205 | <programSingleItem> 1206 | <constantVector> 1207 | <constantScalar> 1208 1209 <paramUseDB> ::= <stateSingleItem> 1210 | <programSingleItem> 1211 | <constantVector> 1212 | <signedConstantScalar> 1213 1214 <paramUseDM> ::= <stateMultipleItem> 1215 | <programMultipleItem> 1216 | <constantVector> 1217 | <signedConstantScalar> 1218 1219 <stateMultipleItem> ::= <stateSingleItem> 1220 | "state" "." <stateMatrixRows> 1221 1222 <stateSingleItem> ::= "state" "." <stateMaterialItem> 1223 | "state" "." <stateLightItem> 1224 | "state" "." <stateLightModelItem> 1225 | "state" "." <stateLightProdItem> 1226 | "state" "." <stateFogItem> 1227 | "state" "." <stateMatrixRow> 1228 | "state" "." <stateTexGenItem> 1229 | "state" "." <stateClipPlaneItem> 1230 | "state" "." <statePointItem> 1231 1232 <stateMaterialItem> ::= "material" "." <stateMatProperty> 1233 | "material" "." <faceType> "." 1234 <stateMatProperty> 1235 1236 <stateMatProperty> ::= "ambient" 1237 | "diffuse" 1238 | "specular" 1239 | "emission" 1240 | "shininess" 1241 1242 <stateLightItem> ::= "light" "[" <stateLightNumber> "]" "." 1243 <stateLightProperty> 1244 1245 <stateLightProperty> ::= "ambient" 1246 | "diffuse" 1247 | "specular" 1248 | "position" 1249 | "attenuation" 1250 | "spot" "." <stateSpotProperty> 1251 | "half" 1252 1253 <stateSpotProperty> ::= "direction" 1254 1255 <stateLightModelItem> ::= "lightmodel" <stateLModProperty> 1256 1257 <stateLModProperty> ::= "." "ambient" 1258 | "." "scenecolor" 1259 | "." <faceType> "." "scenecolor" 1260 1261 <stateLightProdItem> ::= "lightprod" "[" <stateLightNumber> "]" "." 1262 <stateLProdProperty> 1263 | "lightprod" "[" <stateLightNumber> "]" "." 1264 <faceType> "." <stateLProdProperty> 1265 1266 <stateLProdProperty> ::= "ambient" 1267 | "diffuse" 1268 | "specular" 1269 1270 <stateLightNumber> ::= <integer> /* [0,MAX_LIGHTS-1] */ 1271 1272 <stateFogItem> ::= "fog" "." <stateFogProperty> 1273 1274 <stateFogProperty> ::= "color" 1275 | "params" 1276 1277 <stateMatrixRows> ::= <stateMatrixItem> 1278 | <stateMatrixItem> "." <stateMatModifier> 1279 | <stateMatrixItem> "." "row" "[" 1280 <stateMatrixRowNum> ".." <stateMatrixRowNum> 1281 "]" 1282 | <stateMatrixItem> "." <stateMatModifier> "." 1283 "row" "[" <stateMatrixRowNum> ".." 1284 <stateMatrixRowNum> "]" 1285 1286 <stateMatrixRow> ::= <stateMatrixItem> "." "row" "[" 1287 <stateMatrixRowNum> "]" 1288 | <stateMatrixItem> "." <stateMatModifier> "." 1289 "row" "[" <stateMatrixRowNum> "]" 1290 1291 <stateMatrixItem> ::= "matrix" "." <stateMatrixName> 1292 1293 <stateMatModifier> ::= "inverse" 1294 | "transpose" 1295 | "invtrans" 1296 1297 <stateMatrixName> ::= "modelview" <stateOptModMatNum> 1298 | "projection" 1299 | "mvp" 1300 | "texture" <optTexCoordNum> 1301 | "palette" "[" <statePaletteMatNum> "]" 1302 | "program" "[" <stateProgramMatNum> "]" 1303 1304 <stateMatrixRowNum> ::= <integer> /* [0,3] */ 1305 1306 <stateOptModMatNum> ::= /* empty */ 1307 | "[" <stateModMatNum> "]" 1308 1309 <stateModMatNum> ::= <integer> /*[0,MAX_VERTEX_UNITS_ARB-1]*/ 1310 1311 <statePaletteMatNum> ::= <integer> /*[0,MAX_PALETTE_MATRICES_ARB-1]*/ 1312 1313 <stateProgramMatNum> ::= <integer> /*[0,MAX_PROGRAM_MATRICES_ARB-1]*/ 1314 1315 <stateTexGenItem> ::= "texgen" <optTexCoordNum> "." 1316 <stateTexGenType> "." <stateTexGenCoord> 1317 1318 <stateTexGenType> ::= "eye" 1319 | "object" 1320 1321 <stateTexGenCoord> ::= "s" 1322 | "t" 1323 | "r" 1324 | "q" 1325 1326 <stateClipPlaneItem> ::= "clip" "[" <clipPlaneNum> "]" "." "plane" 1327 1328 <statePointItem> ::= "point" "." <statePointProperty> 1329 1330 <statePointProperty> ::= "size" 1331 | "attenuation" 1332 1333 <programSingleItem> ::= <progEnvParam> 1334 | <progLocalParam> 1335 1336 <programMultipleItem> ::= <progEnvParams> 1337 | <progLocalParams> 1338 1339 <progEnvParams> ::= "program" "." "env" "[" <progEnvParamNums> "]" 1340 1341 <progEnvParamNums> ::= <progEnvParamNum> 1342 | <progEnvParamNum> ".." <progEnvParamNum> 1343 1344 <progEnvParam> ::= "program" "." "env" "[" <progEnvParamNum> "]" 1345 1346 <progLocalParams> ::= "program" "." "local" "[" <progLocalParamNums> 1347 "]" 1348 1349 <progLocalParamNums> ::= <progLocalParamNum> 1350 | <progLocalParamNum> ".." <progLocalParamNum> 1351 1352 <progLocalParam> ::= "program" "." "local" "[" <progLocalParamNum> 1353 "]" 1354 1355 <progEnvParamNum> ::= <integer> 1356 /*[0,MAX_PROGRAM_ENV_PARAMETERS_ARB-1]*/ 1357 1358 <progLocalParamNum> ::= <integer> 1359 /*[0,MAX_PROGRAM_LOCAL_PARAMETERS_ARB-1]*/ 1360 1361 <constantVector> ::= "{" <constantVectorList> "}" 1362 1363 <constantVectorList> ::= <signedConstantScalar> 1364 | <signedConstantScalar> "," 1365 <signedConstantScalar> 1366 | <signedConstantScalar> "," 1367 <signedConstantScalar> "," 1368 <signedConstantScalar> 1369 | <signedConstantScalar> "," 1370 <signedConstantScalar> "," 1371 <signedConstantScalar> "," 1372 <signedConstantScalar> 1373 1374 <signedConstantScalar> ::= <optSign> <constantScalar> 1375 1376 <constantScalar> ::= <floatConstant> 1377 1378 <floatConstant> ::= <float> 1379 1380 <tempUseV> ::= <tempVarName> <swizzleSuffix> 1381 1382 <tempUseS> ::= <tempVarName> <scalarSuffix> 1383 1384 <tempUseVNS> ::= <tempVarName> 1385 1386 <tempUseW> ::= <tempVarName> <optWriteMask> 1387 1388 <resultUseW> ::= <resultBasic> <optWriteMask> 1389 | <resultVarName> <optWriteMask> 1390 | <resultVtxColor> <optWriteMask> 1391 | <resultVtxColor> "." <colorType> 1392 <optWriteMask> 1393 | <resultVtxColor> "." <faceType> <optWriteMask> 1394 | <resultVtxColor> "." <faceType> "." 1395 <colorType> "." <optWriteMask> 1396 1397 <resultUseD> ::= <resultBasic> 1398 | <resultVtxColor> 1399 | <resultVtxColor> "." <colorType> 1400 | <resultVtxColor> "." <faceType> 1401 | <resultVtxColor> "." <faceType> "." 1402 <colorType> 1403 1404 <resultBasic> ::= "result" "." <resultVtxBasic> 1405 1406 <resultVtxBasic> ::= "position" 1407 | "fogcoord" 1408 | "pointsize" 1409 | "texcoord" <optTexCoordNum> 1410 1411 <resultVtxColor> ::= "result" "." "color" 1412 1413 <arrayMem> ::= <arrayMemAbs> 1414 | <arrayMemRel> 1415 1416 <arrayMemRel> ::= <addrUseS> <arrayMemRelOffset> 1417 1418 <arrayMemAbs> ::= <integer> 1419 1420 <arrayMemRelOffset> ::= /* empty */ 1421 | "+" <integer> 1422 | "-" <integer> 1423 1424 <addrUseS> ::= <addrVarName> <scalarAddrSuffix> 1425 1426 <addrUseW> ::= <addrVarName> <addrWriteMask> 1427 1428 <addrWriteMask> ::= "." "x" 1429 1430 <optWriteMask> ::= /* empty */ 1431 | <xyzwMask> 1432 1433 <xyzwMask> ::= "." "x" 1434 | "." "y" 1435 | "." "xy" 1436 | "." "z" 1437 | "." "xz" 1438 | "." "yz" 1439 | "." "xyz" 1440 | "." "w" 1441 | "." "xw" 1442 | "." "yw" 1443 | "." "xyw" 1444 | "." "zw" 1445 | "." "xzw" 1446 | "." "yzw" 1447 | "." "xyzw" 1448 1449 <swizzleSuffix> ::= /* empty */ 1450 | "." <component> 1451 | "." <xyzwComponent> <xyzwComponent> 1452 <xyzwComponent> <xyzwComponent> 1453 1454 <extendedSwizzle> ::= <extSwizComp> "," <extSwizComp> "," 1455 <extSwizComp> "," <extSwizComp> 1456 1457 <extSwizComp> ::= <optSign> <xyzwExtSwizSel> 1458 1459 <xyzwExtSwizSel> ::= "0" 1460 | "1" 1461 | <xyzwComponent> 1462 1463 <scalarAddrSuffix> ::= "." <addrComponent> 1464 1465 <addrComponent> ::= "x" 1466 1467 <scalarSuffix> ::= "." <component> 1468 1469 <component> ::= <xyzwComponent> 1470 1471 <xyzwComponent> ::= "x" 1472 | "y" 1473 | "z" 1474 | "w" 1475 1476 <optSign> ::= /* empty */ 1477 | "-" 1478 | "+" 1479 1480 <faceType> ::= "front" 1481 | "back" 1482 1483 <colorType> ::= "primary" 1484 | "secondary" 1485 1486 <vtxAttribNum> ::= <integer> /*[0,MAX_VERTEX_ATTRIBS_ARB-1]*/ 1487 1488 <vtxOptWeightNum> ::= /* empty */ 1489 | "[" <vtxWeightNum> "]" 1490 1491 <vtxWeightNum> ::= <integer> /*[0,MAX_VERTEX_UNITS_ARB-1] must be 1492 divisible by four */ 1493 1494 <optTexCoordNum> ::= /* empty */ 1495 | "[" <texCoordNum> "]" 1496 1497 <texCoordNum> ::= <integer> /*[0,MAX_TEXTURE_COORDS_ARB-1]*/ 1498 1499 <clipPlaneNum> ::= <integer> /*[0,MAX_CLIP_PLANES-1]*/ 1500 1501 The <integer>, <float>, and <identifier> grammar rules match 1502 integer constants, floating point constants, and identifier names 1503 as described in the ARB_vertex_program specification. The <float> 1504 grammar rule here is identical to the <floatConstant> grammar rule 1505 in ARB_vertex_program. 1506 1507 The grammar rules <tempVarName>, <addrVarName>, <attribVarName>, 1508 <paramArrayVarName>, <paramSingleVarName>, <resultVarName> refer 1509 to the names of temporary, address register, attribute, program 1510 parameter array, program parameter, and result variables declared 1511 in the program text. 1512 1513GLX Protocol 1514 1515 None. 1516 1517Errors 1518 1519 None. 1520 1521New State 1522 1523 None. 1524 1525 1526New Implementation Dependent State 1527 Min 1528 Get Value Type Get Command Value Description Sec Attrib 1529 ----------------------------------- ---- --------------- ------ ----------------- -------- ------ 1530 MAX_PROGRAM_EXEC_INSTRUCTIONS_NV Z+ GetProgramivARB 65536 maximum program 2.14.4.4 - 1531 execution inst- 1532 ruction count 1533 MAX_PROGRAM_CALL_DEPTH_NV Z+ GetProgramivARB 4 maximum program 2.14.4.4 - 1534 call stack depth 1535 1536 (add to Table X.11. New Implementation-Dependent Values Introduced 1537 by ARB_vertex_program. Values queried by GetProgramivARB require 1538 a <pname> of VERTEX_PROGRAM_ARB.) 1539 1540Revision History 1541 1542 Rev. Date Author Changes 1543 ---- -------- ------- -------------------------------------------- 1544 3 06/23/04 pbrown Documented that vertex results are undefined 1545 if the call stack overflows, and clarified that 1546 RET with an empty call stack is not an error. 1547 1548 2 05/16/04 pbrown Documented terminals in modified vertex program 1549 grammar. 1550 1551 1 -------- pbrown Internal pre-release revisions. 1552