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