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