Be more consistant with paths in #includes. Eventually, eliminate a bunch of -I...
[mesa.git] / src / mesa / swrast / swrast.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5
4 *
5 * Copyright (C) 1999-2006 Brian Paul 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 "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 */
25
26 /**
27 * \file swrast/swrast.h
28 * \brief Public interface to the software rasterization functions.
29 * \author Keith Whitwell <keith@tungstengraphics.com>
30 */
31
32 #ifndef SWRAST_H
33 #define SWRAST_H
34
35 #include "main/mtypes.h"
36
37 /**
38 * \struct SWvertex
39 * \brief Data-structure to handle vertices in the software rasterizer.
40 *
41 * The software rasterizer now uses this format for vertices. Thus a
42 * 'RasterSetup' stage or other translation is required between the
43 * tnl module and the swrast rasterization functions. This serves to
44 * isolate the swrast module from the internals of the tnl module, and
45 * improve its usefulness as a fallback mechanism for hardware
46 * drivers.
47 *
48 * wpos = attr[FRAG_ATTRIB_WPOS] and MUST BE THE FIRST values in the
49 * vertex because of the tnl clipping code.
50
51 * wpos[0] and [1] are the screen-coords of SWvertex.
52 * wpos[2] is the z-buffer coord (if 16-bit Z buffer, in range [0,65535]).
53 * wpos[3] is 1/w where w is the clip-space W coord. This is the value
54 * that clip{XYZ} were multiplied by to get ndc{XYZ}.
55 *
56 * Full software drivers:
57 * - Register the rastersetup and triangle functions from
58 * utils/software_helper.
59 * - On statechange, update the rasterization pointers in that module.
60 *
61 * Rasterization hardware drivers:
62 * - Keep native rastersetup.
63 * - Implement native twoside,offset and unfilled triangle setup.
64 * - Implement a translator from native vertices to swrast vertices.
65 * - On partial fallback (mix of accelerated and unaccelerated
66 * prims), call a pass-through function which translates native
67 * vertices to SWvertices and calls the appropriate swrast function.
68 * - On total fallback (vertex format insufficient for state or all
69 * primitives unaccelerated), hook in swrast_setup instead.
70 */
71 typedef struct {
72 GLfloat attrib[FRAG_ATTRIB_MAX][4];
73 GLchan color[4]; /** integer color */
74 GLfloat pointSize;
75 } SWvertex;
76
77
78 #define FRAG_ATTRIB_CI FRAG_ATTRIB_COL0
79
80
81 struct swrast_device_driver;
82
83
84 /* These are the public-access functions exported from swrast.
85 */
86
87 extern GLboolean
88 _swrast_CreateContext( GLcontext *ctx );
89
90 extern void
91 _swrast_DestroyContext( GLcontext *ctx );
92
93 /* Get a (non-const) reference to the device driver struct for swrast.
94 */
95 extern struct swrast_device_driver *
96 _swrast_GetDeviceDriverReference( GLcontext *ctx );
97
98 extern void
99 _swrast_Bitmap( GLcontext *ctx,
100 GLint px, GLint py,
101 GLsizei width, GLsizei height,
102 const struct gl_pixelstore_attrib *unpack,
103 const GLubyte *bitmap );
104
105 extern void
106 _swrast_CopyPixels( GLcontext *ctx,
107 GLint srcx, GLint srcy,
108 GLint destx, GLint desty,
109 GLsizei width, GLsizei height,
110 GLenum type );
111
112 extern void
113 _swrast_DrawPixels( GLcontext *ctx,
114 GLint x, GLint y,
115 GLsizei width, GLsizei height,
116 GLenum format, GLenum type,
117 const struct gl_pixelstore_attrib *unpack,
118 const GLvoid *pixels );
119
120 extern void
121 _swrast_ReadPixels( GLcontext *ctx,
122 GLint x, GLint y, GLsizei width, GLsizei height,
123 GLenum format, GLenum type,
124 const struct gl_pixelstore_attrib *unpack,
125 GLvoid *pixels );
126
127 extern void
128 _swrast_BlitFramebuffer(GLcontext *ctx,
129 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
130 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
131 GLbitfield mask, GLenum filter);
132
133 extern void
134 _swrast_Clear(GLcontext *ctx, GLbitfield buffers);
135
136 extern void
137 _swrast_Accum(GLcontext *ctx, GLenum op, GLfloat value);
138
139
140
141 /* Reset the stipple counter
142 */
143 extern void
144 _swrast_ResetLineStipple( GLcontext *ctx );
145
146 /* These will always render the correct point/line/triangle for the
147 * current state.
148 *
149 * For flatshaded primitives, the provoking vertex is the final one.
150 */
151 extern void
152 _swrast_Point( GLcontext *ctx, const SWvertex *v );
153
154 extern void
155 _swrast_Line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 );
156
157 extern void
158 _swrast_Triangle( GLcontext *ctx, const SWvertex *v0,
159 const SWvertex *v1, const SWvertex *v2 );
160
161 extern void
162 _swrast_Quad( GLcontext *ctx,
163 const SWvertex *v0, const SWvertex *v1,
164 const SWvertex *v2, const SWvertex *v3);
165
166 extern void
167 _swrast_flush( GLcontext *ctx );
168
169 extern void
170 _swrast_render_primitive( GLcontext *ctx, GLenum mode );
171
172 extern void
173 _swrast_render_start( GLcontext *ctx );
174
175 extern void
176 _swrast_render_finish( GLcontext *ctx );
177
178 /* Tell the software rasterizer about core state changes.
179 */
180 extern void
181 _swrast_InvalidateState( GLcontext *ctx, GLbitfield new_state );
182
183 /* Configure software rasterizer to match hardware rasterizer characteristics:
184 */
185 extern void
186 _swrast_allow_vertex_fog( GLcontext *ctx, GLboolean value );
187
188 extern void
189 _swrast_allow_pixel_fog( GLcontext *ctx, GLboolean value );
190
191 /* Debug:
192 */
193 extern void
194 _swrast_print_vertex( GLcontext *ctx, const SWvertex *v );
195
196
197 /*
198 * Imaging fallbacks (a better solution should be found, perhaps
199 * moving all the imaging fallback code to a new module)
200 */
201 extern void
202 _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target,
203 GLenum internalFormat,
204 GLint x, GLint y, GLsizei width,
205 GLsizei height);
206 extern void
207 _swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target,
208 GLenum internalFormat,
209 GLint x, GLint y, GLsizei width);
210 extern void
211 _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start,
212 GLint x, GLint y, GLsizei width);
213 extern void
214 _swrast_CopyColorTable( GLcontext *ctx,
215 GLenum target, GLenum internalformat,
216 GLint x, GLint y, GLsizei width);
217
218
219 /*
220 * Texture fallbacks. Could also live in a new module
221 * with the rest of the texture store fallbacks?
222 */
223 extern void
224 _swrast_copy_teximage1d(GLcontext *ctx, GLenum target, GLint level,
225 GLenum internalFormat,
226 GLint x, GLint y, GLsizei width, GLint border);
227
228 extern void
229 _swrast_copy_teximage2d(GLcontext *ctx, GLenum target, GLint level,
230 GLenum internalFormat,
231 GLint x, GLint y, GLsizei width, GLsizei height,
232 GLint border);
233
234
235 extern void
236 _swrast_copy_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
237 GLint xoffset, GLint x, GLint y, GLsizei width);
238
239 extern void
240 _swrast_copy_texsubimage2d(GLcontext *ctx,
241 GLenum target, GLint level,
242 GLint xoffset, GLint yoffset,
243 GLint x, GLint y, GLsizei width, GLsizei height);
244
245 extern void
246 _swrast_copy_texsubimage3d(GLcontext *ctx,
247 GLenum target, GLint level,
248 GLint xoffset, GLint yoffset, GLint zoffset,
249 GLint x, GLint y, GLsizei width, GLsizei height);
250
251
252 extern void
253 _swrast_eject_texture_images(GLcontext *ctx);
254
255
256 #if FEATURE_MESA_program_debug
257 extern void
258 _swrast_get_program_register(GLcontext *, enum register_file file,
259 GLuint index, GLfloat val[4]);
260 #endif /* FEATURE_MESA_program_debug */
261
262
263 /**
264 * The driver interface for the software rasterizer.
265 * XXX this may go away.
266 * We may move these functions to ctx->Driver.RenderStart, RenderEnd.
267 */
268 struct swrast_device_driver {
269 /*
270 * These are called before and after accessing renderbuffers during
271 * software rasterization.
272 *
273 * These are a suitable place for grabbing/releasing hardware locks.
274 *
275 * NOTE: The swrast triangle/line/point routines *DO NOT* call
276 * these functions. Locking in that case must be organized by the
277 * driver by other mechanisms.
278 */
279 void (*SpanRenderStart)(GLcontext *ctx);
280 void (*SpanRenderFinish)(GLcontext *ctx);
281 };
282
283
284
285 #endif