2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
27 * \file swrast/swrast.h
28 * \brief Public interface to the software rasterization functions.
29 * \author Keith Whitwell <keith@tungstengraphics.com>
35 #include "main/mtypes.h"
36 #include "swrast_features.h"
40 * \brief Data-structure to handle vertices in the software rasterizer.
42 * The software rasterizer now uses this format for vertices. Thus a
43 * 'RasterSetup' stage or other translation is required between the
44 * tnl module and the swrast rasterization functions. This serves to
45 * isolate the swrast module from the internals of the tnl module, and
46 * improve its usefulness as a fallback mechanism for hardware
49 * wpos = attr[FRAG_ATTRIB_WPOS] and MUST BE THE FIRST values in the
50 * vertex because of the tnl clipping code.
52 * wpos[0] and [1] are the screen-coords of SWvertex.
53 * wpos[2] is the z-buffer coord (if 16-bit Z buffer, in range [0,65535]).
54 * wpos[3] is 1/w where w is the clip-space W coord. This is the value
55 * that clip{XYZ} were multiplied by to get ndc{XYZ}.
57 * Full software drivers:
58 * - Register the rastersetup and triangle functions from
59 * utils/software_helper.
60 * - On statechange, update the rasterization pointers in that module.
62 * Rasterization hardware drivers:
63 * - Keep native rastersetup.
64 * - Implement native twoside,offset and unfilled triangle setup.
65 * - Implement a translator from native vertices to swrast vertices.
66 * - On partial fallback (mix of accelerated and unaccelerated
67 * prims), call a pass-through function which translates native
68 * vertices to SWvertices and calls the appropriate swrast function.
69 * - On total fallback (vertex format insufficient for state or all
70 * primitives unaccelerated), hook in swrast_setup instead.
73 GLfloat attrib[FRAG_ATTRIB_MAX][4];
74 GLchan color[4]; /** integer color */
80 * Fixed point data type.
85 #define FRAG_ATTRIB_CI FRAG_ATTRIB_COL0
88 struct swrast_device_driver;
91 /* These are the public-access functions exported from swrast.
95 _swrast_CreateContext( GLcontext *ctx );
98 _swrast_DestroyContext( GLcontext *ctx );
100 /* Get a (non-const) reference to the device driver struct for swrast.
102 extern struct swrast_device_driver *
103 _swrast_GetDeviceDriverReference( GLcontext *ctx );
106 _swrast_ReadPixels( GLcontext *ctx,
107 GLint x, GLint y, GLsizei width, GLsizei height,
108 GLenum format, GLenum type,
109 const struct gl_pixelstore_attrib *unpack,
113 _swrast_BlitFramebuffer(GLcontext *ctx,
114 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
115 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
116 GLbitfield mask, GLenum filter);
119 _swrast_Clear(GLcontext *ctx, GLbitfield buffers);
122 /* Reset the stipple counter
125 _swrast_ResetLineStipple( GLcontext *ctx );
128 * Indicates front/back facing for subsequent points/lines when drawing
129 * unfilled polygons. Needed for two-side stencil.
132 _swrast_SetFacing(GLcontext *ctx, GLuint facing);
134 /* These will always render the correct point/line/triangle for the
137 * For flatshaded primitives, the provoking vertex is the final one.
140 _swrast_Point( GLcontext *ctx, const SWvertex *v );
143 _swrast_Line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 );
146 _swrast_Triangle( GLcontext *ctx, const SWvertex *v0,
147 const SWvertex *v1, const SWvertex *v2 );
150 _swrast_Quad( GLcontext *ctx,
151 const SWvertex *v0, const SWvertex *v1,
152 const SWvertex *v2, const SWvertex *v3);
155 _swrast_flush( GLcontext *ctx );
158 _swrast_render_primitive( GLcontext *ctx, GLenum mode );
161 _swrast_render_start( GLcontext *ctx );
164 _swrast_render_finish( GLcontext *ctx );
166 /* Tell the software rasterizer about core state changes.
169 _swrast_InvalidateState( GLcontext *ctx, GLbitfield new_state );
171 /* Configure software rasterizer to match hardware rasterizer characteristics:
174 _swrast_allow_vertex_fog( GLcontext *ctx, GLboolean value );
177 _swrast_allow_pixel_fog( GLcontext *ctx, GLboolean value );
182 _swrast_print_vertex( GLcontext *ctx, const SWvertex *v );
186 * Texture fallbacks. Could also live in a new module
187 * with the rest of the texture store fallbacks?
190 _swrast_copy_teximage1d(GLcontext *ctx, GLenum target, GLint level,
191 GLenum internalFormat,
192 GLint x, GLint y, GLsizei width, GLint border);
195 _swrast_copy_teximage2d(GLcontext *ctx, GLenum target, GLint level,
196 GLenum internalFormat,
197 GLint x, GLint y, GLsizei width, GLsizei height,
202 _swrast_copy_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
203 GLint xoffset, GLint x, GLint y, GLsizei width);
206 _swrast_copy_texsubimage2d(GLcontext *ctx,
207 GLenum target, GLint level,
208 GLint xoffset, GLint yoffset,
209 GLint x, GLint y, GLsizei width, GLsizei height);
212 _swrast_copy_texsubimage3d(GLcontext *ctx,
213 GLenum target, GLint level,
214 GLint xoffset, GLint yoffset, GLint zoffset,
215 GLint x, GLint y, GLsizei width, GLsizei height);
219 _swrast_eject_texture_images(GLcontext *ctx);
224 * The driver interface for the software rasterizer.
225 * XXX this may go away.
226 * We may move these functions to ctx->Driver.RenderStart, RenderEnd.
228 struct swrast_device_driver {
230 * These are called before and after accessing renderbuffers during
231 * software rasterization.
233 * These are a suitable place for grabbing/releasing hardware locks.
235 * NOTE: The swrast triangle/line/point routines *DO NOT* call
236 * these functions. Locking in that case must be organized by the
237 * driver by other mechanisms.
239 void (*SpanRenderStart)(GLcontext *ctx);
240 void (*SpanRenderFinish)(GLcontext *ctx);
243 #endif /* SWRAST_H */