1 /**************************************************************************
3 * Copyright 2007-2008 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 **************************************************************************/
32 #include "pipe/p_context.h"
33 #include "pipe/p_state.h"
34 #include "pipe/p_defines.h"
44 struct cso_context
*cso_create_context( struct pipe_context
*pipe
);
45 void cso_destroy_context( struct cso_context
*cso
);
48 enum pipe_error
cso_set_blend( struct cso_context
*cso
,
49 const struct pipe_blend_state
*blend
);
50 void cso_save_blend(struct cso_context
*cso
);
51 void cso_restore_blend(struct cso_context
*cso
);
55 enum pipe_error
cso_set_depth_stencil_alpha( struct cso_context
*cso
,
56 const struct pipe_depth_stencil_alpha_state
*dsa
);
57 void cso_save_depth_stencil_alpha(struct cso_context
*cso
);
58 void cso_restore_depth_stencil_alpha(struct cso_context
*cso
);
62 enum pipe_error
cso_set_rasterizer( struct cso_context
*cso
,
63 const struct pipe_rasterizer_state
*rasterizer
);
64 void cso_save_rasterizer(struct cso_context
*cso
);
65 void cso_restore_rasterizer(struct cso_context
*cso
);
69 cso_set_samplers(struct cso_context
*cso
,
70 unsigned shader_stage
,
72 const struct pipe_sampler_state
**states
);
75 cso_save_fragment_samplers(struct cso_context
*cso
);
78 cso_restore_fragment_samplers(struct cso_context
*cso
);
80 /* Alternate interface to support state trackers that like to modify
81 * samplers one at a time:
84 cso_single_sampler(struct cso_context
*cso
, unsigned shader_stage
,
85 unsigned idx
, const struct pipe_sampler_state
*states
);
88 cso_single_sampler_done(struct cso_context
*cso
, unsigned shader_stage
);
91 enum pipe_error
cso_set_vertex_elements(struct cso_context
*ctx
,
93 const struct pipe_vertex_element
*states
);
94 void cso_save_vertex_elements(struct cso_context
*ctx
);
95 void cso_restore_vertex_elements(struct cso_context
*ctx
);
98 void cso_set_vertex_buffers(struct cso_context
*ctx
,
99 unsigned start_slot
, unsigned count
,
100 const struct pipe_vertex_buffer
*buffers
);
102 /* One vertex buffer slot is provided with the save/restore functionality.
103 * cso_context chooses the slot, it can be non-zero. */
104 void cso_save_aux_vertex_buffer_slot(struct cso_context
*ctx
);
105 void cso_restore_aux_vertex_buffer_slot(struct cso_context
*ctx
);
106 unsigned cso_get_aux_vertex_buffer_slot(struct cso_context
*ctx
);
109 void cso_set_stream_outputs(struct cso_context
*ctx
,
110 unsigned num_targets
,
111 struct pipe_stream_output_target
**targets
,
112 const unsigned *offsets
);
113 void cso_save_stream_outputs(struct cso_context
*ctx
);
114 void cso_restore_stream_outputs(struct cso_context
*ctx
);
118 * We don't provide shader caching in CSO. Most of the time the api provides
119 * object semantics for shaders anyway, and the cases where it doesn't
120 * (eg mesa's internally-generated texenv programs), it will be up to
121 * the state tracker to implement their own specialized caching.
124 void cso_set_fragment_shader_handle(struct cso_context
*ctx
, void *handle
);
125 void cso_delete_fragment_shader(struct cso_context
*ctx
, void *handle
);
126 void cso_save_fragment_shader(struct cso_context
*cso
);
127 void cso_restore_fragment_shader(struct cso_context
*cso
);
130 void cso_set_vertex_shader_handle(struct cso_context
*ctx
, void *handle
);
131 void cso_delete_vertex_shader(struct cso_context
*ctx
, void *handle
);
132 void cso_save_vertex_shader(struct cso_context
*cso
);
133 void cso_restore_vertex_shader(struct cso_context
*cso
);
136 void cso_set_geometry_shader_handle(struct cso_context
*ctx
, void *handle
);
137 void cso_delete_geometry_shader(struct cso_context
*ctx
, void *handle
);
138 void cso_save_geometry_shader(struct cso_context
*cso
);
139 void cso_restore_geometry_shader(struct cso_context
*cso
);
142 void cso_set_tessctrl_shader_handle(struct cso_context
*ctx
, void *handle
);
143 void cso_delete_tessctrl_shader(struct cso_context
*ctx
, void *handle
);
144 void cso_save_tessctrl_shader(struct cso_context
*cso
);
145 void cso_restore_tessctrl_shader(struct cso_context
*cso
);
148 void cso_set_tesseval_shader_handle(struct cso_context
*ctx
, void *handle
);
149 void cso_delete_tesseval_shader(struct cso_context
*ctx
, void *handle
);
150 void cso_save_tesseval_shader(struct cso_context
*cso
);
151 void cso_restore_tesseval_shader(struct cso_context
*cso
);
154 void cso_set_compute_shader_handle(struct cso_context
*ctx
, void *handle
);
155 void cso_delete_compute_shader(struct cso_context
*ctx
, void *handle
);
158 void cso_set_framebuffer(struct cso_context
*cso
,
159 const struct pipe_framebuffer_state
*fb
);
160 void cso_save_framebuffer(struct cso_context
*cso
);
161 void cso_restore_framebuffer(struct cso_context
*cso
);
164 void cso_set_viewport(struct cso_context
*cso
,
165 const struct pipe_viewport_state
*vp
);
166 void cso_set_viewport_dims(struct cso_context
*ctx
,
167 float width
, float height
, boolean invert
);
168 void cso_save_viewport(struct cso_context
*cso
);
169 void cso_restore_viewport(struct cso_context
*cso
);
172 void cso_set_blend_color(struct cso_context
*cso
,
173 const struct pipe_blend_color
*bc
);
175 void cso_set_sample_mask(struct cso_context
*cso
, unsigned stencil_mask
);
176 void cso_save_sample_mask(struct cso_context
*ctx
);
177 void cso_restore_sample_mask(struct cso_context
*ctx
);
179 void cso_set_min_samples(struct cso_context
*cso
, unsigned min_samples
);
180 void cso_save_min_samples(struct cso_context
*ctx
);
181 void cso_restore_min_samples(struct cso_context
*ctx
);
183 void cso_set_stencil_ref(struct cso_context
*cso
,
184 const struct pipe_stencil_ref
*sr
);
185 void cso_save_stencil_ref(struct cso_context
*cso
);
186 void cso_restore_stencil_ref(struct cso_context
*cso
);
188 void cso_set_render_condition(struct cso_context
*cso
,
189 struct pipe_query
*query
,
190 boolean condition
, uint mode
);
191 void cso_save_render_condition(struct cso_context
*cso
);
192 void cso_restore_render_condition(struct cso_context
*cso
);
195 /* sampler view state */
198 cso_set_sampler_views(struct cso_context
*cso
,
199 unsigned shader_stage
,
201 struct pipe_sampler_view
**views
);
204 cso_save_fragment_sampler_views(struct cso_context
*ctx
);
207 cso_restore_fragment_sampler_views(struct cso_context
*ctx
);
210 /* constant buffers */
212 void cso_set_constant_buffer(struct cso_context
*cso
, unsigned shader_stage
,
213 unsigned index
, struct pipe_constant_buffer
*cb
);
214 void cso_set_constant_buffer_resource(struct cso_context
*cso
,
215 unsigned shader_stage
,
217 struct pipe_resource
*buffer
);
218 void cso_save_constant_buffer_slot0(struct cso_context
*cso
,
219 unsigned shader_stage
);
220 void cso_restore_constant_buffer_slot0(struct cso_context
*cso
,
221 unsigned shader_stage
);
227 cso_set_index_buffer(struct cso_context
*cso
,
228 const struct pipe_index_buffer
*ib
);
231 cso_draw_vbo(struct cso_context
*cso
,
232 const struct pipe_draw_info
*info
);
235 cso_draw_arrays_instanced(struct cso_context
*cso
, uint mode
,
236 uint start
, uint count
,
237 uint start_instance
, uint instance_count
);
240 cso_draw_arrays(struct cso_context
*cso
, uint mode
, uint start
, uint count
);