Merge branch 'master' into pipe-video
[mesa.git] / src / gallium / drivers / svga / svgadump / svga_shader.h
1 /**********************************************************
2 * Copyright 2007-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 Definitions
29 *
30 * @author Michal Krol <michal@vmware.com>
31 */
32
33 #ifndef ST_SHADER_SVGA_H
34 #define ST_SHADER_SVGA_H
35
36 #include "pipe/p_compiler.h"
37
38 struct sh_op
39 {
40 unsigned opcode:16;
41 unsigned control:8;
42 unsigned length:4;
43 unsigned predicated:1;
44 unsigned unused:1;
45 unsigned coissue:1;
46 unsigned is_reg:1;
47 };
48
49 struct sh_reg
50 {
51 unsigned number:11;
52 unsigned type_hi:2;
53 unsigned relative:1;
54 unsigned unused:14;
55 unsigned type_lo:3;
56 unsigned is_reg:1;
57 };
58
59 static INLINE unsigned
60 sh_reg_type( struct sh_reg reg )
61 {
62 return reg.type_lo | (reg.type_hi << 3);
63 }
64
65 struct sh_cdata
66 {
67 float xyzw[4];
68 };
69
70 struct sh_def
71 {
72 struct sh_op op;
73 struct sh_reg reg;
74 struct sh_cdata cdata;
75 };
76
77 struct sh_defb
78 {
79 struct sh_op op;
80 struct sh_reg reg;
81 uint data;
82 };
83
84 struct sh_idata
85 {
86 int xyzw[4];
87 };
88
89 struct sh_defi
90 {
91 struct sh_op op;
92 struct sh_reg reg;
93 struct sh_idata idata;
94 };
95
96 #define PS_TEXTURETYPE_UNKNOWN SVGA3DSAMP_UNKNOWN
97 #define PS_TEXTURETYPE_2D SVGA3DSAMP_2D
98 #define PS_TEXTURETYPE_CUBE SVGA3DSAMP_CUBE
99 #define PS_TEXTURETYPE_VOLUME SVGA3DSAMP_VOLUME
100
101 struct ps_sampleinfo
102 {
103 unsigned unused:27;
104 unsigned texture_type:4;
105 unsigned is_reg:1;
106 };
107
108 struct vs_semantic
109 {
110 unsigned usage:5;
111 unsigned unused1:11;
112 unsigned usage_index:4;
113 unsigned unused2:12;
114 };
115
116 struct sh_dstreg
117 {
118 unsigned number:11;
119 unsigned type_hi:2;
120 unsigned relative:1;
121 unsigned unused:2;
122 unsigned write_mask:4;
123 unsigned modifier:4;
124 unsigned shift_scale:4;
125 unsigned type_lo:3;
126 unsigned is_reg:1;
127 };
128
129 static INLINE unsigned
130 sh_dstreg_type( struct sh_dstreg reg )
131 {
132 return reg.type_lo | (reg.type_hi << 3);
133 }
134
135 struct sh_dcl
136 {
137 struct sh_op op;
138 union {
139 struct {
140 struct ps_sampleinfo sampleinfo;
141 } ps;
142 struct {
143 struct vs_semantic semantic;
144 } vs;
145 } u;
146 struct sh_dstreg reg;
147 };
148
149
150 struct sh_srcreg
151 {
152 unsigned number:11;
153 unsigned type_hi:2;
154 unsigned relative:1;
155 unsigned unused:2;
156 unsigned swizzle_x:2;
157 unsigned swizzle_y:2;
158 unsigned swizzle_z:2;
159 unsigned swizzle_w:2;
160 unsigned modifier:4;
161 unsigned type_lo:3;
162 unsigned is_reg:1;
163 };
164
165 static INLINE unsigned
166 sh_srcreg_type( struct sh_srcreg reg )
167 {
168 return reg.type_lo | (reg.type_hi << 3);
169 }
170
171 struct sh_dstop
172 {
173 struct sh_op op;
174 struct sh_dstreg dst;
175 };
176
177 struct sh_srcop
178 {
179 struct sh_op op;
180 struct sh_srcreg src;
181 };
182
183 struct sh_src2op
184 {
185 struct sh_op op;
186 struct sh_srcreg src0;
187 struct sh_srcreg src1;
188 };
189
190 struct sh_unaryop
191 {
192 struct sh_op op;
193 struct sh_dstreg dst;
194 struct sh_srcreg src;
195 };
196
197 struct sh_binaryop
198 {
199 struct sh_op op;
200 struct sh_dstreg dst;
201 struct sh_srcreg src0;
202 struct sh_srcreg src1;
203 };
204
205 struct sh_trinaryop
206 {
207 struct sh_op op;
208 struct sh_dstreg dst;
209 struct sh_srcreg src0;
210 struct sh_srcreg src1;
211 struct sh_srcreg src2;
212 };
213
214 struct sh_comment
215 {
216 unsigned opcode:16;
217 unsigned size:16;
218 };
219
220 #endif /* ST_SHADER_SVGA_H */