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>
39 * \brief Data-structure to handle vertices in the software rasterizer.
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
48 * Full software drivers:
49 * - Register the rastersetup and triangle functions from
50 * utils/software_helper.
51 * - On statechange, update the rasterization pointers in that module.
53 * Rasterization hardware drivers:
54 * - Keep native rastersetup.
55 * - Implement native twoside,offset and unfilled triangle setup.
56 * - Implement a translator from native vertices to swrast vertices.
57 * - On partial fallback (mix of accelerated and unaccelerated
58 * prims), call a pass-through function which translates native
59 * vertices to SWvertices and calls the appropriate swrast function.
60 * - On total fallback (vertex format insufficient for state or all
61 * primitives unaccelerated), hook in swrast_setup instead.
64 /** win[0], win[1] are the screen-coords of SWvertex.
65 * win[2] is the z-buffer coord (if 16-bit Z buffer, in range [0,65535]).
66 * win[3] is 1/w where w is the clip-space W coord. This is the value
67 * that clip{XYZ} were multiplied by to get ndc{XYZ}.
70 GLfloat texcoord
[MAX_TEXTURE_COORD_UNITS
][4];
76 GLfloat attribute
[MAX_VERTEX_ATTRIBS
][4];
80 struct swrast_device_driver
;
83 /* These are the public-access functions exported from swrast.
87 _swrast_CreateContext( GLcontext
*ctx
);
90 _swrast_DestroyContext( GLcontext
*ctx
);
92 /* Get a (non-const) reference to the device driver struct for swrast.
94 extern struct swrast_device_driver
*
95 _swrast_GetDeviceDriverReference( GLcontext
*ctx
);
98 _swrast_Bitmap( GLcontext
*ctx
,
100 GLsizei width
, GLsizei height
,
101 const struct gl_pixelstore_attrib
*unpack
,
102 const GLubyte
*bitmap
);
105 _swrast_CopyPixels( GLcontext
*ctx
,
106 GLint srcx
, GLint srcy
,
107 GLint destx
, GLint desty
,
108 GLsizei width
, GLsizei height
,
112 _swrast_DrawPixels( GLcontext
*ctx
,
114 GLsizei width
, GLsizei height
,
115 GLenum format
, GLenum type
,
116 const struct gl_pixelstore_attrib
*unpack
,
117 const GLvoid
*pixels
);
120 _swrast_ReadPixels( GLcontext
*ctx
,
121 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
122 GLenum format
, GLenum type
,
123 const struct gl_pixelstore_attrib
*unpack
,
127 _swrast_BlitFramebuffer(GLcontext
*ctx
,
128 GLint srcX0
, GLint srcY0
, GLint srcX1
, GLint srcY1
,
129 GLint dstX0
, GLint dstY0
, GLint dstX1
, GLint dstY1
,
130 GLbitfield mask
, GLenum filter
);
133 _swrast_Clear( GLcontext
*ctx
, GLbitfield mask
, GLboolean all
,
134 GLint x
, GLint y
, GLint width
, GLint height
);
137 _swrast_Accum( GLcontext
*ctx
, GLenum op
,
138 GLfloat value
, GLint xpos
, GLint ypos
,
139 GLint width
, GLint height
);
143 /* Reset the stipple counter
146 _swrast_ResetLineStipple( GLcontext
*ctx
);
148 /* These will always render the correct point/line/triangle for the
151 * For flatshaded primitives, the provoking vertex is the final one.
154 _swrast_Point( GLcontext
*ctx
, const SWvertex
*v
);
157 _swrast_Line( GLcontext
*ctx
, const SWvertex
*v0
, const SWvertex
*v1
);
160 _swrast_Triangle( GLcontext
*ctx
, const SWvertex
*v0
,
161 const SWvertex
*v1
, const SWvertex
*v2
);
164 _swrast_Quad( GLcontext
*ctx
,
165 const SWvertex
*v0
, const SWvertex
*v1
,
166 const SWvertex
*v2
, const SWvertex
*v3
);
169 _swrast_flush( GLcontext
*ctx
);
172 _swrast_render_primitive( GLcontext
*ctx
, GLenum mode
);
175 _swrast_render_start( GLcontext
*ctx
);
178 _swrast_render_finish( GLcontext
*ctx
);
180 /* Tell the software rasterizer about core state changes.
183 _swrast_InvalidateState( GLcontext
*ctx
, GLbitfield new_state
);
185 /* Configure software rasterizer to match hardware rasterizer characteristics:
188 _swrast_allow_vertex_fog( GLcontext
*ctx
, GLboolean value
);
191 _swrast_allow_pixel_fog( GLcontext
*ctx
, GLboolean value
);
196 _swrast_print_vertex( GLcontext
*ctx
, const SWvertex
*v
);
200 * Imaging fallbacks (a better solution should be found, perhaps
201 * moving all the imaging fallback code to a new module)
204 _swrast_CopyConvolutionFilter2D(GLcontext
*ctx
, GLenum target
,
205 GLenum internalFormat
,
206 GLint x
, GLint y
, GLsizei width
,
209 _swrast_CopyConvolutionFilter1D(GLcontext
*ctx
, GLenum target
,
210 GLenum internalFormat
,
211 GLint x
, GLint y
, GLsizei width
);
213 _swrast_CopyColorSubTable( GLcontext
*ctx
,GLenum target
, GLsizei start
,
214 GLint x
, GLint y
, GLsizei width
);
216 _swrast_CopyColorTable( GLcontext
*ctx
,
217 GLenum target
, GLenum internalformat
,
218 GLint x
, GLint y
, GLsizei width
);
222 * Texture fallbacks. Could also live in a new module
223 * with the rest of the texture store fallbacks?
226 _swrast_copy_teximage1d(GLcontext
*ctx
, GLenum target
, GLint level
,
227 GLenum internalFormat
,
228 GLint x
, GLint y
, GLsizei width
, GLint border
);
231 _swrast_copy_teximage2d(GLcontext
*ctx
, GLenum target
, GLint level
,
232 GLenum internalFormat
,
233 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
238 _swrast_copy_texsubimage1d(GLcontext
*ctx
, GLenum target
, GLint level
,
239 GLint xoffset
, GLint x
, GLint y
, GLsizei width
);
242 _swrast_copy_texsubimage2d(GLcontext
*ctx
,
243 GLenum target
, GLint level
,
244 GLint xoffset
, GLint yoffset
,
245 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
248 _swrast_copy_texsubimage3d(GLcontext
*ctx
,
249 GLenum target
, GLint level
,
250 GLint xoffset
, GLint yoffset
, GLint zoffset
,
251 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
255 _swrast_eject_texture_images(GLcontext
*ctx
);
259 * The driver interface for the software rasterizer.
260 * XXX this may go away.
261 * We may move these functions to ctx->Driver.RenderStart, RenderEnd.
263 struct swrast_device_driver
{
265 * These are called before and after accessing renderbuffers during
266 * software rasterization.
268 * These are a suitable place for grabbing/releasing hardware locks.
270 * NOTE: The swrast triangle/line/point routines *DO NOT* call
271 * these functions. Locking in that case must be organized by the
272 * driver by other mechanisms.
274 void (*SpanRenderStart
)(GLcontext
*ctx
);
275 void (*SpanRenderFinish
)(GLcontext
*ctx
);