OSDN Git Service

c7a40a1b1a28cc0ce00509b5803a4a72a0eb6581
[android-x86/external-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
52 /*
53  * structure to contain driver internal information 
54  * for stream out support. mapping stores the pointer
55  * to the buffer contents, and internal offset stores
56  * stores an internal counter to how much of the stream
57  * out buffer is used (in bytes).
58  */
59 struct draw_so_target {
60    struct pipe_stream_output_target target;
61    void *mapping;
62    int internal_offset;
63    int emitted_vertices;
64 };
65
66 struct draw_context *draw_create( struct pipe_context *pipe );
67
68 struct draw_context *draw_create_no_llvm(struct pipe_context *pipe);
69
70 void draw_destroy( struct draw_context *draw );
71
72 void draw_flush(struct draw_context *draw);
73
74 void draw_set_viewport_state( struct draw_context *draw,
75                               const struct pipe_viewport_state *viewport );
76
77 void draw_set_clip_state( struct draw_context *pipe,
78                           const struct pipe_clip_state *clip );
79
80 /**
81  * Sets the rasterization state used by the draw module.
82  * The rast_handle is used to pass the driver specific representation
83  * of the rasterization state. It's going to be used when the
84  * draw module sets the state back on the driver itself using the
85  * pipe::bind_rasterizer_state method.
86  *
87  * NOTE: if you're calling this function from within the pipe's
88  * bind_rasterizer_state you should always call it before binding
89  * the actual state - that's because the draw module can try to
90  * bind its own rasterizer state which would reset your newly
91  * set state. i.e. always do
92  * draw_set_rasterizer_state(driver->draw, state->pipe_state, state);
93  * driver->state.raster = state;
94  */
95 void draw_set_rasterizer_state( struct draw_context *draw,
96                                 const struct pipe_rasterizer_state *raster,
97                                 void *rast_handle );
98
99 void draw_set_rasterize_stage( struct draw_context *draw,
100                                struct draw_stage *stage );
101
102 void draw_wide_point_threshold(struct draw_context *draw, float threshold);
103
104 void draw_wide_point_sprites(struct draw_context *draw, boolean draw_sprite);
105
106 void draw_wide_line_threshold(struct draw_context *draw, float threshold);
107
108 void draw_enable_line_stipple(struct draw_context *draw, boolean enable);
109
110 void draw_enable_point_sprites(struct draw_context *draw, boolean enable);
111
112 void draw_set_mrd(struct draw_context *draw, double mrd);
113
114 boolean
115 draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe);
116
117 boolean
118 draw_install_aapoint_stage(struct draw_context *draw, struct pipe_context *pipe);
119
120 boolean
121 draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe);
122
123
124 struct tgsi_shader_info *
125 draw_get_shader_info(const struct draw_context *draw);
126
127 int
128 draw_find_shader_output(const struct draw_context *draw,
129                         uint semantic_name, uint semantic_index);
130
131 uint
132 draw_num_shader_outputs(const struct draw_context *draw);
133
134
135 void
136 draw_texture_sampler(struct draw_context *draw,
137                      uint shader_type,
138                      struct tgsi_sampler *sampler);
139
140 void
141 draw_set_sampler_views(struct draw_context *draw,
142                        unsigned shader_stage,
143                        struct pipe_sampler_view **views,
144                        unsigned num);
145 void
146 draw_set_samplers(struct draw_context *draw,
147                   unsigned shader_stage,
148                   struct pipe_sampler_state **samplers,
149                   unsigned num);
150
151 void
152 draw_set_mapped_texture(struct draw_context *draw,
153                         unsigned shader_stage,
154                         unsigned sview_idx,
155                         uint32_t width, uint32_t height, uint32_t depth,
156                         uint32_t first_level, uint32_t last_level,
157                         const void *base,
158                         uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS],
159                         uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
160                         uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS]);
161
162
163 /*
164  * Vertex shader functions
165  */
166
167 struct draw_vertex_shader *
168 draw_create_vertex_shader(struct draw_context *draw,
169                           const struct pipe_shader_state *shader);
170 void draw_bind_vertex_shader(struct draw_context *draw,
171                              struct draw_vertex_shader *dvs);
172 void draw_delete_vertex_shader(struct draw_context *draw,
173                                struct draw_vertex_shader *dvs);
174 void draw_vs_attach_so(struct draw_vertex_shader *dvs,
175                        const struct pipe_stream_output_info *info);
176 void draw_vs_reset_so(struct draw_vertex_shader *dvs);
177
178
179 /*
180  * Fragment shader functions
181  */
182 struct draw_fragment_shader *
183 draw_create_fragment_shader(struct draw_context *draw,
184                             const struct pipe_shader_state *shader);
185 void draw_bind_fragment_shader(struct draw_context *draw,
186                                struct draw_fragment_shader *dvs);
187 void draw_delete_fragment_shader(struct draw_context *draw,
188                                  struct draw_fragment_shader *dvs);
189
190 /*
191  * Geometry shader functions
192  */
193 struct draw_geometry_shader *
194 draw_create_geometry_shader(struct draw_context *draw,
195                             const struct pipe_shader_state *shader);
196 void draw_bind_geometry_shader(struct draw_context *draw,
197                                struct draw_geometry_shader *dvs);
198 void draw_delete_geometry_shader(struct draw_context *draw,
199                                  struct draw_geometry_shader *dvs);
200
201
202 /*
203  * Vertex data functions
204  */
205
206 void draw_set_vertex_buffers(struct draw_context *draw,
207                              unsigned start_slot, unsigned count,
208                              const struct pipe_vertex_buffer *buffers);
209
210 void draw_set_vertex_elements(struct draw_context *draw,
211                               unsigned count,
212                               const struct pipe_vertex_element *elements);
213
214 void draw_set_indexes(struct draw_context *draw,
215                       const void *elements, unsigned elem_size);
216
217 void draw_set_mapped_vertex_buffer(struct draw_context *draw,
218                                    unsigned attr, const void *buffer,
219                                    size_t size);
220
221 void
222 draw_set_mapped_constant_buffer(struct draw_context *draw,
223                                 unsigned shader_type,
224                                 unsigned slot,
225                                 const void *buffer,
226                                 unsigned size);
227
228 void
229 draw_set_mapped_so_targets(struct draw_context *draw,
230                            int num_targets,
231                            struct draw_so_target *targets[PIPE_MAX_SO_BUFFERS]);
232
233
234 /***********************************************************************
235  * draw_pt.c 
236  */
237
238 void draw_vbo(struct draw_context *draw,
239               const struct pipe_draw_info *info);
240
241 void draw_arrays(struct draw_context *draw, unsigned prim,
242                  unsigned start, unsigned count);
243
244 void
245 draw_arrays_instanced(struct draw_context *draw,
246                       unsigned mode,
247                       unsigned start,
248                       unsigned count,
249                       unsigned startInstance,
250                       unsigned instanceCount);
251
252
253 /*******************************************************************************
254  * Driver backend interface 
255  */
256 struct vbuf_render;
257 void draw_set_render( struct draw_context *draw, 
258                       struct vbuf_render *render );
259
260 void draw_set_driver_clipping( struct draw_context *draw,
261                                boolean bypass_clip_xy,
262                                boolean bypass_clip_z,
263                                boolean guard_band_xy);
264
265 void draw_set_force_passthrough( struct draw_context *draw, 
266                                  boolean enable );
267
268
269 /*******************************************************************************
270  * Draw statistics
271  */
272 void draw_collect_pipeline_statistics(struct draw_context *draw,
273                                       boolean enable);
274
275 /*******************************************************************************
276  * Draw pipeline 
277  */
278 boolean draw_need_pipeline(const struct draw_context *draw,
279                            const struct pipe_rasterizer_state *rasterizer,
280                            unsigned prim );
281
282 int
283 draw_get_shader_param(unsigned shader, enum pipe_shader_cap param);
284
285 int
286 draw_get_shader_param_no_llvm(unsigned shader, enum pipe_shader_cap param);
287
288 #ifdef HAVE_LLVM
289 boolean
290 draw_get_option_use_llvm(void);
291 #endif
292
293 #endif /* DRAW_CONTEXT_H */