• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef __NOUVEAU_GLDEFS_H__
2 #define __NOUVEAU_GLDEFS_H__
3 
4 static INLINE unsigned
nvgl_blend_func(unsigned factor)5 nvgl_blend_func(unsigned factor)
6 {
7 	switch (factor) {
8 	case PIPE_BLENDFACTOR_ZERO:
9 		return 0x0000;
10 	case PIPE_BLENDFACTOR_ONE:
11 		return 0x0001;
12 	case PIPE_BLENDFACTOR_SRC_COLOR:
13 		return 0x0300;
14 	case PIPE_BLENDFACTOR_INV_SRC_COLOR:
15 		return 0x0301;
16 	case PIPE_BLENDFACTOR_SRC_ALPHA:
17 		return 0x0302;
18 	case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
19 		return 0x0303;
20 	case PIPE_BLENDFACTOR_DST_ALPHA:
21 		return 0x0304;
22 	case PIPE_BLENDFACTOR_INV_DST_ALPHA:
23 		return 0x0305;
24 	case PIPE_BLENDFACTOR_DST_COLOR:
25 		return 0x0306;
26 	case PIPE_BLENDFACTOR_INV_DST_COLOR:
27 		return 0x0307;
28 	case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
29 		return 0x0308;
30 	case PIPE_BLENDFACTOR_CONST_COLOR:
31 		return 0x8001;
32 	case PIPE_BLENDFACTOR_INV_CONST_COLOR:
33 		return 0x8002;
34 	case PIPE_BLENDFACTOR_CONST_ALPHA:
35 		return 0x8003;
36 	case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
37 		return 0x8004;
38 	default:
39 		return 0x0000;
40 	}
41 }
42 
43 static INLINE unsigned
nvgl_blend_eqn(unsigned func)44 nvgl_blend_eqn(unsigned func)
45 {
46 	switch (func) {
47 	case PIPE_BLEND_ADD:
48 		return 0x8006;
49 	case PIPE_BLEND_MIN:
50 		return 0x8007;
51 	case PIPE_BLEND_MAX:
52 		return 0x8008;
53 	case PIPE_BLEND_SUBTRACT:
54 		return 0x800a;
55 	case PIPE_BLEND_REVERSE_SUBTRACT:
56 		return 0x800b;
57 	default:
58 		return 0x8006;
59 	}
60 }
61 
62 static INLINE unsigned
nvgl_logicop_func(unsigned func)63 nvgl_logicop_func(unsigned func)
64 {
65 	switch (func) {
66 	case PIPE_LOGICOP_CLEAR:
67 		return 0x1500;
68 	case PIPE_LOGICOP_NOR:
69 		return 0x1508;
70 	case PIPE_LOGICOP_AND_INVERTED:
71 		return 0x1504;
72 	case PIPE_LOGICOP_COPY_INVERTED:
73 		return 0x150c;
74 	case PIPE_LOGICOP_AND_REVERSE:
75 		return 0x1502;
76 	case PIPE_LOGICOP_INVERT:
77 		return 0x150a;
78 	case PIPE_LOGICOP_XOR:
79 		return 0x1506;
80 	case PIPE_LOGICOP_NAND:
81 		return 0x150e;
82 	case PIPE_LOGICOP_AND:
83 		return 0x1501;
84 	case PIPE_LOGICOP_EQUIV:
85 		return 0x1509;
86 	case PIPE_LOGICOP_NOOP:
87 		return 0x1505;
88 	case PIPE_LOGICOP_OR_INVERTED:
89 		return 0x150d;
90 	case PIPE_LOGICOP_COPY:
91 		return 0x1503;
92 	case PIPE_LOGICOP_OR_REVERSE:
93 		return 0x150b;
94 	case PIPE_LOGICOP_OR:
95 		return 0x1507;
96 	case PIPE_LOGICOP_SET:
97 		return 0x150f;
98 	default:
99 		return 0x1505;
100 	}
101 }
102 
103 static INLINE unsigned
nvgl_comparison_op(unsigned op)104 nvgl_comparison_op(unsigned op)
105 {
106 	switch (op) {
107 	case PIPE_FUNC_NEVER:
108 		return 0x0200;
109 	case PIPE_FUNC_LESS:
110 		return 0x0201;
111 	case PIPE_FUNC_EQUAL:
112 		return 0x0202;
113 	case PIPE_FUNC_LEQUAL:
114 		return 0x0203;
115 	case PIPE_FUNC_GREATER:
116 		return 0x0204;
117 	case PIPE_FUNC_NOTEQUAL:
118 		return 0x0205;
119 	case PIPE_FUNC_GEQUAL:
120 		return 0x0206;
121 	case PIPE_FUNC_ALWAYS:
122 		return 0x0207;
123 	default:
124 		return 0x0207;
125 	}
126 }
127 
128 static INLINE unsigned
nvgl_polygon_mode(unsigned mode)129 nvgl_polygon_mode(unsigned mode)
130 {
131 	switch (mode) {
132 	case PIPE_POLYGON_MODE_POINT:
133 		return 0x1b00;
134 	case PIPE_POLYGON_MODE_LINE:
135 		return 0x1b01;
136 	case PIPE_POLYGON_MODE_FILL:
137 		return 0x1b02;
138 	default:
139 		return 0x1b02;
140 	}
141 }
142 
143 static INLINE unsigned
nvgl_stencil_op(unsigned op)144 nvgl_stencil_op(unsigned op)
145 {
146 	switch (op) {
147 	case PIPE_STENCIL_OP_ZERO:
148 		return 0x0000;
149 	case PIPE_STENCIL_OP_INVERT:
150 		return 0x150a;
151 	case PIPE_STENCIL_OP_KEEP:
152 		return 0x1e00;
153 	case PIPE_STENCIL_OP_REPLACE:
154 		return 0x1e01;
155 	case PIPE_STENCIL_OP_INCR:
156 		return 0x1e02;
157 	case PIPE_STENCIL_OP_DECR:
158 		return 0x1e03;
159 	case PIPE_STENCIL_OP_INCR_WRAP:
160 		return 0x8507;
161 	case PIPE_STENCIL_OP_DECR_WRAP:
162 		return 0x8508;
163 	default:
164 		return 0x1e00;
165 	}
166 }
167 
168 static INLINE unsigned
nvgl_primitive(unsigned prim)169 nvgl_primitive(unsigned prim) {
170 	switch (prim) {
171 	case PIPE_PRIM_POINTS:
172 		return 0x0001;
173 	case PIPE_PRIM_LINES:
174 		return 0x0002;
175 	case PIPE_PRIM_LINE_LOOP:
176 		return 0x0003;
177 	case PIPE_PRIM_LINE_STRIP:
178 		return 0x0004;
179 	case PIPE_PRIM_TRIANGLES:
180 		return 0x0005;
181 	case PIPE_PRIM_TRIANGLE_STRIP:
182 		return 0x0006;
183 	case PIPE_PRIM_TRIANGLE_FAN:
184 		return 0x0007;
185 	case PIPE_PRIM_QUADS:
186 		return 0x0008;
187 	case PIPE_PRIM_QUAD_STRIP:
188 		return 0x0009;
189 	case PIPE_PRIM_POLYGON:
190 		return 0x000a;
191 	default:
192 		return 0;
193 	}
194 }
195 
196 #endif
197