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 **************************************************************************/
36 #include "intel_screen.h"
37 #include "intel_context.h"
38 #include "intel_regions.h"
39 #include "swrast/swrast.h"
41 int intel_translate_shadow_compare_func( GLenum func
)
45 return COMPAREFUNC_ALWAYS
;
47 return COMPAREFUNC_LEQUAL
;
49 return COMPAREFUNC_LESS
;
51 return COMPAREFUNC_GEQUAL
;
53 return COMPAREFUNC_GREATER
;
55 return COMPAREFUNC_EQUAL
;
57 return COMPAREFUNC_NOTEQUAL
;
59 return COMPAREFUNC_NEVER
;
62 fprintf(stderr
, "Unknown value in %s: %x\n", __FUNCTION__
, func
);
63 return COMPAREFUNC_NEVER
;
66 int intel_translate_compare_func( GLenum func
)
70 return COMPAREFUNC_NEVER
;
72 return COMPAREFUNC_LESS
;
74 return COMPAREFUNC_LEQUAL
;
76 return COMPAREFUNC_GREATER
;
78 return COMPAREFUNC_GEQUAL
;
80 return COMPAREFUNC_NOTEQUAL
;
82 return COMPAREFUNC_EQUAL
;
84 return COMPAREFUNC_ALWAYS
;
87 fprintf(stderr
, "Unknown value in %s: %x\n", __FUNCTION__
, func
);
88 return COMPAREFUNC_ALWAYS
;
91 int intel_translate_stencil_op( GLenum op
)
95 return STENCILOP_KEEP
;
97 return STENCILOP_ZERO
;
99 return STENCILOP_REPLACE
;
101 return STENCILOP_INCRSAT
;
103 return STENCILOP_DECRSAT
;
105 return STENCILOP_INCR
;
107 return STENCILOP_DECR
;
109 return STENCILOP_INVERT
;
111 return STENCILOP_ZERO
;
115 int intel_translate_blend_factor( GLenum factor
)
119 return BLENDFACT_ZERO
;
121 return BLENDFACT_SRC_ALPHA
;
123 return BLENDFACT_ONE
;
125 return BLENDFACT_SRC_COLR
;
126 case GL_ONE_MINUS_SRC_COLOR
:
127 return BLENDFACT_INV_SRC_COLR
;
129 return BLENDFACT_DST_COLR
;
130 case GL_ONE_MINUS_DST_COLOR
:
131 return BLENDFACT_INV_DST_COLR
;
132 case GL_ONE_MINUS_SRC_ALPHA
:
133 return BLENDFACT_INV_SRC_ALPHA
;
135 return BLENDFACT_DST_ALPHA
;
136 case GL_ONE_MINUS_DST_ALPHA
:
137 return BLENDFACT_INV_DST_ALPHA
;
138 case GL_SRC_ALPHA_SATURATE
:
139 return BLENDFACT_SRC_ALPHA_SATURATE
;
140 case GL_CONSTANT_COLOR
:
141 return BLENDFACT_CONST_COLOR
;
142 case GL_ONE_MINUS_CONSTANT_COLOR
:
143 return BLENDFACT_INV_CONST_COLOR
;
144 case GL_CONSTANT_ALPHA
:
145 return BLENDFACT_CONST_ALPHA
;
146 case GL_ONE_MINUS_CONSTANT_ALPHA
:
147 return BLENDFACT_INV_CONST_ALPHA
;
150 fprintf(stderr
, "Unknown value in %s: %x\n", __FUNCTION__
, factor
);
151 return BLENDFACT_ZERO
;
154 int intel_translate_logic_op( GLenum opcode
)
158 return LOGICOP_CLEAR
;
162 return LOGICOP_AND_RVRSE
;
165 case GL_COPY_INVERTED
:
166 return LOGICOP_COPY_INV
;
167 case GL_AND_INVERTED
:
168 return LOGICOP_AND_INV
;
176 return LOGICOP_OR_INV
;
180 return LOGICOP_EQUIV
;
184 return LOGICOP_OR_RVRSE
;
195 static void intelClearColor(GLcontext
*ctx
, const GLfloat color
[4])
197 struct intel_context
*intel
= intel_context(ctx
);
199 UNCLAMPED_FLOAT_TO_RGBA_CHAN(intel
->clear_chan
, color
);
201 intel
->ClearColor8888
= INTEL_PACKCOLOR8888(intel
->clear_chan
[0],
202 intel
->clear_chan
[1],
203 intel
->clear_chan
[2],
204 intel
->clear_chan
[3]);
205 intel
->ClearColor565
= INTEL_PACKCOLOR565(intel
->clear_chan
[0],
206 intel
->clear_chan
[1],
207 intel
->clear_chan
[2]);
212 /* Fallback to swrast for select and feedback.
214 static void intelRenderMode( GLcontext
*ctx
, GLenum mode
)
216 struct intel_context
*intel
= intel_context(ctx
);
217 FALLBACK( intel
, INTEL_FALLBACK_RENDERMODE
, (mode
!= GL_RENDER
) );
221 void intelInitStateFuncs( struct dd_function_table
*functions
)
223 functions
->RenderMode
= intelRenderMode
;
224 functions
->ClearColor
= intelClearColor
;