OSDN Git Service

Merge remote branch 'main/master' into radeon-rewrite
[android-x86/external-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 /**
79  * Fixed point data type.
80  */
81 typedef int GLfixed;
82
83
84 #define FRAG_ATTRIB_CI FRAG_ATTRIB_COL0
85
86
87 struct swrast_device_driver;
88
89
90 /* These are the public-access functions exported from swrast.
91  */
92
93 extern GLboolean
94 _swrast_CreateContext( GLcontext *ctx );
95
96 extern void
97 _swrast_DestroyContext( GLcontext *ctx );
98
99 /* Get a (non-const) reference to the device driver struct for swrast.
100  */
101 extern struct swrast_device_driver *
102 _swrast_GetDeviceDriverReference( GLcontext *ctx );
103
104 extern void
105 _swrast_Bitmap( GLcontext *ctx,
106                 GLint px, GLint py,
107                 GLsizei width, GLsizei height,
108                 const struct gl_pixelstore_attrib *unpack,
109                 const GLubyte *bitmap );
110
111 extern void
112 _swrast_CopyPixels( GLcontext *ctx,
113                     GLint srcx, GLint srcy,
114                     GLint destx, GLint desty,
115                     GLsizei width, GLsizei height,
116                     GLenum type );
117
118 extern void
119 _swrast_DrawPixels( GLcontext *ctx,
120                     GLint x, GLint y,
121                     GLsizei width, GLsizei height,
122                     GLenum format, GLenum type,
123                     const struct gl_pixelstore_attrib *unpack,
124                     const GLvoid *pixels );
125
126 extern void
127 _swrast_ReadPixels( GLcontext *ctx,
128                     GLint x, GLint y, GLsizei width, GLsizei height,
129                     GLenum format, GLenum type,
130                     const struct gl_pixelstore_attrib *unpack,
131                     GLvoid *pixels );
132
133 extern void
134 _swrast_BlitFramebuffer(GLcontext *ctx,
135                         GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
136                         GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
137                         GLbitfield mask, GLenum filter);
138
139 extern void
140 _swrast_Clear(GLcontext *ctx, GLbitfield buffers);
141
142 extern void
143 _swrast_Accum(GLcontext *ctx, GLenum op, GLfloat value);
144
145
146
147 /* Reset the stipple counter
148  */
149 extern void
150 _swrast_ResetLineStipple( GLcontext *ctx );
151
152 /**
153  * Indicates front/back facing for subsequent points/lines when drawing
154  * unfilled polygons.  Needed for two-side stencil.
155  */
156 extern void
157 _swrast_SetFacing(GLcontext *ctx, GLuint facing);
158
159 /* These will always render the correct point/line/triangle for the
160  * current state.
161  *
162  * For flatshaded primitives, the provoking vertex is the final one.
163  */
164 extern void
165 _swrast_Point( GLcontext *ctx, const SWvertex *v );
166
167 extern void
168 _swrast_Line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 );
169
170 extern void
171 _swrast_Triangle( GLcontext *ctx, const SWvertex *v0,
172                   const SWvertex *v1, const SWvertex *v2 );
173
174 extern void
175 _swrast_Quad( GLcontext *ctx,
176               const SWvertex *v0, const SWvertex *v1,
177               const SWvertex *v2,  const SWvertex *v3);
178
179 extern void
180 _swrast_flush( GLcontext *ctx );
181
182 extern void
183 _swrast_render_primitive( GLcontext *ctx, GLenum mode );
184
185 extern void
186 _swrast_render_start( GLcontext *ctx );
187
188 extern void
189 _swrast_render_finish( GLcontext *ctx );
190
191 /* Tell the software rasterizer about core state changes.
192  */
193 extern void
194 _swrast_InvalidateState( GLcontext *ctx, GLbitfield new_state );
195
196 /* Configure software rasterizer to match hardware rasterizer characteristics:
197  */
198 extern void
199 _swrast_allow_vertex_fog( GLcontext *ctx, GLboolean value );
200
201 extern void
202 _swrast_allow_pixel_fog( GLcontext *ctx, GLboolean value );
203
204 /* Debug:
205  */
206 extern void
207 _swrast_print_vertex( GLcontext *ctx, const SWvertex *v );
208
209
210 /*
211  * Imaging fallbacks (a better solution should be found, perhaps
212  * moving all the imaging fallback code to a new module) 
213  */
214 extern void
215 _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target, 
216                                 GLenum internalFormat, 
217                                 GLint x, GLint y, GLsizei width, 
218                                 GLsizei height);
219 extern void
220 _swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target, 
221                                 GLenum internalFormat, 
222                                 GLint x, GLint y, GLsizei width);
223 extern void
224 _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start,
225                            GLint x, GLint y, GLsizei width);
226 extern void
227 _swrast_CopyColorTable( GLcontext *ctx, 
228                         GLenum target, GLenum internalformat,
229                         GLint x, GLint y, GLsizei width);
230
231
232 /*
233  * Texture fallbacks.  Could also live in a new module
234  * with the rest of the texture store fallbacks?
235  */
236 extern void
237 _swrast_copy_teximage1d(GLcontext *ctx, GLenum target, GLint level,
238                         GLenum internalFormat,
239                         GLint x, GLint y, GLsizei width, GLint border);
240
241 extern void
242 _swrast_copy_teximage2d(GLcontext *ctx, GLenum target, GLint level,
243                         GLenum internalFormat,
244                         GLint x, GLint y, GLsizei width, GLsizei height,
245                         GLint border);
246
247
248 extern void
249 _swrast_copy_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
250                            GLint xoffset, GLint x, GLint y, GLsizei width);
251
252 extern void
253 _swrast_copy_texsubimage2d(GLcontext *ctx,
254                            GLenum target, GLint level,
255                            GLint xoffset, GLint yoffset,
256                            GLint x, GLint y, GLsizei width, GLsizei height);
257
258 extern void
259 _swrast_copy_texsubimage3d(GLcontext *ctx,
260                            GLenum target, GLint level,
261                            GLint xoffset, GLint yoffset, GLint zoffset,
262                            GLint x, GLint y, GLsizei width, GLsizei height);
263
264
265 extern void
266 _swrast_eject_texture_images(GLcontext *ctx);
267
268
269
270 /**
271  * The driver interface for the software rasterizer.
272  * XXX this may go away.
273  * We may move these functions to ctx->Driver.RenderStart, RenderEnd.
274  */
275 struct swrast_device_driver {
276    /*
277     * These are called before and after accessing renderbuffers during
278     * software rasterization.
279     *
280     * These are a suitable place for grabbing/releasing hardware locks.
281     *
282     * NOTE: The swrast triangle/line/point routines *DO NOT* call
283     * these functions.  Locking in that case must be organized by the
284     * driver by other mechanisms.
285     */
286    void (*SpanRenderStart)(GLcontext *ctx);
287    void (*SpanRenderFinish)(GLcontext *ctx);
288 };
289
290
291
292 #endif