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 | |
Brian Paul | d276a40 | 2013-02-01 10:59:43 -0700 | [diff] [blame^] | 92 | .. opcode:: SQRT - Square Root |
| 93 | |
| 94 | This instruction replicates its result. |
| 95 | |
| 96 | .. math:: |
| 97 | |
| 98 | dst = {\sqrt{src.x}} |
| 99 | |
| 100 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 101 | .. opcode:: EXP - Approximate Exponential Base 2 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 102 | |
| 103 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 104 | |
Corbin Simpson | dd801e5 | 2009-12-21 19:41:09 -0800 | [diff] [blame] | 105 | dst.x = 2^{\lfloor src.x\rfloor} |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 106 | |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 107 | dst.y = src.x - \lfloor src.x\rfloor |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 108 | |
Corbin Simpson | dd801e5 | 2009-12-21 19:41:09 -0800 | [diff] [blame] | 109 | dst.z = 2^{src.x} |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 110 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 111 | dst.w = 1 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 112 | |
| 113 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 114 | .. opcode:: LOG - Approximate Logarithm Base 2 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 115 | |
| 116 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 117 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 118 | dst.x = \lfloor\log_2{|src.x|}\rfloor |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 119 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 120 | dst.y = \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}} |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 121 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 122 | dst.z = \log_2{|src.x|} |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 123 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 124 | dst.w = 1 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 125 | |
| 126 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 127 | .. opcode:: MUL - Multiply |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 128 | |
| 129 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 130 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 131 | dst.x = src0.x \times src1.x |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 132 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 133 | dst.y = src0.y \times src1.y |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 134 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 135 | dst.z = src0.z \times src1.z |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 136 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 137 | dst.w = src0.w \times src1.w |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 138 | |
| 139 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 140 | .. opcode:: ADD - Add |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 141 | |
| 142 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 143 | |
| 144 | dst.x = src0.x + src1.x |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 145 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 146 | dst.y = src0.y + src1.y |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 147 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 148 | dst.z = src0.z + src1.z |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 149 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 150 | dst.w = src0.w + src1.w |
| 151 | |
| 152 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 153 | .. opcode:: DP3 - 3-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 |
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:: DP4 - 4-component Dot Product |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 163 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 164 | This instruction replicates its result. |
| 165 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 166 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 167 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 168 | 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] | 169 | |
| 170 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 171 | .. opcode:: DST - Distance Vector |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 172 | |
| 173 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 174 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 175 | dst.x = 1 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 176 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 177 | dst.y = src0.y \times src1.y |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 178 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 179 | dst.z = src0.z |
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.w = src1.w |
| 182 | |
| 183 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 184 | .. opcode:: MIN - Minimum |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 185 | |
| 186 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 187 | |
| 188 | dst.x = min(src0.x, src1.x) |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 189 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 190 | dst.y = min(src0.y, src1.y) |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 191 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 192 | dst.z = min(src0.z, src1.z) |
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.w = min(src0.w, src1.w) |
| 195 | |
| 196 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 197 | .. opcode:: MAX - Maximum |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 198 | |
| 199 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 200 | |
| 201 | dst.x = max(src0.x, src1.x) |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 202 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 203 | dst.y = max(src0.y, src1.y) |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 204 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 205 | dst.z = max(src0.z, src1.z) |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 206 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 207 | dst.w = max(src0.w, src1.w) |
| 208 | |
| 209 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 210 | .. opcode:: SLT - Set On Less Than |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 211 | |
| 212 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 213 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 214 | dst.x = (src0.x < src1.x) ? 1 : 0 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 215 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 216 | dst.y = (src0.y < src1.y) ? 1 : 0 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 217 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 218 | dst.z = (src0.z < src1.z) ? 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.w = (src0.w < src1.w) ? 1 : 0 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 221 | |
| 222 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 223 | .. opcode:: SGE - Set On Greater Equal Than |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 224 | |
| 225 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 226 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 227 | dst.x = (src0.x >= src1.x) ? 1 : 0 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 228 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 229 | dst.y = (src0.y >= src1.y) ? 1 : 0 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 230 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 231 | dst.z = (src0.z >= src1.z) ? 1 : 0 |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 232 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 233 | dst.w = (src0.w >= src1.w) ? 1 : 0 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 234 | |
| 235 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 236 | .. opcode:: MAD - Multiply And Add |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 237 | |
| 238 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 239 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 240 | dst.x = src0.x \times src1.x + src2.x |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 241 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 242 | dst.y = src0.y \times src1.y + src2.y |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 243 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 244 | dst.z = src0.z \times src1.z + src2.z |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 245 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 246 | dst.w = src0.w \times src1.w + src2.w |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 247 | |
| 248 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 249 | .. opcode:: SUB - Subtract |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 250 | |
| 251 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 252 | |
| 253 | dst.x = src0.x - src1.x |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 254 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 255 | dst.y = src0.y - src1.y |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 256 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 257 | dst.z = src0.z - src1.z |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 258 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 259 | dst.w = src0.w - src1.w |
| 260 | |
| 261 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 262 | .. opcode:: LRP - Linear Interpolate |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 263 | |
| 264 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 265 | |
Michal Krol | b3567fc | 2010-01-04 12:59:17 +0100 | [diff] [blame] | 266 | 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] | 267 | |
Michal Krol | b3567fc | 2010-01-04 12:59:17 +0100 | [diff] [blame] | 268 | 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] | 269 | |
Michal Krol | b3567fc | 2010-01-04 12:59:17 +0100 | [diff] [blame] | 270 | 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] | 271 | |
Michal Krol | b3567fc | 2010-01-04 12:59:17 +0100 | [diff] [blame] | 272 | 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] | 273 | |
| 274 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 275 | .. opcode:: CND - Condition |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 276 | |
| 277 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 278 | |
| 279 | dst.x = (src2.x > 0.5) ? src0.x : src1.x |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 280 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 281 | dst.y = (src2.y > 0.5) ? src0.y : src1.y |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 282 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 283 | dst.z = (src2.z > 0.5) ? src0.z : src1.z |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 284 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 285 | dst.w = (src2.w > 0.5) ? src0.w : src1.w |
| 286 | |
| 287 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 288 | .. opcode:: DP2A - 2-component Dot Product And Add |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 289 | |
| 290 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 291 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 292 | 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] | 293 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 294 | 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] | 295 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 296 | 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] | 297 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 298 | 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] | 299 | |
| 300 | |
José Fonseca | d9c6ebb | 2010-06-01 16:25:05 +0100 | [diff] [blame] | 301 | .. opcode:: FRC - Fraction |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 302 | |
| 303 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 304 | |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 305 | dst.x = src.x - \lfloor src.x\rfloor |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 306 | |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 307 | dst.y = src.y - \lfloor src.y\rfloor |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 308 | |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 309 | dst.z = src.z - \lfloor src.z\rfloor |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 310 | |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 311 | dst.w = src.w - \lfloor src.w\rfloor |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 312 | |
| 313 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 314 | .. opcode:: CLAMP - Clamp |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 315 | |
| 316 | .. math:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 317 | |
| 318 | dst.x = clamp(src0.x, src1.x, src2.x) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 319 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 320 | dst.y = clamp(src0.y, src1.y, src2.y) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 321 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 322 | dst.z = clamp(src0.z, src1.z, src2.z) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 323 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 324 | dst.w = clamp(src0.w, src1.w, src2.w) |
| 325 | |
| 326 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 327 | .. opcode:: FLR - Floor |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 328 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 329 | This is identical to :opcode:`ARL`. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 330 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 331 | .. math:: |
| 332 | |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 333 | dst.x = \lfloor src.x\rfloor |
| 334 | |
| 335 | dst.y = \lfloor src.y\rfloor |
| 336 | |
| 337 | dst.z = \lfloor src.z\rfloor |
| 338 | |
| 339 | dst.w = \lfloor src.w\rfloor |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 340 | |
| 341 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 342 | .. opcode:: ROUND - Round |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 343 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 344 | .. math:: |
| 345 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 346 | dst.x = round(src.x) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 347 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 348 | dst.y = round(src.y) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 349 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 350 | dst.z = round(src.z) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 351 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 352 | dst.w = round(src.w) |
| 353 | |
| 354 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 355 | .. opcode:: EX2 - Exponential 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 = 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:: LG2 - Logarithm Base 2 |
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 = \log_2{src.x} |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 371 | |
| 372 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 373 | .. opcode:: POW - Power |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 374 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 375 | This instruction replicates its result. |
| 376 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 377 | .. math:: |
| 378 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 379 | dst = src0.x^{src1.x} |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 380 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 381 | .. opcode:: XPD - Cross Product |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 382 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 383 | .. math:: |
| 384 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 385 | dst.x = src0.y \times src1.z - src1.y \times src0.z |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 386 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 387 | dst.y = src0.z \times src1.x - src1.z \times src0.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 388 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 389 | dst.z = src0.x \times src1.y - src1.x \times src0.y |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 390 | |
| 391 | dst.w = 1 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 392 | |
| 393 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 394 | .. opcode:: ABS - Absolute |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 395 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 396 | .. math:: |
| 397 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 398 | dst.x = |src.x| |
| 399 | |
| 400 | dst.y = |src.y| |
| 401 | |
| 402 | dst.z = |src.z| |
| 403 | |
| 404 | dst.w = |src.w| |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 405 | |
| 406 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 407 | .. opcode:: RCC - Reciprocal Clamped |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 408 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 409 | This instruction replicates its result. |
| 410 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 411 | XXX cleanup on aisle three |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 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 = (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] | 416 | |
| 417 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 418 | .. opcode:: DPH - Homogeneous Dot Product |
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 = 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] | 425 | |
| 426 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 427 | .. opcode:: COS - Cosine |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 428 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 429 | This instruction replicates its result. |
| 430 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 431 | .. math:: |
| 432 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 433 | dst = \cos{src.x} |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 434 | |
| 435 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 436 | .. opcode:: DDX - Derivative Relative To X |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 437 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 438 | .. math:: |
| 439 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 440 | dst.x = partialx(src.x) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 441 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 442 | dst.y = partialx(src.y) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 443 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 444 | dst.z = partialx(src.z) |
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.w = partialx(src.w) |
| 447 | |
| 448 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 449 | .. opcode:: DDY - Derivative Relative To Y |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 450 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 451 | .. math:: |
| 452 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 453 | dst.x = partialy(src.x) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 454 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 455 | dst.y = partialy(src.y) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 456 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 457 | dst.z = partialy(src.z) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 458 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 459 | dst.w = partialy(src.w) |
| 460 | |
| 461 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 462 | .. opcode:: KILP - Predicated Discard |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 463 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 464 | discard |
| 465 | |
| 466 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 467 | .. opcode:: PK2H - Pack Two 16-bit Floats |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 468 | |
| 469 | TBD |
| 470 | |
| 471 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 472 | .. opcode:: PK2US - Pack Two Unsigned 16-bit Scalars |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 473 | |
| 474 | TBD |
| 475 | |
| 476 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 477 | .. opcode:: PK4B - Pack Four Signed 8-bit Scalars |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 478 | |
| 479 | TBD |
| 480 | |
| 481 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 482 | .. opcode:: PK4UB - Pack Four Unsigned 8-bit Scalars |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 483 | |
| 484 | TBD |
| 485 | |
| 486 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 487 | .. opcode:: RFL - Reflection Vector |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 488 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 489 | .. math:: |
| 490 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 491 | 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 |
| 492 | |
| 493 | 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 |
| 494 | |
| 495 | 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 |
| 496 | |
| 497 | dst.w = 1 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 498 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 499 | .. note:: |
| 500 | |
| 501 | Considered for removal. |
Keith Whitwell | 14eacb0 | 2009-12-21 23:38:29 +0000 | [diff] [blame] | 502 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 503 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 504 | .. opcode:: SEQ - Set On Equal |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 505 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 506 | .. math:: |
| 507 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 508 | dst.x = (src0.x == src1.x) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 509 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 510 | dst.y = (src0.y == src1.y) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 511 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 512 | dst.z = (src0.z == src1.z) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 513 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 514 | dst.w = (src0.w == src1.w) ? 1 : 0 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 515 | |
| 516 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 517 | .. opcode:: SFL - Set On False |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 518 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 519 | This instruction replicates its result. |
| 520 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 521 | .. math:: |
| 522 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 523 | dst = 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 524 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 525 | .. note:: |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 526 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 527 | Considered for removal. |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 528 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 529 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 530 | .. opcode:: SGT - Set On Greater Than |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 531 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 532 | .. math:: |
| 533 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 534 | dst.x = (src0.x > src1.x) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 535 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 536 | dst.y = (src0.y > src1.y) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 537 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 538 | dst.z = (src0.z > src1.z) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 539 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 540 | dst.w = (src0.w > src1.w) ? 1 : 0 |
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:: SIN - Sine |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 544 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 545 | This instruction replicates its result. |
| 546 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 547 | .. math:: |
| 548 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 549 | dst = \sin{src.x} |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 550 | |
| 551 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 552 | .. opcode:: SLE - Set On Less Equal Than |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 553 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 554 | .. math:: |
| 555 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 556 | dst.x = (src0.x <= src1.x) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 557 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 558 | dst.y = (src0.y <= src1.y) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 559 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 560 | dst.z = (src0.z <= src1.z) ? 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.w = (src0.w <= src1.w) ? 1 : 0 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 563 | |
| 564 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 565 | .. opcode:: SNE - Set On Not Equal |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 566 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 567 | .. math:: |
| 568 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 569 | dst.x = (src0.x != src1.x) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 570 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 571 | dst.y = (src0.y != src1.y) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 572 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 573 | dst.z = (src0.z != src1.z) ? 1 : 0 |
Corbin Simpson | 0477191 | 2010-01-18 17:31:56 -0800 | [diff] [blame] | 574 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 575 | dst.w = (src0.w != src1.w) ? 1 : 0 |
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:: STR - Set On True |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 579 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 580 | This instruction replicates its result. |
| 581 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 582 | .. math:: |
| 583 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 584 | dst = 1 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 585 | |
| 586 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 587 | .. opcode:: TEX - Texture Lookup |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 588 | |
Brian Paul | 2a77c3c | 2010-12-14 12:45:36 -0700 | [diff] [blame] | 589 | .. math:: |
| 590 | |
| 591 | coord = src0 |
| 592 | |
| 593 | bias = 0.0 |
| 594 | |
| 595 | dst = texture_sample(unit, coord, bias) |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 596 | |
Dave Airlie | 35db326 | 2011-12-19 16:40:05 +0000 | [diff] [blame] | 597 | for array textures src0.y contains the slice for 1D, |
| 598 | and src0.z contain the slice for 2D. |
| 599 | for shadow textures with no arrays, src0.z contains |
| 600 | the reference value. |
| 601 | for shadow textures with arrays, src0.z contains |
| 602 | the reference value for 1D arrays, and src0.w contains |
| 603 | the reference value for 2D arrays. |
| 604 | There is no way to pass a bias in the .w value for |
| 605 | shadow arrays, and GLSL doesn't allow this. |
| 606 | GLSL does allow cube shadows maps to take a bias value, |
| 607 | and we have to determine how this will look in TGSI. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 608 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 609 | .. opcode:: TXD - Texture Lookup with Derivatives |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 610 | |
Brian Paul | 2a77c3c | 2010-12-14 12:45:36 -0700 | [diff] [blame] | 611 | .. math:: |
| 612 | |
| 613 | coord = src0 |
| 614 | |
| 615 | ddx = src1 |
| 616 | |
| 617 | ddy = src2 |
| 618 | |
| 619 | bias = 0.0 |
| 620 | |
| 621 | dst = texture_sample_deriv(unit, coord, bias, ddx, ddy) |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 622 | |
| 623 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 624 | .. opcode:: TXP - Projective Texture Lookup |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 625 | |
Brian Paul | 2a77c3c | 2010-12-14 12:45:36 -0700 | [diff] [blame] | 626 | .. math:: |
| 627 | |
| 628 | coord.x = src0.x / src.w |
| 629 | |
| 630 | coord.y = src0.y / src.w |
| 631 | |
| 632 | coord.z = src0.z / src.w |
| 633 | |
| 634 | coord.w = src0.w |
| 635 | |
| 636 | bias = 0.0 |
| 637 | |
| 638 | dst = texture_sample(unit, coord, bias) |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 639 | |
| 640 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 641 | .. opcode:: UP2H - Unpack Two 16-Bit Floats |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 642 | |
| 643 | TBD |
| 644 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 645 | .. note:: |
| 646 | |
| 647 | Considered for removal. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 648 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 649 | .. opcode:: UP2US - Unpack Two Unsigned 16-Bit Scalars |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 650 | |
| 651 | TBD |
| 652 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 653 | .. note:: |
| 654 | |
| 655 | Considered for removal. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 656 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 657 | .. opcode:: UP4B - Unpack Four Signed 8-Bit Values |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 658 | |
| 659 | TBD |
| 660 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 661 | .. note:: |
| 662 | |
| 663 | Considered for removal. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 664 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 665 | .. opcode:: UP4UB - Unpack Four Unsigned 8-Bit Scalars |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 666 | |
| 667 | TBD |
| 668 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 669 | .. note:: |
| 670 | |
| 671 | Considered for removal. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 672 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 673 | .. opcode:: X2D - 2D Coordinate Transformation |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 674 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 675 | .. math:: |
| 676 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 677 | 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] | 678 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 679 | 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] | 680 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 681 | 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] | 682 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 683 | 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] | 684 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 685 | .. note:: |
| 686 | |
| 687 | Considered for removal. |
Keith Whitwell | 14eacb0 | 2009-12-21 23:38:29 +0000 | [diff] [blame] | 688 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 689 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 690 | .. opcode:: ARA - Address Register Add |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 691 | |
| 692 | TBD |
| 693 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 694 | .. note:: |
| 695 | |
| 696 | Considered for removal. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 697 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 698 | .. opcode:: ARR - Address Register Load With Round |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 699 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 700 | .. math:: |
| 701 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 702 | dst.x = round(src.x) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 703 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 704 | dst.y = round(src.y) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 705 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 706 | dst.z = round(src.z) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 707 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 708 | dst.w = round(src.w) |
| 709 | |
| 710 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 711 | .. opcode:: BRA - Branch |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 712 | |
| 713 | pc = target |
| 714 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 715 | .. note:: |
| 716 | |
| 717 | Considered for removal. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 718 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 719 | .. opcode:: CAL - Subroutine Call |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 720 | |
| 721 | push(pc) |
| 722 | pc = target |
| 723 | |
| 724 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 725 | .. opcode:: RET - Subroutine Call Return |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 726 | |
| 727 | pc = pop() |
| 728 | |
| 729 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 730 | .. opcode:: SSG - Set Sign |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 731 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 732 | .. math:: |
| 733 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 734 | dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0 |
| 735 | |
| 736 | dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0 |
| 737 | |
| 738 | dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0 |
| 739 | |
| 740 | dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 741 | |
| 742 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 743 | .. opcode:: CMP - Compare |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 744 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 745 | .. math:: |
| 746 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 747 | dst.x = (src0.x < 0) ? src1.x : src2.x |
| 748 | |
| 749 | dst.y = (src0.y < 0) ? src1.y : src2.y |
| 750 | |
| 751 | dst.z = (src0.z < 0) ? src1.z : src2.z |
| 752 | |
| 753 | dst.w = (src0.w < 0) ? src1.w : src2.w |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 754 | |
| 755 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 756 | .. opcode:: KIL - Conditional Discard |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 757 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 758 | .. math:: |
| 759 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 760 | 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] | 761 | discard |
| 762 | endif |
| 763 | |
| 764 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 765 | .. opcode:: SCS - Sine Cosine |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 766 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 767 | .. math:: |
| 768 | |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 769 | dst.x = \cos{src.x} |
| 770 | |
| 771 | dst.y = \sin{src.x} |
| 772 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 773 | dst.z = 0 |
Corbin Simpson | d92a685 | 2009-12-21 19:30:29 -0800 | [diff] [blame] | 774 | |
Tilman Sauerbeck | d323118 | 2010-09-19 09:03:11 +0200 | [diff] [blame] | 775 | dst.w = 1 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 776 | |
| 777 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 778 | .. opcode:: TXB - Texture Lookup With Bias |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 779 | |
Brian Paul | 2a77c3c | 2010-12-14 12:45:36 -0700 | [diff] [blame] | 780 | .. math:: |
| 781 | |
| 782 | coord.x = src.x |
| 783 | |
| 784 | coord.y = src.y |
| 785 | |
| 786 | coord.z = src.z |
| 787 | |
| 788 | coord.w = 1.0 |
| 789 | |
| 790 | bias = src.z |
| 791 | |
| 792 | dst = texture_sample(unit, coord, bias) |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 793 | |
| 794 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 795 | .. opcode:: NRM - 3-component Vector Normalise |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 796 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 797 | .. math:: |
| 798 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 799 | 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] | 800 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 801 | 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] | 802 | |
Corbin Simpson | ecb2f2a | 2009-12-21 20:07:10 -0800 | [diff] [blame] | 803 | 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] | 804 | |
| 805 | dst.w = 1 |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 806 | |
| 807 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 808 | .. opcode:: DIV - Divide |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 809 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 810 | .. math:: |
| 811 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 812 | dst.x = \frac{src0.x}{src1.x} |
| 813 | |
| 814 | dst.y = \frac{src0.y}{src1.y} |
| 815 | |
| 816 | dst.z = \frac{src0.z}{src1.z} |
| 817 | |
| 818 | dst.w = \frac{src0.w}{src1.w} |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 819 | |
| 820 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 821 | .. opcode:: DP2 - 2-component Dot Product |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 822 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 823 | This instruction replicates its result. |
| 824 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 825 | .. math:: |
| 826 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 827 | dst = src0.x \times src1.x + src0.y \times src1.y |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 828 | |
| 829 | |
Brian Paul | 2a77c3c | 2010-12-14 12:45:36 -0700 | [diff] [blame] | 830 | .. opcode:: TXL - Texture Lookup With explicit LOD |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 831 | |
Brian Paul | 2a77c3c | 2010-12-14 12:45:36 -0700 | [diff] [blame] | 832 | .. math:: |
| 833 | |
| 834 | coord.x = src0.x |
| 835 | |
| 836 | coord.y = src0.y |
| 837 | |
| 838 | coord.z = src0.z |
| 839 | |
| 840 | coord.w = 1.0 |
| 841 | |
| 842 | lod = src0.w |
| 843 | |
| 844 | dst = texture_sample(unit, coord, lod) |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 845 | |
| 846 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 847 | .. opcode:: BRK - Break |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 848 | |
| 849 | TBD |
| 850 | |
| 851 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 852 | .. opcode:: IF - If |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 853 | |
| 854 | TBD |
| 855 | |
| 856 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 857 | .. opcode:: ELSE - Else |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 858 | |
| 859 | TBD |
| 860 | |
| 861 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 862 | .. opcode:: ENDIF - End If |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 863 | |
| 864 | TBD |
| 865 | |
| 866 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 867 | .. opcode:: PUSHA - Push Address Register On Stack |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 868 | |
| 869 | push(src.x) |
| 870 | push(src.y) |
| 871 | push(src.z) |
| 872 | push(src.w) |
| 873 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 874 | .. note:: |
| 875 | |
| 876 | Considered for cleanup. |
| 877 | |
| 878 | .. note:: |
| 879 | |
| 880 | Considered for removal. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 881 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 882 | .. opcode:: POPA - Pop Address Register From Stack |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 883 | |
| 884 | dst.w = pop() |
| 885 | dst.z = pop() |
| 886 | dst.y = pop() |
| 887 | dst.x = pop() |
| 888 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 889 | .. note:: |
| 890 | |
| 891 | Considered for cleanup. |
| 892 | |
| 893 | .. note:: |
| 894 | |
| 895 | Considered for removal. |
Keith Whitwell | 14eacb0 | 2009-12-21 23:38:29 +0000 | [diff] [blame] | 896 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 897 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 898 | Compute ISA |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 899 | ^^^^^^^^^^^^^^^^^^^^^^^^ |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 900 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 901 | These opcodes are primarily provided for special-use computational shaders. |
Keith Whitwell | 14eacb0 | 2009-12-21 23:38:29 +0000 | [diff] [blame] | 902 | Support for these opcodes indicated by a special pipe capability bit (TBD). |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 903 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 904 | XXX so let's discuss it, yeah? |
| 905 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 906 | .. opcode:: CEIL - Ceiling |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 907 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 908 | .. math:: |
| 909 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 910 | dst.x = \lceil src.x\rceil |
| 911 | |
| 912 | dst.y = \lceil src.y\rceil |
| 913 | |
| 914 | dst.z = \lceil src.z\rceil |
| 915 | |
| 916 | dst.w = \lceil src.w\rceil |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 917 | |
| 918 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 919 | .. opcode:: I2F - Integer To Float |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 920 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 921 | .. math:: |
| 922 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 923 | dst.x = (float) src.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 924 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 925 | dst.y = (float) src.y |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 926 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 927 | dst.z = (float) src.z |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 928 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 929 | dst.w = (float) src.w |
| 930 | |
| 931 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 932 | .. opcode:: NOT - Bitwise Not |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 933 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 934 | .. math:: |
| 935 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 936 | dst.x = ~src.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 937 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 938 | dst.y = ~src.y |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 939 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 940 | dst.z = ~src.z |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 941 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 942 | dst.w = ~src.w |
| 943 | |
| 944 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 945 | .. opcode:: TRUNC - Truncate |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 946 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 947 | .. math:: |
| 948 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 949 | dst.x = trunc(src.x) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 950 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 951 | dst.y = trunc(src.y) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 952 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 953 | dst.z = trunc(src.z) |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 954 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 955 | dst.w = trunc(src.w) |
| 956 | |
| 957 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 958 | .. opcode:: SHL - Shift Left |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 959 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 960 | .. math:: |
| 961 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 962 | dst.x = src0.x << src1.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 963 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 964 | dst.y = src0.y << src1.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 965 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 966 | dst.z = src0.z << src1.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 967 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 968 | dst.w = src0.w << src1.x |
| 969 | |
| 970 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 971 | .. opcode:: SHR - Shift Right |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 972 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 973 | .. math:: |
| 974 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 975 | dst.x = src0.x >> src1.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 976 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 977 | dst.y = src0.y >> src1.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 978 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 979 | dst.z = src0.z >> src1.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 980 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 981 | dst.w = src0.w >> src1.x |
| 982 | |
| 983 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 984 | .. opcode:: AND - Bitwise And |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 985 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 986 | .. math:: |
| 987 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 988 | dst.x = src0.x & src1.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 989 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 990 | dst.y = src0.y & src1.y |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 991 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 992 | dst.z = src0.z & src1.z |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 993 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 994 | dst.w = src0.w & src1.w |
| 995 | |
| 996 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 997 | .. opcode:: OR - Bitwise Or |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 998 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 999 | .. math:: |
| 1000 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1001 | dst.x = src0.x | src1.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1002 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1003 | dst.y = src0.y | src1.y |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1004 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1005 | dst.z = src0.z | src1.z |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1006 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1007 | dst.w = src0.w | src1.w |
| 1008 | |
| 1009 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1010 | .. opcode:: MOD - Modulus |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1011 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 1012 | .. math:: |
| 1013 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1014 | dst.x = src0.x \bmod src1.x |
| 1015 | |
| 1016 | dst.y = src0.y \bmod src1.y |
| 1017 | |
| 1018 | dst.z = src0.z \bmod src1.z |
| 1019 | |
| 1020 | dst.w = src0.w \bmod src1.w |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1021 | |
| 1022 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1023 | .. opcode:: XOR - Bitwise Xor |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1024 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 1025 | .. math:: |
| 1026 | |
Corbin Simpson | f90733c | 2010-01-18 17:37:25 -0800 | [diff] [blame] | 1027 | dst.x = src0.x \oplus src1.x |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1028 | |
Corbin Simpson | f90733c | 2010-01-18 17:37:25 -0800 | [diff] [blame] | 1029 | dst.y = src0.y \oplus src1.y |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1030 | |
Corbin Simpson | f90733c | 2010-01-18 17:37:25 -0800 | [diff] [blame] | 1031 | dst.z = src0.z \oplus src1.z |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1032 | |
Corbin Simpson | f90733c | 2010-01-18 17:37:25 -0800 | [diff] [blame] | 1033 | dst.w = src0.w \oplus src1.w |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1034 | |
| 1035 | |
Bryan Cain | 324ac98 | 2011-09-10 12:31:54 -0500 | [diff] [blame] | 1036 | .. opcode:: UCMP - Integer Conditional Move |
| 1037 | |
| 1038 | .. math:: |
| 1039 | |
| 1040 | dst.x = src0.x ? src1.x : src2.x |
| 1041 | |
| 1042 | dst.y = src0.y ? src1.y : src2.y |
| 1043 | |
| 1044 | dst.z = src0.z ? src1.z : src2.z |
| 1045 | |
| 1046 | dst.w = src0.w ? src1.w : src2.w |
| 1047 | |
| 1048 | |
| 1049 | .. opcode:: UARL - Integer Address Register Load |
| 1050 | |
| 1051 | Moves the contents of the source register, assumed to be an integer, into the |
| 1052 | destination register, which is assumed to be an address (ADDR) register. |
| 1053 | |
| 1054 | |
Bryan Cain | 4c0f1fb | 2012-01-07 10:43:04 -0600 | [diff] [blame] | 1055 | .. opcode:: IABS - Integer Absolute Value |
| 1056 | |
| 1057 | .. math:: |
| 1058 | |
| 1059 | dst.x = |src.x| |
| 1060 | |
| 1061 | dst.y = |src.y| |
| 1062 | |
| 1063 | dst.z = |src.z| |
| 1064 | |
| 1065 | dst.w = |src.w| |
| 1066 | |
| 1067 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1068 | .. opcode:: SAD - Sum Of Absolute Differences |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1069 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 1070 | .. math:: |
| 1071 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 1072 | dst.x = |src0.x - src1.x| + src2.x |
| 1073 | |
| 1074 | dst.y = |src0.y - src1.y| + src2.y |
| 1075 | |
| 1076 | dst.z = |src0.z - src1.z| + src2.z |
| 1077 | |
| 1078 | dst.w = |src0.w - src1.w| + src2.w |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1079 | |
| 1080 | |
Dave Airlie | 2083a27 | 2011-08-26 10:59:18 +0100 | [diff] [blame] | 1081 | .. opcode:: TXF - Texel Fetch (as per NV_gpu_shader4), extract a single texel |
| 1082 | from a specified texture image. The source sampler may |
| 1083 | not be a CUBE or SHADOW. |
| 1084 | src 0 is a four-component signed integer vector used to |
| 1085 | identify the single texel accessed. 3 components + level. |
| 1086 | src 1 is a 3 component constant signed integer vector, |
| 1087 | with each component only have a range of |
| 1088 | -8..+8 (hw only seems to deal with this range, interface |
| 1089 | allows for up to unsigned int). |
| 1090 | TXF(uint_vec coord, int_vec offset). |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1091 | |
| 1092 | |
Dave Airlie | 6fb12bf | 2011-08-25 13:03:19 +0100 | [diff] [blame] | 1093 | .. opcode:: TXQ - Texture Size Query (as per NV_gpu_program4) |
| 1094 | retrieve the dimensions of the texture |
| 1095 | depending on the target. For 1D (width), 2D/RECT/CUBE |
| 1096 | (width, height), 3D (width, height, depth), |
| 1097 | 1D array (width, layers), 2D array (width, height, layers) |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1098 | |
Dave Airlie | 6fb12bf | 2011-08-25 13:03:19 +0100 | [diff] [blame] | 1099 | .. math:: |
| 1100 | |
| 1101 | lod = src0 |
| 1102 | |
| 1103 | dst.x = texture_width(unit, lod) |
| 1104 | |
| 1105 | dst.y = texture_height(unit, lod) |
| 1106 | |
| 1107 | dst.z = texture_depth(unit, lod) |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1108 | |
| 1109 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1110 | .. opcode:: CONT - Continue |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1111 | |
| 1112 | TBD |
| 1113 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 1114 | .. note:: |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1115 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 1116 | Support for CONT is determined by a special capability bit, |
| 1117 | ``TGSI_CONT_SUPPORTED``. See :ref:`Screen` for more information. |
| 1118 | |
| 1119 | |
| 1120 | Geometry ISA |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 1121 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1122 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 1123 | These opcodes are only supported in geometry shaders; they have no meaning |
| 1124 | in any other type of shader. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1125 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1126 | .. opcode:: EMIT - Emit |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1127 | |
| 1128 | TBD |
| 1129 | |
| 1130 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1131 | .. opcode:: ENDPRIM - End Primitive |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1132 | |
| 1133 | TBD |
| 1134 | |
| 1135 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 1136 | GLSL ISA |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 1137 | ^^^^^^^^^^ |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1138 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 1139 | These opcodes are part of :term:`GLSL`'s opcode set. Support for these |
| 1140 | opcodes is determined by a special capability bit, ``GLSL``. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1141 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1142 | .. opcode:: BGNLOOP - Begin a Loop |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1143 | |
| 1144 | TBD |
| 1145 | |
| 1146 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1147 | .. opcode:: BGNSUB - Begin Subroutine |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1148 | |
| 1149 | TBD |
| 1150 | |
| 1151 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1152 | .. opcode:: ENDLOOP - End a Loop |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1153 | |
| 1154 | TBD |
| 1155 | |
| 1156 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1157 | .. opcode:: ENDSUB - End Subroutine |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1158 | |
| 1159 | TBD |
| 1160 | |
| 1161 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1162 | .. opcode:: NOP - No Operation |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1163 | |
Michal Krol | 8ab89d7 | 2010-01-04 13:23:41 +0100 | [diff] [blame] | 1164 | Do nothing. |
| 1165 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1166 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1167 | .. opcode:: NRM4 - 4-component Vector Normalise |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1168 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 1169 | This instruction replicates its result. |
| 1170 | |
Corbin Simpson | e8ed3b9 | 2009-12-21 19:12:55 -0800 | [diff] [blame] | 1171 | .. math:: |
| 1172 | |
Corbin Simpson | 17c2a44 | 2010-02-02 17:02:28 -0800 | [diff] [blame] | 1173 | 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] | 1174 | |
| 1175 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1176 | ps_2_x |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 1177 | ^^^^^^^^^^^^ |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1178 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 1179 | XXX wait what |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1180 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1181 | .. opcode:: CALLNZ - Subroutine Call If Not Zero |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1182 | |
| 1183 | TBD |
| 1184 | |
| 1185 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1186 | .. opcode:: IFC - If |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1187 | |
| 1188 | TBD |
| 1189 | |
| 1190 | |
Corbin Simpson | 8580522 | 2010-02-02 16:20:12 -0800 | [diff] [blame] | 1191 | .. opcode:: BREAKC - Break Conditional |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1192 | |
| 1193 | TBD |
| 1194 | |
Corbin Simpson | 62ca7b8 | 2010-02-02 16:36:34 -0800 | [diff] [blame] | 1195 | .. _doubleopcodes: |
| 1196 | |
Corbin Simpson | 9d4cb6e | 2010-06-16 18:34:32 -0700 | [diff] [blame] | 1197 | Double ISA |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1198 | ^^^^^^^^^^^^^^^ |
| 1199 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1200 | The double-precision opcodes reinterpret four-component vectors into |
| 1201 | two-component vectors with doubled precision in each component. |
| 1202 | |
| 1203 | Support for these opcodes is XXX undecided. :T |
| 1204 | |
| 1205 | .. opcode:: DADD - Add |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1206 | |
| 1207 | .. math:: |
| 1208 | |
| 1209 | dst.xy = src0.xy + src1.xy |
| 1210 | |
| 1211 | dst.zw = src0.zw + src1.zw |
| 1212 | |
| 1213 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1214 | .. opcode:: DDIV - Divide |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1215 | |
| 1216 | .. math:: |
| 1217 | |
| 1218 | dst.xy = src0.xy / src1.xy |
| 1219 | |
| 1220 | dst.zw = src0.zw / src1.zw |
| 1221 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1222 | .. opcode:: DSEQ - Set on Equal |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1223 | |
| 1224 | .. math:: |
| 1225 | |
| 1226 | dst.xy = src0.xy == src1.xy ? 1.0F : 0.0F |
| 1227 | |
| 1228 | dst.zw = src0.zw == src1.zw ? 1.0F : 0.0F |
| 1229 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1230 | .. opcode:: DSLT - Set on Less than |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1231 | |
| 1232 | .. math:: |
| 1233 | |
| 1234 | dst.xy = src0.xy < src1.xy ? 1.0F : 0.0F |
| 1235 | |
| 1236 | dst.zw = src0.zw < src1.zw ? 1.0F : 0.0F |
| 1237 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1238 | .. opcode:: DFRAC - Fraction |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1239 | |
| 1240 | .. math:: |
| 1241 | |
| 1242 | dst.xy = src.xy - \lfloor src.xy\rfloor |
| 1243 | |
| 1244 | dst.zw = src.zw - \lfloor src.zw\rfloor |
| 1245 | |
| 1246 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1247 | .. opcode:: DFRACEXP - Convert Number to Fractional and Integral Components |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1248 | |
Corbin Simpson | f98c462 | 2010-06-16 18:45:50 -0700 | [diff] [blame] | 1249 | Like the ``frexp()`` routine in many math libraries, this opcode stores the |
| 1250 | exponent of its source to ``dst0``, and the significand to ``dst1``, such that |
| 1251 | :math:`dst1 \times 2^{dst0} = src` . |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1252 | |
| 1253 | .. math:: |
| 1254 | |
Corbin Simpson | f98c462 | 2010-06-16 18:45:50 -0700 | [diff] [blame] | 1255 | dst0.xy = exp(src.xy) |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1256 | |
Corbin Simpson | f98c462 | 2010-06-16 18:45:50 -0700 | [diff] [blame] | 1257 | dst1.xy = frac(src.xy) |
| 1258 | |
| 1259 | dst0.zw = exp(src.zw) |
| 1260 | |
| 1261 | dst1.zw = frac(src.zw) |
| 1262 | |
| 1263 | .. opcode:: DLDEXP - Multiply Number by Integral Power of 2 |
| 1264 | |
| 1265 | This opcode is the inverse of :opcode:`DFRACEXP`. |
| 1266 | |
| 1267 | .. math:: |
| 1268 | |
| 1269 | dst.xy = src0.xy \times 2^{src1.xy} |
| 1270 | |
| 1271 | dst.zw = src0.zw \times 2^{src1.zw} |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1272 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1273 | .. opcode:: DMIN - Minimum |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1274 | |
| 1275 | .. math:: |
| 1276 | |
| 1277 | dst.xy = min(src0.xy, src1.xy) |
| 1278 | |
| 1279 | dst.zw = min(src0.zw, src1.zw) |
| 1280 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1281 | .. opcode:: DMAX - Maximum |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1282 | |
| 1283 | .. math:: |
| 1284 | |
| 1285 | dst.xy = max(src0.xy, src1.xy) |
| 1286 | |
| 1287 | dst.zw = max(src0.zw, src1.zw) |
| 1288 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1289 | .. opcode:: DMUL - Multiply |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1290 | |
| 1291 | .. math:: |
| 1292 | |
| 1293 | dst.xy = src0.xy \times src1.xy |
| 1294 | |
| 1295 | dst.zw = src0.zw \times src1.zw |
| 1296 | |
| 1297 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1298 | .. opcode:: DMAD - Multiply And Add |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1299 | |
| 1300 | .. math:: |
| 1301 | |
| 1302 | dst.xy = src0.xy \times src1.xy + src2.xy |
| 1303 | |
| 1304 | dst.zw = src0.zw \times src1.zw + src2.zw |
| 1305 | |
| 1306 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1307 | .. opcode:: DRCP - Reciprocal |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1308 | |
| 1309 | .. math:: |
| 1310 | |
| 1311 | dst.xy = \frac{1}{src.xy} |
| 1312 | |
| 1313 | dst.zw = \frac{1}{src.zw} |
| 1314 | |
Corbin Simpson | dbc95e8 | 2010-06-16 18:34:51 -0700 | [diff] [blame] | 1315 | .. opcode:: DSQRT - Square Root |
Igor Oliveira | db89bf4 | 2010-01-25 19:23:04 -0400 | [diff] [blame] | 1316 | |
| 1317 | .. math:: |
| 1318 | |
| 1319 | dst.xy = \sqrt{src.xy} |
| 1320 | |
| 1321 | dst.zw = \sqrt{src.zw} |
| 1322 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1323 | |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1324 | .. _samplingopcodes: |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1325 | |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1326 | Resource Sampling Opcodes |
| 1327 | ^^^^^^^^^^^^^^^^^^^^^^^^^ |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1328 | |
| 1329 | Those opcodes follow very closely semantics of the respective Direct3D |
| 1330 | instructions. If in doubt double check Direct3D documentation. |
| 1331 | |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1332 | .. opcode:: SAMPLE - Using provided address, sample data from the |
| 1333 | specified texture using the filtering mode identified |
| 1334 | by the gven sampler. The source data may come from |
| 1335 | any resource type other than buffers. |
| 1336 | SAMPLE dst, address, sampler_view, sampler |
| 1337 | e.g. |
| 1338 | SAMPLE TEMP[0], TEMP[1], SVIEW[0], SAMP[0] |
| 1339 | |
| 1340 | .. opcode:: SAMPLE_I - Simplified alternative to the SAMPLE instruction. |
| 1341 | Using the provided integer address, SAMPLE_I fetches data |
| 1342 | from the specified sampler view without any filtering. |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1343 | The source data may come from any resource type other |
| 1344 | than CUBE. |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1345 | SAMPLE_I dst, address, sampler_view |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1346 | e.g. |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1347 | SAMPLE_I TEMP[0], TEMP[1], SVIEW[0] |
Zack Rusin | 3fa814d | 2011-01-24 21:45:37 -0500 | [diff] [blame] | 1348 | The 'address' is specified as unsigned integers. If the |
| 1349 | 'address' is out of range [0...(# texels - 1)] the |
| 1350 | result of the fetch is always 0 in all components. |
| 1351 | As such the instruction doesn't honor address wrap |
| 1352 | modes, in cases where that behavior is desirable |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1353 | 'SAMPLE' instruction should be used. |
Zack Rusin | 3fa814d | 2011-01-24 21:45:37 -0500 | [diff] [blame] | 1354 | address.w always provides an unsigned integer mipmap |
| 1355 | level. If the value is out of the range then the |
| 1356 | instruction always returns 0 in all components. |
| 1357 | address.yz are ignored for buffers and 1d textures. |
| 1358 | address.z is ignored for 1d texture arrays and 2d |
| 1359 | textures. |
| 1360 | For 1D texture arrays address.y provides the array |
| 1361 | index (also as unsigned integer). If the value is |
| 1362 | out of the range of available array indices |
| 1363 | [0... (array size - 1)] then the opcode always returns |
| 1364 | 0 in all components. |
| 1365 | For 2D texture arrays address.z provides the array |
| 1366 | index, otherwise it exhibits the same behavior as in |
| 1367 | the case for 1D texture arrays. |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1368 | The exact semantics of the source address are presented |
Zack Rusin | 3fa814d | 2011-01-24 21:45:37 -0500 | [diff] [blame] | 1369 | in the table below: |
| 1370 | resource type X Y Z W |
| 1371 | ------------- ------------------------ |
| 1372 | PIPE_BUFFER x ignored |
| 1373 | PIPE_TEXTURE_1D x mpl |
| 1374 | PIPE_TEXTURE_2D x y mpl |
| 1375 | PIPE_TEXTURE_3D x y z mpl |
| 1376 | PIPE_TEXTURE_RECT x y mpl |
| 1377 | PIPE_TEXTURE_CUBE not allowed as source |
| 1378 | PIPE_TEXTURE_1D_ARRAY x idx mpl |
| 1379 | PIPE_TEXTURE_2D_ARRAY x y idx mpl |
| 1380 | |
| 1381 | Where 'mpl' is a mipmap level and 'idx' is the |
| 1382 | array index. |
| 1383 | |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1384 | .. opcode:: SAMPLE_I_MS - Just like SAMPLE_I but allows fetch data from |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1385 | multi-sampled surfaces. |
| 1386 | |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1387 | .. opcode:: SAMPLE_B - Just like the SAMPLE instruction with the |
| 1388 | exception that an additiona bias is applied to the |
| 1389 | level of detail computed as part of the instruction |
| 1390 | execution. |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1391 | SAMPLE_B dst, address, sampler_view, sampler, lod_bias |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1392 | e.g. |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1393 | SAMPLE_B TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2].x |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1394 | |
Zack Rusin | 3fa814d | 2011-01-24 21:45:37 -0500 | [diff] [blame] | 1395 | .. opcode:: SAMPLE_C - Similar to the SAMPLE instruction but it |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1396 | performs a comparison filter. The operands to SAMPLE_C |
| 1397 | are identical to SAMPLE, except that tere is an additional |
| 1398 | float32 operand, reference value, which must be a register |
| 1399 | with single-component, or a scalar literal. |
| 1400 | SAMPLE_C makes the hardware use the current samplers |
| 1401 | compare_func (in pipe_sampler_state) to compare |
| 1402 | reference value against the red component value for the |
| 1403 | surce resource at each texel that the currently configured |
| 1404 | texture filter covers based on the provided coordinates. |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1405 | SAMPLE_C dst, address, sampler_view.r, sampler, ref_value |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1406 | e.g. |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1407 | SAMPLE_C TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1408 | |
| 1409 | .. opcode:: SAMPLE_C_LZ - Same as SAMPLE_C, but LOD is 0 and derivatives |
| 1410 | are ignored. The LZ stands for level-zero. |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1411 | SAMPLE_C_LZ dst, address, sampler_view.r, sampler, ref_value |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1412 | e.g. |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1413 | SAMPLE_C_LZ TEMP[0], TEMP[1], SVIEW[0].r, SAMP[0], TEMP[2].x |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1414 | |
| 1415 | |
| 1416 | .. opcode:: SAMPLE_D - SAMPLE_D is identical to the SAMPLE opcode except |
| 1417 | that the derivatives for the source address in the x |
| 1418 | direction and the y direction are provided by extra |
| 1419 | parameters. |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1420 | SAMPLE_D dst, address, sampler_view, sampler, der_x, der_y |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1421 | e.g. |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1422 | SAMPLE_D TEMP[0], TEMP[1], SVIEW[0], SAMP[0], TEMP[2], TEMP[3] |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1423 | |
| 1424 | .. opcode:: SAMPLE_L - SAMPLE_L is identical to the SAMPLE opcode except |
| 1425 | that the LOD is provided directly as a scalar value, |
| 1426 | representing no anisotropy. Source addresses A channel |
| 1427 | is used as the LOD. |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1428 | SAMPLE_L dst, address, sampler_view, sampler |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1429 | e.g. |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1430 | SAMPLE_L TEMP[0], TEMP[1], SVIEW[0], SAMP[0] |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1431 | |
| 1432 | .. opcode:: GATHER4 - Gathers the four texels to be used in a bi-linear |
| 1433 | filtering operation and packs them into a single register. |
Brian Paul | 0cd6800 | 2012-03-30 09:41:42 -0600 | [diff] [blame] | 1434 | Only works with 2D, 2D array, cubemaps, and cubemaps arrays. |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1435 | For 2D textures, only the addressing modes of the sampler and |
| 1436 | the top level of any mip pyramid are used. Set W to zero. |
| 1437 | It behaves like the SAMPLE instruction, but a filtered |
| 1438 | sample is not generated. The four samples that contribute |
Brian Paul | 0cd6800 | 2012-03-30 09:41:42 -0600 | [diff] [blame] | 1439 | to filtering are placed into xyzw in counter-clockwise order, |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1440 | starting with the (u,v) texture coordinate delta at the |
| 1441 | following locations (-, +), (+, +), (+, -), (-, -), where |
| 1442 | the magnitude of the deltas are half a texel. |
| 1443 | |
| 1444 | |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1445 | .. opcode:: SVIEWINFO - query the dimensions of a given sampler view. |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1446 | dst receives width, height, depth or array size and |
Zack Rusin | 3fa814d | 2011-01-24 21:45:37 -0500 | [diff] [blame] | 1447 | number of mipmap levels. The dst can have a writemask |
| 1448 | which will specify what info is the caller interested |
| 1449 | in. |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1450 | SVIEWINFO dst, src_mip_level, sampler_view |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1451 | e.g. |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1452 | SVIEWINFO TEMP[0], TEMP[1].x, SVIEW[0] |
Zack Rusin | 3fa814d | 2011-01-24 21:45:37 -0500 | [diff] [blame] | 1453 | src_mip_level is an unsigned integer scalar. If it's |
| 1454 | out of range then returns 0 for width, height and |
| 1455 | depth/array size but the total number of mipmap is |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1456 | still returned correctly for the given sampler view. |
Zack Rusin | 3fa814d | 2011-01-24 21:45:37 -0500 | [diff] [blame] | 1457 | The returned width, height and depth values are for |
| 1458 | the mipmap level selected by the src_mip_level and |
| 1459 | are in the number of texels. |
| 1460 | For 1d texture array width is in dst.x, array size |
| 1461 | is in dst.y and dst.zw are always 0. |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1462 | |
| 1463 | .. opcode:: SAMPLE_POS - query the position of a given sample. |
| 1464 | dst receives float4 (x, y, 0, 0) indicated where the |
| 1465 | sample is located. If the resource is not a multi-sample |
| 1466 | resource and not a render target, the result is 0. |
| 1467 | |
Zack Rusin | 3fa814d | 2011-01-24 21:45:37 -0500 | [diff] [blame] | 1468 | .. opcode:: SAMPLE_INFO - dst receives number of samples in x. |
| 1469 | If the resource is not a multi-sample resource and |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1470 | not a render target, the result is 0. |
| 1471 | |
| 1472 | |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1473 | .. _resourceopcodes: |
| 1474 | |
| 1475 | Resource Access Opcodes |
| 1476 | ^^^^^^^^^^^^^^^^^^^^^^^ |
| 1477 | |
| 1478 | .. opcode:: LOAD - Fetch data from a shader resource |
| 1479 | |
| 1480 | Syntax: ``LOAD dst, resource, address`` |
| 1481 | |
| 1482 | Example: ``LOAD TEMP[0], RES[0], TEMP[1]`` |
| 1483 | |
| 1484 | Using the provided integer address, LOAD fetches data |
| 1485 | from the specified buffer or texture without any |
| 1486 | filtering. |
| 1487 | |
| 1488 | The 'address' is specified as a vector of unsigned |
| 1489 | integers. If the 'address' is out of range the result |
| 1490 | is unspecified. |
| 1491 | |
| 1492 | Only the first mipmap level of a resource can be read |
| 1493 | from using this instruction. |
| 1494 | |
| 1495 | For 1D or 2D texture arrays, the array index is |
| 1496 | provided as an unsigned integer in address.y or |
| 1497 | address.z, respectively. address.yz are ignored for |
| 1498 | buffers and 1D textures. address.z is ignored for 1D |
| 1499 | texture arrays and 2D textures. address.w is always |
| 1500 | ignored. |
| 1501 | |
Francisco Jerez | b8e808f | 2012-04-30 20:20:29 +0200 | [diff] [blame] | 1502 | .. opcode:: STORE - Write data to a shader resource |
| 1503 | |
| 1504 | Syntax: ``STORE resource, address, src`` |
| 1505 | |
| 1506 | Example: ``STORE RES[0], TEMP[0], TEMP[1]`` |
| 1507 | |
| 1508 | Using the provided integer address, STORE writes data |
| 1509 | to the specified buffer or texture. |
| 1510 | |
| 1511 | The 'address' is specified as a vector of unsigned |
| 1512 | integers. If the 'address' is out of range the result |
| 1513 | is unspecified. |
| 1514 | |
| 1515 | Only the first mipmap level of a resource can be |
| 1516 | written to using this instruction. |
| 1517 | |
| 1518 | For 1D or 2D texture arrays, the array index is |
| 1519 | provided as an unsigned integer in address.y or |
| 1520 | address.z, respectively. address.yz are ignored for |
| 1521 | buffers and 1D textures. address.z is ignored for 1D |
| 1522 | texture arrays and 2D textures. address.w is always |
| 1523 | ignored. |
| 1524 | |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1525 | |
Francisco Jerez | 9e550c3 | 2012-04-30 20:21:38 +0200 | [diff] [blame] | 1526 | .. _threadsyncopcodes: |
| 1527 | |
| 1528 | Inter-thread synchronization opcodes |
| 1529 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 1530 | |
| 1531 | These opcodes are intended for communication between threads running |
| 1532 | within the same compute grid. For now they're only valid in compute |
| 1533 | programs. |
| 1534 | |
| 1535 | .. opcode:: MFENCE - Memory fence |
| 1536 | |
| 1537 | Syntax: ``MFENCE resource`` |
| 1538 | |
| 1539 | Example: ``MFENCE RES[0]`` |
| 1540 | |
| 1541 | This opcode forces strong ordering between any memory access |
| 1542 | operations that affect the specified resource. This means that |
| 1543 | previous loads and stores (and only those) will be performed and |
| 1544 | visible to other threads before the program execution continues. |
| 1545 | |
| 1546 | |
| 1547 | .. opcode:: LFENCE - Load memory fence |
| 1548 | |
| 1549 | Syntax: ``LFENCE resource`` |
| 1550 | |
| 1551 | Example: ``LFENCE RES[0]`` |
| 1552 | |
| 1553 | Similar to MFENCE, but it only affects the ordering of memory loads. |
| 1554 | |
| 1555 | |
| 1556 | .. opcode:: SFENCE - Store memory fence |
| 1557 | |
| 1558 | Syntax: ``SFENCE resource`` |
| 1559 | |
| 1560 | Example: ``SFENCE RES[0]`` |
| 1561 | |
| 1562 | Similar to MFENCE, but it only affects the ordering of memory stores. |
| 1563 | |
| 1564 | |
| 1565 | .. opcode:: BARRIER - Thread group barrier |
| 1566 | |
| 1567 | ``BARRIER`` |
| 1568 | |
| 1569 | This opcode suspends the execution of the current thread until all |
| 1570 | the remaining threads in the working group reach the same point of |
| 1571 | the program. Results are unspecified if any of the remaining |
| 1572 | threads terminates or never reaches an executed BARRIER instruction. |
| 1573 | |
| 1574 | |
Francisco Jerez | c2d31a8 | 2012-04-30 20:22:23 +0200 | [diff] [blame] | 1575 | .. _atomopcodes: |
| 1576 | |
| 1577 | Atomic opcodes |
| 1578 | ^^^^^^^^^^^^^^ |
| 1579 | |
| 1580 | These opcodes provide atomic variants of some common arithmetic and |
| 1581 | logical operations. In this context atomicity means that another |
| 1582 | concurrent memory access operation that affects the same memory |
| 1583 | location is guaranteed to be performed strictly before or after the |
| 1584 | entire execution of the atomic operation. |
| 1585 | |
| 1586 | For the moment they're only valid in compute programs. |
| 1587 | |
| 1588 | .. opcode:: ATOMUADD - Atomic integer addition |
| 1589 | |
| 1590 | Syntax: ``ATOMUADD dst, resource, offset, src`` |
| 1591 | |
| 1592 | Example: ``ATOMUADD TEMP[0], RES[0], TEMP[1], TEMP[2]`` |
| 1593 | |
| 1594 | The following operation is performed atomically on each component: |
| 1595 | |
| 1596 | .. math:: |
| 1597 | |
| 1598 | dst_i = resource[offset]_i |
| 1599 | |
| 1600 | resource[offset]_i = dst_i + src_i |
| 1601 | |
| 1602 | |
| 1603 | .. opcode:: ATOMXCHG - Atomic exchange |
| 1604 | |
| 1605 | Syntax: ``ATOMXCHG dst, resource, offset, src`` |
| 1606 | |
| 1607 | Example: ``ATOMXCHG TEMP[0], RES[0], TEMP[1], TEMP[2]`` |
| 1608 | |
| 1609 | The following operation is performed atomically on each component: |
| 1610 | |
| 1611 | .. math:: |
| 1612 | |
| 1613 | dst_i = resource[offset]_i |
| 1614 | |
| 1615 | resource[offset]_i = src_i |
| 1616 | |
| 1617 | |
| 1618 | .. opcode:: ATOMCAS - Atomic compare-and-exchange |
| 1619 | |
| 1620 | Syntax: ``ATOMCAS dst, resource, offset, cmp, src`` |
| 1621 | |
| 1622 | Example: ``ATOMCAS TEMP[0], RES[0], TEMP[1], TEMP[2], TEMP[3]`` |
| 1623 | |
| 1624 | The following operation is performed atomically on each component: |
| 1625 | |
| 1626 | .. math:: |
| 1627 | |
| 1628 | dst_i = resource[offset]_i |
| 1629 | |
| 1630 | resource[offset]_i = (dst_i == cmp_i ? src_i : dst_i) |
| 1631 | |
| 1632 | |
| 1633 | .. opcode:: ATOMAND - Atomic bitwise And |
| 1634 | |
| 1635 | Syntax: ``ATOMAND dst, resource, offset, src`` |
| 1636 | |
| 1637 | Example: ``ATOMAND TEMP[0], RES[0], TEMP[1], TEMP[2]`` |
| 1638 | |
| 1639 | The following operation is performed atomically on each component: |
| 1640 | |
| 1641 | .. math:: |
| 1642 | |
| 1643 | dst_i = resource[offset]_i |
| 1644 | |
| 1645 | resource[offset]_i = dst_i \& src_i |
| 1646 | |
| 1647 | |
| 1648 | .. opcode:: ATOMOR - Atomic bitwise Or |
| 1649 | |
| 1650 | Syntax: ``ATOMOR dst, resource, offset, src`` |
| 1651 | |
| 1652 | Example: ``ATOMOR TEMP[0], RES[0], TEMP[1], TEMP[2]`` |
| 1653 | |
| 1654 | The following operation is performed atomically on each component: |
| 1655 | |
| 1656 | .. math:: |
| 1657 | |
| 1658 | dst_i = resource[offset]_i |
| 1659 | |
| 1660 | resource[offset]_i = dst_i | src_i |
| 1661 | |
| 1662 | |
| 1663 | .. opcode:: ATOMXOR - Atomic bitwise Xor |
| 1664 | |
| 1665 | Syntax: ``ATOMXOR dst, resource, offset, src`` |
| 1666 | |
| 1667 | Example: ``ATOMXOR TEMP[0], RES[0], TEMP[1], TEMP[2]`` |
| 1668 | |
| 1669 | The following operation is performed atomically on each component: |
| 1670 | |
| 1671 | .. math:: |
| 1672 | |
| 1673 | dst_i = resource[offset]_i |
| 1674 | |
| 1675 | resource[offset]_i = dst_i \oplus src_i |
| 1676 | |
| 1677 | |
| 1678 | .. opcode:: ATOMUMIN - Atomic unsigned minimum |
| 1679 | |
| 1680 | Syntax: ``ATOMUMIN dst, resource, offset, src`` |
| 1681 | |
| 1682 | Example: ``ATOMUMIN TEMP[0], RES[0], TEMP[1], TEMP[2]`` |
| 1683 | |
| 1684 | The following operation is performed atomically on each component: |
| 1685 | |
| 1686 | .. math:: |
| 1687 | |
| 1688 | dst_i = resource[offset]_i |
| 1689 | |
| 1690 | resource[offset]_i = (dst_i < src_i ? dst_i : src_i) |
| 1691 | |
| 1692 | |
| 1693 | .. opcode:: ATOMUMAX - Atomic unsigned maximum |
| 1694 | |
| 1695 | Syntax: ``ATOMUMAX dst, resource, offset, src`` |
| 1696 | |
| 1697 | Example: ``ATOMUMAX TEMP[0], RES[0], TEMP[1], TEMP[2]`` |
| 1698 | |
| 1699 | The following operation is performed atomically on each component: |
| 1700 | |
| 1701 | .. math:: |
| 1702 | |
| 1703 | dst_i = resource[offset]_i |
| 1704 | |
| 1705 | resource[offset]_i = (dst_i > src_i ? dst_i : src_i) |
| 1706 | |
| 1707 | |
| 1708 | .. opcode:: ATOMIMIN - Atomic signed minimum |
| 1709 | |
| 1710 | Syntax: ``ATOMIMIN dst, resource, offset, src`` |
| 1711 | |
| 1712 | Example: ``ATOMIMIN TEMP[0], RES[0], TEMP[1], TEMP[2]`` |
| 1713 | |
| 1714 | The following operation is performed atomically on each component: |
| 1715 | |
| 1716 | .. math:: |
| 1717 | |
| 1718 | dst_i = resource[offset]_i |
| 1719 | |
| 1720 | resource[offset]_i = (dst_i < src_i ? dst_i : src_i) |
| 1721 | |
| 1722 | |
| 1723 | .. opcode:: ATOMIMAX - Atomic signed maximum |
| 1724 | |
| 1725 | Syntax: ``ATOMIMAX dst, resource, offset, src`` |
| 1726 | |
| 1727 | Example: ``ATOMIMAX TEMP[0], RES[0], TEMP[1], TEMP[2]`` |
| 1728 | |
| 1729 | The following operation is performed atomically on each component: |
| 1730 | |
| 1731 | .. math:: |
| 1732 | |
| 1733 | dst_i = resource[offset]_i |
| 1734 | |
| 1735 | resource[offset]_i = (dst_i > src_i ? dst_i : src_i) |
| 1736 | |
| 1737 | |
| 1738 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1739 | Explanation of symbols used |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 1740 | ------------------------------ |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1741 | |
| 1742 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1743 | Functions |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 1744 | ^^^^^^^^^^^^^^ |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1745 | |
| 1746 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 1747 | :math:`|x|` Absolute value of `x`. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1748 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 1749 | :math:`\lceil x \rceil` Ceiling of `x`. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1750 | |
| 1751 | clamp(x,y,z) Clamp x between y and z. |
| 1752 | (x < y) ? y : (x > z) ? z : x |
| 1753 | |
Corbin Simpson | dd801e5 | 2009-12-21 19:41:09 -0800 | [diff] [blame] | 1754 | :math:`\lfloor x\rfloor` Floor of `x`. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1755 | |
Corbin Simpson | 14743ac | 2009-12-21 19:57:56 -0800 | [diff] [blame] | 1756 | :math:`\log_2{x}` Logarithm of `x`, base 2. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1757 | |
| 1758 | max(x,y) Maximum of x and y. |
| 1759 | (x > y) ? x : y |
| 1760 | |
| 1761 | min(x,y) Minimum of x and y. |
| 1762 | (x < y) ? x : y |
| 1763 | |
| 1764 | partialx(x) Derivative of x relative to fragment's X. |
| 1765 | |
| 1766 | partialy(x) Derivative of x relative to fragment's Y. |
| 1767 | |
| 1768 | pop() Pop from stack. |
| 1769 | |
Corbin Simpson | dd801e5 | 2009-12-21 19:41:09 -0800 | [diff] [blame] | 1770 | :math:`x^y` `x` to the power `y`. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1771 | |
| 1772 | push(x) Push x on stack. |
| 1773 | |
| 1774 | round(x) Round x. |
| 1775 | |
Michal Krol | 07f416c | 2010-01-04 13:21:32 +0100 | [diff] [blame] | 1776 | trunc(x) Truncate x, i.e. drop the fraction bits. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1777 | |
| 1778 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1779 | Keywords |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 1780 | ^^^^^^^^^^^^^ |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1781 | |
| 1782 | |
| 1783 | discard Discard fragment. |
| 1784 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1785 | pc Program counter. |
| 1786 | |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1787 | target Label of target instruction. |
| 1788 | |
| 1789 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1790 | Other tokens |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 1791 | --------------- |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1792 | |
| 1793 | |
Michal Krol | 63d6097 | 2010-02-03 15:45:32 +0100 | [diff] [blame] | 1794 | Declaration |
| 1795 | ^^^^^^^^^^^ |
| 1796 | |
| 1797 | |
| 1798 | Declares a register that is will be referenced as an operand in Instruction |
| 1799 | tokens. |
| 1800 | |
| 1801 | File field contains register file that is being declared and is one |
| 1802 | of TGSI_FILE. |
| 1803 | |
| 1804 | UsageMask field specifies which of the register components can be accessed |
| 1805 | and is one of TGSI_WRITEMASK. |
| 1806 | |
Francisco Jerez | 2644952 | 2012-03-18 19:21:36 +0100 | [diff] [blame] | 1807 | The Local flag specifies that a given value isn't intended for |
| 1808 | subroutine parameter passing and, as a result, the implementation |
| 1809 | isn't required to give any guarantees of it being preserved across |
| 1810 | subroutine boundaries. As it's merely a compiler hint, the |
| 1811 | implementation is free to ignore it. |
| 1812 | |
Michal Krol | 63d6097 | 2010-02-03 15:45:32 +0100 | [diff] [blame] | 1813 | If Dimension flag is set to 1, a Declaration Dimension token follows. |
| 1814 | |
| 1815 | If Semantic flag is set to 1, a Declaration Semantic token follows. |
| 1816 | |
Francisco Jerez | 1279923 | 2012-04-30 18:27:52 +0200 | [diff] [blame] | 1817 | If Interpolate flag is set to 1, a Declaration Interpolate token follows. |
Michal Krol | 63d6097 | 2010-02-03 15:45:32 +0100 | [diff] [blame] | 1818 | |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1819 | If file is TGSI_FILE_RESOURCE, a Declaration Resource token follows. |
| 1820 | |
Michal Krol | 63d6097 | 2010-02-03 15:45:32 +0100 | [diff] [blame] | 1821 | |
Corbin Simpson | da65ac6 | 2009-12-21 20:32:46 -0800 | [diff] [blame] | 1822 | Declaration Semantic |
Corbin Simpson | 5bcd26c | 2009-12-21 21:04:10 -0800 | [diff] [blame] | 1823 | ^^^^^^^^^^^^^^^^^^^^^^^^ |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1824 | |
Brian Paul | 05a18f4 | 2010-06-24 07:21:15 -0600 | [diff] [blame] | 1825 | Vertex and fragment shader input and output registers may be labeled |
| 1826 | with semantic information consisting of a name and index. |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1827 | |
| 1828 | Follows Declaration token if Semantic bit is set. |
| 1829 | |
| 1830 | Since its purpose is to link a shader with other stages of the pipeline, |
| 1831 | it is valid to follow only those Declaration tokens that declare a register |
| 1832 | either in INPUT or OUTPUT file. |
| 1833 | |
| 1834 | SemanticName field contains the semantic name of the register being declared. |
| 1835 | There is no default value. |
| 1836 | |
| 1837 | SemanticIndex is an optional subscript that can be used to distinguish |
| 1838 | different register declarations with the same semantic name. The default value |
| 1839 | is 0. |
| 1840 | |
| 1841 | The meanings of the individual semantic names are explained in the following |
| 1842 | sections. |
| 1843 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1844 | TGSI_SEMANTIC_POSITION |
| 1845 | """""""""""""""""""""" |
Keith Whitwell | a62aaa7 | 2009-12-21 23:25:15 +0000 | [diff] [blame] | 1846 | |
Brian Paul | 50b3f2e | 2010-06-23 17:00:10 -0600 | [diff] [blame] | 1847 | For vertex shaders, TGSI_SEMANTIC_POSITION indicates the vertex shader |
| 1848 | output register which contains the homogeneous vertex position in the clip |
| 1849 | space coordinate system. After clipping, the X, Y and Z components of the |
| 1850 | 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] | 1851 | |
Brian Paul | 50b3f2e | 2010-06-23 17:00:10 -0600 | [diff] [blame] | 1852 | For fragment shaders, TGSI_SEMANTIC_POSITION is used to indicate that |
| 1853 | fragment shader input contains the fragment's window position. The X |
| 1854 | component starts at zero and always increases from left to right. |
| 1855 | The Y component starts at zero and always increases but Y=0 may either |
| 1856 | indicate the top of the window or the bottom depending on the fragment |
| 1857 | coordinate origin convention (see TGSI_PROPERTY_FS_COORD_ORIGIN). |
| 1858 | The Z coordinate ranges from 0 to 1 to represent depth from the front |
| 1859 | to the back of the Z buffer. The W component contains the reciprocol |
| 1860 | of the interpolated vertex position W component. |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1861 | |
Brian Paul | 05a18f4 | 2010-06-24 07:21:15 -0600 | [diff] [blame] | 1862 | Fragment shaders may also declare an output register with |
| 1863 | TGSI_SEMANTIC_POSITION. Only the Z component is writable. This allows |
| 1864 | the fragment shader to change the fragment's Z position. |
| 1865 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1866 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1867 | |
| 1868 | TGSI_SEMANTIC_COLOR |
| 1869 | """"""""""""""""""" |
| 1870 | |
Brian Paul | 50b3f2e | 2010-06-23 17:00:10 -0600 | [diff] [blame] | 1871 | For vertex shader outputs or fragment shader inputs/outputs, this |
| 1872 | label indicates that the resister contains an R,G,B,A color. |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1873 | |
Brian Paul | 50b3f2e | 2010-06-23 17:00:10 -0600 | [diff] [blame] | 1874 | Several shader inputs/outputs may contain colors so the semantic index |
| 1875 | is used to distinguish them. For example, color[0] may be the diffuse |
| 1876 | color while color[1] may be the specular color. |
| 1877 | |
| 1878 | This label is needed so that the flat/smooth shading can be applied |
| 1879 | to the right interpolants during rasterization. |
| 1880 | |
| 1881 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1882 | |
| 1883 | TGSI_SEMANTIC_BCOLOR |
| 1884 | """""""""""""""""""" |
| 1885 | |
| 1886 | Back-facing colors are only used for back-facing polygons, and are only valid |
| 1887 | in vertex shader outputs. After rasterization, all polygons are front-facing |
Brian Paul | 50b3f2e | 2010-06-23 17:00:10 -0600 | [diff] [blame] | 1888 | and COLOR and BCOLOR end up occupying the same slots in the fragment shader, |
| 1889 | so all BCOLORs effectively become regular COLORs in the fragment shader. |
| 1890 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1891 | |
| 1892 | TGSI_SEMANTIC_FOG |
| 1893 | """"""""""""""""" |
| 1894 | |
Brian Paul | 05a18f4 | 2010-06-24 07:21:15 -0600 | [diff] [blame] | 1895 | Vertex shader inputs and outputs and fragment shader inputs may be |
| 1896 | labeled with TGSI_SEMANTIC_FOG to indicate that the register contains |
| 1897 | a fog coordinate in the form (F, 0, 0, 1). Typically, the fragment |
| 1898 | shader will use the fog coordinate to compute a fog blend factor which |
| 1899 | 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] | 1900 | |
Brian Paul | 05a18f4 | 2010-06-24 07:21:15 -0600 | [diff] [blame] | 1901 | Only the first component matters when writing from the vertex shader; |
| 1902 | the driver will ensure that the coordinate is in this format when used |
| 1903 | as a fragment shader input. |
| 1904 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1905 | |
| 1906 | TGSI_SEMANTIC_PSIZE |
| 1907 | """"""""""""""""""" |
| 1908 | |
Brian Paul | 05a18f4 | 2010-06-24 07:21:15 -0600 | [diff] [blame] | 1909 | Vertex shader input and output registers may be labeled with |
| 1910 | TGIS_SEMANTIC_PSIZE to indicate that the register contains a point size |
| 1911 | in the form (S, 0, 0, 1). The point size controls the width or diameter |
| 1912 | of points for rasterization. This label cannot be used in fragment |
| 1913 | shaders. |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1914 | |
| 1915 | When using this semantic, be sure to set the appropriate state in the |
| 1916 | :ref:`rasterizer` first. |
| 1917 | |
Brian Paul | 05a18f4 | 2010-06-24 07:21:15 -0600 | [diff] [blame] | 1918 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1919 | TGSI_SEMANTIC_GENERIC |
| 1920 | """"""""""""""""""""" |
| 1921 | |
Brian Paul | 05a18f4 | 2010-06-24 07:21:15 -0600 | [diff] [blame] | 1922 | All vertex/fragment shader inputs/outputs not labeled with any other |
| 1923 | semantic label can be considered to be generic attributes. Typical |
| 1924 | uses of generic inputs/outputs are texcoords and user-defined values. |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1925 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1926 | |
| 1927 | TGSI_SEMANTIC_NORMAL |
| 1928 | """""""""""""""""""" |
| 1929 | |
Brian Paul | 05a18f4 | 2010-06-24 07:21:15 -0600 | [diff] [blame] | 1930 | Indicates that a vertex shader input is a normal vector. This is |
| 1931 | typically only used for legacy graphics APIs. |
| 1932 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1933 | |
| 1934 | TGSI_SEMANTIC_FACE |
| 1935 | """""""""""""""""" |
| 1936 | |
Brian Paul | 05a18f4 | 2010-06-24 07:21:15 -0600 | [diff] [blame] | 1937 | This label applies to fragment shader inputs only and indicates that |
| 1938 | the register contains front/back-face information of the form (F, 0, |
| 1939 | 0, 1). The first component will be positive when the fragment belongs |
| 1940 | to a front-facing polygon, and negative when the fragment belongs to a |
| 1941 | back-facing polygon. |
| 1942 | |
Corbin Simpson | 54ddf64 | 2009-12-23 23:36:06 -0800 | [diff] [blame] | 1943 | |
| 1944 | TGSI_SEMANTIC_EDGEFLAG |
| 1945 | """""""""""""""""""""" |
| 1946 | |
Brian Paul | 7315300 | 2010-06-23 17:38:58 -0600 | [diff] [blame] | 1947 | For vertex shaders, this sematic label indicates that an input or |
| 1948 | output is a boolean edge flag. The register layout is [F, x, x, x] |
| 1949 | where F is 0.0 or 1.0 and x = don't care. Normally, the vertex shader |
| 1950 | simply copies the edge flag input to the edgeflag output. |
| 1951 | |
| 1952 | Edge flags are used to control which lines or points are actually |
| 1953 | drawn when the polygon mode converts triangles/quads/polygons into |
| 1954 | points or lines. |
| 1955 | |
Dave Airlie | 4ecb2c1 | 2010-10-06 09:28:46 +1000 | [diff] [blame] | 1956 | TGSI_SEMANTIC_STENCIL |
| 1957 | """""""""""""""""""""" |
| 1958 | |
| 1959 | For fragment shaders, this semantic label indicates than an output |
| 1960 | is a writable stencil reference value. Only the Y component is writable. |
| 1961 | This allows the fragment shader to change the fragments stencilref value. |
Luca Barbieri | 7331713 | 2010-01-21 05:36:14 +0100 | [diff] [blame] | 1962 | |
| 1963 | |
Francisco Jerez | 1279923 | 2012-04-30 18:27:52 +0200 | [diff] [blame] | 1964 | Declaration Interpolate |
| 1965 | ^^^^^^^^^^^^^^^^^^^^^^^ |
| 1966 | |
| 1967 | This token is only valid for fragment shader INPUT declarations. |
| 1968 | |
| 1969 | The Interpolate field specifes the way input is being interpolated by |
| 1970 | the rasteriser and is one of TGSI_INTERPOLATE_*. |
| 1971 | |
| 1972 | The CylindricalWrap bitfield specifies which register components |
| 1973 | should be subject to cylindrical wrapping when interpolating by the |
| 1974 | rasteriser. If TGSI_CYLINDRICAL_WRAP_X is set to 1, the X component |
| 1975 | should be interpolated according to cylindrical wrapping rules. |
| 1976 | |
| 1977 | |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1978 | Declaration Sampler View |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1979 | ^^^^^^^^^^^^^^^^^^^^^^^^ |
| 1980 | |
Francisco Jerez | a5f44cc | 2012-05-01 02:38:51 +0200 | [diff] [blame] | 1981 | Follows Declaration token if file is TGSI_FILE_SAMPLER_VIEW. |
| 1982 | |
| 1983 | DCL SVIEW[#], resource, type(s) |
| 1984 | |
| 1985 | Declares a shader input sampler view and assigns it to a SVIEW[#] |
| 1986 | register. |
| 1987 | |
| 1988 | resource can be one of BUFFER, 1D, 2D, 3D, 1DArray and 2DArray. |
| 1989 | |
| 1990 | type must be 1 or 4 entries (if specifying on a per-component |
| 1991 | level) out of UNORM, SNORM, SINT, UINT and FLOAT. |
| 1992 | |
| 1993 | |
| 1994 | Declaration Resource |
| 1995 | ^^^^^^^^^^^^^^^^^^^^ |
| 1996 | |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 1997 | Follows Declaration token if file is TGSI_FILE_RESOURCE. |
| 1998 | |
Francisco Jerez | b8e808f | 2012-04-30 20:20:29 +0200 | [diff] [blame] | 1999 | DCL RES[#], resource [, WR] [, RAW] |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 2000 | |
| 2001 | Declares a shader input resource and assigns it to a RES[#] |
| 2002 | register. |
| 2003 | |
| 2004 | resource can be one of BUFFER, 1D, 2D, 3D, CUBE, 1DArray and |
| 2005 | 2DArray. |
| 2006 | |
Francisco Jerez | 82c90b2 | 2012-04-30 19:08:55 +0200 | [diff] [blame] | 2007 | If the RAW keyword is not specified, the texture data will be |
| 2008 | subject to conversion, swizzling and scaling as required to yield |
| 2009 | the specified data type from the physical data format of the bound |
| 2010 | resource. |
| 2011 | |
| 2012 | If the RAW keyword is specified, no channel conversion will be |
| 2013 | performed: the values read for each of the channels (X,Y,Z,W) will |
| 2014 | correspond to consecutive words in the same order and format |
| 2015 | they're found in memory. No element-to-address conversion will be |
| 2016 | performed either: the value of the provided X coordinate will be |
| 2017 | interpreted in byte units instead of texel units. The result of |
| 2018 | accessing a misaligned address is undefined. |
| 2019 | |
Francisco Jerez | b8e808f | 2012-04-30 20:20:29 +0200 | [diff] [blame] | 2020 | Usage of the STORE opcode is only allowed if the WR (writable) flag |
| 2021 | is set. |
| 2022 | |
Zack Rusin | bdbe77f | 2011-01-24 17:47:10 -0500 | [diff] [blame] | 2023 | |
Luca Barbieri | 7331713 | 2010-01-21 05:36:14 +0100 | [diff] [blame] | 2024 | Properties |
| 2025 | ^^^^^^^^^^^^^^^^^^^^^^^^ |
| 2026 | |
| 2027 | |
| 2028 | Properties are general directives that apply to the whole TGSI program. |
| 2029 | |
| 2030 | FS_COORD_ORIGIN |
| 2031 | """"""""""""""" |
| 2032 | |
| 2033 | Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin. |
| 2034 | The default value is UPPER_LEFT. |
| 2035 | |
| 2036 | If UPPER_LEFT, the position will be (0,0) at the upper left corner and |
| 2037 | increase downward and rightward. |
| 2038 | If LOWER_LEFT, the position will be (0,0) at the lower left corner and |
| 2039 | increase upward and rightward. |
| 2040 | |
| 2041 | OpenGL defaults to LOWER_LEFT, and is configurable with the |
| 2042 | GL_ARB_fragment_coord_conventions extension. |
| 2043 | |
| 2044 | DirectX 9/10 use UPPER_LEFT. |
| 2045 | |
| 2046 | FS_COORD_PIXEL_CENTER |
| 2047 | """"""""""""""""""""" |
| 2048 | |
| 2049 | Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention. |
| 2050 | The default value is HALF_INTEGER. |
| 2051 | |
| 2052 | If HALF_INTEGER, the fractionary part of the position will be 0.5 |
| 2053 | If INTEGER, the fractionary part of the position will be 0.0 |
| 2054 | |
| 2055 | Note that this does not affect the set of fragments generated by |
| 2056 | rasterization, which is instead controlled by gl_rasterization_rules in the |
| 2057 | rasterizer. |
| 2058 | |
| 2059 | OpenGL defaults to HALF_INTEGER, and is configurable with the |
| 2060 | GL_ARB_fragment_coord_conventions extension. |
| 2061 | |
| 2062 | DirectX 9 uses INTEGER. |
| 2063 | DirectX 10 uses HALF_INTEGER. |
Brian Paul | 4778f46 | 2010-02-02 08:14:40 -0700 | [diff] [blame] | 2064 | |
Dave Airlie | c9c8a5e | 2010-12-18 10:34:35 +1000 | [diff] [blame] | 2065 | FS_COLOR0_WRITES_ALL_CBUFS |
| 2066 | """""""""""""""""""""""""" |
| 2067 | Specifies that writes to the fragment shader color 0 are replicated to all |
| 2068 | bound cbufs. This facilitates OpenGL's fragColor output vs fragData[0] where |
| 2069 | fragData is directed to a single color buffer, but fragColor is broadcast. |
Brian Paul | 4778f46 | 2010-02-02 08:14:40 -0700 | [diff] [blame] | 2070 | |
Marek Olšák | dc4c821 | 2012-01-10 00:19:00 +0100 | [diff] [blame] | 2071 | VS_PROHIBIT_UCPS |
| 2072 | """""""""""""""""""""""""" |
| 2073 | If this property is set on the program bound to the shader stage before the |
| 2074 | fragment shader, user clip planes should have no effect (be disabled) even if |
| 2075 | that shader does not write to any clip distance outputs and the rasterizer's |
| 2076 | clip_plane_enable is non-zero. |
| 2077 | This property is only supported by drivers that also support shader clip |
| 2078 | distance outputs. |
| 2079 | This is useful for APIs that don't have UCPs and where clip distances written |
| 2080 | by a shader cannot be disabled. |
| 2081 | |
Brian Paul | 4778f46 | 2010-02-02 08:14:40 -0700 | [diff] [blame] | 2082 | |
| 2083 | Texture Sampling and Texture Formats |
| 2084 | ------------------------------------ |
| 2085 | |
Corbin Simpson | 797dcc0 | 2010-02-02 17:07:26 -0800 | [diff] [blame] | 2086 | This table shows how texture image components are returned as (x,y,z,w) tuples |
| 2087 | by TGSI texture instructions, such as :opcode:`TEX`, :opcode:`TXD`, and |
| 2088 | :opcode:`TXP`. For reference, OpenGL and Direct3D conventions are shown as |
| 2089 | well. |
Brian Paul | 4778f46 | 2010-02-02 08:14:40 -0700 | [diff] [blame] | 2090 | |
Corbin Simpson | 516e715 | 2010-02-02 12:44:22 -0800 | [diff] [blame] | 2091 | +--------------------+--------------+--------------------+--------------+ |
| 2092 | | Texture Components | Gallium | OpenGL | Direct3D 9 | |
| 2093 | +====================+==============+====================+==============+ |
Corbin Simpson | 92867dc | 2010-06-16 16:56:55 -0700 | [diff] [blame] | 2094 | | 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] | 2095 | +--------------------+--------------+--------------------+--------------+ |
Corbin Simpson | 92867dc | 2010-06-16 16:56:55 -0700 | [diff] [blame] | 2096 | | 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] | 2097 | +--------------------+--------------+--------------------+--------------+ |
| 2098 | | RGB | (r, g, b, 1) | (r, g, b, 1) | (r, g, b, 1) | |
| 2099 | +--------------------+--------------+--------------------+--------------+ |
| 2100 | | RGBA | (r, g, b, a) | (r, g, b, a) | (r, g, b, a) | |
| 2101 | +--------------------+--------------+--------------------+--------------+ |
| 2102 | | A | (0, 0, 0, a) | (0, 0, 0, a) | (0, 0, 0, a) | |
| 2103 | +--------------------+--------------+--------------------+--------------+ |
| 2104 | | L | (l, l, l, 1) | (l, l, l, 1) | (l, l, l, 1) | |
| 2105 | +--------------------+--------------+--------------------+--------------+ |
| 2106 | | LA | (l, l, l, a) | (l, l, l, a) | (l, l, l, a) | |
| 2107 | +--------------------+--------------+--------------------+--------------+ |
| 2108 | | I | (i, i, i, i) | (i, i, i, i) | N/A | |
| 2109 | +--------------------+--------------+--------------------+--------------+ |
| 2110 | | UV | XXX TBD | (0, 0, 0, 1) | (u, v, 1, 1) | |
| 2111 | | | | [#envmap-bumpmap]_ | | |
| 2112 | +--------------------+--------------+--------------------+--------------+ |
Brian Paul | 3e572eb | 2010-02-02 16:27:07 -0700 | [diff] [blame] | 2113 | | Z | XXX TBD | (z, z, z, 1) | (0, z, 0, 1) | |
Corbin Simpson | 516e715 | 2010-02-02 12:44:22 -0800 | [diff] [blame] | 2114 | | | | [#depth-tex-mode]_ | | |
| 2115 | +--------------------+--------------+--------------------+--------------+ |
Dave Airlie | 66a0d1e | 2010-10-06 09:30:17 +1000 | [diff] [blame] | 2116 | | S | (s, s, s, s) | unknown | unknown | |
| 2117 | +--------------------+--------------+--------------------+--------------+ |
Brian Paul | 4778f46 | 2010-02-02 08:14:40 -0700 | [diff] [blame] | 2118 | |
Corbin Simpson | 516e715 | 2010-02-02 12:44:22 -0800 | [diff] [blame] | 2119 | .. [#envmap-bumpmap] http://www.opengl.org/registry/specs/ATI/envmap_bumpmap.txt |
Brian Paul | 3e572eb | 2010-02-02 16:27:07 -0700 | [diff] [blame] | 2120 | .. [#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] | 2121 | or (z, z, z, z) depending on the value of GL_DEPTH_TEXTURE_MODE. |