1 /**************************************************************************
3 * Copyright 2007 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 **************************************************************************/
30 * Keith Whitwell <keith@tungstengraphics.com>
35 #include "st_context.h"
38 #include "pipe/p_context.h"
39 #include "pipe/p_defines.h"
43 * Convert GLenum stencil func tokens to pipe tokens.
46 gl_alpha_func_to_sp(GLenum func
)
48 /* Same values, just biased */
49 assert(PIPE_FUNC_NEVER
== GL_NEVER
- GL_NEVER
);
50 assert(PIPE_FUNC_LESS
== GL_LESS
- GL_NEVER
);
51 assert(PIPE_FUNC_EQUAL
== GL_EQUAL
- GL_NEVER
);
52 assert(PIPE_FUNC_LEQUAL
== GL_LEQUAL
- GL_NEVER
);
53 assert(PIPE_FUNC_GREATER
== GL_GREATER
- GL_NEVER
);
54 assert(PIPE_FUNC_NOTEQUAL
== GL_NOTEQUAL
- GL_NEVER
);
55 assert(PIPE_FUNC_GEQUAL
== GL_GEQUAL
- GL_NEVER
);
56 assert(PIPE_FUNC_ALWAYS
== GL_ALWAYS
- GL_NEVER
);
57 assert(func
>= GL_NEVER
);
58 assert(func
<= GL_ALWAYS
);
59 return func
- GL_NEVER
;
64 update_alpha_test( struct st_context
*st
)
66 struct pipe_alpha_test_state alpha
;
67 const struct cso_alpha_test
*cso
;
69 memset(&alpha
, 0, sizeof(alpha
));
71 if (st
->ctx
->Color
.AlphaEnabled
) {
73 alpha
.func
= gl_alpha_func_to_sp(st
->ctx
->Color
.AlphaFunc
);
74 alpha
.ref
= st
->ctx
->Color
.AlphaRef
;
76 cso
= st_cached_alpha_test_state(st
, &alpha
);
77 if (st
->state
.alpha_test
!= cso
) {
78 /* state has changed */
79 st
->state
.alpha_test
= cso
;
80 st
->pipe
->bind_alpha_test_state(st
->pipe
, cso
->data
); /* bind new state */
85 const struct st_tracked_state st_update_alpha_test
= {
86 .name
= "st_update_alpha_test",
91 .update
= update_alpha_test