1 /**************************************************************************
3 * Copyright 2007 VMware, Inc.
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 VMWARE 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 /* Authors: Keith Whitwell <keithw@vmware.com>
31 #include "util/u_math.h"
32 #include "util/u_memory.h"
33 #include "draw/draw_context.h"
34 #include "sp_context.h"
39 softpipe_create_blend_state(struct pipe_context
*pipe
,
40 const struct pipe_blend_state
*blend
)
42 return mem_dup(blend
, sizeof(*blend
));
47 softpipe_bind_blend_state(struct pipe_context
*pipe
,
50 struct softpipe_context
*softpipe
= softpipe_context(pipe
);
52 draw_flush(softpipe
->draw
);
54 softpipe
->blend
= (struct pipe_blend_state
*)blend
;
56 softpipe
->dirty
|= SP_NEW_BLEND
;
61 softpipe_delete_blend_state(struct pipe_context
*pipe
,
69 softpipe_set_blend_color(struct pipe_context
*pipe
,
70 const struct pipe_blend_color
*blend_color
)
72 struct softpipe_context
*softpipe
= softpipe_context(pipe
);
75 draw_flush(softpipe
->draw
);
77 softpipe
->blend_color
= *blend_color
;
79 /* save clamped color too */
80 for (i
= 0; i
< 4; i
++)
81 softpipe
->blend_color_clamped
.color
[i
] =
82 SATURATE(blend_color
->color
[i
]);
84 softpipe
->dirty
|= SP_NEW_BLEND
;
89 softpipe_create_depth_stencil_state(struct pipe_context
*pipe
,
90 const struct pipe_depth_stencil_alpha_state
*depth_stencil
)
92 return mem_dup(depth_stencil
, sizeof(*depth_stencil
));
97 softpipe_bind_depth_stencil_state(struct pipe_context
*pipe
,
100 struct softpipe_context
*softpipe
= softpipe_context(pipe
);
102 softpipe
->depth_stencil
= (struct pipe_depth_stencil_alpha_state
*)depth_stencil
;
104 softpipe
->dirty
|= SP_NEW_DEPTH_STENCIL_ALPHA
;
109 softpipe_delete_depth_stencil_state(struct pipe_context
*pipe
, void *depth
)
116 softpipe_set_stencil_ref(struct pipe_context
*pipe
,
117 const struct pipe_stencil_ref
*stencil_ref
)
119 struct softpipe_context
*softpipe
= softpipe_context(pipe
);
121 softpipe
->stencil_ref
= *stencil_ref
;
123 softpipe
->dirty
|= SP_NEW_DEPTH_STENCIL_ALPHA
;
128 softpipe_set_sample_mask(struct pipe_context
*pipe
,
129 unsigned sample_mask
)
135 softpipe_init_blend_funcs(struct pipe_context
*pipe
)
137 pipe
->create_blend_state
= softpipe_create_blend_state
;
138 pipe
->bind_blend_state
= softpipe_bind_blend_state
;
139 pipe
->delete_blend_state
= softpipe_delete_blend_state
;
141 pipe
->set_blend_color
= softpipe_set_blend_color
;
143 pipe
->create_depth_stencil_alpha_state
= softpipe_create_depth_stencil_state
;
144 pipe
->bind_depth_stencil_alpha_state
= softpipe_bind_depth_stencil_state
;
145 pipe
->delete_depth_stencil_alpha_state
= softpipe_delete_depth_stencil_state
;
147 pipe
->set_stencil_ref
= softpipe_set_stencil_ref
;
149 pipe
->set_sample_mask
= softpipe_set_sample_mask
;