| 1 | /* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Mesa 3-D graphics library
|
|---|
| 5 | * Version: 3.3
|
|---|
| 6 | *
|
|---|
| 7 | * Copyright (C) 1999 Brian Paul All Rights Reserved.
|
|---|
| 8 | *
|
|---|
| 9 | * Permission is hereby granted, free of charge, to any person obtaining a
|
|---|
| 10 | * copy of this software and associated documentation files (the "Software"),
|
|---|
| 11 | * to deal in the Software without restriction, including without limitation
|
|---|
| 12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|---|
| 13 | * and/or sell copies of the Software, and to permit persons to whom the
|
|---|
| 14 | * Software is furnished to do so, subject to the following conditions:
|
|---|
| 15 | *
|
|---|
| 16 | * The above copyright notice and this permission notice shall be included
|
|---|
| 17 | * in all copies or substantial portions of the Software.
|
|---|
| 18 | *
|
|---|
| 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|---|
| 20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|---|
| 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|---|
| 22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|---|
| 23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|---|
| 24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|---|
| 25 | *
|
|---|
| 26 | *
|
|---|
| 27 | * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
|
|---|
| 28 | * terms stated above.
|
|---|
| 29 | *
|
|---|
| 30 | * Thank you for your contribution, David!
|
|---|
| 31 | *
|
|---|
| 32 | * Please make note of the above copyright/license statement. If you
|
|---|
| 33 | * contributed code or bug fixes to this code under the previous (GNU
|
|---|
| 34 | * Library) license and object to the new license, your code will be
|
|---|
| 35 | * removed at your request. Please see the Mesa docs/COPYRIGHT file
|
|---|
| 36 | * for more information.
|
|---|
| 37 | *
|
|---|
| 38 | * Additional Mesa/3Dfx driver developers:
|
|---|
| 39 | * Daryll Strauss <daryll@precisioninsight.com>
|
|---|
| 40 | * Keith Whitwell <keith@precisioninsight.com>
|
|---|
| 41 | *
|
|---|
| 42 | * See fxapi.h for more revision/author details.
|
|---|
| 43 | */
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 | static void TAG(cva_render_points)( struct vertex_buffer *cvaVB,
|
|---|
| 47 | struct vertex_buffer *VB,
|
|---|
| 48 | const struct gl_prim_state *state,
|
|---|
| 49 | GLuint start,
|
|---|
| 50 | GLuint count )
|
|---|
| 51 | {
|
|---|
| 52 | GLcontext *ctx = VB->ctx;
|
|---|
| 53 | fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
|
|---|
| 54 | fxVertex *gWin = FX_DRIVER_DATA(cvaVB)->verts;
|
|---|
| 55 | const GLuint *elt = VB->EltPtr->data;
|
|---|
| 56 | GLuint i;
|
|---|
| 57 |
|
|---|
| 58 | VARS;
|
|---|
| 59 | INIT;
|
|---|
| 60 | (void) fxMesa;
|
|---|
| 61 |
|
|---|
| 62 | if (cvaVB->ClipOrMask) {
|
|---|
| 63 | const GLubyte *clip = cvaVB->ClipMask;
|
|---|
| 64 | for (i = start ; i < count ; i++ INCR) {
|
|---|
| 65 | GLuint e = elt[i];
|
|---|
| 66 | if (!clip[e]) {
|
|---|
| 67 | GLfloat *v = gWin[e].f; (void) v;
|
|---|
| 68 | if (!DIRECT) { MERGE_VB; }
|
|---|
| 69 | MERGE_RAST;
|
|---|
| 70 | DRAW_POINT;
|
|---|
| 71 | }
|
|---|
| 72 | }
|
|---|
| 73 | } else {
|
|---|
| 74 | for (i = start ; i < count ; i++ INCR) {
|
|---|
| 75 | GLuint e = elt[i];
|
|---|
| 76 | GLfloat *v = gWin[e].f; (void) v;
|
|---|
| 77 | if (!DIRECT) { MERGE_VB; }
|
|---|
| 78 | MERGE_RAST;
|
|---|
| 79 | DRAW_POINT;
|
|---|
| 80 | }
|
|---|
| 81 | }
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 | static void TAG(cva_render_lines)( struct vertex_buffer *cvaVB,
|
|---|
| 85 | struct vertex_buffer *VB,
|
|---|
| 86 | const struct gl_prim_state *state,
|
|---|
| 87 | GLuint start,
|
|---|
| 88 | GLuint count )
|
|---|
| 89 | {
|
|---|
| 90 | GLcontext *ctx = VB->ctx;
|
|---|
| 91 | fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
|
|---|
| 92 | fxVertex *gWin = FX_DRIVER_DATA(cvaVB)->verts;
|
|---|
| 93 | const GLuint *elt = VB->EltPtr->data;
|
|---|
| 94 | GLuint i;
|
|---|
| 95 |
|
|---|
| 96 | VARS;
|
|---|
| 97 | INIT;
|
|---|
| 98 | (void) fxMesa;
|
|---|
| 99 |
|
|---|
| 100 | if (cvaVB->ClipOrMask) {
|
|---|
| 101 | const GLubyte *clip = cvaVB->ClipMask;
|
|---|
| 102 | GLuint prev = 0;
|
|---|
| 103 | GLfloat *prev_v = 0;
|
|---|
| 104 |
|
|---|
| 105 | (void) ctx;
|
|---|
| 106 |
|
|---|
| 107 | for (i = start ; i < count ; i++ INCR) {
|
|---|
| 108 | GLuint e = elt[i];
|
|---|
| 109 | GLfloat *v = gWin[e].f;
|
|---|
| 110 |
|
|---|
| 111 | MERGE_VB;
|
|---|
| 112 |
|
|---|
| 113 | if (!clip[e])
|
|---|
| 114 | MERGE_RAST;
|
|---|
| 115 |
|
|---|
| 116 | if (state->draw) {
|
|---|
| 117 | if (clip[e] | clip[prev])
|
|---|
| 118 | CLIP_LINE;
|
|---|
| 119 | else
|
|---|
| 120 | DRAW_LINE;
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | prev = e;
|
|---|
| 124 | prev_v = v;
|
|---|
| 125 | state = state->next;
|
|---|
| 126 | }
|
|---|
| 127 | if (state->finish_loop) {
|
|---|
| 128 | GLuint e = elt[start];
|
|---|
| 129 | GLfloat *v = gWin[e].f; (void) v;
|
|---|
| 130 |
|
|---|
| 131 | if (!DIRECT) { MERGE_VB; }
|
|---|
| 132 | MERGE_RAST;
|
|---|
| 133 |
|
|---|
| 134 | if (clip[e] | clip[prev])
|
|---|
| 135 | CLIP_LINE;
|
|---|
| 136 | else
|
|---|
| 137 | DRAW_LINE;
|
|---|
| 138 | }
|
|---|
| 139 | } else {
|
|---|
| 140 | GLuint prev = 0;
|
|---|
| 141 | GLfloat *prev_v = 0;
|
|---|
| 142 |
|
|---|
| 143 | for (i = start ; i < count ; i++ INCR) {
|
|---|
| 144 | GLuint e = elt[i];
|
|---|
| 145 | GLfloat *v = gWin[e].f;
|
|---|
| 146 |
|
|---|
| 147 | if (!DIRECT) { MERGE_VB; }
|
|---|
| 148 | MERGE_RAST;
|
|---|
| 149 | if (state->draw) DRAW_LINE;
|
|---|
| 150 | prev = e;
|
|---|
| 151 | prev_v = v;
|
|---|
| 152 | state = state->next;
|
|---|
| 153 | }
|
|---|
| 154 | if (state->finish_loop) {
|
|---|
| 155 | GLuint e = elt[start];
|
|---|
| 156 | GLfloat *v = gWin[e].f; (void) v;
|
|---|
| 157 |
|
|---|
| 158 | if (!DIRECT) { MERGE_VB; }
|
|---|
| 159 | MERGE_RAST;
|
|---|
| 160 | DRAW_LINE;
|
|---|
| 161 | }
|
|---|
| 162 | }
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 | static void TAG(cva_render_tris)( struct vertex_buffer *cvaVB,
|
|---|
| 167 | struct vertex_buffer *VB,
|
|---|
| 168 | const struct gl_prim_state *state,
|
|---|
| 169 | GLuint start,
|
|---|
| 170 | GLuint count )
|
|---|
| 171 | {
|
|---|
| 172 | GLcontext *ctx = VB->ctx;
|
|---|
| 173 | fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
|
|---|
| 174 | fxVertex *gWin = FX_DRIVER_DATA(cvaVB)->verts;
|
|---|
| 175 | const GLuint *elt = VB->EltPtr->data;
|
|---|
| 176 | GLuint i;
|
|---|
| 177 | VARS;
|
|---|
| 178 | INIT;
|
|---|
| 179 | (void) fxMesa;
|
|---|
| 180 |
|
|---|
| 181 | if (cvaVB->ClipOrMask) {
|
|---|
| 182 | GLuint vlist[VB_MAX_CLIPPED_VERTS];
|
|---|
| 183 | GLuint l[3];
|
|---|
| 184 | const GLubyte *clip = cvaVB->ClipMask;
|
|---|
| 185 |
|
|---|
| 186 | (void) vlist;
|
|---|
| 187 |
|
|---|
| 188 | for (i = start ; i < count ; i++ INCR) {
|
|---|
| 189 | GLuint e = l[2] = elt[i];
|
|---|
| 190 | GLfloat *v = gWin[e].f; (void) v;
|
|---|
| 191 |
|
|---|
| 192 | MERGE_VB; /* needed for clip-interp */
|
|---|
| 193 |
|
|---|
| 194 | if (!clip[e]) {
|
|---|
| 195 | MERGE_RAST;
|
|---|
| 196 | }
|
|---|
| 197 |
|
|---|
| 198 | if (state->draw)
|
|---|
| 199 | CLIP_OR_DRAW_TRI;
|
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 | l[0] = l[state->v0];
|
|---|
| 203 | l[1] = l[state->v1];
|
|---|
| 204 | state = state->next;
|
|---|
| 205 | }
|
|---|
| 206 | } else if (DIRECT) {
|
|---|
| 207 | GrVertex *vl[3];
|
|---|
| 208 | for (i = start ; i < count ; i++ INCR) {
|
|---|
| 209 | GLuint e = elt[i];
|
|---|
| 210 | GLfloat *v = gWin[elt[i]].f;
|
|---|
| 211 |
|
|---|
| 212 | vl[2] = (GrVertex *)v;
|
|---|
| 213 |
|
|---|
| 214 | (void) v;
|
|---|
| 215 | (void) e;
|
|---|
| 216 |
|
|---|
| 217 | MERGE_RAST;
|
|---|
| 218 |
|
|---|
| 219 | if (state->draw)
|
|---|
| 220 | DRAW_TRI2;
|
|---|
| 221 |
|
|---|
| 222 | vl[0] = vl[state->v0];
|
|---|
| 223 | vl[1] = vl[state->v1];
|
|---|
| 224 | state = state->next;
|
|---|
| 225 | }
|
|---|
| 226 | } else {
|
|---|
| 227 | GLuint l[3];
|
|---|
| 228 | for (i = start ; i < count ; i++ INCR) {
|
|---|
| 229 | GLuint e = l[2] = elt[i];
|
|---|
| 230 | GLfloat *v = gWin[e].f; (void) v;
|
|---|
| 231 |
|
|---|
| 232 | MERGE_VB; /* needed for ctx->trianglefunc? */
|
|---|
| 233 | MERGE_RAST;
|
|---|
| 234 |
|
|---|
| 235 | if (state->draw)
|
|---|
| 236 | DRAW_TRI;
|
|---|
| 237 |
|
|---|
| 238 | l[0] = l[state->v0];
|
|---|
| 239 | l[1] = l[state->v1];
|
|---|
| 240 | state = state->next;
|
|---|
| 241 | }
|
|---|
| 242 | }
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 | static void TAG(init_cva)( void )
|
|---|
| 247 | {
|
|---|
| 248 | merge_and_render_tab[DIRECT][IDX][PRIM_POINTS] = TAG(cva_render_points);
|
|---|
| 249 | merge_and_render_tab[DIRECT][IDX][PRIM_LINES] = TAG(cva_render_lines);
|
|---|
| 250 | merge_and_render_tab[DIRECT][IDX][PRIM_TRIS] = TAG(cva_render_tris);
|
|---|
| 251 | merge_and_render_tab[DIRECT][IDX][PRIM_CULLED] = fxCvaRenderNoop;
|
|---|
| 252 | }
|
|---|
| 253 |
|
|---|
| 254 |
|
|---|
| 255 | #undef IDX
|
|---|
| 256 | #undef MERGE_RAST
|
|---|
| 257 | #undef MERGE_VB
|
|---|
| 258 | #undef VARS
|
|---|
| 259 | #undef INIT
|
|---|
| 260 | #undef INCR
|
|---|
| 261 | #undef TAG
|
|---|
| 262 |
|
|---|