summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/nouveau/nouveau_gldefs.h
blob: 46ec14ec55dd15e575de9a723e54db26834ec2da (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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/*
 * Copyright (C) 2007-2010 The Nouveau Project.
 * 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 (including the
 * next paragraph) 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 COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS 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.
 *
 */

#ifndef __NOUVEAU_GLDEFS_H__
#define __NOUVEAU_GLDEFS_H__

static inline unsigned
nvgl_blend_func(unsigned func)
{
	switch (func) {
	case GL_ZERO:
		return 0x0000;
	case GL_ONE:
		return 0x0001;
	case GL_SRC_COLOR:
		return 0x0300;
	case GL_ONE_MINUS_SRC_COLOR:
		return 0x0301;
	case GL_SRC_ALPHA:
		return 0x0302;
	case GL_ONE_MINUS_SRC_ALPHA:
		return 0x0303;
	case GL_DST_ALPHA:
		return 0x0304;
	case GL_ONE_MINUS_DST_ALPHA:
		return 0x0305;
	case GL_DST_COLOR:
		return 0x0306;
	case GL_ONE_MINUS_DST_COLOR:
		return 0x0307;
	case GL_SRC_ALPHA_SATURATE:
		return 0x0308;
	case GL_CONSTANT_COLOR:
		return 0x8001;
	case GL_ONE_MINUS_CONSTANT_COLOR:
		return 0x8002;
	case GL_CONSTANT_ALPHA:
		return 0x8003;
	case GL_ONE_MINUS_CONSTANT_ALPHA:
		return 0x8004;
	default:
		assert(0);
	}
}

static inline unsigned
nvgl_blend_eqn(unsigned eqn)
{
	switch (eqn) {
	case GL_FUNC_ADD:
		return 0x8006;
	case GL_MIN:
		return 0x8007;
	case GL_MAX:
		return 0x8008;
	case GL_FUNC_SUBTRACT:
		return 0x800a;
	case GL_FUNC_REVERSE_SUBTRACT:
		return 0x800b;
	default:
		assert(0);
	}
}

static inline unsigned
nvgl_logicop_func(unsigned func)
{
	switch (func) {
	case GL_CLEAR:
		return 0x1500;
	case GL_NOR:
		return 0x1508;
	case GL_AND_INVERTED:
		return 0x1504;
	case GL_COPY_INVERTED:
		return 0x150c;
	case GL_AND_REVERSE:
		return 0x1502;
	case GL_INVERT:
		return 0x150a;
	case GL_XOR:
		return 0x1506;
	case GL_NAND:
		return 0x150e;
	case GL_AND:
		return 0x1501;
	case GL_EQUIV:
		return 0x1509;
	case GL_NOOP:
		return 0x1505;
	case GL_OR_INVERTED:
		return 0x150d;
	case GL_COPY:
		return 0x1503;
	case GL_OR_REVERSE:
		return 0x150b;
	case GL_OR:
		return 0x1507;
	case GL_SET:
		return 0x150f;
	default:
		assert(0);
	}
}

static inline unsigned
nvgl_comparison_op(unsigned op)
{
	switch (op) {
	case GL_NEVER:
		return 0x0200;
	case GL_LESS:
		return 0x0201;
	case GL_EQUAL:
		return 0x0202;
	case GL_LEQUAL:
		return 0x0203;
	case GL_GREATER:
		return 0x0204;
	case GL_NOTEQUAL:
		return 0x0205;
	case GL_GEQUAL:
		return 0x0206;
	case GL_ALWAYS:
		return 0x0207;
	default:
		assert(0);
	}
}

static inline unsigned
nvgl_polygon_mode(unsigned mode)
{
	switch (mode) {
	case GL_POINT:
		return 0x1b00;
	case GL_LINE:
		return 0x1b01;
	case GL_FILL:
		return 0x1b02;
	default:
		assert(0);
	}
}

static inline unsigned
nvgl_stencil_op(unsigned op)
{
	switch (op) {
	case GL_ZERO:
		return 0x0000;
	case GL_INVERT:
		return 0x150a;
	case GL_KEEP:
		return 0x1e00;
	case GL_REPLACE:
		return 0x1e01;
	case GL_INCR:
		return 0x1e02;
	case GL_DECR:
		return 0x1e03;
	case GL_INCR_WRAP_EXT:
		return 0x8507;
	case GL_DECR_WRAP_EXT:
		return 0x8508;
	default:
		assert(0);
	}
}

static inline unsigned
nvgl_primitive(unsigned prim)
{
	switch (prim) {
	case GL_POINTS:
		return 0x0001;
	case GL_LINES:
		return 0x0002;
	case GL_LINE_LOOP:
		return 0x0003;
	case GL_LINE_STRIP:
		return 0x0004;
	case GL_TRIANGLES:
		return 0x0005;
	case GL_TRIANGLE_STRIP:
		return 0x0006;
	case GL_TRIANGLE_FAN:
		return 0x0007;
	case GL_QUADS:
		return 0x0008;
	case GL_QUAD_STRIP:
		return 0x0009;
	case GL_POLYGON:
		return 0x000a;
	default:
		assert(0);
	}
}

static inline unsigned
nvgl_wrap_mode(unsigned wrap)
{
	switch (wrap) {
	case GL_REPEAT:
		return 0x1;
	case GL_MIRRORED_REPEAT:
		return 0x2;
	case GL_CLAMP:
	case GL_CLAMP_TO_EDGE:
		return 0x3;
	case GL_CLAMP_TO_BORDER:
		return 0x4;
	default:
		assert(0);
	}
}

static inline unsigned
nvgl_filter_mode(unsigned filter)
{
	switch (filter) {
	case GL_NEAREST:
		return 0x1;
	case GL_LINEAR:
		return 0x2;
	case GL_NEAREST_MIPMAP_NEAREST:
		return 0x3;
	case GL_LINEAR_MIPMAP_NEAREST:
		return 0x4;
	case GL_NEAREST_MIPMAP_LINEAR:
		return 0x5;
	case GL_LINEAR_MIPMAP_LINEAR:
		return 0x6;
	default:
		assert(0);
	}
}

static inline unsigned
nvgl_texgen_mode(unsigned mode)
{
	switch (mode) {
	case GL_EYE_LINEAR:
		return 0x2400;
	case GL_OBJECT_LINEAR:
		return 0x2401;
	case GL_SPHERE_MAP:
		return 0x2402;
	case GL_NORMAL_MAP:
		return 0x8511;
	case GL_REFLECTION_MAP:
		return 0x8512;
	default:
		assert(0);
	}
}

#endif