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