Major rework of tnl module
[mesa.git] / src / mesa / swrast / swrast.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 3.5
4 *
5 * Copyright (C) 1999 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 * Authors:
25 * Keith Whitwell <keithw@valinux.com>
26 */
27
28 #ifndef SWRAST_H
29 #define SWRAST_H
30
31 #include "mtypes.h"
32
33
34
35 /* The software rasterizer now uses this format for vertices. Thus a
36 * 'RasterSetup' stage or other translation is required between the
37 * tnl module and the swrast rasterization functions. This serves to
38 * isolate the swrast module from the internals of the tnl module, and
39 * improve its usefulness as a fallback mechanism for hardware
40 * drivers.
41 *
42 * Full software drivers:
43 * - Register the rastersetup and triangle functions from
44 * utils/software_helper.
45 * - On statechange, update the rasterization pointers in that module.
46 *
47 * Rasterization hardware drivers:
48 * - Keep native rastersetup.
49 * - Implement native twoside,offset and unfilled triangle setup.
50 * - Implement a translator from native vertices to swrast vertices.
51 * - On partial fallback (mix of accelerated and unaccelerated
52 * prims), call a pass-through function which translates native
53 * vertices to SWvertices and calls the appropriate swrast function.
54 * - On total fallback (vertex format insufficient for state or all
55 * primitives unaccelerated), hook in swrast_setup instead.
56 */
57 typedef struct {
58 GLfloat win[4];
59 GLfloat texcoord[MAX_TEXTURE_UNITS][4];
60 GLchan color[4];
61 GLchan specular[4];
62 GLfloat fog;
63 GLuint index;
64 GLfloat pointSize;
65 } SWvertex;
66
67
68
69
70 /* These are the public-access functions exported from swrast.
71 */
72 extern void
73 _swrast_alloc_buffers( GLcontext *ctx );
74
75 extern GLboolean
76 _swrast_CreateContext( GLcontext *ctx );
77
78 extern void
79 _swrast_DestroyContext( GLcontext *ctx );
80
81
82
83 extern void
84 _swrast_Bitmap( GLcontext *ctx,
85 GLint px, GLint py,
86 GLsizei width, GLsizei height,
87 const struct gl_pixelstore_attrib *unpack,
88 const GLubyte *bitmap );
89
90 extern void
91 _swrast_CopyPixels( GLcontext *ctx,
92 GLint srcx, GLint srcy,
93 GLint destx, GLint desty,
94 GLsizei width, GLsizei height,
95 GLenum type );
96
97 extern void
98 _swrast_DrawPixels( GLcontext *ctx,
99 GLint x, GLint y,
100 GLsizei width, GLsizei height,
101 GLenum format, GLenum type,
102 const struct gl_pixelstore_attrib *unpack,
103 const GLvoid *pixels );
104
105 extern void
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,
110 GLvoid *pixels );
111
112 extern void
113 _swrast_Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
114 GLint x, GLint y, GLint width, GLint height );
115
116 extern void
117 _swrast_Accum( GLcontext *ctx, GLenum op,
118 GLfloat value, GLint xpos, GLint ypos,
119 GLint width, GLint height );
120
121
122 /* Get a pointer to the stipple counter.
123 */
124 extern GLuint *
125 _swrast_get_stipple_counter_ref( GLcontext *ctx );
126
127 /* Reset the stipple pointer via a function call
128 */
129 extern void
130 _swrast_ResetLineStipple( GLcontext *ctx );
131
132 /* These will always render the correct point/line/triangle for the
133 * current state.
134 */
135 extern void
136 _swrast_Point( GLcontext *ctx, const SWvertex *v );
137
138 extern void
139 _swrast_Line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 );
140
141 extern void
142 _swrast_Triangle( GLcontext *ctx, const SWvertex *v0,
143 const SWvertex *v1, const SWvertex *v2 );
144
145 extern void
146 _swrast_Quad( GLcontext *ctx,
147 const SWvertex *v0, const SWvertex *v1,
148 const SWvertex *v2, const SWvertex *v3);
149
150 extern void
151 _swrast_flush( GLcontext *ctx );
152
153
154 /* Tell the software rasterizer about core state changes.
155 */
156 extern void
157 _swrast_InvalidateState( GLcontext *ctx, GLuint new_state );
158
159 /* Configure software rasterizer to match hardware rasterizer characteristics:
160 */
161 extern void
162 _swrast_allow_vertex_fog( GLcontext *ctx, GLboolean value );
163
164 extern void
165 _swrast_allow_pixel_fog( GLcontext *ctx, GLboolean value );
166
167 extern void
168 _swrast_print_vertex( GLcontext *ctx, const SWvertex *v );
169
170 #endif