1 /**************************************************************************
3 * Copyright 2003 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #ifndef I915_STATE_INLINES_H
29 #define I915_STATE_INLINES_H
31 #include "pipe/p_compiler.h"
32 #include "pipe/p_defines.h"
33 #include "util/u_debug.h"
37 static inline unsigned
38 i915_translate_compare_func(unsigned func
)
42 return COMPAREFUNC_NEVER
;
44 return COMPAREFUNC_LESS
;
45 case PIPE_FUNC_LEQUAL
:
46 return COMPAREFUNC_LEQUAL
;
47 case PIPE_FUNC_GREATER
:
48 return COMPAREFUNC_GREATER
;
49 case PIPE_FUNC_GEQUAL
:
50 return COMPAREFUNC_GEQUAL
;
51 case PIPE_FUNC_NOTEQUAL
:
52 return COMPAREFUNC_NOTEQUAL
;
54 return COMPAREFUNC_EQUAL
;
55 case PIPE_FUNC_ALWAYS
:
56 return COMPAREFUNC_ALWAYS
;
58 return COMPAREFUNC_ALWAYS
;
62 static inline unsigned
63 i915_translate_shadow_compare_func(unsigned func
)
67 return COMPAREFUNC_ALWAYS
;
69 return COMPAREFUNC_LEQUAL
;
70 case PIPE_FUNC_LEQUAL
:
71 return COMPAREFUNC_LESS
;
72 case PIPE_FUNC_GREATER
:
73 return COMPAREFUNC_GEQUAL
;
74 case PIPE_FUNC_GEQUAL
:
75 return COMPAREFUNC_GREATER
;
76 case PIPE_FUNC_NOTEQUAL
:
77 return COMPAREFUNC_EQUAL
;
79 return COMPAREFUNC_NOTEQUAL
;
80 case PIPE_FUNC_ALWAYS
:
81 return COMPAREFUNC_NEVER
;
83 return COMPAREFUNC_NEVER
;
87 static inline unsigned
88 i915_translate_stencil_op(unsigned op
)
91 case PIPE_STENCIL_OP_KEEP
:
92 return STENCILOP_KEEP
;
93 case PIPE_STENCIL_OP_ZERO
:
94 return STENCILOP_ZERO
;
95 case PIPE_STENCIL_OP_REPLACE
:
96 return STENCILOP_REPLACE
;
97 case PIPE_STENCIL_OP_INCR
:
98 return STENCILOP_INCRSAT
;
99 case PIPE_STENCIL_OP_DECR
:
100 return STENCILOP_DECRSAT
;
101 case PIPE_STENCIL_OP_INCR_WRAP
:
102 return STENCILOP_INCR
;
103 case PIPE_STENCIL_OP_DECR_WRAP
:
104 return STENCILOP_DECR
;
105 case PIPE_STENCIL_OP_INVERT
:
106 return STENCILOP_INVERT
;
108 return STENCILOP_ZERO
;
112 static inline unsigned
113 i915_translate_blend_factor(unsigned factor
)
116 case PIPE_BLENDFACTOR_ZERO
:
117 return BLENDFACT_ZERO
;
118 case PIPE_BLENDFACTOR_SRC_ALPHA
:
119 return BLENDFACT_SRC_ALPHA
;
120 case PIPE_BLENDFACTOR_ONE
:
121 return BLENDFACT_ONE
;
122 case PIPE_BLENDFACTOR_SRC_COLOR
:
123 return BLENDFACT_SRC_COLR
;
124 case PIPE_BLENDFACTOR_INV_SRC_COLOR
:
125 return BLENDFACT_INV_SRC_COLR
;
126 case PIPE_BLENDFACTOR_DST_COLOR
:
127 return BLENDFACT_DST_COLR
;
128 case PIPE_BLENDFACTOR_INV_DST_COLOR
:
129 return BLENDFACT_INV_DST_COLR
;
130 case PIPE_BLENDFACTOR_INV_SRC_ALPHA
:
131 return BLENDFACT_INV_SRC_ALPHA
;
132 case PIPE_BLENDFACTOR_DST_ALPHA
:
133 return BLENDFACT_DST_ALPHA
;
134 case PIPE_BLENDFACTOR_INV_DST_ALPHA
:
135 return BLENDFACT_INV_DST_ALPHA
;
136 case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE
:
137 return BLENDFACT_SRC_ALPHA_SATURATE
;
138 case PIPE_BLENDFACTOR_CONST_COLOR
:
139 return BLENDFACT_CONST_COLOR
;
140 case PIPE_BLENDFACTOR_INV_CONST_COLOR
:
141 return BLENDFACT_INV_CONST_COLOR
;
142 case PIPE_BLENDFACTOR_CONST_ALPHA
:
143 return BLENDFACT_CONST_ALPHA
;
144 case PIPE_BLENDFACTOR_INV_CONST_ALPHA
:
145 return BLENDFACT_INV_CONST_ALPHA
;
147 return BLENDFACT_ZERO
;
151 static inline unsigned
152 i915_translate_blend_func(unsigned mode
)
156 return BLENDFUNC_ADD
;
158 return BLENDFUNC_MIN
;
160 return BLENDFUNC_MAX
;
161 case PIPE_BLEND_SUBTRACT
:
162 return BLENDFUNC_SUBTRACT
;
163 case PIPE_BLEND_REVERSE_SUBTRACT
:
164 return BLENDFUNC_REVERSE_SUBTRACT
;
171 static inline unsigned
172 i915_translate_logic_op(unsigned opcode
)
175 case PIPE_LOGICOP_CLEAR
:
176 return LOGICOP_CLEAR
;
177 case PIPE_LOGICOP_AND
:
179 case PIPE_LOGICOP_AND_REVERSE
:
180 return LOGICOP_AND_RVRSE
;
181 case PIPE_LOGICOP_COPY
:
183 case PIPE_LOGICOP_COPY_INVERTED
:
184 return LOGICOP_COPY_INV
;
185 case PIPE_LOGICOP_AND_INVERTED
:
186 return LOGICOP_AND_INV
;
187 case PIPE_LOGICOP_NOOP
:
189 case PIPE_LOGICOP_XOR
:
191 case PIPE_LOGICOP_OR
:
193 case PIPE_LOGICOP_OR_INVERTED
:
194 return LOGICOP_OR_INV
;
195 case PIPE_LOGICOP_NOR
:
197 case PIPE_LOGICOP_EQUIV
:
198 return LOGICOP_EQUIV
;
199 case PIPE_LOGICOP_INVERT
:
201 case PIPE_LOGICOP_OR_REVERSE
:
202 return LOGICOP_OR_RVRSE
;
203 case PIPE_LOGICOP_NAND
:
205 case PIPE_LOGICOP_SET
:
214 static inline boolean
i915_validate_vertices( unsigned hw_prim
, unsigned nr
)
219 case PRIM3D_POINTLIST
:
223 case PRIM3D_LINELIST
:
224 ok
= (nr
>= 2) && (nr
% 2) == 0;
227 case PRIM3D_LINESTRIP
:
232 ok
= (nr
>= 3) && (nr
% 3) == 0;
235 case PRIM3D_TRISTRIP
: