GPU/Shader Instruction Set: Difference between revisions
MOVA considers the dest mask |
Clean up and simplify |
||
Line 291: | Line 291: | ||
== Instructions == | == Instructions == | ||
== Instructions == | |||
Unless noted otherwise, SRC1 and SRC2 refer to their respectively indexed float[4] registers (after swizzling). Similarly, DST refers to its indexed register modulo destination component masking, i.e. an expression like DST=SRC1 might actually just set DST.y to SRC1.y. | |||
{| class="wikitable" border="1" | {| class="wikitable" border="1" | ||
Line 302: | Line 306: | ||
| 1 | | 1 | ||
| ADD | | ADD | ||
| Adds two vectors component by component; DST[i] = SRC1[i]+SRC2[i] for all i | | Adds two vectors component by component; DST[i] = SRC1[i]+SRC2[i] for all i | ||
|- | |- | ||
| 0x01 | | 0x01 | ||
Line 327: | Line 331: | ||
| 1u | | 1u | ||
| EX2 | | EX2 | ||
| Computes SRC1's | | Computes SRC1's per-component exponent with base 2; DST[i] = EXP(SRC1[i]) for all i | ||
|- | |- | ||
| 0x06 | | 0x06 | ||
| 1u | | 1u | ||
| LG2 | | LG2 | ||
| Computes SRC1's log2 component by component; DST[i] = LOG2(SRC1[i]) for all i | | Computes SRC1's log2 component by component; DST[i] = LOG2(SRC1[i]) for all i | ||
|- | |- | ||
| 0x07 | | 0x07 | ||
Line 342: | Line 346: | ||
| 1 | | 1 | ||
| MUL | | MUL | ||
| Multiplies two vectors component by component; DST[i] = SRC1[i].SRC2[i] for all i | | Multiplies two vectors component by component; DST[i] = SRC1[i].SRC2[i] for all i | ||
|- | |- | ||
| 0x09 | | 0x09 | ||
| 1 | | 1 | ||
| SGE | | SGE | ||
| Sets output if SRC1 is greater than or equal to SRC2; DST[i] = (SRC1[i] >= SRC2[i]) ? 1.0 : 0.0 for all i | | Sets output if SRC1 is greater than or equal to SRC2; DST[i] = (SRC1[i] >= SRC2[i]) ? 1.0 : 0.0 for all i | ||
|- | |- | ||
| 0x0A | | 0x0A | ||
| 1 | | 1 | ||
| SLT | | SLT | ||
| Sets output if SRC1 is strictly less than SRC2; DST[i] = (SRC1[i] < SRC2[i]) ? 1.0 : 0.0 for all i | | Sets output if SRC1 is strictly less than SRC2; DST[i] = (SRC1[i] < SRC2[i]) ? 1.0 : 0.0 for all i | ||
|- | |- | ||
| 0x0B | | 0x0B | ||
| 1u | | 1u | ||
| FLR | | FLR | ||
| Computes SRC1's floor component by component; DST[i] = FLOOR(SRC1[i]) for all i | | Computes SRC1's floor component by component; DST[i] = FLOOR(SRC1[i]) for all i | ||
|- | |- | ||
| 0x0C | | 0x0C | ||
| 1 | | 1 | ||
| MAX | | MAX | ||
| Takes the max of two vectors, component by component; DST[i] = MAX(SRC1[i], SRC2[i]) for all i | | Takes the max of two vectors, component by component; DST[i] = MAX(SRC1[i], SRC2[i]) for all i | ||
|- | |- | ||
| 0x0D | | 0x0D | ||
| 1 | | 1 | ||
| MIN | | MIN | ||
| Takes the min of two vectors, component by component; DST[i] = MIN(SRC1[i], SRC2[i]) for all i | | Takes the min of two vectors, component by component; DST[i] = MIN(SRC1[i], SRC2[i]) for all i | ||
|- | |- | ||
| 0x0E | | 0x0E | ||
| 1u | | 1u | ||
| RCP | | RCP | ||
| Computes the reciprocal of the vector, component by component; DST[i] = 1/SRC1[i] for all i | | Computes the reciprocal of the vector, component by component; DST[i] = 1/SRC1[i] for all i | ||
|- | |- | ||
| 0x0F | | 0x0F | ||
| 1u | | 1u | ||
| RSQ | | RSQ | ||
| Computes the reciprocal of the square root of the vector, component by component; DST[i] = 1/sqrt(SRC1[i]) for all i | | Computes the reciprocal of the square root of the vector, component by component; DST[i] = 1/sqrt(SRC1[i]) for all i | ||
|- | |- | ||
| 0x10 | | 0x10 | ||
Line 392: | Line 396: | ||
| 1u | | 1u | ||
| MOVA | | MOVA | ||
| Move to address register; Casts the float uniform given by SRC1 to an integer (truncating the fractional part) and assigns the result to (a0.x, a0.y, _, _) | | Move to address register; Casts the float uniform given by SRC1 to an integer (truncating the fractional part) and assigns the result to (a0.x, a0.y, _, _), respecting the destination component mask. | ||
|- | |- | ||
| 0x13 | | 0x13 | ||
Line 432: | Line 436: | ||
| 1i | | 1i | ||
| SGEI | | SGEI | ||
| Sets output if SRC1 is greater than or equal to SRC2; DST[i] = (SRC1[i] >= SRC2[i]) ? 1.0 : 0.0 for all i | | Sets output if SRC1 is greater than or equal to SRC2; DST[i] = (SRC1[i] >= SRC2[i]) ? 1.0 : 0.0 for all i | ||
|- | |- | ||
| 0x1B | | 0x1B | ||
| 1i | | 1i | ||
| SLTI | | SLTI | ||
| Sets output if SRC1 is strictly less than SRC2; DST[i] = (SRC1[i] < SRC2[i]) ? 1.0 : 0.0 for all i | | Sets output if SRC1 is strictly less than SRC2; DST[i] = (SRC1[i] < SRC2[i]) ? 1.0 : 0.0 for all i | ||
|- | |- | ||
| 0x1C | | 0x1C | ||
Line 532: | Line 536: | ||
| 1c | | 1c | ||
| CMP | | CMP | ||
| Sets booleans cmp.x and cmp.y based on the operand's x and y components and the CMPX and CMPY comparison operators respectively. See [[#Comparison_operator|below]] for details about operators. | | Sets booleans cmp.x and cmp.y based on the operand's x and y components and the CMPX and CMPY comparison operators respectively. See [[#Comparison_operator|below]] for details about operators. It's unknown whether CMP respects the destination component mask or not. | ||
|- | |- | ||
| 0x30-0x37 | | 0x30-0x37 | ||
| 5i | | 5i | ||
| MADI | | MADI | ||
| Multiplies two vectors and adds a third one component by component; DST[i] = SRC3[i] + SRC2[i].SRC1[i] for all i | | Multiplies two vectors and adds a third one component by component; DST[i] = SRC3[i] + SRC2[i].SRC1[i] for all i | ||
|- | |- | ||
| 0x38-0x3F | | 0x38-0x3F | ||
| 5 | | 5 | ||
| MAD | | MAD | ||
| Multiplies two vectors and adds a third one component by component; DST[i] = SRC3[i] + SRC2[i].SRC1[i] for all i | | Multiplies two vectors and adds a third one component by component; DST[i] = SRC3[i] + SRC2[i].SRC1[i] for all i | ||
|} | |} | ||