draw_context.h revision 3e22c7a25321554a32fa6254485912fd53deff3a
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;
51struct gallivm_state;
52
53
54
55struct draw_context *draw_create( struct pipe_context *pipe );
56
57struct draw_context *draw_create_no_llvm(struct pipe_context *pipe);
58
59struct draw_context *
60draw_create_gallivm(struct pipe_context *pipe, struct gallivm_state *gallivm);
61
62void draw_destroy( struct draw_context *draw );
63
64void draw_flush(struct draw_context *draw);
65
66void draw_set_viewport_state( struct draw_context *draw,
67                              const struct pipe_viewport_state *viewport );
68
69void draw_set_clip_state( struct draw_context *pipe,
70                          const struct pipe_clip_state *clip );
71
72void draw_set_rasterizer_state( struct draw_context *draw,
73                                const struct pipe_rasterizer_state *raster,
74                                void *rast_handle );
75
76void draw_set_rasterize_stage( struct draw_context *draw,
77                               struct draw_stage *stage );
78
79void draw_wide_point_threshold(struct draw_context *draw, float threshold);
80
81void draw_wide_point_sprites(struct draw_context *draw, boolean draw_sprite);
82
83void draw_wide_line_threshold(struct draw_context *draw, float threshold);
84
85void draw_enable_line_stipple(struct draw_context *draw, boolean enable);
86
87void draw_enable_point_sprites(struct draw_context *draw, boolean enable);
88
89void draw_set_mrd(struct draw_context *draw, double mrd);
90
91boolean
92draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe);
93
94boolean
95draw_install_aapoint_stage(struct draw_context *draw, struct pipe_context *pipe);
96
97boolean
98draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe);
99
100
101struct tgsi_shader_info *
102draw_get_shader_info(const struct draw_context *draw);
103
104int
105draw_find_shader_output(const struct draw_context *draw,
106                        uint semantic_name, uint semantic_index);
107
108uint
109draw_num_shader_outputs(const struct draw_context *draw);
110
111
112void
113draw_texture_samplers(struct draw_context *draw,
114                      uint shader_type,
115                      uint num_samplers,
116                      struct tgsi_sampler **samplers);
117
118void
119draw_set_sampler_views(struct draw_context *draw,
120                       struct pipe_sampler_view **views,
121                       unsigned num);
122void
123draw_set_samplers(struct draw_context *draw,
124                  struct pipe_sampler_state **samplers,
125                  unsigned num);
126
127void
128draw_set_mapped_texture(struct draw_context *draw,
129                        unsigned sampler_idx,
130                        uint32_t width, uint32_t height, uint32_t depth,
131                        uint32_t first_level, uint32_t last_level,
132                        uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS],
133                        uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
134                        const void *data[PIPE_MAX_TEXTURE_LEVELS]);
135
136
137/*
138 * Vertex shader functions
139 */
140
141struct draw_vertex_shader *
142draw_create_vertex_shader(struct draw_context *draw,
143                          const struct pipe_shader_state *shader);
144void draw_bind_vertex_shader(struct draw_context *draw,
145                             struct draw_vertex_shader *dvs);
146void draw_delete_vertex_shader(struct draw_context *draw,
147                               struct draw_vertex_shader *dvs);
148
149
150/*
151 * Fragment shader functions
152 */
153struct draw_fragment_shader *
154draw_create_fragment_shader(struct draw_context *draw,
155                            const struct pipe_shader_state *shader);
156void draw_bind_fragment_shader(struct draw_context *draw,
157                               struct draw_fragment_shader *dvs);
158void draw_delete_fragment_shader(struct draw_context *draw,
159                                 struct draw_fragment_shader *dvs);
160
161/*
162 * Geometry shader functions
163 */
164struct draw_geometry_shader *
165draw_create_geometry_shader(struct draw_context *draw,
166                            const struct pipe_shader_state *shader);
167void draw_bind_geometry_shader(struct draw_context *draw,
168                               struct draw_geometry_shader *dvs);
169void draw_delete_geometry_shader(struct draw_context *draw,
170                                 struct draw_geometry_shader *dvs);
171
172
173/*
174 * Vertex data functions
175 */
176
177void draw_set_vertex_buffers(struct draw_context *draw,
178                             unsigned count,
179                             const struct pipe_vertex_buffer *buffers);
180
181void draw_set_vertex_elements(struct draw_context *draw,
182			      unsigned count,
183                              const struct pipe_vertex_element *elements);
184
185void draw_set_index_buffer(struct draw_context *draw,
186                           const struct pipe_index_buffer *ib);
187
188void draw_set_mapped_index_buffer(struct draw_context *draw,
189                                  const void *elements);
190
191void draw_set_mapped_vertex_buffer(struct draw_context *draw,
192                                   unsigned attr, const void *buffer);
193
194void
195draw_set_mapped_constant_buffer(struct draw_context *draw,
196                                unsigned shader_type,
197                                unsigned slot,
198                                const void *buffer,
199                                unsigned size);
200
201void
202draw_set_mapped_so_buffers(struct draw_context *draw,
203                           void *buffers[PIPE_MAX_SO_BUFFERS],
204                           unsigned num_buffers);
205void
206draw_set_so_state(struct draw_context *draw,
207                  struct pipe_stream_output_info *state);
208
209
210/***********************************************************************
211 * draw_pt.c
212 */
213
214void draw_vbo(struct draw_context *draw,
215              const struct pipe_draw_info *info);
216
217void draw_arrays(struct draw_context *draw, unsigned prim,
218		 unsigned start, unsigned count);
219
220void
221draw_arrays_instanced(struct draw_context *draw,
222                      unsigned mode,
223                      unsigned start,
224                      unsigned count,
225                      unsigned startInstance,
226                      unsigned instanceCount);
227
228
229/*******************************************************************************
230 * Driver backend interface
231 */
232struct vbuf_render;
233void draw_set_render( struct draw_context *draw,
234		      struct vbuf_render *render );
235
236void draw_set_driver_clipping( struct draw_context *draw,
237                               boolean bypass_clip_xy,
238                               boolean bypass_clip_z,
239                               boolean guard_band_xy);
240
241void draw_set_force_passthrough( struct draw_context *draw,
242                                 boolean enable );
243
244/*******************************************************************************
245 * Draw pipeline
246 */
247boolean draw_need_pipeline(const struct draw_context *draw,
248                           const struct pipe_rasterizer_state *rasterizer,
249                           unsigned prim );
250
251static INLINE int
252draw_get_shader_param(unsigned shader, enum pipe_shader_cap param)
253{
254   switch(shader) {
255   case PIPE_SHADER_VERTEX:
256   case PIPE_SHADER_GEOMETRY:
257      return tgsi_exec_get_shader_param(param);
258   default:
259      return 0;
260   }
261}
262
263#endif /* DRAW_CONTEXT_H */
264