1 /**************************************************************************
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
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 TUNGSTEN GRAPHICS 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_stencil_op(unsigned op
)
66 case PIPE_STENCIL_OP_KEEP
:
67 return STENCILOP_KEEP
;
68 case PIPE_STENCIL_OP_ZERO
:
69 return STENCILOP_ZERO
;
70 case PIPE_STENCIL_OP_REPLACE
:
71 return STENCILOP_REPLACE
;
72 case PIPE_STENCIL_OP_INCR
:
73 return STENCILOP_INCRSAT
;
74 case PIPE_STENCIL_OP_DECR
:
75 return STENCILOP_DECRSAT
;
76 case PIPE_STENCIL_OP_INCR_WRAP
:
77 return STENCILOP_INCR
;
78 case PIPE_STENCIL_OP_DECR_WRAP
:
79 return STENCILOP_DECR
;
80 case PIPE_STENCIL_OP_INVERT
:
81 return STENCILOP_INVERT
;
83 return STENCILOP_ZERO
;
87 static INLINE
unsigned
88 i915_translate_blend_factor(unsigned factor
)
91 case PIPE_BLENDFACTOR_ZERO
:
92 return BLENDFACT_ZERO
;
93 case PIPE_BLENDFACTOR_SRC_ALPHA
:
94 return BLENDFACT_SRC_ALPHA
;
95 case PIPE_BLENDFACTOR_ONE
:
97 case PIPE_BLENDFACTOR_SRC_COLOR
:
98 return BLENDFACT_SRC_COLR
;
99 case PIPE_BLENDFACTOR_INV_SRC_COLOR
:
100 return BLENDFACT_INV_SRC_COLR
;
101 case PIPE_BLENDFACTOR_DST_COLOR
:
102 return BLENDFACT_DST_COLR
;
103 case PIPE_BLENDFACTOR_INV_DST_COLOR
:
104 return BLENDFACT_INV_DST_COLR
;
105 case PIPE_BLENDFACTOR_INV_SRC_ALPHA
:
106 return BLENDFACT_INV_SRC_ALPHA
;
107 case PIPE_BLENDFACTOR_DST_ALPHA
:
108 return BLENDFACT_DST_ALPHA
;
109 case PIPE_BLENDFACTOR_INV_DST_ALPHA
:
110 return BLENDFACT_INV_DST_ALPHA
;
111 case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE
:
112 return BLENDFACT_SRC_ALPHA_SATURATE
;
113 case PIPE_BLENDFACTOR_CONST_COLOR
:
114 return BLENDFACT_CONST_COLOR
;
115 case PIPE_BLENDFACTOR_INV_CONST_COLOR
:
116 return BLENDFACT_INV_CONST_COLOR
;
117 case PIPE_BLENDFACTOR_CONST_ALPHA
:
118 return BLENDFACT_CONST_ALPHA
;
119 case PIPE_BLENDFACTOR_INV_CONST_ALPHA
:
120 return BLENDFACT_INV_CONST_ALPHA
;
122 return BLENDFACT_ZERO
;
126 static INLINE
unsigned
127 i915_translate_blend_func(unsigned mode
)
131 return BLENDFUNC_ADD
;
133 return BLENDFUNC_MIN
;
135 return BLENDFUNC_MAX
;
136 case PIPE_BLEND_SUBTRACT
:
137 return BLENDFUNC_SUBTRACT
;
138 case PIPE_BLEND_REVERSE_SUBTRACT
:
139 return BLENDFUNC_REVERSE_SUBTRACT
;
146 static INLINE
unsigned
147 i915_translate_logic_op(unsigned opcode
)
150 case PIPE_LOGICOP_CLEAR
:
151 return LOGICOP_CLEAR
;
152 case PIPE_LOGICOP_AND
:
154 case PIPE_LOGICOP_AND_REVERSE
:
155 return LOGICOP_AND_RVRSE
;
156 case PIPE_LOGICOP_COPY
:
158 case PIPE_LOGICOP_COPY_INVERTED
:
159 return LOGICOP_COPY_INV
;
160 case PIPE_LOGICOP_AND_INVERTED
:
161 return LOGICOP_AND_INV
;
162 case PIPE_LOGICOP_NOOP
:
164 case PIPE_LOGICOP_XOR
:
166 case PIPE_LOGICOP_OR
:
168 case PIPE_LOGICOP_OR_INVERTED
:
169 return LOGICOP_OR_INV
;
170 case PIPE_LOGICOP_NOR
:
172 case PIPE_LOGICOP_EQUIV
:
173 return LOGICOP_EQUIV
;
174 case PIPE_LOGICOP_INVERT
:
176 case PIPE_LOGICOP_OR_REVERSE
:
177 return LOGICOP_OR_RVRSE
;
178 case PIPE_LOGICOP_NAND
:
180 case PIPE_LOGICOP_SET
:
189 static INLINE boolean
i915_validate_vertices( unsigned hw_prim
, unsigned nr
)
194 case PRIM3D_POINTLIST
:
198 case PRIM3D_LINELIST
:
199 ok
= (nr
>= 2) && (nr
% 2) == 0;
202 case PRIM3D_LINESTRIP
:
207 ok
= (nr
>= 3) && (nr
% 3) == 0;
210 case PRIM3D_TRISTRIP
: