gallium: interface changes necessary to implement transform feedback (v5)
[mesa.git] / src / gallium / auxiliary / draw / draw_context.h
1
2 /**************************************************************************
3 *
4 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
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 TUNGSTEN GRAPHICS 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 <keith@tungstengraphics.com>
34 */
35
36
37 #ifndef DRAW_CONTEXT_H
38 #define DRAW_CONTEXT_H
39
40
41 #include "pipe/p_state.h"
42 #include "tgsi/tgsi_exec.h"
43
44 struct pipe_context;
45 struct draw_context;
46 struct draw_stage;
47 struct draw_vertex_shader;
48 struct draw_geometry_shader;
49 struct draw_fragment_shader;
50 struct tgsi_sampler;
51 struct gallivm_state;
52
53
54
55 struct draw_context *draw_create( struct pipe_context *pipe );
56
57 struct draw_context *
58 draw_create_gallivm(struct pipe_context *pipe, struct gallivm_state *gallivm);
59
60 void draw_destroy( struct draw_context *draw );
61
62 void draw_flush(struct draw_context *draw);
63
64 void draw_set_viewport_state( struct draw_context *draw,
65 const struct pipe_viewport_state *viewport );
66
67 void draw_set_clip_state( struct draw_context *pipe,
68 const struct pipe_clip_state *clip );
69
70 void draw_set_rasterizer_state( struct draw_context *draw,
71 const struct pipe_rasterizer_state *raster,
72 void *rast_handle );
73
74 void draw_set_rasterize_stage( struct draw_context *draw,
75 struct draw_stage *stage );
76
77 void draw_wide_point_threshold(struct draw_context *draw, float threshold);
78
79 void draw_wide_point_sprites(struct draw_context *draw, boolean draw_sprite);
80
81 void draw_wide_line_threshold(struct draw_context *draw, float threshold);
82
83 void draw_enable_line_stipple(struct draw_context *draw, boolean enable);
84
85 void draw_enable_point_sprites(struct draw_context *draw, boolean enable);
86
87 void draw_set_mrd(struct draw_context *draw, double mrd);
88
89 boolean
90 draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe);
91
92 boolean
93 draw_install_aapoint_stage(struct draw_context *draw, struct pipe_context *pipe);
94
95 boolean
96 draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe);
97
98
99 struct tgsi_shader_info *
100 draw_get_shader_info(const struct draw_context *draw);
101
102 int
103 draw_find_shader_output(const struct draw_context *draw,
104 uint semantic_name, uint semantic_index);
105
106 uint
107 draw_num_shader_outputs(const struct draw_context *draw);
108
109
110 void
111 draw_texture_samplers(struct draw_context *draw,
112 uint shader_type,
113 uint num_samplers,
114 struct tgsi_sampler **samplers);
115
116 void
117 draw_set_sampler_views(struct draw_context *draw,
118 struct pipe_sampler_view **views,
119 unsigned num);
120 void
121 draw_set_samplers(struct draw_context *draw,
122 struct pipe_sampler_state **samplers,
123 unsigned num);
124
125 void
126 draw_set_mapped_texture(struct draw_context *draw,
127 unsigned sampler_idx,
128 uint32_t width, uint32_t height, uint32_t depth,
129 uint32_t first_level, uint32_t last_level,
130 uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS],
131 uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
132 const void *data[PIPE_MAX_TEXTURE_LEVELS]);
133
134
135 /*
136 * Vertex shader functions
137 */
138
139 struct draw_vertex_shader *
140 draw_create_vertex_shader(struct draw_context *draw,
141 const struct pipe_shader_state *shader);
142 void draw_bind_vertex_shader(struct draw_context *draw,
143 struct draw_vertex_shader *dvs);
144 void draw_delete_vertex_shader(struct draw_context *draw,
145 struct draw_vertex_shader *dvs);
146
147
148 /*
149 * Fragment shader functions
150 */
151 struct draw_fragment_shader *
152 draw_create_fragment_shader(struct draw_context *draw,
153 const struct pipe_shader_state *shader);
154 void draw_bind_fragment_shader(struct draw_context *draw,
155 struct draw_fragment_shader *dvs);
156 void draw_delete_fragment_shader(struct draw_context *draw,
157 struct draw_fragment_shader *dvs);
158
159 /*
160 * Geometry shader functions
161 */
162 struct draw_geometry_shader *
163 draw_create_geometry_shader(struct draw_context *draw,
164 const struct pipe_shader_state *shader);
165 void draw_bind_geometry_shader(struct draw_context *draw,
166 struct draw_geometry_shader *dvs);
167 void draw_delete_geometry_shader(struct draw_context *draw,
168 struct draw_geometry_shader *dvs);
169
170
171 /*
172 * Vertex data functions
173 */
174
175 void draw_set_vertex_buffers(struct draw_context *draw,
176 unsigned count,
177 const struct pipe_vertex_buffer *buffers);
178
179 void draw_set_vertex_elements(struct draw_context *draw,
180 unsigned count,
181 const struct pipe_vertex_element *elements);
182
183 void draw_set_index_buffer(struct draw_context *draw,
184 const struct pipe_index_buffer *ib);
185
186 void draw_set_mapped_index_buffer(struct draw_context *draw,
187 const void *elements);
188
189 void draw_set_mapped_vertex_buffer(struct draw_context *draw,
190 unsigned attr, const void *buffer);
191
192 void
193 draw_set_mapped_constant_buffer(struct draw_context *draw,
194 unsigned shader_type,
195 unsigned slot,
196 const void *buffer,
197 unsigned size);
198
199 void
200 draw_set_mapped_so_buffers(struct draw_context *draw,
201 void *buffers[PIPE_MAX_SO_BUFFERS],
202 unsigned num_buffers);
203 void
204 draw_set_so_state(struct draw_context *draw,
205 struct pipe_stream_output_info *state);
206
207
208 /***********************************************************************
209 * draw_pt.c
210 */
211
212 void draw_vbo(struct draw_context *draw,
213 const struct pipe_draw_info *info);
214
215 void draw_arrays(struct draw_context *draw, unsigned prim,
216 unsigned start, unsigned count);
217
218 void
219 draw_arrays_instanced(struct draw_context *draw,
220 unsigned mode,
221 unsigned start,
222 unsigned count,
223 unsigned startInstance,
224 unsigned instanceCount);
225
226
227 /*******************************************************************************
228 * Driver backend interface
229 */
230 struct vbuf_render;
231 void draw_set_render( struct draw_context *draw,
232 struct vbuf_render *render );
233
234 void draw_set_driver_clipping( struct draw_context *draw,
235 boolean bypass_clip_xy,
236 boolean bypass_clip_z,
237 boolean guard_band_xy);
238
239 void draw_set_force_passthrough( struct draw_context *draw,
240 boolean enable );
241
242 /*******************************************************************************
243 * Draw pipeline
244 */
245 boolean draw_need_pipeline(const struct draw_context *draw,
246 const struct pipe_rasterizer_state *rasterizer,
247 unsigned prim );
248
249 static INLINE int
250 draw_get_shader_param(unsigned shader, enum pipe_shader_cap param)
251 {
252 switch(shader) {
253 case PIPE_SHADER_VERTEX:
254 case PIPE_SHADER_GEOMETRY:
255 return tgsi_exec_get_shader_param(param);
256 default:
257 return 0;
258 }
259 }
260
261 #endif /* DRAW_CONTEXT_H */