Corbin Simpson | c686e17 | 2009-12-20 15:00:40 -0800 | [diff] [blame] | 1 | TGSI |
| 2 | ==== |
| 3 | |
Michal Krol | b665968 | 2010-01-04 12:52:43 +0100 | [diff] [blame] | 4 | TGSI, Tungsten Graphics Shader Infrastructure, is an intermediate language |
Corbin Simpson | c686e17 | 2009-12-20 15:00:40 -0800 | [diff] [blame] | 5 | for describing shaders. Since Gallium is inherently shaderful, shaders are |
| 6 | an important part of the API. TGSI is the only intermediate representation |
| 7 | used by all drivers. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 8 | |
Corbin Simpson | 62ca7b8 | 2010-02-02 16:36:34 -0800 | [diff] [blame] | 9 | Basics |
| 10 | ------ |
| 11 | |
| 12 | All TGSI instructions, known as *opcodes*, operate on arbitrary-precision |
| 13 | floating-point four-component vectors. An opcode may have up to one |
| 14 | destination register, known as *dst*, and between zero and three source |
| 15 | registers, called *src0* through *src2*, or simply *src* if there is only |
| 16 | one. |
| 17 | |
| 18 | Some instructions, like :opcode:`I2F`, permit re-interpretation of vector |
| 19 | components as integers. Other instructions permit using registers as |
| 20 | two-component vectors with double precision; see :ref:`Double Opcodes`. |
| 21 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 22 | When an instruction has a scalar result, the result is usually copied into |
| 23 | each of the components of *dst*. When this happens, the result is said to be |
| 24 | *replicated* to *dst*. :opcode:`RCP` is one such instruction. |
| 25 | |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 26 | Instruction Set |
| 27 | --------------- |
| 28 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 29 | Core ISA |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 30 | ^^^^^^^^^^^^^^^^^^^^^^^^^ |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 31 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 32 | These opcodes are guaranteed to be available regardless of the driver being |
| 33 | used. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 34 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 35 | .. opcode:: ARL - Address Register Load |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 36 | |
| 37 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 38 | |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 39 | dst.x = \lfloor src.x\rfloor |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 40 | |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 41 | dst.y = \lfloor src.y\rfloor |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 42 | |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 43 | dst.z = \lfloor src.z\rfloor |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 44 | |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 45 | dst.w = \lfloor src.w\rfloor |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 46 | |
| 47 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 48 | .. opcode:: MOV - Move |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 49 | |
| 50 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 51 | |
| 52 | dst.x = src.x |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 53 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 54 | dst.y = src.y |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 55 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 56 | dst.z = src.z |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 57 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 58 | dst.w = src.w |
| 59 | |
| 60 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 61 | .. opcode:: LIT - Light Coefficients |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 62 | |
| 63 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 64 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 65 | dst.x = 1 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 66 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 67 | dst.y = max(src.x, 0) |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 68 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 69 | dst.z = (src.x > 0) ? max(src.y, 0)^{clamp(src.w, -128, 128))} : 0 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 70 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 71 | dst.w = 1 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 72 | |
| 73 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 74 | .. opcode:: RCP - Reciprocal |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 75 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 76 | This instruction replicates its result. |
| 77 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 78 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 79 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 80 | dst = \frac{1}{src.x} |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 81 | |
| 82 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 83 | .. opcode:: RSQ - Reciprocal Square Root |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 84 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 85 | This instruction replicates its result. |
| 86 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 87 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 88 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 89 | dst = \frac{1}{\sqrt{|src.x|}} |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 90 | |
| 91 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 92 | .. opcode:: EXP - Approximate Exponential Base 2 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 93 | |
| 94 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 95 | |
Corbin Simpson | dd801e5 | 2009-12-21 19:41:09 -0800 | [diff] [blame] | 96 | dst.x = 2^{\lfloor src.x\rfloor} |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 97 | |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 98 | dst.y = src.x - \lfloor src.x\rfloor |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 99 | |
Corbin Simpson | dd801e5 | 2009-12-21 19:41:09 -0800 | [diff] [blame] | 100 | dst.z = 2^{src.x} |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 101 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 102 | dst.w = 1 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 103 | |
| 104 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 105 | .. opcode:: LOG - Approximate Logarithm Base 2 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 106 | |
| 107 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 108 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 109 | dst.x = \lfloor\log_2{|src.x|}\rfloor |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 110 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 111 | dst.y = \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}} |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 112 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 113 | dst.z = \log_2{|src.x|} |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 114 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 115 | dst.w = 1 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 116 | |
| 117 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 118 | .. opcode:: MUL - Multiply |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 119 | |
| 120 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 121 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 122 | dst.x = src0.x \times src1.x |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 123 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 124 | dst.y = src0.y \times src1.y |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 125 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 126 | dst.z = src0.z \times src1.z |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 127 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 128 | dst.w = src0.w \times src1.w |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 129 | |
| 130 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 131 | .. opcode:: ADD - Add |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 132 | |
| 133 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 134 | |
| 135 | dst.x = src0.x + src1.x |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 136 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 137 | dst.y = src0.y + src1.y |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 138 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 139 | dst.z = src0.z + src1.z |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 140 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 141 | dst.w = src0.w + src1.w |
| 142 | |
| 143 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 144 | .. opcode:: DP3 - 3-component Dot Product |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 145 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 146 | This instruction replicates its result. |
| 147 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 148 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 149 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 150 | dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 151 | |
| 152 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 153 | .. opcode:: DP4 - 4-component Dot Product |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 154 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 155 | This instruction replicates its result. |
| 156 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 157 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 158 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 159 | dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 160 | |
| 161 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 162 | .. opcode:: DST - Distance Vector |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 163 | |
| 164 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 165 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 166 | dst.x = 1 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 167 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 168 | dst.y = src0.y \times src1.y |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 169 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 170 | dst.z = src0.z |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 171 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 172 | dst.w = src1.w |
| 173 | |
| 174 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 175 | .. opcode:: MIN - Minimum |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 176 | |
| 177 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 178 | |
| 179 | dst.x = min(src0.x, src1.x) |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 180 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 181 | dst.y = min(src0.y, src1.y) |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 182 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 183 | dst.z = min(src0.z, src1.z) |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 184 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 185 | dst.w = min(src0.w, src1.w) |
| 186 | |
| 187 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 188 | .. opcode:: MAX - Maximum |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 189 | |
| 190 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 191 | |
| 192 | dst.x = max(src0.x, src1.x) |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 193 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 194 | dst.y = max(src0.y, src1.y) |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 195 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 196 | dst.z = max(src0.z, src1.z) |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 197 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 198 | dst.w = max(src0.w, src1.w) |
| 199 | |
| 200 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 201 | .. opcode:: SLT - Set On Less Than |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 202 | |
| 203 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 204 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 205 | dst.x = (src0.x < src1.x) ? 1 : 0 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 206 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 207 | dst.y = (src0.y < src1.y) ? 1 : 0 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 208 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 209 | dst.z = (src0.z < src1.z) ? 1 : 0 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 210 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 211 | dst.w = (src0.w < src1.w) ? 1 : 0 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 212 | |
| 213 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 214 | .. opcode:: SGE - Set On Greater Equal Than |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 215 | |
| 216 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 217 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 218 | dst.x = (src0.x >= src1.x) ? 1 : 0 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 219 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 220 | dst.y = (src0.y >= src1.y) ? 1 : 0 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 221 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 222 | dst.z = (src0.z >= src1.z) ? 1 : 0 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 223 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 224 | dst.w = (src0.w >= src1.w) ? 1 : 0 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 225 | |
| 226 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 227 | .. opcode:: MAD - Multiply And Add |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 228 | |
| 229 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 230 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 231 | dst.x = src0.x \times src1.x + src2.x |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 232 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 233 | dst.y = src0.y \times src1.y + src2.y |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 234 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 235 | dst.z = src0.z \times src1.z + src2.z |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 236 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 237 | dst.w = src0.w \times src1.w + src2.w |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 238 | |
| 239 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 240 | .. opcode:: SUB - Subtract |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 241 | |
| 242 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 243 | |
| 244 | dst.x = src0.x - src1.x |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 245 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 246 | dst.y = src0.y - src1.y |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 247 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 248 | dst.z = src0.z - src1.z |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 249 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 250 | dst.w = src0.w - src1.w |
| 251 | |
| 252 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 253 | .. opcode:: LRP - Linear Interpolate |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 254 | |
| 255 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 256 | |
Michal Krol | b3567fc | 2010-01-04 12:59:17 +0100 | [diff] [blame] | 257 | dst.x = src0.x \times src1.x + (1 - src0.x) \times src2.x |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 258 | |
Michal Krol | b3567fc | 2010-01-04 12:59:17 +0100 | [diff] [blame] | 259 | dst.y = src0.y \times src1.y + (1 - src0.y) \times src2.y |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 260 | |
Michal Krol | b3567fc | 2010-01-04 12:59:17 +0100 | [diff] [blame] | 261 | dst.z = src0.z \times src1.z + (1 - src0.z) \times src2.z |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 262 | |
Michal Krol | b3567fc | 2010-01-04 12:59:17 +0100 | [diff] [blame] | 263 | dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 264 | |
| 265 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 266 | .. opcode:: CND - Condition |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 267 | |
| 268 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 269 | |
| 270 | dst.x = (src2.x > 0.5) ? src0.x : src1.x |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 271 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 272 | dst.y = (src2.y > 0.5) ? src0.y : src1.y |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 273 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 274 | dst.z = (src2.z > 0.5) ? src0.z : src1.z |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 275 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 276 | dst.w = (src2.w > 0.5) ? src0.w : src1.w |
| 277 | |
| 278 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 279 | .. opcode:: DP2A - 2-component Dot Product And Add |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 280 | |
| 281 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 282 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 283 | dst.x = src0.x \times src1.x + src0.y \times src1.y + src2.x |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 284 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 285 | dst.y = src0.x \times src1.x + src0.y \times src1.y + src2.x |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 286 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 287 | dst.z = src0.x \times src1.x + src0.y \times src1.y + src2.x |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 288 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 289 | dst.w = src0.x \times src1.x + src0.y \times src1.y + src2.x |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 290 | |
| 291 | |
José Fonseca | d9c6ebb | 2010-06-01 16:25:05 +0100 | [diff] [blame] | 292 | .. opcode:: FRC - Fraction |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 293 | |
| 294 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 295 | |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 296 | dst.x = src.x - \lfloor src.x\rfloor |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 297 | |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 298 | dst.y = src.y - \lfloor src.y\rfloor |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 299 | |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 300 | dst.z = src.z - \lfloor src.z\rfloor |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 301 | |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 302 | dst.w = src.w - \lfloor src.w\rfloor |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 303 | |
| 304 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 305 | .. opcode:: CLAMP - Clamp |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 306 | |
| 307 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 308 | |
| 309 | dst.x = clamp(src0.x, src1.x, src2.x) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 310 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 311 | dst.y = clamp(src0.y, src1.y, src2.y) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 312 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 313 | dst.z = clamp(src0.z, src1.z, src2.z) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 314 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 315 | dst.w = clamp(src0.w, src1.w, src2.w) |
| 316 | |
| 317 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 318 | .. opcode:: FLR - Floor |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 319 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 320 | This is identical to :opcode:`ARL`. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 321 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 322 | .. math:: |
| 323 | |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 324 | dst.x = \lfloor src.x\rfloor |
| 325 | |
| 326 | dst.y = \lfloor src.y\rfloor |
| 327 | |
| 328 | dst.z = \lfloor src.z\rfloor |
| 329 | |
| 330 | dst.w = \lfloor src.w\rfloor |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 331 | |
| 332 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 333 | .. opcode:: ROUND - Round |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 334 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 335 | .. math:: |
| 336 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 337 | dst.x = round(src.x) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 338 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 339 | dst.y = round(src.y) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 340 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 341 | dst.z = round(src.z) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 342 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 343 | dst.w = round(src.w) |
| 344 | |
| 345 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 346 | .. opcode:: EX2 - Exponential Base 2 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 347 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 348 | This instruction replicates its result. |
| 349 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 350 | .. math:: |
| 351 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 352 | dst = 2^{src.x} |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 353 | |
| 354 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 355 | .. opcode:: LG2 - Logarithm Base 2 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 356 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 357 | This instruction replicates its result. |
| 358 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 359 | .. math:: |
| 360 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 361 | dst = \log_2{src.x} |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 362 | |
| 363 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 364 | .. opcode:: POW - Power |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 365 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 366 | This instruction replicates its result. |
| 367 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 368 | .. math:: |
| 369 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 370 | dst = src0.x^{src1.x} |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 371 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 372 | .. opcode:: XPD - Cross Product |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 373 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 374 | .. math:: |
| 375 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 376 | dst.x = src0.y \times src1.z - src1.y \times src0.z |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 377 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 378 | dst.y = src0.z \times src1.x - src1.z \times src0.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 379 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 380 | dst.z = src0.x \times src1.y - src1.x \times src0.y |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 381 | |
| 382 | dst.w = 1 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 383 | |
| 384 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 385 | .. opcode:: ABS - Absolute |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 386 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 387 | .. math:: |
| 388 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 389 | dst.x = |src.x| |
| 390 | |
| 391 | dst.y = |src.y| |
| 392 | |
| 393 | dst.z = |src.z| |
| 394 | |
| 395 | dst.w = |src.w| |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 396 | |
| 397 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 398 | .. opcode:: RCC - Reciprocal Clamped |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 399 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 400 | This instruction replicates its result. |
| 401 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 402 | XXX cleanup on aisle three |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 403 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 404 | .. math:: |
| 405 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 406 | dst = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020) |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 407 | |
| 408 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 409 | .. opcode:: DPH - Homogeneous Dot Product |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 410 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 411 | This instruction replicates its result. |
| 412 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 413 | .. math:: |
| 414 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 415 | dst = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 416 | |
| 417 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 418 | .. opcode:: COS - Cosine |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 419 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 420 | This instruction replicates its result. |
| 421 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 422 | .. math:: |
| 423 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 424 | dst = \cos{src.x} |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 425 | |
| 426 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 427 | .. opcode:: DDX - Derivative Relative To X |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 428 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 429 | .. math:: |
| 430 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 431 | dst.x = partialx(src.x) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 432 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 433 | dst.y = partialx(src.y) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 434 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 435 | dst.z = partialx(src.z) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 436 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 437 | dst.w = partialx(src.w) |
| 438 | |
| 439 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 440 | .. opcode:: DDY - Derivative Relative To Y |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 441 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 442 | .. math:: |
| 443 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 444 | dst.x = partialy(src.x) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 445 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 446 | dst.y = partialy(src.y) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 447 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 448 | dst.z = partialy(src.z) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 449 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 450 | dst.w = partialy(src.w) |
| 451 | |
| 452 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 453 | .. opcode:: KILP - Predicated Discard |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 454 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 455 | discard |
| 456 | |
| 457 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 458 | .. opcode:: PK2H - Pack Two 16-bit Floats |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 459 | |
| 460 | TBD |
| 461 | |
| 462 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 463 | .. opcode:: PK2US - Pack Two Unsigned 16-bit Scalars |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 464 | |
| 465 | TBD |
| 466 | |
| 467 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 468 | .. opcode:: PK4B - Pack Four Signed 8-bit Scalars |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 469 | |
| 470 | TBD |
| 471 | |
| 472 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 473 | .. opcode:: PK4UB - Pack Four Unsigned 8-bit Scalars |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 474 | |
| 475 | TBD |
| 476 | |
| 477 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 478 | .. opcode:: RFL - Reflection Vector |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 479 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 480 | .. math:: |
| 481 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 482 | dst.x = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.x - src1.x |
| 483 | |
| 484 | dst.y = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.y - src1.y |
| 485 | |
| 486 | dst.z = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.z - src1.z |
| 487 | |
| 488 | dst.w = 1 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 489 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 490 | .. note:: |
| 491 | |
| 492 | Considered for removal. |
Keith Whitwell | 14eacb0 | 2009-12-21 23:38:29 +0000 | [diff] [blame] | 493 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 494 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 495 | .. opcode:: SEQ - Set On Equal |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 496 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 497 | .. math:: |
| 498 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 499 | dst.x = (src0.x == src1.x) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 500 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 501 | dst.y = (src0.y == src1.y) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 502 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 503 | dst.z = (src0.z == src1.z) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 504 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 505 | dst.w = (src0.w == src1.w) ? 1 : 0 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 506 | |
| 507 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 508 | .. opcode:: SFL - Set On False |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 509 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 510 | This instruction replicates its result. |
| 511 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 512 | .. math:: |
| 513 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 514 | dst = 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 515 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 516 | .. note:: |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 517 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 518 | Considered for removal. |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 519 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 520 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 521 | .. opcode:: SGT - Set On Greater Than |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 522 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 523 | .. math:: |
| 524 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 525 | dst.x = (src0.x > src1.x) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 526 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 527 | dst.y = (src0.y > src1.y) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 528 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 529 | dst.z = (src0.z > src1.z) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 530 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 531 | dst.w = (src0.w > src1.w) ? 1 : 0 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 532 | |
| 533 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 534 | .. opcode:: SIN - Sine |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 535 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 536 | This instruction replicates its result. |
| 537 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 538 | .. math:: |
| 539 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 540 | dst = \sin{src.x} |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 541 | |
| 542 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 543 | .. opcode:: SLE - Set On Less Equal Than |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 544 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 545 | .. math:: |
| 546 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 547 | dst.x = (src0.x <= src1.x) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 548 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 549 | dst.y = (src0.y <= src1.y) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 550 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 551 | dst.z = (src0.z <= src1.z) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 552 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 553 | dst.w = (src0.w <= src1.w) ? 1 : 0 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 554 | |
| 555 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 556 | .. opcode:: SNE - Set On Not Equal |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 557 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 558 | .. math:: |
| 559 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 560 | dst.x = (src0.x != src1.x) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 561 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 562 | dst.y = (src0.y != src1.y) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 563 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 564 | dst.z = (src0.z != src1.z) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 565 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 566 | dst.w = (src0.w != src1.w) ? 1 : 0 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 567 | |
| 568 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 569 | .. opcode:: STR - Set On True |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 570 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 571 | This instruction replicates its result. |
| 572 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 573 | .. math:: |
| 574 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 575 | dst = 1 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 576 | |
| 577 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 578 | .. opcode:: TEX - Texture Lookup |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 579 | |
Brian Paul | 2a77c3c | 2010-12-14 12:45:36 -0700 | [diff] [blame] | 580 | .. math:: |
| 581 | |
| 582 | coord = src0 |
| 583 | |
| 584 | bias = 0.0 |
| 585 | |
| 586 | dst = texture_sample(unit, coord, bias) |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 587 | |
| 588 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 589 | .. opcode:: TXD - Texture Lookup with Derivatives |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 590 | |
Brian Paul | 2a77c3c | 2010-12-14 12:45:36 -0700 | [diff] [blame] | 591 | .. math:: |
| 592 | |
| 593 | coord = src0 |
| 594 | |
| 595 | ddx = src1 |
| 596 | |
| 597 | ddy = src2 |
| 598 | |
| 599 | bias = 0.0 |
| 600 | |
| 601 | dst = texture_sample_deriv(unit, coord, bias, ddx, ddy) |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 602 | |
| 603 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 604 | .. opcode:: TXP - Projective Texture Lookup |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 605 | |
Brian Paul | 2a77c3c | 2010-12-14 12:45:36 -0700 | [diff] [blame] | 606 | .. math:: |
| 607 | |
| 608 | coord.x = src0.x / src.w |
| 609 | |
| 610 | coord.y = src0.y / src.w |
| 611 | |
| 612 | coord.z = src0.z / src.w |
| 613 | |
| 614 | coord.w = src0.w |
| 615 | |
| 616 | bias = 0.0 |
| 617 | |
| 618 | dst = texture_sample(unit, coord, bias) |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 619 | |
| 620 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 621 | .. opcode:: UP2H - Unpack Two 16-Bit Floats |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 622 | |
| 623 | TBD |
| 624 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 625 | .. note:: |
| 626 | |
| 627 | Considered for removal. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 628 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 629 | .. opcode:: UP2US - Unpack Two Unsigned 16-Bit Scalars |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 630 | |
| 631 | TBD |
| 632 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 633 | .. note:: |
| 634 | |
| 635 | Considered for removal. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 636 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 637 | .. opcode:: UP4B - Unpack Four Signed 8-Bit Values |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 638 | |
| 639 | TBD |
| 640 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 641 | .. note:: |
| 642 | |
| 643 | Considered for removal. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 644 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 645 | .. opcode:: UP4UB - Unpack Four Unsigned 8-Bit Scalars |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 646 | |
| 647 | TBD |
| 648 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 649 | .. note:: |
| 650 | |
| 651 | Considered for removal. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 652 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 653 | .. opcode:: X2D - 2D Coordinate Transformation |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 654 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 655 | .. math:: |
| 656 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 657 | dst.x = src0.x + src1.x \times src2.x + src1.y \times src2.y |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 658 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 659 | dst.y = src0.y + src1.x \times src2.z + src1.y \times src2.w |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 660 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 661 | dst.z = src0.x + src1.x \times src2.x + src1.y \times src2.y |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 662 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 663 | dst.w = src0.y + src1.x \times src2.z + src1.y \times src2.w |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 664 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 665 | .. note:: |
| 666 | |
| 667 | Considered for removal. |
Keith Whitwell | 14eacb0 | 2009-12-21 23:38:29 +0000 | [diff] [blame] | 668 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 669 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 670 | .. opcode:: ARA - Address Register Add |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 671 | |
| 672 | TBD |
| 673 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 674 | .. note:: |
| 675 | |
| 676 | Considered for removal. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 677 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 678 | .. opcode:: ARR - Address Register Load With Round |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 679 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 680 | .. math:: |
| 681 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 682 | dst.x = round(src.x) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 683 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 684 | dst.y = round(src.y) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 685 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 686 | dst.z = round(src.z) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 687 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 688 | dst.w = round(src.w) |
| 689 | |
| 690 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 691 | .. opcode:: BRA - Branch |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 692 | |
| 693 | pc = target |
| 694 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 695 | .. note:: |
| 696 | |
| 697 | Considered for removal. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 698 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 699 | .. opcode:: CAL - Subroutine Call |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 700 | |
| 701 | push(pc) |
| 702 | pc = target |
| 703 | |
| 704 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 705 | .. opcode:: RET - Subroutine Call Return |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 706 | |
| 707 | pc = pop() |
| 708 | |
| 709 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 710 | .. opcode:: SSG - Set Sign |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 711 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 712 | .. math:: |
| 713 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 714 | dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0 |
| 715 | |
| 716 | dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0 |
| 717 | |
| 718 | dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0 |
| 719 | |
| 720 | dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 721 | |
| 722 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 723 | .. opcode:: CMP - Compare |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 724 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 725 | .. math:: |
| 726 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 727 | dst.x = (src0.x < 0) ? src1.x : src2.x |
| 728 | |
| 729 | dst.y = (src0.y < 0) ? src1.y : src2.y |
| 730 | |
| 731 | dst.z = (src0.z < 0) ? src1.z : src2.z |
| 732 | |
| 733 | dst.w = (src0.w < 0) ? src1.w : src2.w |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 734 | |
| 735 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 736 | .. opcode:: KIL - Conditional Discard |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 737 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 738 | .. math:: |
| 739 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 740 | if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0) |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 741 | discard |
| 742 | endif |
| 743 | |
| 744 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 745 | .. opcode:: SCS - Sine Cosine |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 746 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 747 | .. math:: |
| 748 | |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 749 | dst.x = \cos{src.x} |
| 750 | |
| 751 | dst.y = \sin{src.x} |
| 752 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 753 | dst.z = 0 |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 754 | |
Tilman Sauerbeck | d323118 | 2010-09-19 09:03:11 +0200 | [diff] [blame] | 755 | dst.w = 1 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 756 | |
| 757 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 758 | .. opcode:: TXB - Texture Lookup With Bias |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 759 | |
Brian Paul | 2a77c3c | 2010-12-14 12:45:36 -0700 | [diff] [blame] | 760 | .. math:: |
| 761 | |
| 762 | coord.x = src.x |
| 763 | |
| 764 | coord.y = src.y |
| 765 | |
| 766 | coord.z = src.z |
| 767 | |
| 768 | coord.w = 1.0 |
| 769 | |
| 770 | bias = src.z |
| 771 | |
| 772 | dst = texture_sample(unit, coord, bias) |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 773 | |
| 774 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 775 | .. opcode:: NRM - 3-component Vector Normalise |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 776 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 777 | .. math:: |
| 778 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 779 | dst.x = src.x / (src.x \times src.x + src.y \times src.y + src.z \times src.z) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 780 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 781 | dst.y = src.y / (src.x \times src.x + src.y \times src.y + src.z \times src.z) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 782 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 783 | dst.z = src.z / (src.x \times src.x + src.y \times src.y + src.z \times src.z) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 784 | |
| 785 | dst.w = 1 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 786 | |
| 787 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 788 | .. opcode:: DIV - Divide |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 789 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 790 | .. math:: |
| 791 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 792 | dst.x = \frac{src0.x}{src1.x} |
| 793 | |
| 794 | dst.y = \frac{src0.y}{src1.y} |
| 795 | |
| 796 | dst.z = \frac{src0.z}{src1.z} |
| 797 | |
| 798 | dst.w = \frac{src0.w}{src1.w} |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 799 | |
| 800 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 801 | .. opcode:: DP2 - 2-component Dot Product |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 802 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 803 | This instruction replicates its result. |
| 804 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 805 | .. math:: |
| 806 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 807 | dst = src0.x \times src1.x + src0.y \times src1.y |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 808 | |
| 809 | |
Brian Paul | 2a77c3c | 2010-12-14 12:45:36 -0700 | [diff] [blame] | 810 | .. opcode:: TXL - Texture Lookup With explicit LOD |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 811 | |
Brian Paul | 2a77c3c | 2010-12-14 12:45:36 -0700 | [diff] [blame] | 812 | .. math:: |
| 813 | |
| 814 | coord.x = src0.x |
| 815 | |
| 816 | coord.y = src0.y |
| 817 | |
| 818 | coord.z = src0.z |
| 819 | |
| 820 | coord.w = 1.0 |
| 821 | |
| 822 | lod = src0.w |
| 823 | |
| 824 | dst = texture_sample(unit, coord, lod) |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 825 | |
| 826 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 827 | .. opcode:: BRK - Break |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 828 | |
| 829 | TBD |
| 830 | |
| 831 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 832 | .. opcode:: IF - If |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 833 | |
| 834 | TBD |
| 835 | |
| 836 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 837 | .. opcode:: ELSE - Else |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 838 | |
| 839 | TBD |
| 840 | |
| 841 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 842 | .. opcode:: ENDIF - End If |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 843 | |
| 844 | TBD |
| 845 | |
| 846 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 847 | .. opcode:: PUSHA - Push Address Register On Stack |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 848 | |
| 849 | push(src.x) |
| 850 | push(src.y) |
| 851 | push(src.z) |
| 852 | push(src.w) |
| 853 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 854 | .. note:: |
| 855 | |
| 856 | Considered for cleanup. |
| 857 | |
| 858 | .. note:: |
| 859 | |
| 860 | Considered for removal. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 861 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 862 | .. opcode:: POPA - Pop Address Register From Stack |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 863 | |
| 864 | dst.w = pop() |
| 865 | dst.z = pop() |
| 866 | dst.y = pop() |
| 867 | dst.x = pop() |
| 868 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 869 | .. note:: |
| 870 | |
| 871 | Considered for cleanup. |
| 872 | |
| 873 | .. note:: |
| 874 | |
| 875 | Considered for removal. |
Keith Whitwell | 14eacb0 | 2009-12-21 23:38:29 +0000 | [diff] [blame] | 876 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 877 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 878 | Compute ISA |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 879 | ^^^^^^^^^^^^^^^^^^^^^^^^ |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 880 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 881 | These opcodes are primarily provided for special-use computational shaders. |
Keith Whitwell | 14eacb0 | 2009-12-21 23:38:29 +0000 | [diff] [blame] | 882 | Support for these opcodes indicated by a special pipe capability bit (TBD). |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 883 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 884 | XXX so let's discuss it, yeah? |
| 885 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 886 | .. opcode:: CEIL - Ceiling |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 887 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 888 | .. math:: |
| 889 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 890 | dst.x = \lceil src.x\rceil |
| 891 | |
| 892 | dst.y = \lceil src.y\rceil |
| 893 | |
| 894 | dst.z = \lceil src.z\rceil |
| 895 | |
| 896 | dst.w = \lceil src.w\rceil |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 897 | |
| 898 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 899 | .. opcode:: I2F - Integer To Float |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 900 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 901 | .. math:: |
| 902 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 903 | dst.x = (float) src.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 904 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 905 | dst.y = (float) src.y |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 906 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 907 | dst.z = (float) src.z |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 908 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 909 | dst.w = (float) src.w |
| 910 | |
| 911 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 912 | .. opcode:: NOT - Bitwise Not |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 913 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 914 | .. math:: |
| 915 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 916 | dst.x = ~src.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 917 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 918 | dst.y = ~src.y |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 919 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 920 | dst.z = ~src.z |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 921 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 922 | dst.w = ~src.w |
| 923 | |
| 924 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 925 | .. opcode:: TRUNC - Truncate |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 926 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 927 | .. math:: |
| 928 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 929 | dst.x = trunc(src.x) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 930 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 931 | dst.y = trunc(src.y) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 932 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 933 | dst.z = trunc(src.z) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 934 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 935 | dst.w = trunc(src.w) |
| 936 | |
| 937 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 938 | .. opcode:: SHL - Shift Left |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 939 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 940 | .. math:: |
| 941 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 942 | dst.x = src0.x << src1.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 943 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 944 | dst.y = src0.y << src1.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 945 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 946 | dst.z = src0.z << src1.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 947 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 948 | dst.w = src0.w << src1.x |
| 949 | |
| 950 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 951 | .. opcode:: SHR - Shift Right |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 952 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 953 | .. math:: |
| 954 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 955 | dst.x = src0.x >> src1.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 956 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 957 | dst.y = src0.y >> src1.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 958 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 959 | dst.z = src0.z >> src1.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 960 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 961 | dst.w = src0.w >> src1.x |
| 962 | |
| 963 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 964 | .. opcode:: AND - Bitwise And |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 965 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 966 | .. math:: |
| 967 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 968 | dst.x = src0.x & src1.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 969 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 970 | dst.y = src0.y & src1.y |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 971 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 972 | dst.z = src0.z & src1.z |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 973 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 974 | dst.w = src0.w & src1.w |
| 975 | |
| 976 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 977 | .. opcode:: OR - Bitwise Or |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 978 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 979 | .. math:: |
| 980 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 981 | dst.x = src0.x | src1.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 982 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 983 | dst.y = src0.y | src1.y |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 984 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 985 | dst.z = src0.z | src1.z |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 986 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 987 | dst.w = src0.w | src1.w |
| 988 | |
| 989 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 990 | .. opcode:: MOD - Modulus |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 991 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 992 | .. math:: |
| 993 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 994 | dst.x = src0.x \bmod src1.x |
| 995 | |
| 996 | dst.y = src0.y \bmod src1.y |
| 997 | |
| 998 | dst.z = src0.z \bmod src1.z |
| 999 | |
| 1000 | dst.w = src0.w \bmod src1.w |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1001 | |
| 1002 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1003 | .. opcode:: XOR - Bitwise Xor |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1004 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 1005 | .. math:: |
| 1006 | |
Corbin Simpson | f90733c | 2010-01-18 17:37:25 -0800 | [diff] [blame] | 1007 | dst.x = src0.x \oplus src1.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1008 | |
Corbin Simpson | f90733c | 2010-01-18 17:37:25 -0800 | [diff] [blame] | 1009 | dst.y = src0.y \oplus src1.y |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1010 | |
Corbin Simpson | f90733c | 2010-01-18 17:37:25 -0800 | [diff] [blame] | 1011 | dst.z = src0.z \oplus src1.z |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1012 | |
Corbin Simpson | f90733c | 2010-01-18 17:37:25 -0800 | [diff] [blame] | 1013 | dst.w = src0.w \oplus src1.w |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1014 | |
| 1015 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1016 | .. opcode:: SAD - Sum Of Absolute Differences |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1017 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 1018 | .. math:: |
| 1019 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 1020 | dst.x = |src0.x - src1.x| + src2.x |
| 1021 | |
| 1022 | dst.y = |src0.y - src1.y| + src2.y |
| 1023 | |
| 1024 | dst.z = |src0.z - src1.z| + src2.z |
| 1025 | |
| 1026 | dst.w = |src0.w - src1.w| + src2.w |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1027 | |
| 1028 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1029 | .. opcode:: TXF - Texel Fetch |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1030 | |
| 1031 | TBD |
| 1032 | |
| 1033 | |
Dave Airlie | 6fb12bf | 2011-08-25 13:03:19 +0100 | [diff] [blame^] | 1034 | .. opcode:: TXQ - Texture Size Query (as per NV_gpu_program4) |
| 1035 | retrieve the dimensions of the texture |
| 1036 | depending on the target. For 1D (width), 2D/RECT/CUBE |
| 1037 | (width, height), 3D (width, height, depth), |
| 1038 | 1D array (width, layers), 2D array (width, height, layers) |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1039 | |
Dave Airlie | 6fb12bf | 2011-08-25 13:03:19 +0100 | [diff] [blame^] | 1040 | .. math:: |
| 1041 | |
| 1042 | lod = src0 |
| 1043 | |
| 1044 | dst.x = texture_width(unit, lod) |
| 1045 | |
| 1046 | dst.y = texture_height(unit, lod) |
| 1047 | |
| 1048 | dst.z = texture_depth(unit, lod) |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1049 | |
| 1050 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1051 | .. opcode:: CONT - Continue |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1052 | |
| 1053 | TBD |
| 1054 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 1055 | .. note:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1056 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 1057 | Support for CONT is determined by a special capability bit, |
| 1058 | ``TGSI_CONT_SUPPORTED``. See :ref:`Screen` for more information. |
| 1059 | |
| 1060 | |
| 1061 | Geometry ISA |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 1062 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1063 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 1064 | These opcodes are only supported in geometry shaders; they have no meaning |
| 1065 | in any other type of shader. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1066 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1067 | .. opcode:: EMIT - Emit |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1068 | |
| 1069 | TBD |
| 1070 | |
| 1071 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1072 | .. opcode:: ENDPRIM - End Primitive |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1073 | |
| 1074 | TBD |
| 1075 | |
| 1076 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 1077 | GLSL ISA |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 1078 | ^^^^^^^^^^ |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1079 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 1080 | These opcodes are part of :term:`GLSL`'s opcode set. Support for these |
| 1081 | opcodes is determined by a special capability bit, ``GLSL``. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1082 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1083 | .. opcode:: BGNLOOP - Begin a Loop |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1084 | |
| 1085 | TBD |
| 1086 | |
| 1087 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1088 | .. opcode:: BGNSUB - Begin Subroutine |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1089 | |
| 1090 | TBD |
| 1091 | |
| 1092 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1093 | .. opcode:: ENDLOOP - End a Loop |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1094 | |
| 1095 | TBD |
| 1096 | |
| 1097 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1098 | .. opcode:: ENDSUB - End Subroutine |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1099 | |
| 1100 | TBD |
| 1101 | |
| 1102 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1103 | .. opcode:: NOP - No Operation |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1104 | |
Michal Krol | 8ab89d7 | 2010-01-04 13:23:41 +0100 | [diff] [blame] | 1105 | Do nothing. |
| 1106 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1107 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1108 | .. opcode:: NRM4 - 4-component Vector Normalise |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1109 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 1110 | This instruction replicates its result. |
| 1111 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 1112 | .. math:: |
| 1113 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 1114 | dst = \frac{src.x}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w} |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1115 | |
| 1116 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1117 | ps_2_x |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 1118 | ^^^^^^^^^^^^ |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1119 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 1120 | XXX wait what |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1121 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1122 | .. opcode:: CALLNZ - Subroutine Call If Not Zero |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1123 | |
| 1124 | TBD |
| 1125 | |
| 1126 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1127 | .. opcode:: IFC - If |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1128 | |
| 1129 | TBD |
| 1130 | |
| 1131 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1132 | .. opcode:: BREAKC - Break Conditional |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1133 | |
| 1134 | TBD |
| 1135 | |
Corbin Simpson | 62ca7b8 | 2010-02-02 16:36:34 -0800 | [diff] [blame] | 1136 | .. _doubleopcodes: |
| 1137 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 1138 | Double ISA |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1139 | ^^^^^^^^^^^^^^^ |
| 1140 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1141 | The double-precision opcodes reinterpret four-component vectors into |
| 1142 | two-component vectors with doubled precision in each component. |
| 1143 | |
| 1144 | Support for these opcodes is XXX undecided. :T |
| 1145 | |
| 1146 | .. opcode:: DADD - Add |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1147 | |
| 1148 | .. math:: |
| 1149 | |
| 1150 | dst.xy = src0.xy + src1.xy |
| 1151 | |
| 1152 | dst.zw = src0.zw + src1.zw |
| 1153 | |
| 1154 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1155 | .. opcode:: DDIV - Divide |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1156 | |
| 1157 | .. math:: |
| 1158 | |
| 1159 | dst.xy = src0.xy / src1.xy |
| 1160 | |
| 1161 | dst.zw = src0.zw / src1.zw |
| 1162 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1163 | .. opcode:: DSEQ - Set on Equal |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1164 | |
| 1165 | .. math:: |
| 1166 | |
| 1167 | dst.xy = src0.xy == src1.xy ? 1.0F : 0.0F |
| 1168 | |
| 1169 | dst.zw = src0.zw == src1.zw ? 1.0F : 0.0F |
| 1170 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1171 | .. opcode:: DSLT - Set on Less than |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1172 | |
| 1173 | .. math:: |
| 1174 | |
| 1175 | dst.xy = src0.xy < src1.xy ? 1.0F : 0.0F |
| 1176 | |
| 1177 | dst.zw = src0.zw < src1.zw ? 1.0F : 0.0F |
| 1178 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1179 | .. opcode:: DFRAC - Fraction |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1180 | |
| 1181 | .. math:: |
| 1182 | |
| 1183 | dst.xy = src.xy - \lfloor src.xy\rfloor |
| 1184 | |
| 1185 | dst.zw = src.zw - \lfloor src.zw\rfloor |
| 1186 | |
| 1187 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1188 | .. opcode:: DFRACEXP - Convert Number to Fractional and Integral Components |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1189 | |
Corbin Simpson | f98c462 | 2010-06-16 18:45:50 -0700 | [diff] [blame] | 1190 | Like the ``frexp()`` routine in many math libraries, this opcode stores the |
| 1191 | exponent of its source to ``dst0``, and the significand to ``dst1``, such that |
| 1192 | :math:`dst1 \times 2^{dst0} = src` . |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1193 | |
| 1194 | .. math:: |
| 1195 | |
Corbin Simpson | f98c462 | 2010-06-16 18:45:50 -0700 | [diff] [blame] | 1196 | dst0.xy = exp(src.xy) |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1197 | |
Corbin Simpson | f98c462 | 2010-06-16 18:45:50 -0700 | [diff] [blame] | 1198 | dst1.xy = frac(src.xy) |
| 1199 | |
| 1200 | dst0.zw = exp(src.zw) |
| 1201 | |
| 1202 | dst1.zw = frac(src.zw) |
| 1203 | |
| 1204 | .. opcode:: DLDEXP - Multiply Number by Integral Power of 2 |
| 1205 | |
| 1206 | This opcode is the inverse of :opcode:`DFRACEXP`. |
| 1207 | |
| 1208 | .. math:: |
| 1209 | |
| 1210 | dst.xy = src0.xy \times 2^{src1.xy} |
| 1211 | |
| 1212 | dst.zw = src0.zw \times 2^{src1.zw} |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1213 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1214 | .. opcode:: DMIN - Minimum |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1215 | |
| 1216 | .. math:: |
| 1217 | |
| 1218 | dst.xy = min(src0.xy, src1.xy) |
| 1219 | |
| 1220 | dst.zw = min(src0.zw, src1.zw) |
| 1221 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1222 | .. opcode:: DMAX - Maximum |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1223 | |
| 1224 | .. math:: |
| 1225 | |
| 1226 | dst.xy = max(src0.xy, src1.xy) |
| 1227 | |
| 1228 | dst.zw = max(src0.zw, src1.zw) |
| 1229 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1230 | .. opcode:: DMUL - Multiply |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1231 | |
| 1232 | .. math:: |
| 1233 | |
| 1234 | dst.xy = src0.xy \times src1.xy |
| 1235 | |
| 1236 | dst.zw = src0.zw \times src1.zw |
| 1237 | |
| 1238 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1239 | .. opcode:: DMAD - Multiply And Add |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1240 | |
| 1241 | .. math:: |
| 1242 | |
| 1243 | dst.xy = src0.xy \times src1.xy + src2.xy |
| 1244 | |
| 1245 | dst.zw = src0.zw \times src1.zw + src2.zw |
| 1246 | |
| 1247 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1248 | .. opcode:: DRCP - Reciprocal |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1249 | |
| 1250 | .. math:: |
| 1251 | |
| 1252 | dst.xy = \frac{1}{src.xy} |
| 1253 | |
| 1254 | dst.zw = \frac{1}{src.zw} |
| 1255 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1256 | .. opcode:: DSQRT - Square Root |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1257 | |
| 1258 | .. math:: |
| 1259 | |
| 1260 | dst.xy = \sqrt{src.xy} |
| 1261 | |
| 1262 | dst.zw = \sqrt{src.zw} |
| 1263 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1264 | |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1265 | .. _resourceopcodes: |
| 1266 | |
| 1267 | Resource Access Opcodes |
| 1268 | ^^^^^^^^^^^^^^^^^^^^^^^^ |
| 1269 | |
| 1270 | Those opcodes follow very closely semantics of the respective Direct3D |
| 1271 | instructions. If in doubt double check Direct3D documentation. |
| 1272 | |
| 1273 | .. opcode:: LOAD - Simplified alternative to the "SAMPLE" instruction. |
| 1274 | Using the provided integer address, LOAD fetches data |
| 1275 | from the specified buffer/texture without any filtering. |
| 1276 | The source data may come from any resource type other |
| 1277 | than CUBE. |
| 1278 | LOAD dst, address, resource |
| 1279 | e.g. |
| 1280 | LOAD TEMP[0], TEMP[1], RES[0] |
Zack Rusin | 3fa814d | 2011-01-24 21:45:37 -0500 | [diff] [blame] | 1281 | The 'address' is specified as unsigned integers. If the |
| 1282 | 'address' is out of range [0...(# texels - 1)] the |
| 1283 | result of the fetch is always 0 in all components. |
| 1284 | As such the instruction doesn't honor address wrap |
| 1285 | modes, in cases where that behavior is desirable |
| 1286 | 'sample' instruction should be used. |
| 1287 | address.w always provides an unsigned integer mipmap |
| 1288 | level. If the value is out of the range then the |
| 1289 | instruction always returns 0 in all components. |
| 1290 | address.yz are ignored for buffers and 1d textures. |
| 1291 | address.z is ignored for 1d texture arrays and 2d |
| 1292 | textures. |
| 1293 | For 1D texture arrays address.y provides the array |
| 1294 | index (also as unsigned integer). If the value is |
| 1295 | out of the range of available array indices |
| 1296 | [0... (array size - 1)] then the opcode always returns |
| 1297 | 0 in all components. |
| 1298 | For 2D texture arrays address.z provides the array |
| 1299 | index, otherwise it exhibits the same behavior as in |
| 1300 | the case for 1D texture arrays. |
| 1301 | The exeact semantics of the source address are presented |
| 1302 | in the table below: |
| 1303 | resource type X Y Z W |
| 1304 | ------------- ------------------------ |
| 1305 | PIPE_BUFFER x ignored |
| 1306 | PIPE_TEXTURE_1D x mpl |
| 1307 | PIPE_TEXTURE_2D x y mpl |
| 1308 | PIPE_TEXTURE_3D x y z mpl |
| 1309 | PIPE_TEXTURE_RECT x y mpl |
| 1310 | PIPE_TEXTURE_CUBE not allowed as source |
| 1311 | PIPE_TEXTURE_1D_ARRAY x idx mpl |
| 1312 | PIPE_TEXTURE_2D_ARRAY x y idx mpl |
| 1313 | |
| 1314 | Where 'mpl' is a mipmap level and 'idx' is the |
| 1315 | array index. |
| 1316 | |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1317 | |
| 1318 | .. opcode:: LOAD_MS - Just like LOAD but allows fetch data from |
| 1319 | multi-sampled surfaces. |
| 1320 | |
| 1321 | .. opcode:: SAMPLE - Using provided address, sample data from the |
| 1322 | specified texture using the filtering mode identified |
| 1323 | by the gven sampler. The source data may come from |
| 1324 | any resource type other than buffers. |
| 1325 | SAMPLE dst, address, resource, sampler |
| 1326 | e.g. |
| 1327 | SAMPLE TEMP[0], TEMP[1], RES[0], SAMP[0] |
| 1328 | |
| 1329 | .. opcode:: SAMPLE_B - Just like the SAMPLE instruction with the |
| 1330 | exception that an additiona bias is applied to the |
| 1331 | level of detail computed as part of the instruction |
| 1332 | execution. |
| 1333 | SAMPLE_B dst, address, resource, sampler, lod_bias |
| 1334 | e.g. |
| 1335 | SAMPLE_B TEMP[0], TEMP[1], RES[0], SAMP[0], TEMP[2].x |
| 1336 | |
Zack Rusin | 3fa814d | 2011-01-24 21:45:37 -0500 | [diff] [blame] | 1337 | .. opcode:: SAMPLE_C - Similar to the SAMPLE instruction but it |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1338 | performs a comparison filter. The operands to SAMPLE_C |
| 1339 | are identical to SAMPLE, except that tere is an additional |
| 1340 | float32 operand, reference value, which must be a register |
| 1341 | with single-component, or a scalar literal. |
| 1342 | SAMPLE_C makes the hardware use the current samplers |
| 1343 | compare_func (in pipe_sampler_state) to compare |
| 1344 | reference value against the red component value for the |
| 1345 | surce resource at each texel that the currently configured |
| 1346 | texture filter covers based on the provided coordinates. |
| 1347 | SAMPLE_C dst, address, resource.r, sampler, ref_value |
| 1348 | e.g. |
| 1349 | SAMPLE_C TEMP[0], TEMP[1], RES[0].r, SAMP[0], TEMP[2].x |
| 1350 | |
| 1351 | .. opcode:: SAMPLE_C_LZ - Same as SAMPLE_C, but LOD is 0 and derivatives |
| 1352 | are ignored. The LZ stands for level-zero. |
| 1353 | SAMPLE_C_LZ dst, address, resource.r, sampler, ref_value |
| 1354 | e.g. |
| 1355 | SAMPLE_C_LZ TEMP[0], TEMP[1], RES[0].r, SAMP[0], TEMP[2].x |
| 1356 | |
| 1357 | |
| 1358 | .. opcode:: SAMPLE_D - SAMPLE_D is identical to the SAMPLE opcode except |
| 1359 | that the derivatives for the source address in the x |
| 1360 | direction and the y direction are provided by extra |
| 1361 | parameters. |
| 1362 | SAMPLE_D dst, address, resource, sampler, der_x, der_y |
| 1363 | e.g. |
| 1364 | SAMPLE_D TEMP[0], TEMP[1], RES[0], SAMP[0], TEMP[2], TEMP[3] |
| 1365 | |
| 1366 | .. opcode:: SAMPLE_L - SAMPLE_L is identical to the SAMPLE opcode except |
| 1367 | that the LOD is provided directly as a scalar value, |
| 1368 | representing no anisotropy. Source addresses A channel |
| 1369 | is used as the LOD. |
| 1370 | SAMPLE_L dst, address, resource, sampler |
| 1371 | e.g. |
| 1372 | SAMPLE_L TEMP[0], TEMP[1], RES[0], SAMP[0] |
| 1373 | |
| 1374 | |
| 1375 | .. opcode:: GATHER4 - Gathers the four texels to be used in a bi-linear |
| 1376 | filtering operation and packs them into a single register. |
| 1377 | Only woth with 2D, 2D array, cubemaps, and cubemaps arrays. |
| 1378 | For 2D textures, only the addressing modes of the sampler and |
| 1379 | the top level of any mip pyramid are used. Set W to zero. |
| 1380 | It behaves like the SAMPLE instruction, but a filtered |
| 1381 | sample is not generated. The four samples that contribute |
| 1382 | to filtering are places into xyzw in cunter-clockwise order, |
| 1383 | starting with the (u,v) texture coordinate delta at the |
| 1384 | following locations (-, +), (+, +), (+, -), (-, -), where |
| 1385 | the magnitude of the deltas are half a texel. |
| 1386 | |
| 1387 | |
Zack Rusin | 3fa814d | 2011-01-24 21:45:37 -0500 | [diff] [blame] | 1388 | .. opcode:: RESINFO - query the dimensions of a given input buffer. |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1389 | dst receives width, height, depth or array size and |
Zack Rusin | 3fa814d | 2011-01-24 21:45:37 -0500 | [diff] [blame] | 1390 | number of mipmap levels. The dst can have a writemask |
| 1391 | which will specify what info is the caller interested |
| 1392 | in. |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1393 | RESINFO dst, src_mip_level, resource |
| 1394 | e.g. |
| 1395 | RESINFO TEMP[0], TEMP[1].x, RES[0] |
Zack Rusin | 3fa814d | 2011-01-24 21:45:37 -0500 | [diff] [blame] | 1396 | src_mip_level is an unsigned integer scalar. If it's |
| 1397 | out of range then returns 0 for width, height and |
| 1398 | depth/array size but the total number of mipmap is |
| 1399 | still returned correctly for the given resource. |
| 1400 | The returned width, height and depth values are for |
| 1401 | the mipmap level selected by the src_mip_level and |
| 1402 | are in the number of texels. |
| 1403 | For 1d texture array width is in dst.x, array size |
| 1404 | is in dst.y and dst.zw are always 0. |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1405 | |
| 1406 | .. opcode:: SAMPLE_POS - query the position of a given sample. |
| 1407 | dst receives float4 (x, y, 0, 0) indicated where the |
| 1408 | sample is located. If the resource is not a multi-sample |
| 1409 | resource and not a render target, the result is 0. |
| 1410 | |
Zack Rusin | 3fa814d | 2011-01-24 21:45:37 -0500 | [diff] [blame] | 1411 | .. opcode:: SAMPLE_INFO - dst receives number of samples in x. |
| 1412 | If the resource is not a multi-sample resource and |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1413 | not a render target, the result is 0. |
| 1414 | |
| 1415 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1416 | Explanation of symbols used |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 1417 | ------------------------------ |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1418 | |
| 1419 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1420 | Functions |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 1421 | ^^^^^^^^^^^^^^ |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1422 | |
| 1423 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 1424 | :math:`|x|` Absolute value of `x`. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1425 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 1426 | :math:`\lceil x \rceil` Ceiling of `x`. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1427 | |
| 1428 | clamp(x,y,z) Clamp x between y and z. |
| 1429 | (x < y) ? y : (x > z) ? z : x |
| 1430 | |
Corbin Simpson | dd801e5 | 2009-12-21 19:41:09 -0800 | [diff] [blame] | 1431 | :math:`\lfloor x\rfloor` Floor of `x`. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1432 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 1433 | :math:`\log_2{x}` Logarithm of `x`, base 2. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1434 | |
| 1435 | max(x,y) Maximum of x and y. |
| 1436 | (x > y) ? x : y |
| 1437 | |
| 1438 | min(x,y) Minimum of x and y. |
| 1439 | (x < y) ? x : y |
| 1440 | |
| 1441 | partialx(x) Derivative of x relative to fragment's X. |
| 1442 | |
| 1443 | partialy(x) Derivative of x relative to fragment's Y. |
| 1444 | |
| 1445 | pop() Pop from stack. |
| 1446 | |
Corbin Simpson | dd801e5 | 2009-12-21 19:41:09 -0800 | [diff] [blame] | 1447 | :math:`x^y` `x` to the power `y`. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1448 | |
| 1449 | push(x) Push x on stack. |
| 1450 | |
| 1451 | round(x) Round x. |
| 1452 | |
Michal Krol | 07f416c | 2010-01-04 13:21:32 +0100 | [diff] [blame] | 1453 | trunc(x) Truncate x, i.e. drop the fraction bits. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1454 | |
| 1455 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1456 | Keywords |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 1457 | ^^^^^^^^^^^^^ |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1458 | |
| 1459 | |
| 1460 | discard Discard fragment. |
| 1461 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1462 | pc Program counter. |
| 1463 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1464 | target Label of target instruction. |
| 1465 | |
| 1466 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1467 | Other tokens |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 1468 | --------------- |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1469 | |
| 1470 | |
Michal Krol | 63d6097 | 2010-02-03 15:45:32 +0100 | [diff] [blame] | 1471 | Declaration |
| 1472 | ^^^^^^^^^^^ |
| 1473 | |
| 1474 | |
| 1475 | Declares a register that is will be referenced as an operand in Instruction |
| 1476 | tokens. |
| 1477 | |
| 1478 | File field contains register file that is being declared and is one |
| 1479 | of TGSI_FILE. |
| 1480 | |
| 1481 | UsageMask field specifies which of the register components can be accessed |
| 1482 | and is one of TGSI_WRITEMASK. |
| 1483 | |
| 1484 | Interpolate field is only valid for fragment shader INPUT register files. |
| 1485 | It specifes the way input is being interpolated by the rasteriser and is one |
| 1486 | of TGSI_INTERPOLATE. |
| 1487 | |
| 1488 | If Dimension flag is set to 1, a Declaration Dimension token follows. |
| 1489 | |
| 1490 | If Semantic flag is set to 1, a Declaration Semantic token follows. |
| 1491 | |
| 1492 | CylindricalWrap bitfield is only valid for fragment shader INPUT register |
| 1493 | files. It specifies which register components should be subject to cylindrical |
| 1494 | wrapping when interpolating by the rasteriser. If TGSI_CYLINDRICAL_WRAP_X |
| 1495 | is set to 1, the X component should be interpolated according to cylindrical |
| 1496 | wrapping rules. |
| 1497 | |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1498 | If file is TGSI_FILE_RESOURCE, a Declaration Resource token follows. |
| 1499 | |
Michal Krol | 63d6097 | 2010-02-03 15:45:32 +0100 | [diff] [blame] | 1500 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1501 | Declaration Semantic |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 1502 | ^^^^^^^^^^^^^^^^^^^^^^^^ |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1503 | |
Brian Paul | 05a18f4 | 2010-06-24 07:21:15 -0600 | [diff] [blame] | 1504 | Vertex and fragment shader input and output registers may be labeled |
| 1505 | with semantic information consisting of a name and index. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1506 | |
| 1507 | Follows Declaration token if Semantic bit is set. |
| 1508 | |
| 1509 | Since its purpose is to link a shader with other stages of the pipeline, |
| 1510 | it is valid to follow only those Declaration tokens that declare a register |
| 1511 | either in INPUT or OUTPUT file. |
| 1512 | |
| 1513 | SemanticName field contains the semantic name of the register being declared. |
| 1514 | There is no default value. |
| 1515 | |
| 1516 | SemanticIndex is an optional subscript that can be used to distinguish |
| 1517 | different register declarations with the same semantic name. The default value |
| 1518 | is 0. |
| 1519 | |
| 1520 | The meanings of the individual semantic names are explained in the following |
| 1521 | sections. |
| 1522 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1523 | TGSI_SEMANTIC_POSITION |
| 1524 | """""""""""""""""""""" |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1525 | |
Brian Paul | 50b3f2e | 2010-06-23 17:00:10 -0600 | [diff] [blame] | 1526 | For vertex shaders, TGSI_SEMANTIC_POSITION indicates the vertex shader |
| 1527 | output register which contains the homogeneous vertex position in the clip |
| 1528 | space coordinate system. After clipping, the X, Y and Z components of the |
| 1529 | vertex will be divided by the W value to get normalized device coordinates. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1530 | |
Brian Paul | 50b3f2e | 2010-06-23 17:00:10 -0600 | [diff] [blame] | 1531 | For fragment shaders, TGSI_SEMANTIC_POSITION is used to indicate that |
| 1532 | fragment shader input contains the fragment's window position. The X |
| 1533 | component starts at zero and always increases from left to right. |
| 1534 | The Y component starts at zero and always increases but Y=0 may either |
| 1535 | indicate the top of the window or the bottom depending on the fragment |
| 1536 | coordinate origin convention (see TGSI_PROPERTY_FS_COORD_ORIGIN). |
| 1537 | The Z coordinate ranges from 0 to 1 to represent depth from the front |
| 1538 | to the back of the Z buffer. The W component contains the reciprocol |
| 1539 | of the interpolated vertex position W component. |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1540 | |
Brian Paul | 05a18f4 | 2010-06-24 07:21:15 -0600 | [diff] [blame] | 1541 | Fragment shaders may also declare an output register with |
| 1542 | TGSI_SEMANTIC_POSITION. Only the Z component is writable. This allows |
| 1543 | the fragment shader to change the fragment's Z position. |
| 1544 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1545 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1546 | |
| 1547 | TGSI_SEMANTIC_COLOR |
| 1548 | """"""""""""""""""" |
| 1549 | |
Brian Paul | 50b3f2e | 2010-06-23 17:00:10 -0600 | [diff] [blame] | 1550 | For vertex shader outputs or fragment shader inputs/outputs, this |
| 1551 | label indicates that the resister contains an R,G,B,A color. |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1552 | |
Brian Paul | 50b3f2e | 2010-06-23 17:00:10 -0600 | [diff] [blame] | 1553 | Several shader inputs/outputs may contain colors so the semantic index |
| 1554 | is used to distinguish them. For example, color[0] may be the diffuse |
| 1555 | color while color[1] may be the specular color. |
| 1556 | |
| 1557 | This label is needed so that the flat/smooth shading can be applied |
| 1558 | to the right interpolants during rasterization. |
| 1559 | |
| 1560 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1561 | |
| 1562 | TGSI_SEMANTIC_BCOLOR |
| 1563 | """""""""""""""""""" |
| 1564 | |
| 1565 | Back-facing colors are only used for back-facing polygons, and are only valid |
| 1566 | in vertex shader outputs. After rasterization, all polygons are front-facing |
Brian Paul | 50b3f2e | 2010-06-23 17:00:10 -0600 | [diff] [blame] | 1567 | and COLOR and BCOLOR end up occupying the same slots in the fragment shader, |
| 1568 | so all BCOLORs effectively become regular COLORs in the fragment shader. |
| 1569 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1570 | |
| 1571 | TGSI_SEMANTIC_FOG |
| 1572 | """"""""""""""""" |
| 1573 | |
Brian Paul | 05a18f4 | 2010-06-24 07:21:15 -0600 | [diff] [blame] | 1574 | Vertex shader inputs and outputs and fragment shader inputs may be |
| 1575 | labeled with TGSI_SEMANTIC_FOG to indicate that the register contains |
| 1576 | a fog coordinate in the form (F, 0, 0, 1). Typically, the fragment |
| 1577 | shader will use the fog coordinate to compute a fog blend factor which |
| 1578 | is used to blend the normal fragment color with a constant fog color. |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1579 | |
Brian Paul | 05a18f4 | 2010-06-24 07:21:15 -0600 | [diff] [blame] | 1580 | Only the first component matters when writing from the vertex shader; |
| 1581 | the driver will ensure that the coordinate is in this format when used |
| 1582 | as a fragment shader input. |
| 1583 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1584 | |
| 1585 | TGSI_SEMANTIC_PSIZE |
| 1586 | """"""""""""""""""" |
| 1587 | |
Brian Paul | 05a18f4 | 2010-06-24 07:21:15 -0600 | [diff] [blame] | 1588 | Vertex shader input and output registers may be labeled with |
| 1589 | TGIS_SEMANTIC_PSIZE to indicate that the register contains a point size |
| 1590 | in the form (S, 0, 0, 1). The point size controls the width or diameter |
| 1591 | of points for rasterization. This label cannot be used in fragment |
| 1592 | shaders. |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1593 | |
| 1594 | When using this semantic, be sure to set the appropriate state in the |
| 1595 | :ref:`rasterizer` first. |
| 1596 | |
Brian Paul | 05a18f4 | 2010-06-24 07:21:15 -0600 | [diff] [blame] | 1597 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1598 | TGSI_SEMANTIC_GENERIC |
| 1599 | """"""""""""""""""""" |
| 1600 | |
Brian Paul | 05a18f4 | 2010-06-24 07:21:15 -0600 | [diff] [blame] | 1601 | All vertex/fragment shader inputs/outputs not labeled with any other |
| 1602 | semantic label can be considered to be generic attributes. Typical |
| 1603 | uses of generic inputs/outputs are texcoords and user-defined values. |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1604 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1605 | |
| 1606 | TGSI_SEMANTIC_NORMAL |
| 1607 | """""""""""""""""""" |
| 1608 | |
Brian Paul | 05a18f4 | 2010-06-24 07:21:15 -0600 | [diff] [blame] | 1609 | Indicates that a vertex shader input is a normal vector. This is |
| 1610 | typically only used for legacy graphics APIs. |
| 1611 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1612 | |
| 1613 | TGSI_SEMANTIC_FACE |
| 1614 | """""""""""""""""" |
| 1615 | |
Brian Paul | 05a18f4 | 2010-06-24 07:21:15 -0600 | [diff] [blame] | 1616 | This label applies to fragment shader inputs only and indicates that |
| 1617 | the register contains front/back-face information of the form (F, 0, |
| 1618 | 0, 1). The first component will be positive when the fragment belongs |
| 1619 | to a front-facing polygon, and negative when the fragment belongs to a |
| 1620 | back-facing polygon. |
| 1621 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1622 | |
| 1623 | TGSI_SEMANTIC_EDGEFLAG |
| 1624 | """""""""""""""""""""" |
| 1625 | |
Brian Paul | 7315300 | 2010-06-23 17:38:58 -0600 | [diff] [blame] | 1626 | For vertex shaders, this sematic label indicates that an input or |
| 1627 | output is a boolean edge flag. The register layout is [F, x, x, x] |
| 1628 | where F is 0.0 or 1.0 and x = don't care. Normally, the vertex shader |
| 1629 | simply copies the edge flag input to the edgeflag output. |
| 1630 | |
| 1631 | Edge flags are used to control which lines or points are actually |
| 1632 | drawn when the polygon mode converts triangles/quads/polygons into |
| 1633 | points or lines. |
| 1634 | |
Dave Airlie | 4ecb2c1 | 2010-10-06 09:28:46 +1000 | [diff] [blame] | 1635 | TGSI_SEMANTIC_STENCIL |
| 1636 | """""""""""""""""""""" |
| 1637 | |
| 1638 | For fragment shaders, this semantic label indicates than an output |
| 1639 | is a writable stencil reference value. Only the Y component is writable. |
| 1640 | This allows the fragment shader to change the fragments stencilref value. |
Luca Barbieri | 7331713 | 2010-01-21 05:36:14 +0100 | [diff] [blame] | 1641 | |
| 1642 | |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1643 | Declaration Resource |
| 1644 | ^^^^^^^^^^^^^^^^^^^^^^^^ |
| 1645 | |
| 1646 | Follows Declaration token if file is TGSI_FILE_RESOURCE. |
| 1647 | |
| 1648 | DCL RES[#], resource, type(s) |
| 1649 | |
| 1650 | Declares a shader input resource and assigns it to a RES[#] |
| 1651 | register. |
| 1652 | |
| 1653 | resource can be one of BUFFER, 1D, 2D, 3D, CUBE, 1DArray and |
| 1654 | 2DArray. |
| 1655 | |
| 1656 | type must be 1 or 4 entries (if specifying on a per-component |
| 1657 | level) out of UNORM, SNORM, SINT, UINT and FLOAT. |
| 1658 | |
| 1659 | |
Luca Barbieri | 7331713 | 2010-01-21 05:36:14 +0100 | [diff] [blame] | 1660 | Properties |
| 1661 | ^^^^^^^^^^^^^^^^^^^^^^^^ |
| 1662 | |
| 1663 | |
| 1664 | Properties are general directives that apply to the whole TGSI program. |
| 1665 | |
| 1666 | FS_COORD_ORIGIN |
| 1667 | """"""""""""""" |
| 1668 | |
| 1669 | Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin. |
| 1670 | The default value is UPPER_LEFT. |
| 1671 | |
| 1672 | If UPPER_LEFT, the position will be (0,0) at the upper left corner and |
| 1673 | increase downward and rightward. |
| 1674 | If LOWER_LEFT, the position will be (0,0) at the lower left corner and |
| 1675 | increase upward and rightward. |
| 1676 | |
| 1677 | OpenGL defaults to LOWER_LEFT, and is configurable with the |
| 1678 | GL_ARB_fragment_coord_conventions extension. |
| 1679 | |
| 1680 | DirectX 9/10 use UPPER_LEFT. |
| 1681 | |
| 1682 | FS_COORD_PIXEL_CENTER |
| 1683 | """"""""""""""""""""" |
| 1684 | |
| 1685 | Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention. |
| 1686 | The default value is HALF_INTEGER. |
| 1687 | |
| 1688 | If HALF_INTEGER, the fractionary part of the position will be 0.5 |
| 1689 | If INTEGER, the fractionary part of the position will be 0.0 |
| 1690 | |
| 1691 | Note that this does not affect the set of fragments generated by |
| 1692 | rasterization, which is instead controlled by gl_rasterization_rules in the |
| 1693 | rasterizer. |
| 1694 | |
| 1695 | OpenGL defaults to HALF_INTEGER, and is configurable with the |
| 1696 | GL_ARB_fragment_coord_conventions extension. |
| 1697 | |
| 1698 | DirectX 9 uses INTEGER. |
| 1699 | DirectX 10 uses HALF_INTEGER. |
Brian Paul | 4778f46 | 2010-02-02 08:14:40 -0700 | [diff] [blame] | 1700 | |
Dave Airlie | c9c8a5e | 2010-12-18 10:34:35 +1000 | [diff] [blame] | 1701 | FS_COLOR0_WRITES_ALL_CBUFS |
| 1702 | """""""""""""""""""""""""" |
| 1703 | Specifies that writes to the fragment shader color 0 are replicated to all |
| 1704 | bound cbufs. This facilitates OpenGL's fragColor output vs fragData[0] where |
| 1705 | fragData is directed to a single color buffer, but fragColor is broadcast. |
Brian Paul | 4778f46 | 2010-02-02 08:14:40 -0700 | [diff] [blame] | 1706 | |
| 1707 | |
| 1708 | Texture Sampling and Texture Formats |
| 1709 | ------------------------------------ |
| 1710 | |
Corbin Simpson | 797dcc0 | 2010-02-02 17:07:26 -0800 | [diff] [blame] | 1711 | This table shows how texture image components are returned as (x,y,z,w) tuples |
| 1712 | by TGSI texture instructions, such as :opcode:`TEX`, :opcode:`TXD`, and |
| 1713 | :opcode:`TXP`. For reference, OpenGL and Direct3D conventions are shown as |
| 1714 | well. |
Brian Paul | 4778f46 | 2010-02-02 08:14:40 -0700 | [diff] [blame] | 1715 | |
Corbin Simpson | 516e715 | 2010-02-02 12:44:22 -0800 | [diff] [blame] | 1716 | +--------------------+--------------+--------------------+--------------+ |
| 1717 | | Texture Components | Gallium | OpenGL | Direct3D 9 | |
| 1718 | +====================+==============+====================+==============+ |
Corbin Simpson | 92867dc | 2010-06-16 16:56:55 -0700 | [diff] [blame] | 1719 | | R | (r, 0, 0, 1) | (r, 0, 0, 1) | (r, 1, 1, 1) | |
Corbin Simpson | 516e715 | 2010-02-02 12:44:22 -0800 | [diff] [blame] | 1720 | +--------------------+--------------+--------------------+--------------+ |
Corbin Simpson | 92867dc | 2010-06-16 16:56:55 -0700 | [diff] [blame] | 1721 | | RG | (r, g, 0, 1) | (r, g, 0, 1) | (r, g, 1, 1) | |
Corbin Simpson | 516e715 | 2010-02-02 12:44:22 -0800 | [diff] [blame] | 1722 | +--------------------+--------------+--------------------+--------------+ |
| 1723 | | RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) | |
| 1724 | +--------------------+--------------+--------------------+--------------+ |
| 1725 | | RGBA | (r, g, b, a) | (r, g, b, a) | (r, g, b, a) | |
| 1726 | +--------------------+--------------+--------------------+--------------+ |
| 1727 | | A | (0, 0, 0, a) | (0, 0, 0, a) | (0, 0, 0, a) | |
| 1728 | +--------------------+--------------+--------------------+--------------+ |
| 1729 | | L | (l, l, l, 1) | (l, l, l, 1) | (l, l, l, 1) | |
| 1730 | +--------------------+--------------+--------------------+--------------+ |
| 1731 | | LA | (l, l, l, a) | (l, l, l, a) | (l, l, l, a) | |
| 1732 | +--------------------+--------------+--------------------+--------------+ |
| 1733 | | I | (i, i, i, i) | (i, i, i, i) | N/A | |
| 1734 | +--------------------+--------------+--------------------+--------------+ |
| 1735 | | UV | XXX TBD | (0, 0, 0, 1) | (u, v, 1, 1) | |
| 1736 | | | | [#envmap-bumpmap]_ | | |
| 1737 | +--------------------+--------------+--------------------+--------------+ |
Brian Paul | 3e572eb | 2010-02-02 16:27:07 -0700 | [diff] [blame] | 1738 | | Z | XXX TBD | (z, z, z, 1) | (0, z, 0, 1) | |
Corbin Simpson | 516e715 | 2010-02-02 12:44:22 -0800 | [diff] [blame] | 1739 | | | | [#depth-tex-mode]_ | | |
| 1740 | +--------------------+--------------+--------------------+--------------+ |
Dave Airlie | 66a0d1e | 2010-10-06 09:30:17 +1000 | [diff] [blame] | 1741 | | S | (s, s, s, s) | unknown | unknown | |
| 1742 | +--------------------+--------------+--------------------+--------------+ |
Brian Paul | 4778f46 | 2010-02-02 08:14:40 -0700 | [diff] [blame] | 1743 | |
Corbin Simpson | 516e715 | 2010-02-02 12:44:22 -0800 | [diff] [blame] | 1744 | .. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt |
Brian Paul | 3e572eb | 2010-02-02 16:27:07 -0700 | [diff] [blame] | 1745 | .. [#depth-tex-mode] the default is (z, z, z, 1) but may also be (0, 0, 0, z) |
Corbin Simpson | 797dcc0 | 2010-02-02 17:07:26 -0800 | [diff] [blame] | 1746 | or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE. |