gallium: michel's patch to rework texture/sampler binding interface
[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
44 struct pipe_context;
45 struct vertex_buffer;
46 struct vertex_info;
47 struct draw_context;
48 struct draw_stage;
49 struct draw_vertex_shader;
50
51
52 /**
53 * Clipmask flags
54 */
55 /*@{*/
56 #define CLIP_RIGHT_BIT 0x01
57 #define CLIP_LEFT_BIT 0x02
58 #define CLIP_TOP_BIT 0x04
59 #define CLIP_BOTTOM_BIT 0x08
60 #define CLIP_NEAR_BIT 0x10
61 #define CLIP_FAR_BIT 0x20
62 /*@}*/
63
64 /**
65 * Bitshift for each clip flag
66 */
67 /*@{*/
68 #define CLIP_RIGHT_SHIFT 0
69 #define CLIP_LEFT_SHIFT 1
70 #define CLIP_TOP_SHIFT 2
71 #define CLIP_BOTTOM_SHIFT 3
72 #define CLIP_NEAR_SHIFT 4
73 #define CLIP_FAR_SHIFT 5
74 /*@}*/
75
76
77 struct draw_context *draw_create( void );
78
79 void draw_destroy( struct draw_context *draw );
80
81 void draw_set_viewport_state( struct draw_context *draw,
82 const struct pipe_viewport_state *viewport );
83
84 void draw_set_clip_state( struct draw_context *pipe,
85 const struct pipe_clip_state *clip );
86
87 void draw_set_rasterizer_state( struct draw_context *draw,
88 const struct pipe_rasterizer_state *raster );
89
90 void draw_set_rasterize_stage( struct draw_context *draw,
91 struct draw_stage *stage );
92
93 void draw_wide_point_threshold(struct draw_context *draw, float threshold);
94
95 void draw_wide_line_threshold(struct draw_context *draw, float threshold);
96
97 boolean draw_use_sse(struct draw_context *draw);
98
99 void
100 draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe);
101
102 void
103 draw_install_aapoint_stage(struct draw_context *draw, struct pipe_context *pipe);
104
105 void
106 draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe);
107
108
109 int
110 draw_find_vs_output(struct draw_context *draw,
111 uint semantic_name, uint semantic_index);
112
113 uint
114 draw_num_vs_outputs(struct draw_context *draw);
115
116
117
118 /*
119 * Vertex shader functions
120 */
121
122 struct draw_vertex_shader *
123 draw_create_vertex_shader(struct draw_context *draw,
124 const struct pipe_shader_state *shader);
125 void draw_bind_vertex_shader(struct draw_context *draw,
126 struct draw_vertex_shader *dvs);
127 void draw_delete_vertex_shader(struct draw_context *draw,
128 struct draw_vertex_shader *dvs);
129
130
131
132 /*
133 * Vertex data functions
134 */
135
136 void draw_set_vertex_buffer(struct draw_context *draw,
137 unsigned attr,
138 const struct pipe_vertex_buffer *buffer);
139
140 void draw_set_vertex_element(struct draw_context *draw,
141 unsigned attr,
142 const struct pipe_vertex_element *element);
143
144 void draw_set_mapped_element_buffer( struct draw_context *draw,
145 unsigned eltSize, void *elements );
146
147 void draw_set_mapped_vertex_buffer(struct draw_context *draw,
148 unsigned attr, const void *buffer);
149
150 void draw_set_mapped_constant_buffer(struct draw_context *draw,
151 const void *buffer);
152
153
154 /***********************************************************************
155 * draw_prim.c
156 */
157
158 void draw_arrays(struct draw_context *draw, unsigned prim,
159 unsigned start, unsigned count);
160
161 void draw_flush(struct draw_context *draw);
162
163 /***********************************************************************
164 * draw_debug.c
165 */
166 boolean draw_validate_prim( unsigned prim, unsigned length );
167 unsigned draw_trim_prim( unsigned mode, unsigned count );
168
169
170
171 #endif /* DRAW_CONTEXT_H */