1bf215546Sopenharmony_ci/**********************************************************
2bf215546Sopenharmony_ci * Copyright 2007-2009 VMware, Inc.  All rights reserved.
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person
5bf215546Sopenharmony_ci * obtaining a copy of this software and associated documentation
6bf215546Sopenharmony_ci * files (the "Software"), to deal in the Software without
7bf215546Sopenharmony_ci * restriction, including without limitation the rights to use, copy,
8bf215546Sopenharmony_ci * modify, merge, publish, distribute, sublicense, and/or sell copies
9bf215546Sopenharmony_ci * of the Software, and to permit persons to whom the Software is
10bf215546Sopenharmony_ci * furnished to do so, subject to the following conditions:
11bf215546Sopenharmony_ci *
12bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be
13bf215546Sopenharmony_ci * included in all copies or substantial portions of the Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16bf215546Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18bf215546Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19bf215546Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20bf215546Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21bf215546Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22bf215546Sopenharmony_ci * SOFTWARE.
23bf215546Sopenharmony_ci *
24bf215546Sopenharmony_ci **********************************************************/
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ci/**
27bf215546Sopenharmony_ci * @file
28bf215546Sopenharmony_ci * SVGA Shader Token Definitions
29bf215546Sopenharmony_ci *
30bf215546Sopenharmony_ci * @author Michal Krol <michal@vmware.com>
31bf215546Sopenharmony_ci */
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_ci#ifndef ST_SHADER_SVGA_H
34bf215546Sopenharmony_ci#define ST_SHADER_SVGA_H
35bf215546Sopenharmony_ci
36bf215546Sopenharmony_ci#include "pipe/p_compiler.h"
37bf215546Sopenharmony_ci
38bf215546Sopenharmony_cistruct sh_op
39bf215546Sopenharmony_ci{
40bf215546Sopenharmony_ci   unsigned opcode:16;
41bf215546Sopenharmony_ci   unsigned control:8;
42bf215546Sopenharmony_ci   unsigned length:4;
43bf215546Sopenharmony_ci   unsigned predicated:1;
44bf215546Sopenharmony_ci   unsigned unused:1;
45bf215546Sopenharmony_ci   unsigned coissue:1;
46bf215546Sopenharmony_ci   unsigned is_reg:1;
47bf215546Sopenharmony_ci};
48bf215546Sopenharmony_ci
49bf215546Sopenharmony_cistruct sh_reg
50bf215546Sopenharmony_ci{
51bf215546Sopenharmony_ci   unsigned number:11;
52bf215546Sopenharmony_ci   unsigned type_hi:2;
53bf215546Sopenharmony_ci   unsigned relative:1;
54bf215546Sopenharmony_ci   unsigned unused:14;
55bf215546Sopenharmony_ci   unsigned type_lo:3;
56bf215546Sopenharmony_ci   unsigned is_reg:1;
57bf215546Sopenharmony_ci};
58bf215546Sopenharmony_ci
59bf215546Sopenharmony_cistatic inline unsigned
60bf215546Sopenharmony_cish_reg_type( struct sh_reg reg )
61bf215546Sopenharmony_ci{
62bf215546Sopenharmony_ci   return reg.type_lo | (reg.type_hi << 3);
63bf215546Sopenharmony_ci}
64bf215546Sopenharmony_ci
65bf215546Sopenharmony_cistruct sh_cdata
66bf215546Sopenharmony_ci{
67bf215546Sopenharmony_ci   float xyzw[4];
68bf215546Sopenharmony_ci};
69bf215546Sopenharmony_ci
70bf215546Sopenharmony_cistruct sh_def
71bf215546Sopenharmony_ci{
72bf215546Sopenharmony_ci   struct sh_op op;
73bf215546Sopenharmony_ci   struct sh_reg reg;
74bf215546Sopenharmony_ci   struct sh_cdata cdata;
75bf215546Sopenharmony_ci};
76bf215546Sopenharmony_ci
77bf215546Sopenharmony_cistruct sh_defb
78bf215546Sopenharmony_ci{
79bf215546Sopenharmony_ci   struct sh_op op;
80bf215546Sopenharmony_ci   struct sh_reg reg;
81bf215546Sopenharmony_ci   uint data;
82bf215546Sopenharmony_ci};
83bf215546Sopenharmony_ci
84bf215546Sopenharmony_cistruct sh_idata
85bf215546Sopenharmony_ci{
86bf215546Sopenharmony_ci   int xyzw[4];
87bf215546Sopenharmony_ci};
88bf215546Sopenharmony_ci
89bf215546Sopenharmony_cistruct sh_defi
90bf215546Sopenharmony_ci{
91bf215546Sopenharmony_ci   struct sh_op op;
92bf215546Sopenharmony_ci   struct sh_reg reg;
93bf215546Sopenharmony_ci   struct sh_idata idata;
94bf215546Sopenharmony_ci};
95bf215546Sopenharmony_ci
96bf215546Sopenharmony_ci#define PS_TEXTURETYPE_UNKNOWN   SVGA3DSAMP_UNKNOWN
97bf215546Sopenharmony_ci#define PS_TEXTURETYPE_2D        SVGA3DSAMP_2D
98bf215546Sopenharmony_ci#define PS_TEXTURETYPE_CUBE      SVGA3DSAMP_CUBE
99bf215546Sopenharmony_ci#define PS_TEXTURETYPE_VOLUME    SVGA3DSAMP_VOLUME
100bf215546Sopenharmony_ci
101bf215546Sopenharmony_cistruct sh_sampleinfo
102bf215546Sopenharmony_ci{
103bf215546Sopenharmony_ci   unsigned unused:27;
104bf215546Sopenharmony_ci   unsigned texture_type:4;
105bf215546Sopenharmony_ci   unsigned is_reg:1;
106bf215546Sopenharmony_ci};
107bf215546Sopenharmony_ci
108bf215546Sopenharmony_cistruct sh_semantic
109bf215546Sopenharmony_ci{
110bf215546Sopenharmony_ci   unsigned usage:4;
111bf215546Sopenharmony_ci   unsigned unused1:12;
112bf215546Sopenharmony_ci   unsigned usage_index:4;
113bf215546Sopenharmony_ci   unsigned unused2:11;
114bf215546Sopenharmony_ci   unsigned is_reg:1;
115bf215546Sopenharmony_ci};
116bf215546Sopenharmony_ci
117bf215546Sopenharmony_ci#define SH_WRITEMASK_0              0x1
118bf215546Sopenharmony_ci#define SH_WRITEMASK_1              0x2
119bf215546Sopenharmony_ci#define SH_WRITEMASK_2              0x4
120bf215546Sopenharmony_ci#define SH_WRITEMASK_3              0x8
121bf215546Sopenharmony_ci#define SH_WRITEMASK_ALL            0xf
122bf215546Sopenharmony_ci
123bf215546Sopenharmony_ci#define SH_DSTMOD_NONE              0x0
124bf215546Sopenharmony_ci#define SH_DSTMOD_SATURATE          0x1
125bf215546Sopenharmony_ci#define SH_DSTMOD_PARTIALPRECISION  0x2
126bf215546Sopenharmony_ci#define SH_DSTMOD_MSAMPCENTROID     0x4
127bf215546Sopenharmony_ci
128bf215546Sopenharmony_cistruct sh_dstreg
129bf215546Sopenharmony_ci{
130bf215546Sopenharmony_ci   unsigned number:11;
131bf215546Sopenharmony_ci   unsigned type_hi:2;
132bf215546Sopenharmony_ci   unsigned relative:1;
133bf215546Sopenharmony_ci   unsigned unused:2;
134bf215546Sopenharmony_ci   unsigned write_mask:4;
135bf215546Sopenharmony_ci   unsigned modifier:4;
136bf215546Sopenharmony_ci   unsigned shift_scale:4;
137bf215546Sopenharmony_ci   unsigned type_lo:3;
138bf215546Sopenharmony_ci   unsigned is_reg:1;
139bf215546Sopenharmony_ci};
140bf215546Sopenharmony_ci
141bf215546Sopenharmony_cistatic inline unsigned
142bf215546Sopenharmony_cish_dstreg_type( struct sh_dstreg reg )
143bf215546Sopenharmony_ci{
144bf215546Sopenharmony_ci   return reg.type_lo | (reg.type_hi << 3);
145bf215546Sopenharmony_ci}
146bf215546Sopenharmony_ci
147bf215546Sopenharmony_cistruct sh_dcl
148bf215546Sopenharmony_ci{
149bf215546Sopenharmony_ci   struct sh_op op;
150bf215546Sopenharmony_ci   union {
151bf215546Sopenharmony_ci      struct sh_sampleinfo sampleinfo;
152bf215546Sopenharmony_ci      struct sh_semantic semantic;
153bf215546Sopenharmony_ci   } u;
154bf215546Sopenharmony_ci   struct sh_dstreg reg;
155bf215546Sopenharmony_ci};
156bf215546Sopenharmony_ci
157bf215546Sopenharmony_cistruct sh_srcreg
158bf215546Sopenharmony_ci{
159bf215546Sopenharmony_ci   unsigned number:11;
160bf215546Sopenharmony_ci   unsigned type_hi:2;
161bf215546Sopenharmony_ci   unsigned relative:1;
162bf215546Sopenharmony_ci   unsigned unused:2;
163bf215546Sopenharmony_ci   unsigned swizzle_x:2;
164bf215546Sopenharmony_ci   unsigned swizzle_y:2;
165bf215546Sopenharmony_ci   unsigned swizzle_z:2;
166bf215546Sopenharmony_ci   unsigned swizzle_w:2;
167bf215546Sopenharmony_ci   unsigned modifier:4;
168bf215546Sopenharmony_ci   unsigned type_lo:3;
169bf215546Sopenharmony_ci   unsigned is_reg:1;
170bf215546Sopenharmony_ci};
171bf215546Sopenharmony_ci
172bf215546Sopenharmony_cistatic inline unsigned
173bf215546Sopenharmony_cish_srcreg_type( struct sh_srcreg reg )
174bf215546Sopenharmony_ci{
175bf215546Sopenharmony_ci   return reg.type_lo | (reg.type_hi << 3);
176bf215546Sopenharmony_ci}
177bf215546Sopenharmony_ci
178bf215546Sopenharmony_cistruct sh_dstop
179bf215546Sopenharmony_ci{
180bf215546Sopenharmony_ci   struct sh_op op;
181bf215546Sopenharmony_ci   struct sh_dstreg dst;
182bf215546Sopenharmony_ci};
183bf215546Sopenharmony_ci
184bf215546Sopenharmony_cistruct sh_srcop
185bf215546Sopenharmony_ci{
186bf215546Sopenharmony_ci   struct sh_op op;
187bf215546Sopenharmony_ci   struct sh_srcreg src;
188bf215546Sopenharmony_ci};
189bf215546Sopenharmony_ci
190bf215546Sopenharmony_cistruct sh_src2op
191bf215546Sopenharmony_ci{
192bf215546Sopenharmony_ci   struct sh_op op;
193bf215546Sopenharmony_ci   struct sh_srcreg src0;
194bf215546Sopenharmony_ci   struct sh_srcreg src1;
195bf215546Sopenharmony_ci};
196bf215546Sopenharmony_ci
197bf215546Sopenharmony_cistruct sh_unaryop
198bf215546Sopenharmony_ci{
199bf215546Sopenharmony_ci   struct sh_op op;
200bf215546Sopenharmony_ci   struct sh_dstreg dst;
201bf215546Sopenharmony_ci   struct sh_srcreg src;
202bf215546Sopenharmony_ci};
203bf215546Sopenharmony_ci
204bf215546Sopenharmony_cistruct sh_binaryop
205bf215546Sopenharmony_ci{
206bf215546Sopenharmony_ci   struct sh_op op;
207bf215546Sopenharmony_ci   struct sh_dstreg dst;
208bf215546Sopenharmony_ci   struct sh_srcreg src0;
209bf215546Sopenharmony_ci   struct sh_srcreg src1;
210bf215546Sopenharmony_ci};
211bf215546Sopenharmony_ci
212bf215546Sopenharmony_cistruct sh_trinaryop
213bf215546Sopenharmony_ci{
214bf215546Sopenharmony_ci   struct sh_op op;
215bf215546Sopenharmony_ci   struct sh_dstreg dst;
216bf215546Sopenharmony_ci   struct sh_srcreg src0;
217bf215546Sopenharmony_ci   struct sh_srcreg src1;
218bf215546Sopenharmony_ci   struct sh_srcreg src2;
219bf215546Sopenharmony_ci};
220bf215546Sopenharmony_ci
221bf215546Sopenharmony_cistruct sh_comment
222bf215546Sopenharmony_ci{
223bf215546Sopenharmony_ci   unsigned opcode:16;
224bf215546Sopenharmony_ci   unsigned size:16;
225bf215546Sopenharmony_ci};
226bf215546Sopenharmony_ci
227bf215546Sopenharmony_ci#endif /* ST_SHADER_SVGA_H */
228