summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/svga/svgadump/svga_shader.h
blob: 5db64bf135b9bb8d98cacc9d115ee15b7b85685d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/**********************************************************
 * Copyright 2007-2009 VMware, Inc.  All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use, copy,
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 **********************************************************/

/**
 * @file
 * SVGA Shader Token Definitions
 * 
 * @author Michal Krol <michal@vmware.com>
 */

#ifndef ST_SHADER_SVGA_H
#define ST_SHADER_SVGA_H

#include "pipe/p_compiler.h"

struct sh_op
{
   unsigned opcode:16;
   unsigned control:8;
   unsigned length:4;
   unsigned predicated:1;
   unsigned unused:1;
   unsigned coissue:1;
   unsigned is_reg:1;
};

struct sh_reg
{
   unsigned number:11;
   unsigned type_hi:2;
   unsigned relative:1;
   unsigned unused:14;
   unsigned type_lo:3;
   unsigned is_reg:1;
};

static INLINE unsigned
sh_reg_type( struct sh_reg reg )
{
   return reg.type_lo | (reg.type_hi << 3);
}

struct sh_cdata
{
   float xyzw[4];
};

struct sh_def
{
   struct sh_op op;
   struct sh_reg reg;
   struct sh_cdata cdata;
};

struct sh_defb
{
   struct sh_op op;
   struct sh_reg reg;
   uint data;
};

struct sh_idata
{
   int xyzw[4];
};

struct sh_defi
{
   struct sh_op op;
   struct sh_reg reg;
   struct sh_idata idata;
};

#define PS_TEXTURETYPE_UNKNOWN   SVGA3DSAMP_UNKNOWN
#define PS_TEXTURETYPE_2D        SVGA3DSAMP_2D
#define PS_TEXTURETYPE_CUBE      SVGA3DSAMP_CUBE
#define PS_TEXTURETYPE_VOLUME    SVGA3DSAMP_VOLUME

struct sh_sampleinfo
{
   unsigned unused:27;
   unsigned texture_type:4;
   unsigned is_reg:1;
};

struct sh_semantic
{
   unsigned usage:4;
   unsigned unused1:12;
   unsigned usage_index:4;
   unsigned unused2:11;
   unsigned is_reg:1;
};

#define SH_WRITEMASK_0              0x1
#define SH_WRITEMASK_1              0x2
#define SH_WRITEMASK_2              0x4
#define SH_WRITEMASK_3              0x8
#define SH_WRITEMASK_ALL            0xf

#define SH_DSTMOD_NONE              0x0
#define SH_DSTMOD_SATURATE          0x1
#define SH_DSTMOD_PARTIALPRECISION  0x2
#define SH_DSTMOD_MSAMPCENTROID     0x4

struct sh_dstreg
{
   unsigned number:11;
   unsigned type_hi:2;
   unsigned relative:1;
   unsigned unused:2;
   unsigned write_mask:4;
   unsigned modifier:4;
   unsigned shift_scale:4;
   unsigned type_lo:3;
   unsigned is_reg:1;
};

static INLINE unsigned
sh_dstreg_type( struct sh_dstreg reg )
{
   return reg.type_lo | (reg.type_hi << 3);
}

struct sh_dcl
{
   struct sh_op op;
   union {
      struct sh_sampleinfo sampleinfo;
      struct sh_semantic semantic;
   } u;
   struct sh_dstreg reg;
};

struct sh_srcreg
{
   unsigned number:11;
   unsigned type_hi:2;
   unsigned relative:1;
   unsigned unused:2;
   unsigned swizzle_x:2;
   unsigned swizzle_y:2;
   unsigned swizzle_z:2;
   unsigned swizzle_w:2;
   unsigned modifier:4;
   unsigned type_lo:3;
   unsigned is_reg:1;
};

static INLINE unsigned
sh_srcreg_type( struct sh_srcreg reg )
{
   return reg.type_lo | (reg.type_hi << 3);
}

struct sh_dstop
{
   struct sh_op op;
   struct sh_dstreg dst;
};

struct sh_srcop
{
   struct sh_op op;
   struct sh_srcreg src;
};

struct sh_src2op
{
   struct sh_op op;
   struct sh_srcreg src0;
   struct sh_srcreg src1;
};

struct sh_unaryop
{
   struct sh_op op;
   struct sh_dstreg dst;
   struct sh_srcreg src;
};

struct sh_binaryop
{
   struct sh_op op;
   struct sh_dstreg dst;
   struct sh_srcreg src0;
   struct sh_srcreg src1;
};

struct sh_trinaryop
{
   struct sh_op op;
   struct sh_dstreg dst;
   struct sh_srcreg src0;
   struct sh_srcreg src1;
   struct sh_srcreg src2;
};

struct sh_comment
{
   unsigned opcode:16;
   unsigned size:16;
};

#endif /* ST_SHADER_SVGA_H */