1 /*
2 * Copyright (c) 2008-2024 Broadcom. All Rights Reserved.
3 * The term “Broadcom” refers to Broadcom Inc.
4 * and/or its subsidiaries.
5 * SPDX-License-Identifier: MIT
6 */
7
8 /**
9 * @file
10 * SVGA Shader Token Opcode Info
11 *
12 * @author Michal Krol <michal@vmware.com>
13 */
14
15 #include "util/u_debug.h"
16 #include "svga_shader_op.h"
17
18 #include "../svga_hw_reg.h"
19 #include "svga3d_shaderdefs.h"
20
21 #define SVGA3DOP_INVALID SVGA3DOP_END
22 #define TGSI_OPCODE_INVALID TGSI_OPCODE_LAST
23
24 static struct sh_opcode_info opcode_info[] =
25 {
26 { "nop", 0, 0, 0, 0, SVGA3DOP_NOP },
27 { "mov", 1, 1, 0, 0, SVGA3DOP_MOV, },
28 { "add", 1, 2, 0, 0, SVGA3DOP_ADD, },
29 { "sub", 1, 2, 0, 0, SVGA3DOP_SUB, },
30 { "mad", 1, 3, 0, 0, SVGA3DOP_MAD, },
31 { "mul", 1, 2, 0, 0, SVGA3DOP_MUL, },
32 { "rcp", 1, 1, 0, 0, SVGA3DOP_RCP, },
33 { "rsq", 1, 1, 0, 0, SVGA3DOP_RSQ, },
34 { "dp3", 1, 2, 0, 0, SVGA3DOP_DP3, },
35 { "dp4", 1, 2, 0, 0, SVGA3DOP_DP4, },
36 { "min", 1, 2, 0, 0, SVGA3DOP_MIN, },
37 { "max", 1, 2, 0, 0, SVGA3DOP_MAX, },
38 { "slt", 1, 2, 0, 0, SVGA3DOP_SLT, },
39 { "sge", 1, 2, 0, 0, SVGA3DOP_SGE, },
40 { "exp", 1, 1, 0, 0, SVGA3DOP_EXP, },
41 { "log", 1, 1, 0, 0, SVGA3DOP_LOG, },
42 { "lit", 1, 1, 0, 0, SVGA3DOP_LIT, },
43 { "dst", 1, 2, 0, 0, SVGA3DOP_DST, },
44 { "lrp", 1, 3, 0, 0, SVGA3DOP_LRP, },
45 { "frc", 1, 1, 0, 0, SVGA3DOP_FRC, },
46 { "m4x4", 1, 2, 0, 0, SVGA3DOP_M4x4, },
47 { "m4x3", 1, 2, 0, 0, SVGA3DOP_M4x3, },
48 { "m3x4", 1, 2, 0, 0, SVGA3DOP_M3x4, },
49 { "m3x3", 1, 2, 0, 0, SVGA3DOP_M3x3, },
50 { "m3x2", 1, 2, 0, 0, SVGA3DOP_M3x2, },
51 { "call", 0, 1, 0, 0, SVGA3DOP_CALL, },
52 { "callnz", 0, 2, 0, 0, SVGA3DOP_CALLNZ, },
53 { "loop", 0, 2, 0, 1, SVGA3DOP_LOOP, },
54 { "ret", 0, 0, 0, 0, SVGA3DOP_RET, },
55 { "endloop", 0, 0, 1, 0, SVGA3DOP_ENDLOOP, },
56 { "label", 0, 1, 0, 0, SVGA3DOP_LABEL, },
57 { "dcl", 0, 0, 0, 0, SVGA3DOP_DCL, },
58 { "pow", 1, 2, 0, 0, SVGA3DOP_POW, },
59 { "crs", 1, 2, 0, 0, SVGA3DOP_CRS, },
60 { "sgn", 1, 3, 0, 0, SVGA3DOP_SGN, },
61 { "abs", 1, 1, 0, 0, SVGA3DOP_ABS, },
62 { "nrm", 1, 1, 0, 0, SVGA3DOP_NRM, }, /* 3-componenet normalization */
63 { "sincos", 1, 3, 0, 0, SVGA3DOP_SINCOS, },
64 { "rep", 0, 1, 0, 1, SVGA3DOP_REP, },
65 { "endrep", 0, 0, 1, 0, SVGA3DOP_ENDREP, },
66 { "if", 0, 1, 0, 1, SVGA3DOP_IF, },
67 { "ifc", 0, 2, 0, 1, SVGA3DOP_IFC, },
68 { "else", 0, 0, 1, 1, SVGA3DOP_ELSE, },
69 { "endif", 0, 0, 1, 0, SVGA3DOP_ENDIF, },
70 { "break", 0, 0, 0, 0, SVGA3DOP_BREAK, },
71 { "breakc", 0, 2, 0, 0, SVGA3DOP_BREAKC, },
72 { "mova", 1, 1, 0, 0, SVGA3DOP_MOVA, },
73 { "defb", 0, 0, 0, 0, SVGA3DOP_DEFB, },
74 { "defi", 0, 0, 0, 0, SVGA3DOP_DEFI, },
75 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
76 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
77 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
78 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
79 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
80 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
81 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
82 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
83 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
84 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
85 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
86 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
87 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
88 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
89 { "???", 0, 0, 0, 0, SVGA3DOP_INVALID, },
90 { "texcoord", 1, 0, 0, 0, SVGA3DOP_TEXCOORD, },
91 { "texkill", 1, 0, 0, 0, SVGA3DOP_TEXKILL, },
92 { "tex", 1, 0, 0, 0, SVGA3DOP_TEX, },
93 { "texbem", 1, 1, 0, 0, SVGA3DOP_TEXBEM, },
94 { "texbeml", 1, 1, 0, 0, SVGA3DOP_TEXBEML, },
95 { "texreg2ar", 1, 1, 0, 0, SVGA3DOP_TEXREG2AR, },
96 { "texreg2gb", 1, 1, 0, 0, SVGA3DOP_TEXREG2GB, },
97 { "texm3x2pad", 1, 1, 0, 0, SVGA3DOP_TEXM3x2PAD, },
98 { "texm3x2tex", 1, 1, 0, 0, SVGA3DOP_TEXM3x2TEX, },
99 { "texm3x3pad", 1, 1, 0, 0, SVGA3DOP_TEXM3x3PAD, },
100 { "texm3x3tex", 1, 1, 0, 0, SVGA3DOP_TEXM3x3TEX, },
101 { "reserved0", 0, 0, 0, 0, SVGA3DOP_RESERVED0, },
102 { "texm3x3spec", 1, 2, 0, 0, SVGA3DOP_TEXM3x3SPEC, },
103 { "texm3x3vspec", 1, 1, 0, 0, SVGA3DOP_TEXM3x3VSPEC,},
104 { "expp", 1, 1, 0, 0, SVGA3DOP_EXPP, },
105 { "logp", 1, 1, 0, 0, SVGA3DOP_LOGP, },
106 { "cnd", 1, 3, 0, 0, SVGA3DOP_CND, },
107 { "def", 0, 0, 0, 0, SVGA3DOP_DEF, },
108 { "texreg2rgb", 1, 1, 0, 0, SVGA3DOP_TEXREG2RGB, },
109 { "texdp3tex", 1, 1, 0, 0, SVGA3DOP_TEXDP3TEX, },
110 { "texm3x2depth", 1, 1, 0, 0, SVGA3DOP_TEXM3x2DEPTH,},
111 { "texdp3", 1, 1, 0, 0, SVGA3DOP_TEXDP3, },
112 { "texm3x3", 1, 1, 0, 0, SVGA3DOP_TEXM3x3, },
113 { "texdepth", 1, 0, 0, 0, SVGA3DOP_TEXDEPTH, },
114 { "cmp", 1, 3, 0, 0, SVGA3DOP_CMP, },
115 { "bem", 1, 2, 0, 0, SVGA3DOP_BEM, },
116 { "dp2add", 1, 3, 0, 0, SVGA3DOP_DP2ADD, },
117 { "dsx", 1, 1, 0, 0, SVGA3DOP_INVALID, },
118 { "dsy", 1, 1, 0, 0, SVGA3DOP_INVALID, },
119 { "texldd", 1, 4, 0, 0, SVGA3DOP_INVALID, },
120 { "setp", 1, 2, 0, 0, SVGA3DOP_SETP, },
121 { "texldl", 1, 2, 0, 0, SVGA3DOP_TEXLDL, },
122 { "breakp", 0, 1, 0, 0, SVGA3DOP_INVALID, },
123 };
124
svga_opcode_info(uint op)125 const struct sh_opcode_info *svga_opcode_info( uint op )
126 {
127 struct sh_opcode_info *info;
128
129 if (op >= ARRAY_SIZE(opcode_info)) {
130 /* The opcode is either PHASE, COMMENT, END or out of range.
131 */
132 assert( 0 );
133 return NULL;
134 }
135
136 info = &opcode_info[op];
137
138 if (info->svga_opcode == SVGA3DOP_INVALID) {
139 /* No valid information. Please provide number of dst/src registers.
140 */
141 _debug_printf("Missing information for opcode %u, '%s'\n", op,
142 opcode_info[op].mnemonic);
143 assert( 0 );
144 return NULL;
145 }
146
147 /* Sanity check.
148 */
149 assert( op == info->svga_opcode );
150
151 return info;
152 }
153