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"
37 #include "pipe/p_context.h"
38 #include "pipe/p_defines.h"
42 * Convert GLenum depth func tokens to pipe tokens.
45 gl_depth_func_to_sp(GLenum func
)
47 /* Same values, just biased */
48 assert(PIPE_FUNC_NEVER
== GL_NEVER
- GL_NEVER
);
49 assert(PIPE_FUNC_LESS
== GL_LESS
- GL_NEVER
);
50 assert(PIPE_FUNC_EQUAL
== GL_EQUAL
- GL_NEVER
);
51 assert(PIPE_FUNC_LEQUAL
== GL_LEQUAL
- GL_NEVER
);
52 assert(PIPE_FUNC_GREATER
== GL_GREATER
- GL_NEVER
);
53 assert(PIPE_FUNC_NOTEQUAL
== GL_NOTEQUAL
- GL_NEVER
);
54 assert(PIPE_FUNC_GEQUAL
== GL_GEQUAL
- GL_NEVER
);
55 assert(PIPE_FUNC_ALWAYS
== GL_ALWAYS
- GL_NEVER
);
56 assert(func
>= GL_NEVER
);
57 assert(func
<= GL_ALWAYS
);
58 return func
- GL_NEVER
;
63 update_depth( struct st_context
*st
)
65 struct pipe_depth_state depth
;
67 memset(&depth
, 0, sizeof(depth
));
69 depth
.enabled
= st
->ctx
->Depth
.Test
;
70 depth
.writemask
= st
->ctx
->Depth
.Mask
;
71 depth
.func
= gl_depth_func_to_sp(st
->ctx
->Depth
.Func
);
72 depth
.clear
= st
->ctx
->Depth
.Clear
;
74 if (st
->ctx
->Query
.CurrentOcclusionObject
&&
75 st
->ctx
->Query
.CurrentOcclusionObject
->Active
)
76 depth
.occlusion_count
= 1;
78 if (memcmp(&depth
, &st
->state
.depth
, sizeof(depth
)) != 0) {
79 /* state has changed */
80 st
->state
.depth
= depth
; /* struct copy */
81 st
->pipe
->set_depth_state(st
->pipe
, &depth
); /* set new state */
86 const struct st_tracked_state st_update_depth
= {
91 .update
= update_depth