2 * Copyright (C) 2009 Nicolai Haehnle.
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial
16 * portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #include "radeon_opcodes.h"
30 #include "radeon_program_constants.h"
32 struct rc_opcode_info rc_opcodes
[MAX_RC_OPCODE
] = {
34 .Opcode
= RC_OPCODE_NOP
,
38 .Opcode
= RC_OPCODE_ILLEGAL_OPCODE
,
39 .Name
= "ILLEGAL OPCODE"
42 .Opcode
= RC_OPCODE_ABS
,
49 .Opcode
= RC_OPCODE_ADD
,
56 .Opcode
= RC_OPCODE_ARL
,
62 .Opcode
= RC_OPCODE_CMP
,
69 .Opcode
= RC_OPCODE_COS
,
76 .Opcode
= RC_OPCODE_DDX
,
83 .Opcode
= RC_OPCODE_DDY
,
90 .Opcode
= RC_OPCODE_DP3
,
96 .Opcode
= RC_OPCODE_DP4
,
102 .Opcode
= RC_OPCODE_DPH
,
108 .Opcode
= RC_OPCODE_DST
,
114 .Opcode
= RC_OPCODE_EX2
,
118 .IsStandardScalar
= 1
121 .Opcode
= RC_OPCODE_EXP
,
127 .Opcode
= RC_OPCODE_FLR
,
134 .Opcode
= RC_OPCODE_FRC
,
141 .Opcode
= RC_OPCODE_KIL
,
146 .Opcode
= RC_OPCODE_LG2
,
150 .IsStandardScalar
= 1
153 .Opcode
= RC_OPCODE_LIT
,
159 .Opcode
= RC_OPCODE_LOG
,
165 .Opcode
= RC_OPCODE_LRP
,
172 .Opcode
= RC_OPCODE_MAD
,
179 .Opcode
= RC_OPCODE_MAX
,
186 .Opcode
= RC_OPCODE_MIN
,
193 .Opcode
= RC_OPCODE_MOV
,
200 .Opcode
= RC_OPCODE_MUL
,
207 .Opcode
= RC_OPCODE_POW
,
211 .IsStandardScalar
= 1
214 .Opcode
= RC_OPCODE_RCP
,
218 .IsStandardScalar
= 1
221 .Opcode
= RC_OPCODE_RSQ
,
225 .IsStandardScalar
= 1
228 .Opcode
= RC_OPCODE_SCS
,
234 .Opcode
= RC_OPCODE_SEQ
,
241 .Opcode
= RC_OPCODE_SFL
,
248 .Opcode
= RC_OPCODE_SGE
,
255 .Opcode
= RC_OPCODE_SGT
,
262 .Opcode
= RC_OPCODE_SIN
,
266 .IsStandardScalar
= 1
269 .Opcode
= RC_OPCODE_SLE
,
276 .Opcode
= RC_OPCODE_SLT
,
283 .Opcode
= RC_OPCODE_SNE
,
290 .Opcode
= RC_OPCODE_SUB
,
297 .Opcode
= RC_OPCODE_SWZ
,
304 .Opcode
= RC_OPCODE_XPD
,
310 .Opcode
= RC_OPCODE_TEX
,
317 .Opcode
= RC_OPCODE_TXB
,
324 .Opcode
= RC_OPCODE_TXD
,
331 .Opcode
= RC_OPCODE_TXL
,
338 .Opcode
= RC_OPCODE_TXP
,
345 .Opcode
= RC_OPCODE_IF
,
351 .Opcode
= RC_OPCODE_ELSE
,
357 .Opcode
= RC_OPCODE_ENDIF
,
363 .Opcode
= RC_OPCODE_REPL_ALPHA
,
364 .Name
= "REPL_ALPHA",
368 .Opcode
= RC_OPCODE_BEGIN_TEX
,
373 void rc_compute_sources_for_writemask(
374 const struct rc_opcode_info
* opcode
,
375 unsigned int writemask
,
376 unsigned int *srcmasks
)
382 if (opcode
->Opcode
== RC_OPCODE_KIL
)
383 srcmasks
[0] |= RC_MASK_XYZW
;
384 else if (opcode
->Opcode
== RC_OPCODE_IF
)
385 srcmasks
[0] |= RC_MASK_X
;
390 if (opcode
->IsComponentwise
) {
391 for(unsigned int src
= 0; src
< opcode
->NumSrcRegs
; ++src
)
392 srcmasks
[src
] |= writemask
;
393 } else if (opcode
->IsStandardScalar
) {
394 for(unsigned int src
= 0; src
< opcode
->NumSrcRegs
; ++src
)
395 srcmasks
[src
] |= RC_MASK_X
;
397 switch(opcode
->Opcode
) {
399 srcmasks
[0] |= RC_MASK_X
;
402 srcmasks
[0] |= RC_MASK_XYZ
;
403 srcmasks
[1] |= RC_MASK_XYZ
;
406 srcmasks
[0] |= RC_MASK_XYZW
;
407 srcmasks
[1] |= RC_MASK_XYZW
;
412 srcmasks
[0] |= RC_MASK_XYZW
;
415 srcmasks
[0] |= RC_MASK_Y
| RC_MASK_Z
;
416 srcmasks
[1] |= RC_MASK_Y
| RC_MASK_W
;
420 srcmasks
[0] |= RC_MASK_XY
;
423 srcmasks
[0] |= RC_MASK_X
| RC_MASK_Y
| RC_MASK_W
;