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