util: Include missing header in u_simple_shaders.c.
[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
43 struct pipe_context;
44 struct draw_context;
45 struct draw_stage;
46 struct draw_vertex_shader;
47 struct draw_geometry_shader;
48 struct tgsi_sampler;
49
50 #define DRAW_MAX_TEXTURE_LEVELS 13 /* 4K x 4K for now */
51
52 struct draw_context *draw_create( struct pipe_context *pipe );
53
54 void draw_destroy( struct draw_context *draw );
55
56 void draw_flush(struct draw_context *draw);
57
58 void draw_set_viewport_state( struct draw_context *draw,
59 const struct pipe_viewport_state *viewport );
60
61 void draw_set_clip_state( struct draw_context *pipe,
62 const struct pipe_clip_state *clip );
63
64 void draw_set_rasterizer_state( struct draw_context *draw,
65 const struct pipe_rasterizer_state *raster,
66 void *rast_handle );
67
68 void draw_set_rasterize_stage( struct draw_context *draw,
69 struct draw_stage *stage );
70
71 void draw_wide_point_threshold(struct draw_context *draw, float threshold);
72
73 void draw_wide_point_sprites(struct draw_context *draw, boolean draw_sprite);
74
75 void draw_wide_line_threshold(struct draw_context *draw, float threshold);
76
77 void draw_enable_line_stipple(struct draw_context *draw, boolean enable);
78
79 void draw_enable_point_sprites(struct draw_context *draw, boolean enable);
80
81 void draw_set_mrd(struct draw_context *draw, double mrd);
82
83 boolean
84 draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe);
85
86 boolean
87 draw_install_aapoint_stage(struct draw_context *draw, struct pipe_context *pipe);
88
89 boolean
90 draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe);
91
92
93 int
94 draw_find_shader_output(const struct draw_context *draw,
95 uint semantic_name, uint semantic_index);
96
97 uint
98 draw_num_shader_outputs(const struct draw_context *draw);
99
100
101 void
102 draw_texture_samplers(struct draw_context *draw,
103 uint shader_type,
104 uint num_samplers,
105 struct tgsi_sampler **samplers);
106
107 void
108 draw_set_sampler_views(struct draw_context *draw,
109 struct pipe_sampler_view **views,
110 unsigned num);
111 void
112 draw_set_samplers(struct draw_context *draw,
113 struct pipe_sampler_state **samplers,
114 unsigned num);
115
116 void
117 draw_set_mapped_texture(struct draw_context *draw,
118 unsigned sampler_idx,
119 uint32_t width, uint32_t height, uint32_t depth,
120 uint32_t last_level,
121 uint32_t row_stride[DRAW_MAX_TEXTURE_LEVELS],
122 uint32_t img_stride[DRAW_MAX_TEXTURE_LEVELS],
123 const void *data[DRAW_MAX_TEXTURE_LEVELS]);
124
125
126 /*
127 * Vertex shader functions
128 */
129
130 struct draw_vertex_shader *
131 draw_create_vertex_shader(struct draw_context *draw,
132 const struct pipe_shader_state *shader);
133 void draw_bind_vertex_shader(struct draw_context *draw,
134 struct draw_vertex_shader *dvs);
135 void draw_delete_vertex_shader(struct draw_context *draw,
136 struct draw_vertex_shader *dvs);
137
138
139 /*
140 * Geometry shader functions
141 */
142 struct draw_geometry_shader *
143 draw_create_geometry_shader(struct draw_context *draw,
144 const struct pipe_shader_state *shader);
145 void draw_bind_geometry_shader(struct draw_context *draw,
146 struct draw_geometry_shader *dvs);
147 void draw_delete_geometry_shader(struct draw_context *draw,
148 struct draw_geometry_shader *dvs);
149
150
151 /*
152 * Vertex data functions
153 */
154
155 void draw_set_vertex_buffers(struct draw_context *draw,
156 unsigned count,
157 const struct pipe_vertex_buffer *buffers);
158
159 void draw_set_vertex_elements(struct draw_context *draw,
160 unsigned count,
161 const struct pipe_vertex_element *elements);
162
163 void draw_set_index_buffer(struct draw_context *draw,
164 const struct pipe_index_buffer *ib);
165
166 void draw_set_mapped_index_buffer(struct draw_context *draw,
167 const void *elements);
168
169 void draw_set_mapped_vertex_buffer(struct draw_context *draw,
170 unsigned attr, const void *buffer);
171
172 void
173 draw_set_mapped_constant_buffer(struct draw_context *draw,
174 unsigned shader_type,
175 unsigned slot,
176 const void *buffer,
177 unsigned size);
178
179 void
180 draw_set_mapped_so_buffers(struct draw_context *draw,
181 void *buffers[PIPE_MAX_SO_BUFFERS],
182 unsigned num_buffers);
183 void
184 draw_set_so_state(struct draw_context *draw,
185 struct pipe_stream_output_state *state);
186
187
188 /***********************************************************************
189 * draw_pt.c
190 */
191
192 void draw_vbo(struct draw_context *draw,
193 const struct pipe_draw_info *info);
194
195 void draw_arrays(struct draw_context *draw, unsigned prim,
196 unsigned start, unsigned count);
197
198 void
199 draw_arrays_instanced(struct draw_context *draw,
200 unsigned mode,
201 unsigned start,
202 unsigned count,
203 unsigned startInstance,
204 unsigned instanceCount);
205
206
207 /*******************************************************************************
208 * Driver backend interface
209 */
210 struct vbuf_render;
211 void draw_set_render( struct draw_context *draw,
212 struct vbuf_render *render );
213
214 void draw_set_driver_clipping( struct draw_context *draw,
215 boolean bypass_clip_xy,
216 boolean bypass_clip_z );
217
218 void draw_set_force_passthrough( struct draw_context *draw,
219 boolean enable );
220
221 /*******************************************************************************
222 * Draw pipeline
223 */
224 boolean draw_need_pipeline(const struct draw_context *draw,
225 const struct pipe_rasterizer_state *rasterizer,
226 unsigned prim );
227
228 #endif /* DRAW_CONTEXT_H */