1 /**************************************************************************
3 * Copyright 2007-2008 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 **************************************************************************/
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
);
46 void cso_install_vbuf(struct cso_context
*ctx
, struct u_vbuf
*vbuf
);
48 void cso_release_all( struct cso_context
*ctx
);
50 void cso_destroy_context( struct cso_context
*cso
);
54 enum pipe_error
cso_set_blend( struct cso_context
*cso
,
55 const struct pipe_blend_state
*blend
);
56 void cso_save_blend(struct cso_context
*cso
);
57 void cso_restore_blend(struct cso_context
*cso
);
61 enum pipe_error
cso_set_depth_stencil_alpha( struct cso_context
*cso
,
62 const struct pipe_depth_stencil_alpha_state
*dsa
);
63 void cso_save_depth_stencil_alpha(struct cso_context
*cso
);
64 void cso_restore_depth_stencil_alpha(struct cso_context
*cso
);
68 enum pipe_error
cso_set_rasterizer( struct cso_context
*cso
,
69 const struct pipe_rasterizer_state
*rasterizer
);
70 void cso_save_rasterizer(struct cso_context
*cso
);
71 void cso_restore_rasterizer(struct cso_context
*cso
);
75 enum pipe_error
cso_set_samplers( struct cso_context
*cso
,
77 const struct pipe_sampler_state
**states
);
78 void cso_save_samplers(struct cso_context
*cso
);
79 void cso_restore_samplers(struct cso_context
*cso
);
81 /* Alternate interface to support state trackers that like to modify
82 * samplers one at a time:
84 enum pipe_error
cso_single_sampler( struct cso_context
*cso
,
86 const struct pipe_sampler_state
*states
);
88 void cso_single_sampler_done( struct cso_context
*cso
);
90 enum pipe_error
cso_set_vertex_samplers(struct cso_context
*cso
,
92 const struct pipe_sampler_state
**states
);
95 cso_save_vertex_samplers(struct cso_context
*cso
);
98 cso_restore_vertex_samplers(struct cso_context
*cso
);
101 cso_single_vertex_sampler(struct cso_context
*cso
,
103 const struct pipe_sampler_state
*states
);
106 cso_single_vertex_sampler_done(struct cso_context
*cso
);
109 enum pipe_error
cso_set_vertex_elements(struct cso_context
*ctx
,
111 const struct pipe_vertex_element
*states
);
112 void cso_save_vertex_elements(struct cso_context
*ctx
);
113 void cso_restore_vertex_elements(struct cso_context
*ctx
);
116 void cso_set_vertex_buffers(struct cso_context
*ctx
,
118 const struct pipe_vertex_buffer
*buffers
);
119 void cso_save_vertex_buffers(struct cso_context
*ctx
);
120 void cso_restore_vertex_buffers(struct cso_context
*ctx
);
123 void cso_set_stream_outputs(struct cso_context
*ctx
,
124 unsigned num_targets
,
125 struct pipe_stream_output_target
**targets
,
126 unsigned append_bitmask
);
127 void cso_save_stream_outputs(struct cso_context
*ctx
);
128 void cso_restore_stream_outputs(struct cso_context
*ctx
);
131 enum pipe_error
cso_set_fragment_shader_handle(struct cso_context
*ctx
,
133 void cso_delete_fragment_shader(struct cso_context
*ctx
, void *handle
);
134 void cso_save_fragment_shader(struct cso_context
*cso
);
135 void cso_restore_fragment_shader(struct cso_context
*cso
);
138 enum pipe_error
cso_set_vertex_shader_handle(struct cso_context
*ctx
,
140 void cso_delete_vertex_shader(struct cso_context
*ctx
, void *handle
);
141 void cso_save_vertex_shader(struct cso_context
*cso
);
142 void cso_restore_vertex_shader(struct cso_context
*cso
);
145 enum pipe_error
cso_set_geometry_shader_handle(struct cso_context
*ctx
,
147 void cso_delete_geometry_shader(struct cso_context
*ctx
, void *handle
);
148 void cso_save_geometry_shader(struct cso_context
*cso
);
149 void cso_restore_geometry_shader(struct cso_context
*cso
);
152 enum pipe_error
cso_set_framebuffer(struct cso_context
*cso
,
153 const struct pipe_framebuffer_state
*fb
);
154 void cso_save_framebuffer(struct cso_context
*cso
);
155 void cso_restore_framebuffer(struct cso_context
*cso
);
158 enum pipe_error
cso_set_viewport(struct cso_context
*cso
,
159 const struct pipe_viewport_state
*vp
);
160 void cso_save_viewport(struct cso_context
*cso
);
161 void cso_restore_viewport(struct cso_context
*cso
);
164 enum pipe_error
cso_set_blend_color(struct cso_context
*cso
,
165 const struct pipe_blend_color
*bc
);
167 enum pipe_error
cso_set_sample_mask(struct cso_context
*cso
,
168 unsigned stencil_mask
);
170 enum pipe_error
cso_set_stencil_ref(struct cso_context
*cso
,
171 const struct pipe_stencil_ref
*sr
);
172 void cso_save_stencil_ref(struct cso_context
*cso
);
173 void cso_restore_stencil_ref(struct cso_context
*cso
);
179 cso_set_clip(struct cso_context
*cso
,
180 const struct pipe_clip_state
*clip
);
183 cso_save_clip(struct cso_context
*cso
);
186 cso_restore_clip(struct cso_context
*cso
);
189 /* fragment sampler view state */
192 * We don't provide shader caching in CSO. Most of the time the api provides
193 * object semantics for shaders anyway, and the cases where it doesn't
194 * (eg mesa's internally-generated texenv programs), it will be up to
195 * the state tracker to implement their own specialized caching.
199 cso_set_fragment_sampler_views(struct cso_context
*cso
,
201 struct pipe_sampler_view
**views
);
204 cso_save_fragment_sampler_views(struct cso_context
*cso
);
207 cso_restore_fragment_sampler_views(struct cso_context
*cso
);
210 /* vertex sampler view state */
213 cso_set_vertex_sampler_views(struct cso_context
*cso
,
215 struct pipe_sampler_view
**views
);
218 cso_save_vertex_sampler_views(struct cso_context
*cso
);
221 cso_restore_vertex_sampler_views(struct cso_context
*cso
);
226 cso_set_index_buffer(struct cso_context
*cso
,
227 const struct pipe_index_buffer
*ib
);
230 cso_draw_vbo(struct cso_context
*cso
,
231 const struct pipe_draw_info
*info
);
233 /* helper drawing function */
235 cso_draw_arrays(struct cso_context
*cso
, uint mode
, uint start
, uint count
);