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