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