RetroArch
gx2_shader_inl.h
Go to the documentation of this file.
1 /* RetroArch - A frontend for libretro.
2  * Copyright (C) 2014-2016 - Ali Bouhlel
3  *
4  * RetroArch is free software: you can redistribute it and/or modify it under the terms
5  * of the GNU General Public License as published by the Free Software Found-
6  * ation, either version 3 of the License, or (at your option) any later version.
7  *
8  * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10  * PURPOSE. See the GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License along with RetroArch.
13  * If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16 #ifndef GX2_SHADER_INL_H
17 #define GX2_SHADER_INL_H
18 
19 #ifdef MSB_FIRST
20 #define to_QWORD(w0, w1) (((u64)(w0) << 32ull) | (w1))
21 #define to_LE(x) (__builtin_bswap32(x))
22 #else
23 #define to_QWORD(w0, w1) (((u64)(w1) << 32ull) | (w0))
24 #define to_LE(x) (x)
25 #endif
26 
27 /* CF */
28 #define CF_DWORD0(addr) to_LE(addr)
29 
30 #define CF_DWORD1(popCount, cfConst, cond, count, callCount, inst) \
31  to_LE(popCount | (cfConst << 3) | (cond << 8) | (count << 10) | (callCount << 13) | (inst << 23) | (1 << 31))
32 
33 #define CF_ALU_WORD0(addr, kcacheBank0, kcacheBank1, kcacheMode0) \
34  to_LE(addr | (kcacheBank0 << 22) | (kcacheBank1 << 26) | (kcacheMode0 << 30))
35 #define CF_ALU_WORD1(kcacheMode1, kcacheAddr0, kcacheAddr1, count, altConst, inst) \
36  to_LE(kcacheMode1 | (kcacheAddr0 << 2) | (kcacheAddr1 << 10) | (count << 18) | (altConst << 25) | (inst << 26) | (1 << 31))
37 
38 #define CF_EXP_WORD0(dstReg_and_type, srcReg, srcRel, indexGpr, elemSize)\
39  to_LE(dstReg_and_type | (srcReg << 15) | (srcRel << 22) | (indexGpr << 23) | (elemSize << 30))
40 
41 #define CF_EXP_WORD1(srcSelX, srcSelY, srcSelZ, srcSelW, validPixelMode, inst) \
42  to_LE(srcSelX | (srcSelY << 3) | (srcSelZ << 6) | (srcSelW << 9) | (validPixelMode << 22) | (inst << 23) | (1 << 31))
43 
44 #define CF_ALLOC_EXPORT_WORD0(arrayBase, type, dstReg, dstRel, indexGpr, elemSize) \
45  to_LE(arrayBase | (type << 13) | (dstReg << 15) | (dstRel << 22) | (indexGpr << 23) | (elemSize << 30))
46 
47 #define CF_ALLOC_EXPORT_WORD1_BUF(arraySize, writeMask, inst) \
48  to_LE(arraySize | (writeMask << 12) | (inst << 23) | (1 << 31))
49 
50 
51 #define ALU_SRC_KCACHE0_BASE 0x80
52 #define ALU_SRC_KCACHE1_BASE 0xA0
53 #define CF_KCACHE_BANK_LOCK_1 0x1
54 #define CB1 0x1
55 #define CB2 0x2
56 #define _0_15 CF_KCACHE_BANK_LOCK_1
57 
58 #define KC0(x) (x + ALU_SRC_KCACHE0_BASE)
59 #define KC1(x) (x + ALU_SRC_KCACHE1_BASE)
60 
61 #define NO_BARRIER & ~to_QWORD(0,to_LE(1 << 31))
62 #define END_OF_PROGRAM | to_QWORD(0,to_LE(1 << 21))
63 #define VALID_PIX | to_QWORD(0,to_LE(1 << 22))
64 #define WHOLE_QUAD_MODE | to_QWORD(0,to_LE(1 << 30))
65 #define BURSTCNT(x) | to_QWORD(0,to_LE(x << 17))
66 #define WRITE(x) (x >> 2)
67 #define ARRAY_SIZE(x) x
68 #define ELEM_SIZE(x) x
69 #define KCACHE0(bank, mode) | to_QWORD(CF_ALU_WORD0(0, bank, 0, mode), 0)
70 #define KCACHE1(bank, mode) | to_QWORD(CF_ALU_WORD0(0, 0, bank, 0), CF_ALU_WORD1(mode,0, 0, 0, 0, 0))
71 
72 
73 #define DEACTIVATE 1
74 #define UPDATE_EXEC_MASK(mode) | to_QWORD(0, to_LE(mode << 2))
75 #define UPDATE_PRED | to_QWORD(0, to_LE(1ull << 3))
76 #define CLAMP | to_QWORD(0, to_LE(1ull << 31))
77 #define ALU_LAST | to_QWORD(to_LE(1ull << 31), 0)
78 
79 /* ALU */
80 
81 #define ALU_WORD0(src0Sel, src0Rel, src0Chan, src0Neg, src1Sel, src1Rel, src1Chan, src1Neg, indexMode, predSel) \
82  to_LE(src0Sel | ((src0Rel) << 9) | ((src0Chan) << 10) | ((src0Neg) << 12) | ((src1Sel) << 13) | ((src1Rel) << 22) \
83  | ((src1Chan) << 23) | ((src1Neg) << 25) | ((indexMode) << 26) | ((predSel) << 29))
84 
85 #define ALU_WORD1_OP2(src0Abs, src1Abs, updateExecuteMask, updatePred, writeMask, omod, inst, encoding, bankSwizzle, dstGpr, dstRel, dstChan, clamp) \
86  to_LE(src0Abs | (src1Abs << 1) | (updateExecuteMask << 2) | (updatePred << 3) | (writeMask << 4) | (omod << 5) | (inst << 7) | \
87  (encoding << 15) | (bankSwizzle << 18) | ((dstGpr&0x7F) << 21) | (dstRel << 28) | ((dstChan&0x3) << 29) | (clamp << 31))
88 
89 #define ALU_WORD1_OP3(src2Sel, src2Rel, src2Chan, src2Neg, inst, bankSwizzle, dstGpr, dstRel, dstChan, clamp) \
90  to_LE(src2Sel | (src2Rel << 9) | (src2Chan << 10) | (src2Neg << 12) | (inst << 13) | \
91  (bankSwizzle << 18) | ((dstGpr&0x7F) << 21) | (dstRel << 28) | ((dstChan&0x3) << 29) | (clamp << 31))
92 
93 /* TEX */
94 #define TEX_WORD0(inst, bcFracMode, fetchWholeQuad, resourceID, srcReg, srcRel, altConst) \
95  to_LE(inst | (bcFracMode << 5) | (fetchWholeQuad << 7) | (resourceID << 8) | (srcReg << 16) | (srcRel << 23) | (altConst << 24))
96 
97 #define TEX_WORD1(dstReg, dstRel, dstSelX, dstSelY, dstSelZ, dstSelW, lodBias, coordTypeX, coordTypeY, coordTypeZ, coordTypeW) \
98  to_LE(dstReg | (dstRel << 7) | (dstSelX << 9) | (dstSelY << 12) | (dstSelZ << 15) | (dstSelW << 18) | \
99  (lodBias << 21) | (coordTypeX << 28) | (coordTypeY << 29) | (coordTypeZ << 30) | (coordTypeW << 31))
100 
101 #define TEX_WORD2(offsetX, offsetY, offsetZ, samplerID, srcSelX, srcSelY, srcSelZ, srcSelW) \
102  to_LE(offsetX | (offsetY << 5) | (offsetZ << 10) | (samplerID << 15) | (srcSelX << 20) | (srcSelY << 23) | (srcSelZ << 26) | (srcSelW << 29))
103 
104 #define VTX_WORD0(inst, type, buffer_id, srcReg, srcSelX, mega) \
105  to_LE(inst | (type << 5) | (buffer_id << 8) | (srcReg << 16) | (srcSelX << 24) | (mega << 26))
106 
107 #define VTX_WORD1(dstReg, dstSelX, dstSelY, dstSelZ, dstSelW) \
108  to_LE(dstReg | (dstSelX << 9) | (dstSelY << 12) | (dstSelZ << 15) | (dstSelW << 18) | (1 << 21))
109 
110 #define VTX_WORD2(offset, ismega) \
111  to_LE(offset| (ismega << 19))
112 
113 #define _x 0
114 #define _y 1
115 #define _z 2
116 #define _w 3
117 #define _0 4
118 #define _1 5
119 #define _m 7 /*mask*/
120 
121 #define _xyzw 0b1111
122 #define _xy__ 0b0011
123 
124 #define GX2_COMP_SEL(c0, c1, c2, c3) (((c0) << 24) | ((c1) << 16) | ((c2) << 8) | (c3))
125 
126 #define ALU_LITERAL(v) to_QWORD(to_LE(v), 0)
127 #define ALU_LITERAL2(v0,v1) to_QWORD(to_LE(v0), to_LE(v1))
128 #define ALU_LITERAL3(v0,v1,v2) ALU_LITERAL2(v0,v1),ALU_LITERAL(v2)
129 #define ALU_LITERAL4(v0,v1,v2,v3) ALU_LITERAL2(v0,v1),ALU_LITERAL2(v2,v3)
130 #define ALU_LITERAL5(v0,v1,v2,v3,v5) ALU_LITERAL4(v0,v1,v2,v3),ALU_LITERAL(v4)
131 
132 /* SRCx_SEL special constants */
133 #define ALU_SRC_1_DBL_L 0xF4
134 #define ALU_SRC_1_DBL_M 0xF5
135 #define ALU_SRC_0_5_DBL_L 0xF6
136 #define ALU_SRC_0_5_DBL_M 0xF7
137 #define ALU_SRC_0 0xF8
138 #define ALU_SRC_1 0xF9
139 #define ALU_SRC_1_INT 0xFA
140 #define ALU_SRC_M_1_INT 0xFB
141 #define ALU_SRC_0_5 0xFC
142 #define ALU_SRC_LITERAL 0xFD
143 #define ALU_SRC_PV 0xFE
144 #define ALU_SRC_PS 0xFF
145 
146 #define _NEG | (1 << 12)
147 #define _ABS | (1 << 13)
148 
149 #define ALU_OMOD_OFF 0x0
150 #define ALU_OMOD_M2 0x1
151 #define ALU_OMOD_M4 0x2
152 #define ALU_OMOD_D2 0x3
153 
154 #define ALU_VEC_012 0x0
155 #define ALU_VEC_021 0x1
156 #define ALU_VEC_120 0x2
157 #define ALU_VEC_102 0x3
158 #define ALU_VEC_201 0x4
159 #define ALU_VEC_210 0x5
160 #define VEC_012 | to_QWORD(0, to_LE(ALU_VEC_012 << 18))
161 #define VEC_021 | to_QWORD(0, to_LE(ALU_VEC_021 << 18))
162 #define VEC_120 | to_QWORD(0, to_LE(ALU_VEC_120 << 18))
163 #define VEC_102 | to_QWORD(0, to_LE(ALU_VEC_102 << 18))
164 #define VEC_201 | to_QWORD(0, to_LE(ALU_VEC_201 << 18))
165 #define VEC_210 | to_QWORD(0, to_LE(ALU_VEC_210 << 18))
166 
167 #define VALID_PIX | to_QWORD(0,to_LE(1 << 22))
168 
169 #define ALU_SCL_210 0x0
170 #define ALU_SCL_122 0x1
171 #define ALU_SCL_212 0x2
172 #define ALU_SCL_221 0x3
173 
174 #define SCL_210 | to_QWORD(0, to_LE(ALU_SCL_210 << 18))
175 #define SCL_122 | to_QWORD(0, to_LE(ALU_SCL_122 << 18))
176 #define SCL_212 | to_QWORD(0, to_LE(ALU_SCL_212 << 18))
177 #define SCL_221 | to_QWORD(0, to_LE(ALU_SCL_221 << 18))
178 
179 
180 #define FETCH_TYPE(x) x
181 #define MINI(x) ((x) - 1)
182 #define MEGA(x) (MINI(x) | 0x80000000)
183 #define OFFSET(x) x
184 
185 #define VERTEX_DATA 0
186 #define INSTANCE_DATA 1
187 #define NO_INDEX_OFFSET 2
188 
189 
190 /* CF defines */
191 #define CF_COND_ACTIVE 0x0
192 #define CF_COND_FALSE 0x1
193 #define CF_COND_BOOL 0x2
194 #define CF_COND_NOT_BOOL 0x3
195 
196 /* TEX defines */
197 #define TEX_UNNORMALIZED 0x0
198 #define TEX_NORMALIZED 0x1
199 
200 /* instructions */
201 /* CF */
202 #define CF_INST_TEX 0x01
203 #define CF_INST_VTX 0x02
204 #define CF_INST_JUMP 0x0A
205 #define CF_INST_ELSE 0x0D
206 #define CF_INST_CALL_FS 0x13
207 #define CF_INST_EMIT_VERTEX 0x15
208 #define CF_INST_MEM_RING 0x26
209 
210 #define CF_INST_ALU 0x08
211 #define CF_INST_ALU_PUSH_BEFORE 0x09
212 #define CF_INST_ALU_POP_AFTER 0x0A
213 /* ALU */
214 #define OP2_INST_ADD 0x0
215 #define OP2_INST_MUL 0x1
216 #define OP2_INST_MUL_IEEE 0x2
217 #define OP2_INST_MIN 0x04
218 #define OP2_INST_MAX 0x03
219 #define OP2_INST_MAX_DX10 0x05
220 #define OP2_INST_FRACT 0x10
221 #define OP2_INST_SETGT 0x09
222 #define OP2_INST_SETE_DX10 0x0C
223 #define OP2_INST_SETGT_DX10 0x0D
224 #define OP2_INST_FLOOR 0x14
225 #define OP2_INST_MOV 0x19
226 #define OP2_INST_PRED_SETGT 0x21
227 #define OP2_INST_PRED_SETE_INT 0x42
228 #define OP2_INST_DOT4 0x50
229 #define OP2_INST_DOT4_IEEE 0x51
230 #define OP2_INST_RECIP_IEEE 0x66
231 #define OP2_INST_RECIPSQRT_IEEE 0x69
232 #define OP2_INST_SQRT_IEEE 0x6A
233 #define OP2_INST_SIN 0x6E
234 #define OP2_INST_COS 0x6F
235 
236 #define OP3_INST_MULADD 0x10
237 #define OP3_INST_CNDGT 0x19
238 #define OP3_INST_CNDE_INT 0x1C
239 /* EXP */
240 #define CF_INST_EXP 0x27
241 #define CF_INST_EXP_DONE 0x28
242 
243 /* TEX */
244 #define TEX_INST_GET_GRADIENTS_H 0x07
245 #define TEX_INST_GET_GRADIENTS_V 0x08
246 #define TEX_INST_SAMPLE 0x10
247 
248 /* VTX */
249 #define VTX_INST_FETCH 0x0
250 
251 /* EXPORT_TYPE */
252 #define EXPORT_TYPE_PIXEL 0x0
253 #define EXPORT_TYPE_POS 0x1
254 #define EXPORT_TYPE_PARAM 0x2
255 
256 #define EXPORT_ARRAY_BASE_POS(id) (0x3C + id) /* [0, 3] */
257 #define EXPORT_ARRAY_BASE_PARAM(id) id /* [0, 31] */
258 #define EXPORT_ARRAY_BASE_PIX(id) id
259 
260 /* exports */
261 #define POS(id) EXPORT_ARRAY_BASE_POS(id) | (EXPORT_TYPE_POS << 13)
262 #define PARAM(id) EXPORT_ARRAY_BASE_PARAM(id) | (EXPORT_TYPE_PARAM << 13)
263 #define PIX(id) EXPORT_ARRAY_BASE_PIX(id) | (EXPORT_TYPE_PIXEL << 13)
264 #define POS0 POS(0)
265 #define PARAM0 PARAM(0)
266 #define PARAM1 PARAM(1)
267 #define PIX0 PIX(0)
268 
269 /* registers */
270 #define __ (0x80) /* invalid regitser (write mask off) */
271 #define _R(x) x
272 #define _R0 _R(0x0)
273 #define _R1 _R(0x1)
274 #define _R2 _R(0x2)
275 #define _R3 _R(0x3)
276 #define _R4 _R(0x4)
277 #define _R5 _R(0x5)
278 #define _R6 _R(0x6)
279 #define _R7 _R(0x7)
280 #define _R8 _R(0x8)
281 #define _R9 _R(0x9)
282 #define _R10 _R(0xA)
283 #define _R11 _R(0xB)
284 #define _R12 _R(0xC)
285 #define _R13 _R(0xD)
286 #define _R14 _R(0xE)
287 #define _R15 _R(0xF)
288 
289 #define _R120 _R(0x78)
290 #define _R121 _R(0x79)
291 #define _R122 _R(0x7A)
292 #define _R123 _R(0x7B)
293 #define _R124 _R(0x7C)
294 #define _R125 _R(0x7D)
295 #define _R126 _R(0x7E)
296 #define _R127 _R(0x7F)
297 
298 
299 /* texture */
300 #define _t(x) x
301 #define _t0 _t(0x0)
302 
303 /* sampler */
304 #define _s(x) x
305 #define _s0 _s(0x0)
306 
307 #define _b(x) x
308 
309 
310 #define CALL_FS to_QWORD(CF_DWORD0(0), CF_DWORD1(0,0,0,0,0,CF_INST_CALL_FS))
311 
312 #define TEX(addr, cnt) to_QWORD(CF_DWORD0(addr), CF_DWORD1(0x0, 0x0, CF_COND_ACTIVE, (cnt - 1), 0x0, CF_INST_TEX))
313 #define VTX(addr, cnt) to_QWORD(CF_DWORD0(addr), CF_DWORD1(0x0, 0x0, CF_COND_ACTIVE, (cnt - 1), 0x0, CF_INST_VTX))
314 #define JUMP(popCount, addr) to_QWORD(CF_DWORD0(addr), CF_DWORD1(popCount, 0x0, CF_COND_ACTIVE, 0x0, 0x0, CF_INST_JUMP))
315 #define ELSE(popCount, addr) to_QWORD(CF_DWORD0(addr), CF_DWORD1(popCount, 0x0, CF_COND_ACTIVE, 0x0, 0x0, CF_INST_ELSE))
316 
317 #define ALU(addr, cnt) to_QWORD(CF_ALU_WORD0(addr, 0x0, 0x0, 0x0), CF_ALU_WORD1(0x0, 0x0, 0x0, (cnt - 1), 0x0, CF_INST_ALU))
318 #define ALU_PUSH_BEFORE(addr, cnt) to_QWORD(CF_ALU_WORD0(addr, 0x0, 0x0, 0x0), CF_ALU_WORD1(0x0, 0x0, 0x0, (cnt - 1), 0x0, CF_INST_ALU_PUSH_BEFORE))
319 #define ALU_POP_AFTER(addr, cnt) to_QWORD(CF_ALU_WORD0(addr, 0x0, 0x0, 0x0), CF_ALU_WORD1(0x0, 0x0, 0x0, (cnt - 1), 0x0, CF_INST_ALU_POP_AFTER))
320 
321 #define EXP_DONE(dstReg_and_type, srcReg, srcSelX, srcSelY, srcSelZ, srcSelW) to_QWORD(CF_EXP_WORD0(dstReg_and_type, srcReg, 0x0, 0x0, 0x0), \
322  CF_EXP_WORD1(srcSelX, srcSelY, srcSelZ, srcSelW, 0x0, CF_INST_EXP_DONE))
323 
324 #define EXP(dstReg_and_type, srcReg, srcSelX, srcSelY, srcSelZ, srcSelW) to_QWORD(CF_EXP_WORD0(dstReg_and_type, srcReg, 0x0, 0x0, 0x0), \
325  CF_EXP_WORD1(srcSelX, srcSelY, srcSelZ, srcSelW, 0x0, CF_INST_EXP))
326 
327 #define MEM_RING(arrayBase, dstReg, writeMask, arraySize, elemSize) \
328  to_QWORD(CF_ALLOC_EXPORT_WORD0(arrayBase, 0x00, dstReg, 0x00, 0x00, elemSize), \
329  CF_ALLOC_EXPORT_WORD1_BUF(arraySize, writeMask, CF_INST_MEM_RING))
330 
331 #define EMIT_VERTEX to_QWORD(0, CF_DWORD1(0, 0, 0, 0, 0, CF_INST_EMIT_VERTEX))
332 
333 #define ALU_OP2(inst, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, omod) \
334  to_QWORD(ALU_WORD0(((src0Sel) & ((1 << 13) - 1)), 0x0, src0Chan, 0x0, ((src1Sel) & ((1 << 13) - 1)), 0x0, src1Chan, 0x0, 0x0, 0x0), \
335  ALU_WORD1_OP2(((src0Sel) >> 13), ((src1Sel) >> 13), 0x0, 0x0, (((dstGpr&__) >> 7) ^ 0x1), omod, inst, 0x0, 0x0, dstGpr, 0x0, dstChan, 0x0))
336 
337 #define ALU_OP3(inst, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, src2Sel, src2Chan) \
338  to_QWORD(ALU_WORD0(src0Sel, 0x0, src0Chan, 0x0, src1Sel, 0x0, src1Chan, 0x0, 0x0, 0x0), \
339  ALU_WORD1_OP3(src2Sel, 0x0, src2Chan, 0x0, inst, 0x0, dstGpr, 0x0, dstChan, 0x0))
340 
341 #define ALU_ADD(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
342  ALU_OP2(OP2_INST_ADD, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
343 
344 #define ALU_ADD_x2(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
345  ALU_OP2(OP2_INST_ADD, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_M2)
346 
347 #define ALU_ADD_D2(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
348  ALU_OP2(OP2_INST_ADD, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_D2)
349 
350 #define ALU_MUL(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
351  ALU_OP2(OP2_INST_MUL, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
352 
353 #define ALU_MUL_x2(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
354  ALU_OP2(OP2_INST_MUL, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_M2)
355 
356 #define ALU_MUL_x4(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
357  ALU_OP2(OP2_INST_MUL, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_M4)
358 
359 #define ALU_MUL_IEEE(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
360  ALU_OP2(OP2_INST_MUL_IEEE, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
361 
362 #define ALU_MUL_IEEE_x2(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
363  ALU_OP2(OP2_INST_MUL_IEEE, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_M2)
364 
365 #define ALU_MUL_IEEE_x4(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
366  ALU_OP2(OP2_INST_MUL_IEEE, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_M4)
367 
368 #define ALU_FRACT(dstGpr, dstChan, src0Sel, src0Chan) \
369  ALU_OP2(OP2_INST_FRACT, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
370 
371 #define ALU_FLOOR(dstGpr, dstChan, src0Sel, src0Chan) \
372  ALU_OP2(OP2_INST_FLOOR, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
373 
374 #define ALU_SQRT_IEEE(dstGpr, dstChan, src0Sel, src0Chan) \
375  ALU_OP2(OP2_INST_SQRT_IEEE, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
376 
377 #define ALU_SQRT_IEEE_D2(dstGpr, dstChan, src0Sel, src0Chan) \
378  ALU_OP2(OP2_INST_SQRT_IEEE, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_D2)
379 
380 #define ALU_MOV(dstGpr, dstChan, src0Sel, src0Chan) \
381  ALU_OP2(OP2_INST_MOV, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
382 
383 #define ALU_MOV_D2(dstGpr, dstChan, src0Sel, src0Chan) \
384  ALU_OP2(OP2_INST_MOV, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_D2)
385 
386 #define ALU_MOV_x2(dstGpr, dstChan, src0Sel, src0Chan) \
387  ALU_OP2(OP2_INST_MOV, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_M2)
388 
389 #define ALU_MOV_x4(dstGpr, dstChan, src0Sel, src0Chan) \
390  ALU_OP2(OP2_INST_MOV, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_M4)
391 
392 #define ALU_DOT4_IEEE(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
393  ALU_OP2(OP2_INST_DOT4_IEEE, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
394 
395 #define ALU_DOT4(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
396  ALU_OP2(OP2_INST_DOT4, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
397 
398 #define ALU_PRED_SETGT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
399  ALU_OP2(OP2_INST_PRED_SETGT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
400 
401 #define ALU_SETE_DX10(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
402  ALU_OP2(OP2_INST_SETE_DX10, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
403 
404 #define ALU_SETGT_DX10(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
405  ALU_OP2(OP2_INST_SETGT_DX10, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
406 
407 #define ALU_SETGT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
408  ALU_OP2(OP2_INST_SETGT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
409 
410 #define ALU_PRED_SETE_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
411  ALU_OP2(OP2_INST_PRED_SETE_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
412 
413 #define ALU_MIN(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
414  ALU_OP2(OP2_INST_MIN, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
415 
416 #define ALU_MAX(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
417  ALU_OP2(OP2_INST_MAX, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
418 
419 #define ALU_MAX_DX10(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan) \
420  ALU_OP2(OP2_INST_MAX_DX10, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, ALU_OMOD_OFF)
421 
422 #define ALU_RECIP_IEEE(dstGpr, dstChan, src0Sel, src0Chan) \
423  ALU_OP2(OP2_INST_RECIP_IEEE, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
424 
425 #define ALU_RECIPSQRT_IEEE(dstGpr, dstChan, src0Sel, src0Chan) \
426  ALU_OP2(OP2_INST_RECIPSQRT_IEEE, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
427 
428 #define ALU_SIN(dstGpr, dstChan, src0Sel, src0Chan) \
429  ALU_OP2(OP2_INST_SIN, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
430 
431 #define ALU_COS(dstGpr, dstChan, src0Sel, src0Chan) \
432  ALU_OP2(OP2_INST_COS, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_OFF)
433 
434 #define ALU_COS_D2(dstGpr, dstChan, src0Sel, src0Chan) \
435  ALU_OP2(OP2_INST_COS, dstGpr, dstChan, src0Sel, src0Chan, ALU_SRC_0, 0x0, ALU_OMOD_D2)
436 
437 #define ALU_MULADD(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, src2Sel, src2Chan) \
438  ALU_OP3(OP3_INST_MULADD, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, src2Sel, src2Chan)
439 
440 #define ALU_CNDGT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, src2Sel, src2Chan) \
441  ALU_OP3(OP3_INST_CNDGT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, src2Sel, src2Chan)
442 
443 #define ALU_CNDE_INT(dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, src2Sel, src2Chan) \
444  ALU_OP3(OP3_INST_CNDE_INT, dstGpr, dstChan, src0Sel, src0Chan, src1Sel, src1Chan, src2Sel, src2Chan)
445 
446 #define TEX_SAMPLE(dstReg, dstSelX, dstSelY, dstSelZ, dstSelW, srcReg, srcSelX, srcSelY, srcSelZ, srcSelW, resourceID, samplerID)\
447  to_QWORD(TEX_WORD0(TEX_INST_SAMPLE, 0x0, 0x0, resourceID, srcReg, 0x0, 0x0), \
448  TEX_WORD1(dstReg, 0x0, dstSelX, dstSelY, dstSelZ, dstSelW, 0x0, TEX_NORMALIZED, TEX_NORMALIZED, TEX_NORMALIZED, TEX_NORMALIZED)), \
449  to_QWORD(TEX_WORD2(0x0, 0x0, 0x0, samplerID, _x, _y, _0, _x), 0x00000000)
450 
451 #define TEX_GET_GRADIENTS_H(dstReg, dstSelX, dstSelY, dstSelZ, dstSelW, srcReg, srcSelX, srcSelY, srcSelZ, srcSelW, resourceID, samplerID)\
452  to_QWORD(TEX_WORD0(TEX_INST_GET_GRADIENTS_H, 0x0, 0x0, resourceID, srcReg, 0x0, 0x0), \
453  TEX_WORD1(dstReg, 0x0, dstSelX, dstSelY, dstSelZ, dstSelW, 0x0, TEX_NORMALIZED, TEX_NORMALIZED, TEX_NORMALIZED, TEX_NORMALIZED)), \
454  to_QWORD(TEX_WORD2(0x0, 0x0, 0x0, samplerID, _x, _y, _z, _x), 0x00000000)
455 
456 #define TEX_GET_GRADIENTS_V(dstReg, dstSelX, dstSelY, dstSelZ, dstSelW, srcReg, srcSelX, srcSelY, srcSelZ, srcSelW, resourceID, samplerID)\
457  to_QWORD(TEX_WORD0(TEX_INST_GET_GRADIENTS_V, 0x0, 0x0, resourceID, srcReg, 0x0, 0x0), \
458  TEX_WORD1(dstReg, 0x0, dstSelX, dstSelY, dstSelZ, dstSelW, 0x0, TEX_NORMALIZED, TEX_NORMALIZED, TEX_NORMALIZED, TEX_NORMALIZED)), \
459  to_QWORD(TEX_WORD2(0x0, 0x0, 0x0, samplerID, _x, _y, _z, _x), 0x00000000)
460 
461 
462 #define VTX_FETCH(dstReg, dstSelX, dstSelY, dstSelZ, dstSelW, srcReg, srcSelX, buffer_id, type, mega, offset) \
463  to_QWORD(VTX_WORD0(VTX_INST_FETCH, type, buffer_id, srcReg, srcSelX, mega), VTX_WORD1(dstReg, dstSelX, dstSelY, dstSelZ, dstSelW)) , \
464  to_QWORD(VTX_WORD2(offset, (mega >> 31)), 0x00000000)
465 
466 #define _x2(v) v, v
467 #define _x4(v) _x2(v), _x2(v)
468 #define _x8(v) _x4(v), _x4(v)
469 #define _x16(v) _x8(v), _x8(v)
470 
471 #define _x9(v) _x8(v), v
472 #define _x30(v) _x16(v), _x8(v), _x4(v),_x2(v)
473 #define _x31(v) _x30(v), v
474 
475 #endif /* GX2_SHADER_INL_H */