Merge commit 'origin/7.8'
[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
51 struct draw_context *draw_create( void );
52
53 void draw_destroy( struct draw_context *draw );
54
55 void draw_set_viewport_state( struct draw_context *draw,
56 const struct pipe_viewport_state *viewport );
57
58 void draw_set_clip_state( struct draw_context *pipe,
59 const struct pipe_clip_state *clip );
60
61 void draw_set_rasterizer_state( struct draw_context *draw,
62 const struct pipe_rasterizer_state *raster );
63
64 void draw_set_rasterize_stage( struct draw_context *draw,
65 struct draw_stage *stage );
66
67 void draw_wide_point_threshold(struct draw_context *draw, float threshold);
68
69 void draw_wide_line_threshold(struct draw_context *draw, float threshold);
70
71 void draw_enable_line_stipple(struct draw_context *draw, boolean enable);
72
73 void draw_enable_point_sprites(struct draw_context *draw, boolean enable);
74
75 void draw_set_mrd(struct draw_context *draw, double mrd);
76
77 boolean
78 draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe);
79
80 boolean
81 draw_install_aapoint_stage(struct draw_context *draw, struct pipe_context *pipe);
82
83 boolean
84 draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe);
85
86
87 int
88 draw_find_shader_output(const struct draw_context *draw,
89 uint semantic_name, uint semantic_index);
90
91 uint
92 draw_num_shader_outputs(const struct draw_context *draw);
93
94
95 void
96 draw_texture_samplers(struct draw_context *draw,
97 uint num_samplers,
98 struct tgsi_sampler **samplers);
99
100
101
102 /*
103 * Vertex shader functions
104 */
105
106 struct draw_vertex_shader *
107 draw_create_vertex_shader(struct draw_context *draw,
108 const struct pipe_shader_state *shader);
109 void draw_bind_vertex_shader(struct draw_context *draw,
110 struct draw_vertex_shader *dvs);
111 void draw_delete_vertex_shader(struct draw_context *draw,
112 struct draw_vertex_shader *dvs);
113
114
115 /*
116 * Geometry shader functions
117 */
118 struct draw_geometry_shader *
119 draw_create_geometry_shader(struct draw_context *draw,
120 const struct pipe_shader_state *shader);
121 void draw_bind_geometry_shader(struct draw_context *draw,
122 struct draw_geometry_shader *dvs);
123 void draw_delete_geometry_shader(struct draw_context *draw,
124 struct draw_geometry_shader *dvs);
125
126
127 /*
128 * Vertex data functions
129 */
130
131 void draw_set_vertex_buffers(struct draw_context *draw,
132 unsigned count,
133 const struct pipe_vertex_buffer *buffers);
134
135 void draw_set_vertex_elements(struct draw_context *draw,
136 unsigned count,
137 const struct pipe_vertex_element *elements);
138
139 void
140 draw_set_mapped_element_buffer_range( struct draw_context *draw,
141 unsigned eltSize,
142 unsigned min_index,
143 unsigned max_index,
144 const void *elements );
145
146 void draw_set_mapped_element_buffer( struct draw_context *draw,
147 unsigned eltSize,
148 const void *elements );
149
150 void draw_set_mapped_vertex_buffer(struct draw_context *draw,
151 unsigned attr, const void *buffer);
152
153 void
154 draw_set_mapped_constant_buffer(struct draw_context *draw,
155 unsigned shader_type,
156 unsigned slot,
157 const void *buffer,
158 unsigned size);
159
160
161 /***********************************************************************
162 * draw_prim.c
163 */
164
165 void draw_arrays(struct draw_context *draw, unsigned prim,
166 unsigned start, unsigned count);
167
168 void
169 draw_arrays_instanced(struct draw_context *draw,
170 unsigned mode,
171 unsigned start,
172 unsigned count,
173 unsigned startInstance,
174 unsigned instanceCount);
175
176 void draw_flush(struct draw_context *draw);
177
178
179 /*******************************************************************************
180 * Driver backend interface
181 */
182 struct vbuf_render;
183 void draw_set_render( struct draw_context *draw,
184 struct vbuf_render *render );
185
186 void draw_set_driver_clipping( struct draw_context *draw,
187 boolean bypass_clipping );
188
189 void draw_set_force_passthrough( struct draw_context *draw,
190 boolean enable );
191
192 /*******************************************************************************
193 * Draw pipeline
194 */
195 boolean draw_need_pipeline(const struct draw_context *draw,
196 const struct pipe_rasterizer_state *rasterizer,
197 unsigned prim );
198
199 #ifdef HAVE_LLVM
200 /*******************************************************************************
201 * LLVM integration
202 */
203 struct draw_context *draw_create_with_llvm(void);
204 #endif
205
206 #endif /* DRAW_CONTEXT_H */