draw: add vs/gs images support
[mesa.git] / src / gallium / auxiliary / draw / draw_context.h
1
2 /**************************************************************************
3 *
4 * Copyright 2007 VMware, Inc.
5 * All Rights Reserved.
6 *
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:
14 *
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
17 * of the Software.
18 *
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 VMWARE 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.
26 *
27 **************************************************************************/
28
29 /**
30 * \brief Public interface into the drawing module.
31 */
32
33 /* Authors: Keith Whitwell <keithw@vmware.com>
34 */
35
36
37 #ifndef DRAW_CONTEXT_H
38 #define DRAW_CONTEXT_H
39
40
41 #include "pipe/p_state.h"
42
43 struct pipe_context;
44 struct draw_context;
45 struct draw_stage;
46 struct draw_vertex_shader;
47 struct draw_geometry_shader;
48 struct draw_fragment_shader;
49 struct tgsi_sampler;
50 struct tgsi_image;
51 struct tgsi_buffer;
52
53 /*
54 * structure to contain driver internal information
55 * for stream out support. mapping stores the pointer
56 * to the buffer contents, and internal offset stores
57 * an internal counter to how much of the stream
58 * out buffer is used (in bytes).
59 */
60 struct draw_so_target {
61 struct pipe_stream_output_target target;
62 void *mapping;
63 int internal_offset;
64 };
65
66 struct draw_context *draw_create( struct pipe_context *pipe );
67
68 #if HAVE_LLVM
69 struct draw_context *draw_create_with_llvm_context(struct pipe_context *pipe,
70 void *context);
71 #endif
72
73 struct draw_context *draw_create_no_llvm(struct pipe_context *pipe);
74
75 void draw_destroy( struct draw_context *draw );
76
77 void draw_flush(struct draw_context *draw);
78
79 void draw_set_viewport_states( struct draw_context *draw,
80 unsigned start_slot,
81 unsigned num_viewports,
82 const struct pipe_viewport_state *viewports );
83
84 void draw_set_clip_state( struct draw_context *pipe,
85 const struct pipe_clip_state *clip );
86
87 /**
88 * Sets the rasterization state used by the draw module.
89 * The rast_handle is used to pass the driver specific representation
90 * of the rasterization state. It's going to be used when the
91 * draw module sets the state back on the driver itself using the
92 * pipe::bind_rasterizer_state method.
93 *
94 * NOTE: if you're calling this function from within the pipe's
95 * bind_rasterizer_state you should always call it before binding
96 * the actual state - that's because the draw module can try to
97 * bind its own rasterizer state which would reset your newly
98 * set state. i.e. always do
99 * draw_set_rasterizer_state(driver->draw, state->pipe_state, state);
100 * driver->state.raster = state;
101 */
102 void draw_set_rasterizer_state( struct draw_context *draw,
103 const struct pipe_rasterizer_state *raster,
104 void *rast_handle );
105
106 void draw_set_rasterize_stage( struct draw_context *draw,
107 struct draw_stage *stage );
108
109 void draw_wide_point_threshold(struct draw_context *draw, float threshold);
110
111 void draw_wide_point_sprites(struct draw_context *draw, boolean draw_sprite);
112
113 void draw_wide_line_threshold(struct draw_context *draw, float threshold);
114
115 void draw_enable_line_stipple(struct draw_context *draw, boolean enable);
116
117 void draw_enable_point_sprites(struct draw_context *draw, boolean enable);
118
119 void draw_set_zs_format(struct draw_context *draw, enum pipe_format format);
120
121 boolean
122 draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe);
123
124 boolean
125 draw_install_aapoint_stage(struct draw_context *draw, struct pipe_context *pipe);
126
127 boolean
128 draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe);
129
130
131 struct tgsi_shader_info *
132 draw_get_shader_info(const struct draw_context *draw);
133
134 void
135 draw_prepare_shader_outputs(struct draw_context *draw);
136
137 int
138 draw_find_shader_output(const struct draw_context *draw,
139 uint semantic_name, uint semantic_index);
140
141 boolean
142 draw_will_inject_frontface(const struct draw_context *draw);
143
144 uint
145 draw_num_shader_outputs(const struct draw_context *draw);
146
147 uint
148 draw_total_vs_outputs(const struct draw_context *draw);
149
150 uint
151 draw_total_gs_outputs(const struct draw_context *draw);
152
153 void
154 draw_texture_sampler(struct draw_context *draw,
155 enum pipe_shader_type shader_type,
156 struct tgsi_sampler *sampler);
157
158 void
159 draw_image(struct draw_context *draw,
160 enum pipe_shader_type shader_type,
161 struct tgsi_image *image);
162
163 void
164 draw_buffer(struct draw_context *draw,
165 enum pipe_shader_type shader_type,
166 struct tgsi_buffer *buffer);
167
168 void
169 draw_set_sampler_views(struct draw_context *draw,
170 enum pipe_shader_type shader_stage,
171 struct pipe_sampler_view **views,
172 unsigned num);
173 void
174 draw_set_samplers(struct draw_context *draw,
175 enum pipe_shader_type shader_stage,
176 struct pipe_sampler_state **samplers,
177 unsigned num);
178
179 void
180 draw_set_images(struct draw_context *draw,
181 enum pipe_shader_type shader_stage,
182 struct pipe_image_view *images,
183 unsigned num);
184
185 void
186 draw_set_mapped_texture(struct draw_context *draw,
187 enum pipe_shader_type shader_stage,
188 unsigned sview_idx,
189 uint32_t width, uint32_t height, uint32_t depth,
190 uint32_t first_level, uint32_t last_level,
191 const void *base,
192 uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS],
193 uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
194 uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS]);
195
196 void
197 draw_set_mapped_image(struct draw_context *draw,
198 enum pipe_shader_type shader_stage,
199 unsigned idx,
200 uint32_t width, uint32_t height, uint32_t depth,
201 const void *base_ptr,
202 uint32_t row_stride,
203 uint32_t img_stride);
204
205 /*
206 * Vertex shader functions
207 */
208
209 struct draw_vertex_shader *
210 draw_create_vertex_shader(struct draw_context *draw,
211 const struct pipe_shader_state *shader);
212 void draw_bind_vertex_shader(struct draw_context *draw,
213 struct draw_vertex_shader *dvs);
214 void draw_delete_vertex_shader(struct draw_context *draw,
215 struct draw_vertex_shader *dvs);
216 void draw_vs_attach_so(struct draw_vertex_shader *dvs,
217 const struct pipe_stream_output_info *info);
218 void draw_vs_reset_so(struct draw_vertex_shader *dvs);
219
220
221 /*
222 * Fragment shader functions
223 */
224 struct draw_fragment_shader *
225 draw_create_fragment_shader(struct draw_context *draw,
226 const struct pipe_shader_state *shader);
227 void draw_bind_fragment_shader(struct draw_context *draw,
228 struct draw_fragment_shader *dvs);
229 void draw_delete_fragment_shader(struct draw_context *draw,
230 struct draw_fragment_shader *dvs);
231
232 /*
233 * Geometry shader functions
234 */
235 struct draw_geometry_shader *
236 draw_create_geometry_shader(struct draw_context *draw,
237 const struct pipe_shader_state *shader);
238 void draw_bind_geometry_shader(struct draw_context *draw,
239 struct draw_geometry_shader *dvs);
240 void draw_delete_geometry_shader(struct draw_context *draw,
241 struct draw_geometry_shader *dvs);
242
243
244 /*
245 * Vertex data functions
246 */
247
248 void draw_set_vertex_buffers(struct draw_context *draw,
249 unsigned start_slot, unsigned count,
250 const struct pipe_vertex_buffer *buffers);
251
252 void draw_set_vertex_elements(struct draw_context *draw,
253 unsigned count,
254 const struct pipe_vertex_element *elements);
255
256 void draw_set_indexes(struct draw_context *draw,
257 const void *elements, unsigned elem_size,
258 unsigned available_space);
259
260 void draw_set_mapped_vertex_buffer(struct draw_context *draw,
261 unsigned attr, const void *buffer,
262 size_t size);
263
264 void
265 draw_set_mapped_constant_buffer(struct draw_context *draw,
266 enum pipe_shader_type shader_type,
267 unsigned slot,
268 const void *buffer,
269 unsigned size);
270
271 void
272 draw_set_mapped_shader_buffer(struct draw_context *draw,
273 enum pipe_shader_type shader_type,
274 unsigned slot,
275 const void *buffer,
276 unsigned size);
277
278 void
279 draw_set_mapped_so_targets(struct draw_context *draw,
280 int num_targets,
281 struct draw_so_target *targets[PIPE_MAX_SO_BUFFERS]);
282
283
284 /***********************************************************************
285 * draw_pt.c
286 */
287
288 void draw_vbo(struct draw_context *draw,
289 const struct pipe_draw_info *info);
290
291
292 /*******************************************************************************
293 * Driver backend interface
294 */
295 struct vbuf_render;
296 void draw_set_render( struct draw_context *draw,
297 struct vbuf_render *render );
298
299 void draw_set_driver_clipping( struct draw_context *draw,
300 boolean bypass_clip_xy,
301 boolean bypass_clip_z,
302 boolean guard_band_xy,
303 boolean bypass_clip_points);
304
305 void draw_set_force_passthrough( struct draw_context *draw,
306 boolean enable );
307
308
309 /*******************************************************************************
310 * Draw statistics
311 */
312 void draw_collect_pipeline_statistics(struct draw_context *draw,
313 boolean enable);
314
315 /*******************************************************************************
316 * Draw pipeline
317 */
318 boolean draw_need_pipeline(const struct draw_context *draw,
319 const struct pipe_rasterizer_state *rasterizer,
320 unsigned prim );
321
322 int
323 draw_get_shader_param(enum pipe_shader_type shader, enum pipe_shader_cap param);
324
325 int
326 draw_get_shader_param_no_llvm(enum pipe_shader_type shader,
327 enum pipe_shader_cap param);
328
329 boolean
330 draw_get_option_use_llvm(void);
331
332 #endif /* DRAW_CONTEXT_H */