1 /**************************************************************************
3 * Copyright 2009 VMware, Inc.
4 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 **************************************************************************/
30 * @author Jose Fonseca <jfonseca@vmware.com>
31 * @author Keith Whitwell <keith@tungstengraphics.com>
34 #include "util/u_memory.h"
35 #include "util/u_math.h"
36 #include "util/u_dump.h"
37 #include "draw/draw_context.h"
38 #include "lp_screen.h"
39 #include "lp_context.h"
44 llvmpipe_create_blend_state(struct pipe_context
*pipe
,
45 const struct pipe_blend_state
*blend
)
47 return mem_dup(blend
, sizeof(*blend
));
52 llvmpipe_bind_blend_state(struct pipe_context
*pipe
, void *blend
)
54 struct llvmpipe_context
*llvmpipe
= llvmpipe_context(pipe
);
56 if (llvmpipe
->blend
== blend
)
59 draw_flush(llvmpipe
->draw
);
61 llvmpipe
->blend
= blend
;
63 llvmpipe
->dirty
|= LP_NEW_BLEND
;
68 llvmpipe_delete_blend_state(struct pipe_context
*pipe
, void *blend
)
75 llvmpipe_set_blend_color(struct pipe_context
*pipe
,
76 const struct pipe_blend_color
*blend_color
)
78 struct llvmpipe_context
*llvmpipe
= llvmpipe_context(pipe
);
83 if(memcmp(&llvmpipe
->blend_color
, blend_color
, sizeof *blend_color
) == 0)
86 draw_flush(llvmpipe
->draw
);
88 memcpy(&llvmpipe
->blend_color
, blend_color
, sizeof *blend_color
);
90 llvmpipe
->dirty
|= LP_NEW_BLEND_COLOR
;
94 /** XXX move someday? Or consolidate all these simple state setters
100 llvmpipe_create_depth_stencil_state(struct pipe_context
*pipe
,
101 const struct pipe_depth_stencil_alpha_state
*depth_stencil
)
103 return mem_dup(depth_stencil
, sizeof(*depth_stencil
));
108 llvmpipe_bind_depth_stencil_state(struct pipe_context
*pipe
,
111 struct llvmpipe_context
*llvmpipe
= llvmpipe_context(pipe
);
113 if (llvmpipe
->depth_stencil
== depth_stencil
)
116 draw_flush(llvmpipe
->draw
);
118 llvmpipe
->depth_stencil
= depth_stencil
;
120 llvmpipe
->dirty
|= LP_NEW_DEPTH_STENCIL_ALPHA
;
125 llvmpipe_delete_depth_stencil_state(struct pipe_context
*pipe
, void *depth
)
132 llvmpipe_set_stencil_ref(struct pipe_context
*pipe
,
133 const struct pipe_stencil_ref
*stencil_ref
)
135 struct llvmpipe_context
*llvmpipe
= llvmpipe_context(pipe
);
140 if(memcmp(&llvmpipe
->stencil_ref
, stencil_ref
, sizeof *stencil_ref
) == 0)
143 draw_flush(llvmpipe
->draw
);
145 memcpy(&llvmpipe
->stencil_ref
, stencil_ref
, sizeof *stencil_ref
);
147 /* not sure. want new flag? */
148 llvmpipe
->dirty
|= LP_NEW_DEPTH_STENCIL_ALPHA
;
152 llvmpipe_set_sample_mask(struct pipe_context
*pipe
,
153 unsigned sample_mask
)
158 llvmpipe_init_blend_funcs(struct llvmpipe_context
*llvmpipe
)
160 llvmpipe
->pipe
.create_blend_state
= llvmpipe_create_blend_state
;
161 llvmpipe
->pipe
.bind_blend_state
= llvmpipe_bind_blend_state
;
162 llvmpipe
->pipe
.delete_blend_state
= llvmpipe_delete_blend_state
;
164 llvmpipe
->pipe
.create_depth_stencil_alpha_state
= llvmpipe_create_depth_stencil_state
;
165 llvmpipe
->pipe
.bind_depth_stencil_alpha_state
= llvmpipe_bind_depth_stencil_state
;
166 llvmpipe
->pipe
.delete_depth_stencil_alpha_state
= llvmpipe_delete_depth_stencil_state
;
168 llvmpipe
->pipe
.set_blend_color
= llvmpipe_set_blend_color
;
170 llvmpipe
->pipe
.set_stencil_ref
= llvmpipe_set_stencil_ref
;
171 llvmpipe
->pipe
.set_sample_mask
= llvmpipe_set_sample_mask
;