summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/nouveau/nouveau_gldefs.h
blob: e1015c93a2757c7209f4f8d55451d20ef19cb403 (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
#ifndef __NOUVEAU_GLDEFS_H__
#define __NOUVEAU_GLDEFS_H__

static INLINE unsigned
nvgl_blend_func(unsigned factor)
{
	switch (factor) {
	case PIPE_BLENDFACTOR_ZERO:
		return 0x0000;
	case PIPE_BLENDFACTOR_ONE:
		return 0x0001;
	case PIPE_BLENDFACTOR_SRC_COLOR:
		return 0x0300;
	case PIPE_BLENDFACTOR_INV_SRC_COLOR:
		return 0x0301;
	case PIPE_BLENDFACTOR_SRC_ALPHA:
		return 0x0302;
	case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
		return 0x0303;
	case PIPE_BLENDFACTOR_DST_ALPHA:
		return 0x0304;
	case PIPE_BLENDFACTOR_INV_DST_ALPHA:
		return 0x0305;
	case PIPE_BLENDFACTOR_DST_COLOR:
		return 0x0306;
	case PIPE_BLENDFACTOR_INV_DST_COLOR:
		return 0x0307;
	case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
		return 0x0308;
	case PIPE_BLENDFACTOR_CONST_COLOR:
		return 0x8001;
	case PIPE_BLENDFACTOR_INV_CONST_COLOR:
		return 0x8002;
	case PIPE_BLENDFACTOR_CONST_ALPHA:
		return 0x8003;
	case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
		return 0x8004;
	default:
		return 0x0000;
	}
}

static INLINE unsigned
nvgl_blend_eqn(unsigned func)
{
	switch (func) {
	case PIPE_BLEND_ADD:
		return 0x8006;
	case PIPE_BLEND_MIN:
		return 0x8007;
	case PIPE_BLEND_MAX:
		return 0x8008;
	case PIPE_BLEND_SUBTRACT:
		return 0x800a;
	case PIPE_BLEND_REVERSE_SUBTRACT:
		return 0x800b;
	default:
		return 0x8006;
	}
}

static INLINE unsigned
nvgl_logicop_func(unsigned func)
{
	switch (func) {
	case PIPE_LOGICOP_CLEAR:
		return 0x1500;
	case PIPE_LOGICOP_NOR:
		return 0x1508;
	case PIPE_LOGICOP_AND_INVERTED:
		return 0x1504;
	case PIPE_LOGICOP_COPY_INVERTED:
		return 0x150c;
	case PIPE_LOGICOP_AND_REVERSE:
		return 0x1502;
	case PIPE_LOGICOP_INVERT:
		return 0x150a;
	case PIPE_LOGICOP_XOR:
		return 0x1506;
	case PIPE_LOGICOP_NAND:
		return 0x150e;
	case PIPE_LOGICOP_AND:
		return 0x1501;
	case PIPE_LOGICOP_EQUIV:
		return 0x1509;
	case PIPE_LOGICOP_NOOP:
		return 0x1505;
	case PIPE_LOGICOP_OR_INVERTED:
		return 0x150d;
	case PIPE_LOGICOP_COPY:
		return 0x1503;
	case PIPE_LOGICOP_OR_REVERSE:
		return 0x150b;
	case PIPE_LOGICOP_OR:
		return 0x1507;
	case PIPE_LOGICOP_SET:
		return 0x150f;
	default:
		return 0x1505;
	}
}

static INLINE unsigned
nvgl_comparison_op(unsigned op)
{
	switch (op) {
	case PIPE_FUNC_NEVER:
		return 0x0200;
	case PIPE_FUNC_LESS:
		return 0x0201;
	case PIPE_FUNC_EQUAL:
		return 0x0202;
	case PIPE_FUNC_LEQUAL:
		return 0x0203;
	case PIPE_FUNC_GREATER:
		return 0x0204;
	case PIPE_FUNC_NOTEQUAL:
		return 0x0205;
	case PIPE_FUNC_GEQUAL:
		return 0x0206;
	case PIPE_FUNC_ALWAYS:
		return 0x0207;
	default:
		return 0x0207;
	}
}

static INLINE unsigned
nvgl_polygon_mode(unsigned mode)
{
	switch (mode) {
	case PIPE_POLYGON_MODE_POINT:
		return 0x1b00;
	case PIPE_POLYGON_MODE_LINE:
		return 0x1b01;
	case PIPE_POLYGON_MODE_FILL:
		return 0x1b02;
	default:
		return 0x1b02;
	}
}

static INLINE unsigned
nvgl_stencil_op(unsigned op)
{
	switch (op) {
	case PIPE_STENCIL_OP_ZERO:
		return 0x0000;
	case PIPE_STENCIL_OP_INVERT:
		return 0x150a;
	case PIPE_STENCIL_OP_KEEP:
		return 0x1e00;
	case PIPE_STENCIL_OP_REPLACE:
		return 0x1e01;
	case PIPE_STENCIL_OP_INCR:
		return 0x1e02;
	case PIPE_STENCIL_OP_DECR:
		return 0x1e03;
	case PIPE_STENCIL_OP_INCR_WRAP:
		return 0x8507;
	case PIPE_STENCIL_OP_DECR_WRAP:
		return 0x8508;
	default:
		return 0x1e00;
	}
}

static INLINE unsigned
nvgl_primitive(unsigned prim) {
	switch (prim) {
	case PIPE_PRIM_POINTS:
		return 0x0001;
	case PIPE_PRIM_LINES:
		return 0x0002;
	case PIPE_PRIM_LINE_LOOP:
		return 0x0003;
	case PIPE_PRIM_LINE_STRIP:
		return 0x0004;
	case PIPE_PRIM_TRIANGLES:
		return 0x0005;
	case PIPE_PRIM_TRIANGLE_STRIP:
		return 0x0006;
	case PIPE_PRIM_TRIANGLE_FAN:
		return 0x0007;
	case PIPE_PRIM_QUADS:
		return 0x0008;
	case PIPE_PRIM_QUAD_STRIP:
		return 0x0009;
	case PIPE_PRIM_POLYGON:
		return 0x000a;
	default:
		return 0x0001;
	}
}

#endif