1 /**********************************************************
2 * Copyright 2008-2009 VMware, Inc. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 *
24 **********************************************************/
25
26 /**
27 * @file
28 * SVGA Shader Token Opcode Info
29 *
30 * @author Michal Krol <michal@vmware.com>
31 */
32
33 #include "util/u_debug.h"
34 #include "svga_shader_op.h"
35
36 #include "../svga_hw_reg.h"
37 #include "svga3d_shaderdefs.h"
38
39 #define SVGA3DOP_INVALID SVGA3DOP_END
40 #define TGSI_OPCODE_INVALID TGSI_OPCODE_LAST
41
42 static struct sh_opcode_info opcode_info[] =
43 {
44 { "nop", 0, 0, 0, 0, SVGA3DOP_NOP },
45 { "mov", 1, 1, 0, 0, SVGA3DOP_MOV, },
46 { "add", 1, 2, 0, 0, SVGA3DOP_ADD, },
47 { "sub", 1, 2, 0, 0, SVGA3DOP_SUB, },
48 { "mad", 1, 3, 0, 0, SVGA3DOP_MAD, },
49 { "mul", 1, 2, 0, 0, SVGA3DOP_MUL, },
50 { "rcp", 1, 1, 0, 0, SVGA3DOP_RCP, },
51 { "rsq", 1, 1, 0, 0, SVGA3DOP_RSQ, },
52 { "dp3", 1, 2, 0, 0, SVGA3DOP_DP3, },
53 { "dp4", 1, 2, 0, 0, SVGA3DOP_DP4, },
54 { "min", 1, 2, 0, 0, SVGA3DOP_MIN, },
55 { "max", 1, 2, 0, 0, SVGA3DOP_MAX, },
56 { "slt", 1, 2, 0, 0, SVGA3DOP_SLT, },
57 { "sge", 1, 2, 0, 0, SVGA3DOP_SGE, },
58 { "exp", 1, 1, 0, 0, SVGA3DOP_EXP, },
59 { "log", 1, 1, 0, 0, SVGA3DOP_LOG, },
60 { "lit", 1, 1, 0, 0, SVGA3DOP_LIT, },
61 { "dst", 1, 2, 0, 0, SVGA3DOP_DST, },
62 { "lrp", 1, 3, 0, 0, SVGA3DOP_LRP, },
63 { "frc", 1, 1, 0, 0, SVGA3DOP_FRC, },
64 { "m4x4", 1, 2, 0, 0, SVGA3DOP_M4x4, },
65 { "m4x3", 1, 2, 0, 0, SVGA3DOP_M4x3, },
66 { "m3x4", 1, 2, 0, 0, SVGA3DOP_M3x4, },
67 { "m3x3", 1, 2, 0, 0, SVGA3DOP_M3x3, },
68 { "m3x2", 1, 2, 0, 0, SVGA3DOP_M3x2, },
69 { "call", 0, 1, 0, 0, SVGA3DOP_CALL, },
70 { "callnz", 0, 2, 0, 0, SVGA3DOP_CALLNZ, },
71 { "loop", 0, 2, 0, 1, SVGA3DOP_LOOP, },
72 { "ret", 0, 0, 0, 0, SVGA3DOP_RET, },
73 { "endloop", 0, 0, 1, 0, SVGA3DOP_ENDLOOP, },
74 { "label", 0, 1, 0, 0, SVGA3DOP_LABEL, },
75 { "dcl", 0, 0, 0, 0, SVGA3DOP_DCL, },
76 { "pow", 1, 2, 0, 0, SVGA3DOP_POW, },
77 { "crs", 1, 2, 0, 0, SVGA3DOP_CRS, },
78 { "sgn", 1, 3, 0, 0, SVGA3DOP_SGN, },
79 { "abs", 1, 1, 0, 0, SVGA3DOP_ABS, },
80 { "nrm", 1, 1, 0, 0, SVGA3DOP_NRM, }, /* 3-componenet normalization */
81 { "sincos", 1, 3, 0, 0, SVGA3DOP_SINCOS, },
82 { "rep", 0, 1, 0, 1, SVGA3DOP_REP, },
83 { "endrep", 0, 0, 1, 0, SVGA3DOP_ENDREP, },
84 { "if", 0, 1, 0, 1, SVGA3DOP_IF, },
85 { "ifc", 0, 2, 0, 1, SVGA3DOP_IFC, },
86 { "else", 0, 0, 1, 1, SVGA3DOP_ELSE, },
87 { "endif", 0, 0, 1, 0, SVGA3DOP_ENDIF, },
88 { "break", 0, 0, 0, 0, SVGA3DOP_BREAK, },
89 { "breakc", 0, 2, 0, 0, SVGA3DOP_BREAKC, },
90 { "mova", 1, 1, 0, 0, SVGA3DOP_MOVA, },
91 { "defb", 0, 0, 0, 0, SVGA3DOP_DEFB, },
92 { "defi", 0, 0, 0, 0, SVGA3DOP_DEFI, },
93 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
94 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
95 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
96 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
97 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
98 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
99 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
100 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
101 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
102 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
103 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
104 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
105 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
106 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
107 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
108 { "texcoord", 1, 0, 0, 0, SVGA3DOP_TEXCOORD, },
109 { "texkill", 1, 0, 0, 0, SVGA3DOP_TEXKILL, },
110 { "tex", 1, 0, 0, 0, SVGA3DOP_TEX, },
111 { "texbem", 1, 1, 0, 0, SVGA3DOP_TEXBEM, },
112 { "texbeml", 1, 1, 0, 0, SVGA3DOP_TEXBEML, },
113 { "texreg2ar", 1, 1, 0, 0, SVGA3DOP_TEXREG2AR, },
114 { "texreg2gb", 1, 1, 0, 0, SVGA3DOP_TEXREG2GB, },
115 { "texm3x2pad", 1, 1, 0, 0, SVGA3DOP_TEXM3x2PAD, },
116 { "texm3x2tex", 1, 1, 0, 0, SVGA3DOP_TEXM3x2TEX, },
117 { "texm3x3pad", 1, 1, 0, 0, SVGA3DOP_TEXM3x3PAD, },
118 { "texm3x3tex", 1, 1, 0, 0, SVGA3DOP_TEXM3x3TEX, },
119 { "reserved0", 0, 0, 0, 0, SVGA3DOP_RESERVED0, },
120 { "texm3x3spec", 1, 2, 0, 0, SVGA3DOP_TEXM3x3SPEC, },
121 { "texm3x3vspec", 1, 1, 0, 0, SVGA3DOP_TEXM3x3VSPEC,},
122 { "expp", 1, 1, 0, 0, SVGA3DOP_EXPP, },
123 { "logp", 1, 1, 0, 0, SVGA3DOP_LOGP, },
124 { "cnd", 1, 3, 0, 0, SVGA3DOP_CND, },
125 { "def", 0, 0, 0, 0, SVGA3DOP_DEF, },
126 { "texreg2rgb", 1, 1, 0, 0, SVGA3DOP_TEXREG2RGB, },
127 { "texdp3tex", 1, 1, 0, 0, SVGA3DOP_TEXDP3TEX, },
128 { "texm3x2depth", 1, 1, 0, 0, SVGA3DOP_TEXM3x2DEPTH,},
129 { "texdp3", 1, 1, 0, 0, SVGA3DOP_TEXDP3, },
130 { "texm3x3", 1, 1, 0, 0, SVGA3DOP_TEXM3x3, },
131 { "texdepth", 1, 0, 0, 0, SVGA3DOP_TEXDEPTH, },
132 { "cmp", 1, 3, 0, 0, SVGA3DOP_CMP, },
133 { "bem", 1, 2, 0, 0, SVGA3DOP_BEM, },
134 { "dp2add", 1, 3, 0, 0, SVGA3DOP_DP2ADD, },
135 { "dsx", 1, 1, 0, 0, SVGA3DOP_INVALID, },
136 { "dsy", 1, 1, 0, 0, SVGA3DOP_INVALID, },
137 { "texldd", 1, 4, 0, 0, SVGA3DOP_INVALID, },
138 { "setp", 1, 2, 0, 0, SVGA3DOP_SETP, },
139 { "texldl", 1, 2, 0, 0, SVGA3DOP_TEXLDL, },
140 { "breakp", 0, 1, 0, 0, SVGA3DOP_INVALID, },
141 };
142
svga_opcode_info(uint op)143 const struct sh_opcode_info *svga_opcode_info( uint op )
144 {
145 struct sh_opcode_info *info;
146
147 if (op >= ARRAY_SIZE(opcode_info)) {
148 /* The opcode is either PHASE, COMMENT, END or out of range.
149 */
150 assert( 0 );
151 return NULL;
152 }
153
154 info = &opcode_info[op];
155
156 if (info->svga_opcode == SVGA3DOP_INVALID) {
157 /* No valid information. Please provide number of dst/src registers.
158 */
159 _debug_printf("Missing information for opcode %u, '%s'\n", op,
160 opcode_info[op].mnemonic);
161 assert( 0 );
162 return NULL;
163 }
164
165 /* Sanity check.
166 */
167 assert( op == info->svga_opcode );
168
169 return info;
170 }
171