Changeset 3598 for trunk/src/opengl/mesa/3dfx/fxclip.c
- Timestamp:
- May 23, 2000, 10:41:28 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/opengl/mesa/3dfx/fxclip.c
r2938 r3598 3 3 /* 4 4 * Mesa 3-D graphics library 5 * Version: 3. 15 * Version: 3.3 6 6 * 7 7 * Copyright (C) 1999 Brian Paul All Rights Reserved. … … 68 68 69 69 70 #define CLIP(sgn,v) 71 do { 72 GLuint out = in ^ 1; 73 GLfloat **indata = inlist[in]; 74 GrVertex **inverts = vertlist[in]; 75 GrVertex **outverts = vertlist[out]; 76 GLfloat **outdata = inlist[in = out]; 77 GLfloat *J = indata[n-1]; 78 GLfloat dpJ = (sgn J[v]) + J[3]; 79 GLuint nr = n; 80 81 for (i = n = 0 ; i < nr ; i++) { 82 GLfloat *I = indata[i]; 83 GLfloat dpI = (sgn I[v]) + I[3]; 84 85 if (DIFFERENT_SIGNS(dpI, dpJ)) { 86 GLuint j;\70 #define CLIP(sgn,v) \ 71 do { \ 72 GLuint out = in ^ 1; \ 73 GLfloat **indata = inlist[in]; \ 74 GrVertex **inverts = vertlist[in]; \ 75 GrVertex **outverts = vertlist[out]; \ 76 GLfloat **outdata = inlist[in = out]; \ 77 GLfloat *J = indata[n-1]; \ 78 GLfloat dpJ = (sgn J[v]) + J[3]; \ 79 GLuint nr = n; \ 80 \ 81 for (i = n = 0 ; i < nr ; i++) { \ 82 GLfloat *I = indata[i]; \ 83 GLfloat dpI = (sgn I[v]) + I[3]; \ 84 \ 85 if (DIFFERENT_SIGNS(dpI, dpJ)) { \ 86 GLuint j; \ 87 87 GLfloat t = dpI / (dpI - dpJ); \ 88 outverts[n] = 0;\89 outdata[n++] = store;\90 store[3] = LINTERP(t, I[3], J[3]);\91 store[v] = - sgn store[3];\92 if (v != 0) store[0] = LINTERP(t, I[0], J[0]);\93 if (v != 1) store[1] = LINTERP(t, I[1], J[1]);\94 if (v != 2) store[2] = LINTERP(t, I[2], J[2]);\95 store += 4;\96 for (j = 4 ; j < sz ; j+=4,store+=4) {\97 store[0] = LINTERP(t, I[j], J[j] );\98 store[1] = LINTERP(t, I[j+1], J[j+1] );\99 store[2] = LINTERP(t, I[j+2], J[j+2] );\100 store[3] = LINTERP(t, I[j+3], J[j+3] );\101 }\102 } 103 104 if (!NEGATIVE(dpI)) { 105 outverts[n] = inverts[i];\106 outdata[n++] = I;\107 } 108 109 110 J = I; 111 dpJ = dpI; 112 } 113 114 if (n < 3) return 0; 88 outverts[n] = 0; \ 89 outdata[n++] = store; \ 90 store[3] = LINTERP(t, I[3], J[3]); \ 91 store[v] = - sgn store[3]; \ 92 if (v != 0) store[0] = LINTERP(t, I[0], J[0]); \ 93 if (v != 1) store[1] = LINTERP(t, I[1], J[1]); \ 94 if (v != 2) store[2] = LINTERP(t, I[2], J[2]); \ 95 store += 4; \ 96 for (j = 4 ; j < sz ; j+=4,store+=4) { \ 97 store[0] = LINTERP(t, I[j], J[j] ); \ 98 store[1] = LINTERP(t, I[j+1], J[j+1] ); \ 99 store[2] = LINTERP(t, I[j+2], J[j+2] ); \ 100 store[3] = LINTERP(t, I[j+3], J[j+3] ); \ 101 } \ 102 } \ 103 \ 104 if (!NEGATIVE(dpI)) { \ 105 outverts[n] = inverts[i]; \ 106 outdata[n++] = I; \ 107 } \ 108 \ 109 \ 110 J = I; \ 111 dpJ = dpI; \ 112 } \ 113 \ 114 if (n < 3) return 0; \ 115 115 } while (0) 116 116 … … 121 121 * code only really differs in the way it sets store[v] to +- w. 122 122 */ 123 #define UCLIP(a,b,c,d) 124 do { 125 GLuint out = in ^ 1; 126 GLfloat **indata = inlist[in]; 127 GrVertex **inverts = vertlist[in]; 128 GrVertex **outverts = vertlist[out]; 129 GLfloat **outdata = inlist[in = out]; 130 GLfloat *J = indata[n-1]; 131 GLfloat dpJ = DOT4V(J,a,b,c,d); 132 GLuint nr = n; 133 134 for (i = n = 0 ; i < nr ; i++) { 135 GLfloat *I = indata[i]; 136 GLfloat dpI = DOT4V(I,a,b,c,d); 137 138 if (DIFFERENT_SIGNS(dpI, dpJ)) { 139 GLuint j;\140 GLfloat t = dpI / (dpI - dpJ);\141 outverts[n] = 0;\142 outdata[n++] = store;\143 for (j = 0 ; j < sz ; j+=4,store+=4) {\144 store[0] = LINTERP(t, I[j], J[j] );\145 store[1] = LINTERP(t, I[j+1], J[j+1] );\146 store[2] = LINTERP(t, I[j+2], J[j+2] );\147 store[3] = LINTERP(t, I[j+3], J[j+3] );\148 }\149 } 150 151 if (!NEGATIVE(dpI)) { 152 outverts[n] = inverts[i];\153 outdata[n++] = I;\154 } 155 156 157 J = I; 158 dpJ = dpI; 159 } 160 161 if (n < 3) return 0; 123 #define UCLIP(a,b,c,d) \ 124 do { \ 125 GLuint out = in ^ 1; \ 126 GLfloat **indata = inlist[in]; \ 127 GrVertex **inverts = vertlist[in]; \ 128 GrVertex **outverts = vertlist[out]; \ 129 GLfloat **outdata = inlist[in = out]; \ 130 GLfloat *J = indata[n-1]; \ 131 GLfloat dpJ = DOT4V(J,a,b,c,d); \ 132 GLuint nr = n; \ 133 \ 134 for (i = n = 0 ; i < nr ; i++) { \ 135 GLfloat *I = indata[i]; \ 136 GLfloat dpI = DOT4V(I,a,b,c,d); \ 137 \ 138 if (DIFFERENT_SIGNS(dpI, dpJ)) { \ 139 GLuint j; \ 140 GLfloat t = dpI / (dpI - dpJ); \ 141 outverts[n] = 0; \ 142 outdata[n++] = store; \ 143 for (j = 0 ; j < sz ; j+=4,store+=4) { \ 144 store[0] = LINTERP(t, I[j], J[j] ); \ 145 store[1] = LINTERP(t, I[j+1], J[j+1] ); \ 146 store[2] = LINTERP(t, I[j+2], J[j+2] ); \ 147 store[3] = LINTERP(t, I[j+3], J[j+3] ); \ 148 } \ 149 } \ 150 \ 151 if (!NEGATIVE(dpI)) { \ 152 outverts[n] = inverts[i]; \ 153 outdata[n++] = I; \ 154 } \ 155 \ 156 \ 157 J = I; \ 158 dpJ = dpI; \ 159 } \ 160 \ 161 if (n < 3) return 0; \ 162 162 } while (0) 163 163 … … 172 172 */ 173 173 static INLINE GLuint fx_clip_triangle( GLcontext *ctx, 174 175 176 177 174 GLfloat *inoutlist[], 175 GrVertex **verts, 176 GLuint sz, 177 GLuint mask ) 178 178 { 179 179 GLuint n = 3; … … 195 195 { 196 196 if (mask & CLIP_RIGHT_BIT) 197 197 CLIP(-,0); 198 198 199 199 if (mask & CLIP_LEFT_BIT) 200 200 CLIP(+,0); 201 201 202 202 if (mask & CLIP_TOP_BIT) 203 203 CLIP(-,1); 204 204 205 205 if (mask & CLIP_BOTTOM_BIT) 206 206 CLIP(+,1); 207 207 208 208 if (mask & CLIP_FAR_BIT) 209 209 CLIP(-,2); 210 210 211 211 if (mask & CLIP_NEAR_BIT) 212 212 CLIP(+,2); 213 213 } 214 214 … … 217 217 GLfloat (*plane)[4] = &ctx->Transform.ClipUserPlane[0]; 218 218 for (bit = 0x100 ; bit < mask ; plane++, bit *= 2) { 219 220 221 222 223 224 225 219 if (mask & bit) { 220 GLfloat a = plane[0][0]; 221 GLfloat b = plane[0][1]; 222 GLfloat c = plane[0][2]; 223 GLfloat d = plane[0][3]; 224 UCLIP(a,b,c,d); 225 } 226 226 } 227 227 } … … 229 229 if (inlist[in] != inoutlist) 230 230 for (i = 0 ; i < n ; i++) { 231 232 231 inoutlist[i] = inlist[in][i]; 232 verts[i] = verts2[i]; 233 233 } 234 234 … … 239 239 240 240 static INLINE GLuint fx_view_clip_triangle( GLcontext *ctx, 241 242 243 244 241 GLfloat *inoutlist[], 242 GrVertex **verts, 243 GLuint sz, 244 GLubyte mask ) 245 245 { 246 246 GLuint n = 3; … … 279 279 if (inlist[in] != inoutlist) 280 280 for (i = 0 ; i < n ; i++) { 281 282 281 inoutlist[i] = inlist[in][i]; 282 verts[i] = verts2[i]; 283 283 } 284 284 … … 290 290 #undef CLIP 291 291 292 #define CLIP(x,y,z,w) 293 do { 294 GLfloat dpI = DOT4V(I,x,y,z,w); 295 GLfloat dpJ = DOT4V(J,x,y,z,w); 296 297 if (DIFFERENT_SIGNS(dpI, dpJ)) { 298 GLuint j; 299 GLfloat t = dpI / (dpI - dpJ); 300 GLfloat *tmp = store; 301 302 for (j = 0 ; j < sz ; j+=2) { 303 *store++ = LINTERP(t, I[j], J[j] );\304 *store++ = LINTERP(t, I[j+1], J[j+1] );\305 } 306 307 if (NEGATIVE(dpI)) 308 I = tmp;\309 else 310 J = tmp;\311 312 } 313 else if (NEGATIVE(dpI)) 314 return 0; 315 292 #define CLIP(x,y,z,w) \ 293 do { \ 294 GLfloat dpI = DOT4V(I,x,y,z,w); \ 295 GLfloat dpJ = DOT4V(J,x,y,z,w); \ 296 \ 297 if (DIFFERENT_SIGNS(dpI, dpJ)) { \ 298 GLuint j; \ 299 GLfloat t = dpI / (dpI - dpJ); \ 300 GLfloat *tmp = store; \ 301 \ 302 for (j = 0 ; j < sz ; j+=2) { \ 303 *store++ = LINTERP(t, I[j], J[j] ); \ 304 *store++ = LINTERP(t, I[j+1], J[j+1] ); \ 305 } \ 306 \ 307 if (NEGATIVE(dpI)) \ 308 I = tmp; \ 309 else \ 310 J = tmp; \ 311 \ 312 } \ 313 else if (NEGATIVE(dpI)) \ 314 return 0; \ 315 \ 316 316 } while (0) 317 317 318 318 319 319 static GLuint fx_clip_line( GLcontext *ctx, 320 321 322 320 GLfloat *inoutlist[], 321 GLuint sz, 322 GLubyte clipor ) 323 323 { 324 324 GLfloat *I = inoutlist[0]; … … 329 329 { 330 330 if (clipor & CLIP_LEFT_BIT) 331 332 331 CLIP(1,0,0,1); 332 333 333 if (clipor & CLIP_RIGHT_BIT) 334 335 334 CLIP(-1,0,0,1); 335 336 336 if (clipor & CLIP_TOP_BIT) 337 338 337 CLIP(0,-1,0,1); 338 339 339 if (clipor & CLIP_BOTTOM_BIT) 340 341 340 CLIP(0,1,0,1); 341 342 342 if (clipor & CLIP_FAR_BIT) 343 344 343 CLIP(0,0,-1,1); 344 345 345 if (clipor & CLIP_NEAR_BIT) 346 346 CLIP(0,0,1,1); 347 347 } 348 348 … … 350 350 GLuint i; 351 351 for (i = 0 ; i < MAX_CLIP_PLANES ; i++) { 352 353 354 355 356 357 358 352 if (ctx->Transform.ClipEnabled[i]) { 353 GLfloat a = ctx->Transform.ClipUserPlane[i][0]; 354 GLfloat b = ctx->Transform.ClipUserPlane[i][1]; 355 GLfloat c = ctx->Transform.ClipUserPlane[i][2]; 356 GLfloat d = ctx->Transform.ClipUserPlane[i][3]; 357 CLIP(a,b,c,d); 358 } 359 359 } 360 360 } … … 373 373 #if defined(FX_V2) 374 374 375 #define VARS_XYZW 376 GLfloat vsx = mat[MAT_SX]; 377 GLfloat vsy = mat[MAT_SY]; 378 GLfloat vsz = mat[MAT_SZ]; 379 GLfloat vtx = mat[MAT_TX]; 380 GLfloat vty = mat[MAT_TY]; 381 GLfloat vtz = mat[MAT_TZ]; 382 383 #define DO_SETUP_XYZW 384 { 385 GLfloat oow = 1.0 / data[3]; 386 v->x = data[0]*oow*vsx + vtx; 387 v->y = data[1]*oow*vsy + vty; 388 v->ooz = data[2]*oow*vsz + vtz; 389 v->oow = oow; 375 #define VARS_XYZW \ 376 GLfloat vsx = mat[MAT_SX]; \ 377 GLfloat vsy = mat[MAT_SY]; \ 378 GLfloat vsz = mat[MAT_SZ]; \ 379 GLfloat vtx = mat[MAT_TX]; \ 380 GLfloat vty = mat[MAT_TY]; \ 381 GLfloat vtz = mat[MAT_TZ]; 382 383 #define DO_SETUP_XYZW \ 384 { \ 385 GLfloat oow = 1.0 / data[3]; \ 386 v->x = data[0]*oow*vsx + vtx; \ 387 v->y = data[1]*oow*vsy + vty; \ 388 v->ooz = data[2]*oow*vsz + vtz; \ 389 v->oow = oow; \ 390 390 } 391 391 #else … … 393 393 #if defined(DRIVERTS) 394 394 395 #define VARS_XYZW 396 GLfloat vsx = mat[MAT_SX]; 397 GLfloat vsy = mat[MAT_SY]; 398 GLfloat vsz = mat[MAT_SZ]; 399 GLfloat vtx = mat[MAT_TX]+fxMesa->x_offset; 400 GLfloat vty = mat[MAT_TY]+fxMesa->y_delta; 395 #define VARS_XYZW \ 396 GLfloat vsx = mat[MAT_SX]; \ 397 GLfloat vsy = mat[MAT_SY]; \ 398 GLfloat vsz = mat[MAT_SZ]; \ 399 GLfloat vtx = mat[MAT_TX]+fxMesa->x_offset; \ 400 GLfloat vty = mat[MAT_TY]+fxMesa->y_delta; \ 401 401 GLfloat vtz = mat[MAT_TZ]; 402 402 403 #define DO_SETUP_XYZW 404 { 405 GLfloat oow = 1.0 / data[3]; 406 v->x = data[0]*oow*vsx + vtx; 407 v->y = data[1]*oow*vsy + vty; 408 v->ooz = data[2]*oow*vsz + vtz; 409 v->oow = oow; 403 #define DO_SETUP_XYZW \ 404 { \ 405 GLfloat oow = 1.0 / data[3]; \ 406 v->x = data[0]*oow*vsx + vtx; \ 407 v->y = data[1]*oow*vsy + vty; \ 408 v->ooz = data[2]*oow*vsz + vtz; \ 409 v->oow = oow; \ 410 410 } 411 411 412 412 #else 413 #define VARS_XYZW 414 GLfloat vsx = mat[MAT_SX]; 415 GLfloat vsy = mat[MAT_SY]; 416 GLfloat vsz = mat[MAT_SZ]; 417 const GLfloat snapper = (3L << 18); 418 GLfloat snap_tx = mat[MAT_TX] + snapper; 419 GLfloat snap_ty = mat[MAT_TY] + snapper; 413 #define VARS_XYZW \ 414 GLfloat vsx = mat[MAT_SX]; \ 415 GLfloat vsy = mat[MAT_SY]; \ 416 GLfloat vsz = mat[MAT_SZ]; \ 417 const GLfloat snapper = (3L << 18); \ 418 GLfloat snap_tx = mat[MAT_TX] + snapper; \ 419 GLfloat snap_ty = mat[MAT_TY] + snapper; \ 420 420 GLfloat vtz = mat[MAT_TZ]; 421 421 422 #define DO_SETUP_XYZW 423 { 424 GLfloat oow = 1.0 / data[3]; 425 v->x = data[0]*oow*vsx + snap_tx; 426 v->y = data[1]*oow*vsy + snap_ty; 427 v->ooz = data[2]*oow*vsz + vtz; 428 v->oow = oow; 429 v->x -= snapper; 430 v->y -= snapper; 422 #define DO_SETUP_XYZW \ 423 { \ 424 GLfloat oow = 1.0 / data[3]; \ 425 v->x = data[0]*oow*vsx + snap_tx; \ 426 v->y = data[1]*oow*vsy + snap_ty; \ 427 v->ooz = data[2]*oow*vsz + vtz; \ 428 v->oow = oow; \ 429 v->x -= snapper; \ 430 v->y -= snapper; \ 431 431 } 432 432 … … 434 434 #endif 435 435 436 #define COPY_XYZW_STRIDE 437 { GLfloat *clip = VEC_ELT(VB->ClipPtr, GLfloat, e); 436 #define COPY_XYZW_STRIDE \ 437 { GLfloat *clip = VEC_ELT(VB->ClipPtr, GLfloat, e); \ 438 438 COPY_4FV(out, clip); } 439 439 440 440 #define VARS_RGBA 441 441 442 #define COPY_RGBA_STRIDE 443 { GLubyte *color = VEC_ELT(VB->ColorPtr, GLubyte, e); 442 #define COPY_RGBA_STRIDE \ 443 { GLubyte *color = VEC_ELT(VB->ColorPtr, GLubyte, e); \ 444 444 UBYTE_RGBA_TO_FLOAT_255_RGBA((out+4), color); } 445 445 446 446 #if FX_USE_PARGB 447 #define DO_SETUP_RGBA 448 GET_PARGB(v) = (((int)data[4+3]) << 24) | 449 (((int)data[4+0]) << 16) |\450 (((int)data[4+1]) << 8) |\451 (((int)data[4+2]) << 0);447 #define DO_SETUP_RGBA \ 448 GET_PARGB(v) = (((int)data[4+3]) << 24) | \ 449 (((int)data[4+0]) << 16) | \ 450 (((int)data[4+1]) << 8) | \ 451 (((int)data[4+2]) << 0); 452 452 #else 453 #define DO_SETUP_RGBA 454 v->r = data[4+0]; 455 v->g = data[4+1]; 456 v->b = data[4+2]; 453 #define DO_SETUP_RGBA \ 454 v->r = data[4+0]; \ 455 v->g = data[4+1]; \ 456 v->b = data[4+2]; \ 457 457 v->a = data[4+3]; 458 458 #endif /* FX_USE_PARGB */ 459 459 460 #define VARS_TMU0 461 struct gl_texture_unit *t0 = &ctx->Texture.Unit[tmu0_source]; 462 GLfloat sScale0 = fxTMGetTexInfo(t0->Current)->sScale; 463 GLfloat tScale0 = fxTMGetTexInfo(t0->Current)->tScale; 464 465 466 #define COPY_TMU0_STRIDE(offset) 467 { GLfloat *tc0 = VEC_ELT(tc0_vec, GLfloat, e); 460 #define VARS_TMU0 \ 461 struct gl_texture_unit *t0 = &ctx->Texture.Unit[tmu0_source]; \ 462 GLfloat sScale0 = fxTMGetTexInfo(t0->Current)->sScale; \ 463 GLfloat tScale0 = fxTMGetTexInfo(t0->Current)->tScale; \ 464 465 466 #define COPY_TMU0_STRIDE(offset) \ 467 { GLfloat *tc0 = VEC_ELT(tc0_vec, GLfloat, e); \ 468 468 COPY_2V((out+offset), tc0); } 469 469 470 470 471 #define DO_SETUP_TMU0(offset) 472 v->tmuvtx[0].sow = data[offset+0]*sScale0*v->oow; 471 #define DO_SETUP_TMU0(offset) \ 472 v->tmuvtx[0].sow = data[offset+0]*sScale0*v->oow; \ 473 473 v->tmuvtx[0].tow = data[offset+1]*tScale0*v->oow; 474 474 475 #define VARS_TMU1 476 struct gl_texture_unit *t1 = &ctx->Texture.Unit[tmu1_source]; 477 GLfloat sScale1 = fxTMGetTexInfo(t1->Current)->sScale; 475 #define VARS_TMU1 \ 476 struct gl_texture_unit *t1 = &ctx->Texture.Unit[tmu1_source]; \ 477 GLfloat sScale1 = fxTMGetTexInfo(t1->Current)->sScale; \ 478 478 GLfloat tScale1 = fxTMGetTexInfo(t1->Current)->tScale; 479 479 480 #define COPY_TMU1_STRIDE(offset) 481 { GLfloat *tc1 = VEC_ELT(tc1_vec, GLfloat, e); 480 #define COPY_TMU1_STRIDE(offset) \ 481 { GLfloat *tc1 = VEC_ELT(tc1_vec, GLfloat, e); \ 482 482 COPY_2V((out+offset), tc1); } 483 483 484 484 485 #define DO_SETUP_TMU1(offset) 486 v->tmuvtx[1].sow = data[offset+0]*sScale1*v->oow; 485 #define DO_SETUP_TMU1(offset) \ 486 v->tmuvtx[1].sow = data[offset+0]*sScale1*v->oow; \ 487 487 v->tmuvtx[1].tow = data[offset+1]*tScale1*v->oow; 488 488
Note:
See TracChangeset
for help on using the changeset viewer.