[MESA]
[reactos.git] / reactos / dll / opengl / 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 #include "swrast/s_chan.h"
37
38 /**
39 * \struct SWvertex
40 * \brief Data-structure to handle vertices in the software rasterizer.
41 *
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
47 * drivers.
48 *
49 * wpos = attr[FRAG_ATTRIB_WPOS] and MUST BE THE FIRST values in the
50 * vertex because of the tnl clipping code.
51
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}.
56 *
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.
61 *
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.
71 */
72 typedef struct {
73 GLfloat attrib[32][4];
74 GLchan color[4]; /** integer color */
75 GLfloat pointSize;
76 } SWvertex;
77
78
79 #define FRAG_ATTRIB_CI FRAG_ATTRIB_COL0
80
81
82 struct swrast_device_driver;
83
84
85 /* These are the public-access functions exported from swrast.
86 */
87
88 extern GLboolean
89 _swrast_CreateContext( struct gl_context *ctx );
90
91 extern void
92 _swrast_DestroyContext( struct gl_context *ctx );
93
94 /* Get a (non-const) reference to the device driver struct for swrast.
95 */
96 extern struct swrast_device_driver *
97 _swrast_GetDeviceDriverReference( struct gl_context *ctx );
98
99 extern void
100 _swrast_Bitmap( struct gl_context *ctx,
101 GLint px, GLint py,
102 GLsizei width, GLsizei height,
103 const struct gl_pixelstore_attrib *unpack,
104 const GLubyte *bitmap );
105
106 extern void
107 _swrast_CopyPixels( struct gl_context *ctx,
108 GLint srcx, GLint srcy,
109 GLint destx, GLint desty,
110 GLsizei width, GLsizei height,
111 GLenum type );
112
113 extern GLboolean
114 swrast_fast_copy_pixels(struct gl_context *ctx,
115 GLint srcX, GLint srcY, GLsizei width, GLsizei height,
116 GLint dstX, GLint dstY, GLenum type);
117
118 extern void
119 _swrast_DrawPixels( struct gl_context *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_Clear(struct gl_context *ctx, GLbitfield buffers);
128
129
130
131 /* Reset the stipple counter
132 */
133 extern void
134 _swrast_ResetLineStipple( struct gl_context *ctx );
135
136 /* These will always render the correct point/line/triangle for the
137 * current state.
138 *
139 * For flatshaded primitives, the provoking vertex is the final one.
140 */
141 extern void
142 _swrast_Point( struct gl_context *ctx, const SWvertex *v );
143
144 extern void
145 _swrast_Line( struct gl_context *ctx, const SWvertex *v0, const SWvertex *v1 );
146
147 extern void
148 _swrast_Triangle( struct gl_context *ctx, const SWvertex *v0,
149 const SWvertex *v1, const SWvertex *v2 );
150
151 extern void
152 _swrast_Quad( struct gl_context *ctx,
153 const SWvertex *v0, const SWvertex *v1,
154 const SWvertex *v2, const SWvertex *v3);
155
156 extern void
157 _swrast_flush( struct gl_context *ctx );
158
159 extern void
160 _swrast_render_primitive( struct gl_context *ctx, GLenum mode );
161
162 extern void
163 _swrast_render_start( struct gl_context *ctx );
164
165 extern void
166 _swrast_render_finish( struct gl_context *ctx );
167
168 extern struct gl_texture_image *
169 _swrast_new_texture_image( struct gl_context *ctx );
170
171 extern void
172 _swrast_delete_texture_image(struct gl_context *ctx,
173 struct gl_texture_image *texImage);
174
175 extern GLboolean
176 _swrast_alloc_texture_image_buffer(struct gl_context *ctx,
177 struct gl_texture_image *texImage,
178 gl_format format, GLsizei width,
179 GLsizei height, GLsizei depth);
180
181 extern void
182 _swrast_init_texture_image(struct gl_texture_image *texImage, GLsizei width,
183 GLsizei height, GLsizei depth);
184
185 extern void
186 _swrast_free_texture_image_buffer(struct gl_context *ctx,
187 struct gl_texture_image *texImage);
188
189 extern void
190 _swrast_map_teximage(struct gl_context *ctx,
191 struct gl_texture_image *texImage,
192 GLuint slice,
193 GLuint x, GLuint y, GLuint w, GLuint h,
194 GLbitfield mode,
195 GLubyte **mapOut,
196 GLint *rowStrideOut);
197
198 extern void
199 _swrast_unmap_teximage(struct gl_context *ctx,
200 struct gl_texture_image *texImage,
201 GLuint slice);
202
203 /* Tell the software rasterizer about core state changes.
204 */
205 extern void
206 _swrast_InvalidateState( struct gl_context *ctx, GLbitfield new_state );
207
208 /* Configure software rasterizer to match hardware rasterizer characteristics:
209 */
210 extern void
211 _swrast_allow_vertex_fog( struct gl_context *ctx, GLboolean value );
212
213 extern void
214 _swrast_allow_pixel_fog( struct gl_context *ctx, GLboolean value );
215
216 /* Debug:
217 */
218 extern void
219 _swrast_print_vertex( struct gl_context *ctx, const SWvertex *v );
220
221
222
223 extern void
224 _swrast_eject_texture_images(struct gl_context *ctx);
225
226
227 extern void
228 _swrast_render_texture(struct gl_context *ctx,
229 struct gl_framebuffer *fb,
230 struct gl_renderbuffer_attachment *att);
231
232
233
234 extern GLboolean
235 _swrast_AllocTextureStorage(struct gl_context *ctx,
236 struct gl_texture_object *texObj,
237 GLsizei levels, GLsizei width,
238 GLsizei height, GLsizei depth);
239
240
241 /**
242 * The driver interface for the software rasterizer.
243 * XXX this may go away.
244 * We may move these functions to ctx->Driver.RenderStart, RenderEnd.
245 */
246 struct swrast_device_driver {
247 /*
248 * These are called before and after accessing renderbuffers during
249 * software rasterization.
250 *
251 * These are a suitable place for grabbing/releasing hardware locks.
252 *
253 * NOTE: The swrast triangle/line/point routines *DO NOT* call
254 * these functions. Locking in that case must be organized by the
255 * driver by other mechanisms.
256 */
257 void (*SpanRenderStart)(struct gl_context *ctx);
258 void (*SpanRenderFinish)(struct gl_context *ctx);
259 };
260
261
262
263 #endif