| 1 |
/* |
| 2 |
* Mesa 3-D graphics library |
| 3 |
* Version: 6.3 |
| 4 |
* |
| 5 |
* Copyright (C) 1999-2005 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 <[email protected]> |
| 30 |
*/ |
| 31 |
|
| 32 |
#ifndef SWRAST_H |
| 33 |
#define SWRAST_H |
| 34 |
|
| 35 |
#include "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 |
* 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. |
| 52 |
* |
| 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. |
| 62 |
*/ |
| 63 |
typedef struct { |
| 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}. |
| 68 |
*/ |
| 69 |
GLfloat win[4]; |
| 70 |
GLfloat texcoord[MAX_TEXTURE_COORD_UNITS][4]; |
| 71 |
GLchan color[4]; |
| 72 |
GLchan specular[4]; |
| 73 |
GLfloat fog; |
| 74 |
GLfloat index; |
| 75 |
GLfloat pointSize; |
| 76 |
} SWvertex; |
| 77 |
|
| 78 |
|
| 79 |
struct swrast_device_driver; |
| 80 |
|
| 81 |
|
| 82 |
/* These are the public-access functions exported from swrast. |
| 83 |
*/ |
| 84 |
extern void |
| 85 |
_swrast_use_read_buffer( GLcontext *ctx ); |
| 86 |
|
| 87 |
extern void |
| 88 |
_swrast_use_draw_buffer( GLcontext *ctx ); |
| 89 |
|
| 90 |
extern GLboolean |
| 91 |
_swrast_CreateContext( GLcontext *ctx ); |
| 92 |
|
| 93 |
extern void |
| 94 |
_swrast_DestroyContext( GLcontext *ctx ); |
| 95 |
|
| 96 |
/* Get a (non-const) reference to the device driver struct for swrast. |
| 97 |
*/ |
| 98 |
extern struct swrast_device_driver * |
| 99 |
_swrast_GetDeviceDriverReference( GLcontext *ctx ); |
| 100 |
|
| 101 |
extern void |
| 102 |
_swrast_Bitmap( GLcontext *ctx, |
| 103 |
GLint px, GLint py, |
| 104 |
GLsizei width, GLsizei height, |
| 105 |
const struct gl_pixelstore_attrib *unpack, |
| 106 |
const GLubyte *bitmap ); |
| 107 |
|
| 108 |
extern void |
| 109 |
_swrast_CopyPixels( GLcontext *ctx, |
| 110 |
GLint srcx, GLint srcy, |
| 111 |
GLint destx, GLint desty, |
| 112 |
GLsizei width, GLsizei height, |
| 113 |
GLenum type ); |
| 114 |
|
| 115 |
extern void |
| 116 |
_swrast_DrawPixels( GLcontext *ctx, |
| 117 |
GLint x, GLint y, |
| 118 |
GLsizei width, GLsizei height, |
| 119 |
GLenum format, GLenum type, |
| 120 |
const struct gl_pixelstore_attrib *unpack, |
| 121 |
const GLvoid *pixels ); |
| 122 |
|
| 123 |
extern void |
| 124 |
_swrast_ReadPixels( GLcontext *ctx, |
| 125 |
GLint x, GLint y, GLsizei width, GLsizei height, |
| 126 |
GLenum format, GLenum type, |
| 127 |
const struct gl_pixelstore_attrib *unpack, |
| 128 |
GLvoid *pixels ); |
| 129 |
|
| 130 |
extern void |
| 131 |
_swrast_Clear( GLcontext *ctx, GLbitfield mask, GLboolean all, |
| 132 |
GLint x, GLint y, GLint width, GLint height ); |
| 133 |
|
| 134 |
extern void |
| 135 |
_swrast_Accum( GLcontext *ctx, GLenum op, |
| 136 |
GLfloat value, GLint xpos, GLint ypos, |
| 137 |
GLint width, GLint height ); |
| 138 |
|
| 139 |
|
| 140 |
extern void |
| 141 |
_swrast_DrawBuffer( GLcontext *ctx, GLenum mode ); |
| 142 |
|
| 143 |
|
| 144 |
extern void |
| 145 |
_swrast_DrawBuffers( GLcontext *ctx, GLsizei n, const GLenum *buffers ); |
| 146 |
|
| 147 |
|
| 148 |
/* Reset the stipple counter |
| 149 |
*/ |
| 150 |
extern void |
| 151 |
_swrast_ResetLineStipple( GLcontext *ctx ); |
| 152 |
|
| 153 |
/* These will always render the correct point/line/triangle for the |
| 154 |
* current state. |
| 155 |
* |
| 156 |
* For flatshaded primitives, the provoking vertex is the final one. |
| 157 |
*/ |
| 158 |
extern void |
| 159 |
_swrast_Point( GLcontext *ctx, const SWvertex *v ); |
| 160 |
|
| 161 |
extern void |
| 162 |
_swrast_Line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 ); |
| 163 |
|
| 164 |
extern void |
| 165 |
_swrast_Triangle( GLcontext *ctx, const SWvertex *v0, |
| 166 |
const SWvertex *v1, const SWvertex *v2 ); |
| 167 |
|
| 168 |
extern void |
| 169 |
_swrast_Quad( GLcontext *ctx, |
| 170 |
const SWvertex *v0, const SWvertex *v1, |
| 171 |
const SWvertex *v2, const SWvertex *v3); |
| 172 |
|
| 173 |
extern void |
| 174 |
_swrast_flush( GLcontext *ctx ); |
| 175 |
|
| 176 |
extern void |
| 177 |
_swrast_render_primitive( GLcontext *ctx, GLenum mode ); |
| 178 |
|
| 179 |
extern void |
| 180 |
_swrast_render_start( GLcontext *ctx ); |
| 181 |
|
| 182 |
extern void |
| 183 |
_swrast_render_finish( GLcontext *ctx ); |
| 184 |
|
| 185 |
/* Tell the software rasterizer about core state changes. |
| 186 |
*/ |
| 187 |
extern void |
| 188 |
_swrast_InvalidateState( GLcontext *ctx, GLuint new_state ); |
| 189 |
|
| 190 |
/* Configure software rasterizer to match hardware rasterizer characteristics: |
| 191 |
*/ |
| 192 |
extern void |
| 193 |
_swrast_allow_vertex_fog( GLcontext *ctx, GLboolean value ); |
| 194 |
|
| 195 |
extern void |
| 196 |
_swrast_allow_pixel_fog( GLcontext *ctx, GLboolean value ); |
| 197 |
|
| 198 |
/* Debug: |
| 199 |
*/ |
| 200 |
extern void |
| 201 |
_swrast_print_vertex( GLcontext *ctx, const SWvertex *v ); |
| 202 |
|
| 203 |
|
| 204 |
/* |
| 205 |
* Imaging fallbacks (a better solution should be found, perhaps |
| 206 |
* moving all the imaging fallback code to a new module) |
| 207 |
*/ |
| 208 |
extern void |
| 209 |
_swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target, |
| 210 |
GLenum internalFormat, |
| 211 |
GLint x, GLint y, GLsizei width, |
| 212 |
GLsizei height); |
| 213 |
extern void |
| 214 |
_swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target, |
| 215 |
GLenum internalFormat, |
| 216 |
GLint x, GLint y, GLsizei width); |
| 217 |
extern void |
| 218 |
_swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start, |
| 219 |
GLint x, GLint y, GLsizei width); |
| 220 |
extern void |
| 221 |
_swrast_CopyColorTable( GLcontext *ctx, |
| 222 |
GLenum target, GLenum internalformat, |
| 223 |
GLint x, GLint y, GLsizei width); |
| 224 |
|
| 225 |
|
| 226 |
/* |
| 227 |
* Texture fallbacks. Could also live in a new module |
| 228 |
* with the rest of the texture store fallbacks? |
| 229 |
*/ |
| 230 |
extern void |
| 231 |
_swrast_copy_teximage1d(GLcontext *ctx, GLenum target, GLint level, |
| 232 |
GLenum internalFormat, |
| 233 |
GLint x, GLint y, GLsizei width, GLint border); |
| 234 |
|
| 235 |
extern void |
| 236 |
_swrast_copy_teximage2d(GLcontext *ctx, GLenum target, GLint level, |
| 237 |
GLenum internalFormat, |
| 238 |
GLint x, GLint y, GLsizei width, GLsizei height, |
| 239 |
GLint border); |
| 240 |
|
| 241 |
|
| 242 |
extern void |
| 243 |
_swrast_copy_texsubimage1d(GLcontext *ctx, GLenum target, GLint level, |
| 244 |
GLint xoffset, GLint x, GLint y, GLsizei width); |
| 245 |
|
| 246 |
extern void |
| 247 |
_swrast_copy_texsubimage2d(GLcontext *ctx, |
| 248 |
GLenum target, GLint level, |
| 249 |
GLint xoffset, GLint yoffset, |
| 250 |
GLint x, GLint y, GLsizei width, GLsizei height); |
| 251 |
|
| 252 |
extern void |
| 253 |
_swrast_copy_texsubimage3d(GLcontext *ctx, |
| 254 |
GLenum target, GLint level, |
| 255 |
GLint xoffset, GLint yoffset, GLint zoffset, |
| 256 |
GLint x, GLint y, GLsizei width, GLsizei height); |
| 257 |
|
| 258 |
|
| 259 |
/* The driver interface for the software rasterizer. |
| 260 |
* Unless otherwise noted, all functions are mandatory. |
| 261 |
*/ |
| 262 |
struct swrast_device_driver { |
| 263 |
#if OLD_RENDERBUFFER |
| 264 |
void (*SetBuffer)(GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit); |
| 265 |
/* |
| 266 |
* Specifies the current color buffer for span/pixel writing/reading. |
| 267 |
* buffer indicates which window to write to / read from. Normally, |
| 268 |
* this'll be the buffer currently bound to the context, but it doesn't |
| 269 |
* have to be! |
| 270 |
* bufferBit indicates which color buffer, exactly one of: |
| 271 |
* DD_FRONT_LEFT_BIT - this buffer always exists |
| 272 |
* DD_BACK_LEFT_BIT - when double buffering |
| 273 |
* DD_FRONT_RIGHT_BIT - when using stereo |
| 274 |
* DD_BACK_RIGHT_BIT - when using stereo and double buffering |
| 275 |
* DD_AUXn_BIT - if aux buffers are implemented |
| 276 |
*/ |
| 277 |
#endif |
| 278 |
|
| 279 |
/*** |
| 280 |
*** Functions for synchronizing access to the framebuffer: |
| 281 |
***/ |
| 282 |
|
| 283 |
void (*SpanRenderStart)(GLcontext *ctx); |
| 284 |
void (*SpanRenderFinish)(GLcontext *ctx); |
| 285 |
/* OPTIONAL. |
| 286 |
* |
| 287 |
* Called before and after all rendering operations, including DrawPixels, |
| 288 |
* ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands. |
| 289 |
* These are a suitable place for grabbing/releasing hardware locks. |
| 290 |
* |
| 291 |
* NOTE: The swrast triangle/line/point routines *DO NOT* call |
| 292 |
* these functions. Locking in that case must be organized by the |
| 293 |
* driver by other mechanisms. |
| 294 |
*/ |
| 295 |
}; |
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
#endif |