cso_context.h revision 877128505431adaf817dc8069172ebe4a1cdf5d8
1/**************************************************************************
2 *
3 * Copyright 2007-2008 VMware, Inc.
4 * All Rights Reserved.
5 *
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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
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.
25 *
26 **************************************************************************/
27
28
29#ifndef CSO_CONTEXT_H
30#define CSO_CONTEXT_H
31
32#include "pipe/p_context.h"
33#include "pipe/p_state.h"
34#include "pipe/p_defines.h"
35
36
37#ifdef	__cplusplus
38extern "C" {
39#endif
40
41struct cso_context;
42struct u_vbuf;
43
44struct cso_context *cso_create_context( struct pipe_context *pipe );
45
46void cso_release_all( struct cso_context *ctx );
47
48void cso_destroy_context( struct cso_context *cso );
49
50
51
52enum pipe_error cso_set_blend( struct cso_context *cso,
53                               const struct pipe_blend_state *blend );
54void cso_save_blend(struct cso_context *cso);
55void cso_restore_blend(struct cso_context *cso);
56
57
58
59enum pipe_error cso_set_depth_stencil_alpha( struct cso_context *cso,
60                                             const struct pipe_depth_stencil_alpha_state *dsa );
61void cso_save_depth_stencil_alpha(struct cso_context *cso);
62void cso_restore_depth_stencil_alpha(struct cso_context *cso);
63
64
65
66enum pipe_error cso_set_rasterizer( struct cso_context *cso,
67                                    const struct pipe_rasterizer_state *rasterizer );
68void cso_save_rasterizer(struct cso_context *cso);
69void cso_restore_rasterizer(struct cso_context *cso);
70
71
72enum pipe_error
73cso_set_samplers(struct cso_context *cso,
74                 unsigned shader_stage,
75                 unsigned count,
76                 const struct pipe_sampler_state **states);
77
78void
79cso_save_samplers(struct cso_context *cso, unsigned shader_stage);
80
81void
82cso_restore_samplers(struct cso_context *cso, unsigned shader_stage);
83
84/* Alternate interface to support state trackers that like to modify
85 * samplers one at a time:
86 */
87enum pipe_error
88cso_single_sampler(struct cso_context *cso,
89                   unsigned shader_stage,
90                   unsigned count,
91                   const struct pipe_sampler_state *states);
92
93void
94cso_single_sampler_done(struct cso_context *cso, unsigned shader_stage);
95
96
97enum pipe_error cso_set_vertex_elements(struct cso_context *ctx,
98                                        unsigned count,
99                                        const struct pipe_vertex_element *states);
100void cso_save_vertex_elements(struct cso_context *ctx);
101void cso_restore_vertex_elements(struct cso_context *ctx);
102
103
104void cso_set_vertex_buffers(struct cso_context *ctx,
105                            unsigned start_slot, unsigned count,
106                            const struct pipe_vertex_buffer *buffers);
107
108/* One vertex buffer slot is provided with the save/restore functionality.
109 * cso_context chooses the slot, it can be non-zero. */
110void cso_save_aux_vertex_buffer_slot(struct cso_context *ctx);
111void cso_restore_aux_vertex_buffer_slot(struct cso_context *ctx);
112unsigned cso_get_aux_vertex_buffer_slot(struct cso_context *ctx);
113
114
115void cso_set_stream_outputs(struct cso_context *ctx,
116                            unsigned num_targets,
117                            struct pipe_stream_output_target **targets,
118                            unsigned append_bitmask);
119void cso_save_stream_outputs(struct cso_context *ctx);
120void cso_restore_stream_outputs(struct cso_context *ctx);
121
122
123/*
124 * We don't provide shader caching in CSO.  Most of the time the api provides
125 * object semantics for shaders anyway, and the cases where it doesn't
126 * (eg mesa's internally-generated texenv programs), it will be up to
127 * the state tracker to implement their own specialized caching.
128 */
129
130void cso_set_fragment_shader_handle(struct cso_context *ctx, void *handle);
131void cso_delete_fragment_shader(struct cso_context *ctx, void *handle );
132void cso_save_fragment_shader(struct cso_context *cso);
133void cso_restore_fragment_shader(struct cso_context *cso);
134
135
136void cso_set_vertex_shader_handle(struct cso_context *ctx, void *handle);
137void cso_delete_vertex_shader(struct cso_context *ctx, void *handle );
138void cso_save_vertex_shader(struct cso_context *cso);
139void cso_restore_vertex_shader(struct cso_context *cso);
140
141
142void cso_set_geometry_shader_handle(struct cso_context *ctx, void *handle);
143void cso_delete_geometry_shader(struct cso_context *ctx, void *handle);
144void cso_save_geometry_shader(struct cso_context *cso);
145void cso_restore_geometry_shader(struct cso_context *cso);
146
147
148void cso_set_framebuffer(struct cso_context *cso,
149                         const struct pipe_framebuffer_state *fb);
150void cso_save_framebuffer(struct cso_context *cso);
151void cso_restore_framebuffer(struct cso_context *cso);
152
153
154void cso_set_viewport(struct cso_context *cso,
155                      const struct pipe_viewport_state *vp);
156void cso_save_viewport(struct cso_context *cso);
157void cso_restore_viewport(struct cso_context *cso);
158
159
160void cso_set_blend_color(struct cso_context *cso,
161                         const struct pipe_blend_color *bc);
162
163void cso_set_sample_mask(struct cso_context *cso, unsigned stencil_mask);
164void cso_save_sample_mask(struct cso_context *ctx);
165void cso_restore_sample_mask(struct cso_context *ctx);
166
167void cso_set_stencil_ref(struct cso_context *cso,
168                         const struct pipe_stencil_ref *sr);
169void cso_save_stencil_ref(struct cso_context *cso);
170void cso_restore_stencil_ref(struct cso_context *cso);
171
172void cso_set_render_condition(struct cso_context *cso,
173                              struct pipe_query *query,
174                              boolean condition, uint mode);
175void cso_save_render_condition(struct cso_context *cso);
176void cso_restore_render_condition(struct cso_context *cso);
177
178
179/* clip state */
180
181void
182cso_set_clip(struct cso_context *cso,
183             const struct pipe_clip_state *clip);
184
185void
186cso_save_clip(struct cso_context *cso);
187
188void
189cso_restore_clip(struct cso_context *cso);
190
191
192/* sampler view state */
193
194void
195cso_set_sampler_views(struct cso_context *cso,
196                      unsigned shader_stage,
197                      unsigned count,
198                      struct pipe_sampler_view **views);
199
200void
201cso_save_sampler_views(struct cso_context *cso, unsigned shader_stage);
202
203void
204cso_restore_sampler_views(struct cso_context *cso, unsigned shader_stage);
205
206
207/* constant buffers */
208
209void cso_set_constant_buffer(struct cso_context *cso, unsigned shader_stage,
210                             unsigned index, struct pipe_constant_buffer *cb);
211void cso_set_constant_buffer_resource(struct cso_context *cso,
212                                      unsigned shader_stage,
213                                      unsigned index,
214                                      struct pipe_resource *buffer);
215void cso_save_constant_buffer_slot0(struct cso_context *cso,
216                                    unsigned shader_stage);
217void cso_restore_constant_buffer_slot0(struct cso_context *cso,
218                                       unsigned shader_stage);
219
220
221/* drawing */
222
223void
224cso_set_index_buffer(struct cso_context *cso,
225                     const struct pipe_index_buffer *ib);
226
227void
228cso_draw_vbo(struct cso_context *cso,
229             const struct pipe_draw_info *info);
230
231void
232cso_draw_arrays_instanced(struct cso_context *cso, uint mode,
233                          uint start, uint count,
234                          uint start_instance, uint instance_count);
235
236/* helper drawing function */
237void
238cso_draw_arrays(struct cso_context *cso, uint mode, uint start, uint count);
239
240#ifdef	__cplusplus
241}
242#endif
243
244#endif
245