intel_tris.c revision bcbfda71b03303d3f008a6f3cf8cb7d9667bf8d2
1/************************************************************************** 2 * 3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. 4 * All Rights Reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sub license, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * 26 **************************************************************************/ 27 28/** @file intel_tris.c 29 * 30 * This file contains functions for managing the vertex buffer and emitting 31 * primitives into it. 32 */ 33 34#include "main/glheader.h" 35#include "main/context.h" 36#include "main/macros.h" 37#include "main/enums.h" 38#include "main/texobj.h" 39#include "main/state.h" 40#include "main/dd.h" 41 42#include "swrast/swrast.h" 43#include "swrast_setup/swrast_setup.h" 44#include "tnl/t_context.h" 45#include "tnl/t_pipeline.h" 46#include "tnl/t_vertex.h" 47 48#include "intel_screen.h" 49#include "intel_context.h" 50#include "intel_tris.h" 51#include "intel_batchbuffer.h" 52#include "intel_buffers.h" 53#include "intel_reg.h" 54#include "intel_span.h" 55#include "intel_tex.h" 56#include "intel_chipset.h" 57#include "i830_context.h" 58#include "i830_reg.h" 59 60static void intelRenderPrimitive(GLcontext * ctx, GLenum prim); 61static void intelRasterPrimitive(GLcontext * ctx, GLenum rprim, 62 GLuint hwprim); 63 64static void 65intel_flush_inline_primitive(struct intel_context *intel) 66{ 67 GLuint used = intel->batch->ptr - intel->prim.start_ptr; 68 69 assert(intel->prim.primitive != ~0); 70 71/* _mesa_printf("/\n"); */ 72 73 if (used < 8) 74 goto do_discard; 75 76 *(int *) intel->prim.start_ptr = (_3DPRIMITIVE | 77 intel->prim.primitive | (used / 4 - 2)); 78 79 goto finished; 80 81 do_discard: 82 intel->batch->ptr -= used; 83 84 finished: 85 intel->prim.primitive = ~0; 86 intel->prim.start_ptr = 0; 87 intel->prim.flush = 0; 88} 89 90static void intel_start_inline(struct intel_context *intel, uint32_t prim) 91{ 92 uint32_t batch_flags = LOOP_CLIPRECTS; 93 BATCH_LOCALS; 94 95 intel->vtbl.emit_state(intel); 96 97 intel->no_batch_wrap = GL_TRUE; 98 99 /*_mesa_printf("%s *", __progname);*/ 100 101 /* Emit a slot which will be filled with the inline primitive 102 * command later. 103 */ 104 BEGIN_BATCH(2, batch_flags); 105 OUT_BATCH(0); 106 107 assert((intel->batch->dirty_state & (1<<1)) == 0); 108 109 intel->prim.start_ptr = intel->batch->ptr; 110 intel->prim.primitive = prim; 111 intel->prim.flush = intel_flush_inline_primitive; 112 113 OUT_BATCH(0); 114 ADVANCE_BATCH(); 115 116 intel->no_batch_wrap = GL_FALSE; 117/* _mesa_printf(">"); */ 118} 119 120static void intel_wrap_inline(struct intel_context *intel) 121{ 122 GLuint prim = intel->prim.primitive; 123 124 intel_flush_inline_primitive(intel); 125 intel_batchbuffer_flush(intel->batch); 126 intel_start_inline(intel, prim); /* ??? */ 127} 128 129static GLuint *intel_extend_inline(struct intel_context *intel, GLuint dwords) 130{ 131 GLuint sz = dwords * sizeof(GLuint); 132 GLuint *ptr; 133 134 assert(intel->prim.flush == intel_flush_inline_primitive); 135 136 if (intel_batchbuffer_space(intel->batch) < sz) 137 intel_wrap_inline(intel); 138 139/* _mesa_printf("."); */ 140 141 intel->vtbl.assert_not_dirty(intel); 142 143 ptr = (GLuint *) intel->batch->ptr; 144 intel->batch->ptr += sz; 145 146 return ptr; 147} 148 149/** Sets the primitive type for a primitive sequence, flushing as needed. */ 150void intel_set_prim(struct intel_context *intel, uint32_t prim) 151{ 152 /* if we have no VBOs */ 153 154 if (intel->intelScreen->no_vbo) { 155 intel_start_inline(intel, prim); 156 return; 157 } 158 if (prim != intel->prim.primitive) { 159 INTEL_FIREVERTICES(intel); 160 intel->prim.primitive = prim; 161 } 162} 163 164/** Returns mapped VB space for the given number of vertices */ 165uint32_t *intel_get_prim_space(struct intel_context *intel, unsigned int count) 166{ 167 uint32_t *addr; 168 169 if (intel->intelScreen->no_vbo) { 170 return intel_extend_inline(intel, count * intel->vertex_size); 171 } 172 173 /* Check for space in the existing VB */ 174 if (intel->prim.vb_bo == NULL || 175 (intel->prim.current_offset + 176 count * intel->vertex_size * 4) > INTEL_VB_SIZE || 177 (intel->prim.count + count) >= (1 << 16)) { 178 /* Flush existing prim if any */ 179 INTEL_FIREVERTICES(intel); 180 181 intel_finish_vb(intel); 182 183 /* Start a new VB */ 184 if (intel->prim.vb == NULL) 185 intel->prim.vb = malloc(INTEL_VB_SIZE); 186 intel->prim.vb_bo = dri_bo_alloc(intel->bufmgr, "vb", 187 INTEL_VB_SIZE, 4); 188 intel->prim.start_offset = 0; 189 intel->prim.current_offset = 0; 190 } 191 192 intel->prim.flush = intel_flush_prim; 193 194 addr = (uint32_t *)(intel->prim.vb + intel->prim.current_offset); 195 intel->prim.current_offset += intel->vertex_size * 4 * count; 196 intel->prim.count += count; 197 198 return addr; 199} 200 201/** Dispatches the accumulated primitive to the batchbuffer. */ 202void intel_flush_prim(struct intel_context *intel) 203{ 204 dri_bo *aper_array[2]; 205 dri_bo *vb_bo; 206 unsigned int offset, count; 207 BATCH_LOCALS; 208 209 /* Must be called after an intel_start_prim. */ 210 assert(intel->prim.primitive != ~0); 211 212 if (intel->prim.count == 0) 213 return; 214 215 /* Clear the current prims out of the context state so that a batch flush 216 * flush triggered by emit_state doesn't loop back to flush_prim again. 217 */ 218 vb_bo = intel->prim.vb_bo; 219 dri_bo_reference(vb_bo); 220 count = intel->prim.count; 221 intel->prim.count = 0; 222 offset = intel->prim.start_offset; 223 intel->prim.start_offset = intel->prim.current_offset; 224 if (!IS_9XX(intel->intelScreen->deviceID)) 225 intel->prim.start_offset = ALIGN(intel->prim.start_offset, 128); 226 intel->prim.flush = NULL; 227 228 intel->vtbl.emit_state(intel); 229 230 aper_array[0] = intel->batch->buf; 231 aper_array[1] = vb_bo; 232 if (dri_bufmgr_check_aperture_space(aper_array, 2)) { 233 intel_batchbuffer_flush(intel->batch); 234 intel->vtbl.emit_state(intel); 235 } 236 237 /* Ensure that we don't start a new batch for the following emit, which 238 * depends on the state just emitted. emit_state should be making sure we 239 * have the space for this. 240 */ 241 intel->no_batch_wrap = GL_TRUE; 242 243 /* Check that we actually emitted the state into this batch, using the 244 * UPLOAD_CTX bit as the signal. 245 */ 246 assert((intel->batch->dirty_state & (1<<1)) == 0); 247 248#if 0 249 printf("emitting %d..%d=%d vertices size %d\n", offset, 250 intel->prim.current_offset, count, 251 intel->vertex_size * 4); 252#endif 253 254 if (IS_9XX(intel->intelScreen->deviceID)) { 255 BEGIN_BATCH(5, LOOP_CLIPRECTS); 256 OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | 257 I1_LOAD_S(0) | I1_LOAD_S(1) | 1); 258 assert((offset & !S0_VB_OFFSET_MASK) == 0); 259 OUT_RELOC(vb_bo, I915_GEM_DOMAIN_VERTEX, 0, offset); 260 OUT_BATCH((intel->vertex_size << S1_VERTEX_WIDTH_SHIFT) | 261 (intel->vertex_size << S1_VERTEX_PITCH_SHIFT)); 262 263 OUT_BATCH(_3DPRIMITIVE | 264 PRIM_INDIRECT | 265 PRIM_INDIRECT_SEQUENTIAL | 266 intel->prim.primitive | 267 count); 268 OUT_BATCH(0); /* Beginning vertex index */ 269 ADVANCE_BATCH(); 270 } else { 271 struct i830_context *i830 = i830_context(&intel->ctx); 272 273 BEGIN_BATCH(5, LOOP_CLIPRECTS); 274 OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | 275 I1_LOAD_S(0) | I1_LOAD_S(2) | 1); 276 /* S0 */ 277 assert((offset & !S0_VB_OFFSET_MASK_830) == 0); 278 OUT_RELOC(vb_bo, I915_GEM_DOMAIN_VERTEX, 0, 279 offset | (intel->vertex_size << S0_VB_PITCH_SHIFT_830) | 280 S0_VB_ENABLE_830); 281 /* S2 282 * This is somewhat unfortunate -- VB width is tied up with 283 * vertex format data that we've already uploaded through 284 * _3DSTATE_VFT[01]_CMD. We may want to replace emits of VFT state with 285 * STATE_IMMEDIATE_1 like this to avoid duplication. 286 */ 287 OUT_BATCH((i830->state.Ctx[I830_CTXREG_VF] & VFT0_TEX_COUNT_MASK) >> 288 VFT0_TEX_COUNT_SHIFT << S2_TEX_COUNT_SHIFT_830 | 289 (i830->state.Ctx[I830_CTXREG_VF2] << 16) | 290 intel->vertex_size << S2_VERTEX_0_WIDTH_SHIFT_830); 291 292 OUT_BATCH(_3DPRIMITIVE | 293 PRIM_INDIRECT | 294 PRIM_INDIRECT_SEQUENTIAL | 295 intel->prim.primitive | 296 count); 297 OUT_BATCH(0); /* Beginning vertex index */ 298 ADVANCE_BATCH(); 299 } 300 301 intel->no_batch_wrap = GL_FALSE; 302 303 dri_bo_unreference(vb_bo); 304} 305 306/** 307 * Uploads the locally-accumulated VB into the buffer object. 308 * 309 * This avoids us thrashing the cachelines in and out as the buffer gets 310 * filled, dispatched, then reused as the hardware completes rendering from it, 311 * and also lets us clflush less if we dispatch with a partially-filled VB. 312 * 313 * This is called normally from get_space when we're finishing a BO, but also 314 * at batch flush time so that we don't try accessing the contents of a 315 * just-dispatched buffer. 316 */ 317void intel_finish_vb(struct intel_context *intel) 318{ 319 if (intel->prim.vb_bo == NULL) 320 return; 321 322 dri_bo_subdata(intel->prim.vb_bo, 0, intel->prim.start_offset, 323 intel->prim.vb); 324 dri_bo_unreference(intel->prim.vb_bo); 325 intel->prim.vb_bo = NULL; 326} 327 328/*********************************************************************** 329 * Emit primitives as inline vertices * 330 ***********************************************************************/ 331 332#ifdef __i386__ 333#define COPY_DWORDS( j, vb, vertsize, v ) \ 334do { \ 335 int __tmp; \ 336 __asm__ __volatile__( "rep ; movsl" \ 337 : "=%c" (j), "=D" (vb), "=S" (__tmp) \ 338 : "0" (vertsize), \ 339 "D" ((long)vb), \ 340 "S" ((long)v) ); \ 341} while (0) 342#else 343#define COPY_DWORDS( j, vb, vertsize, v ) \ 344do { \ 345 for ( j = 0 ; j < vertsize ; j++ ) { \ 346 vb[j] = ((GLuint *)v)[j]; \ 347 } \ 348 vb += vertsize; \ 349} while (0) 350#endif 351 352static void 353intel_draw_quad(struct intel_context *intel, 354 intelVertexPtr v0, 355 intelVertexPtr v1, intelVertexPtr v2, intelVertexPtr v3) 356{ 357 GLuint vertsize = intel->vertex_size; 358 GLuint *vb = intel_get_prim_space(intel, 6); 359 int j; 360 361 COPY_DWORDS(j, vb, vertsize, v0); 362 COPY_DWORDS(j, vb, vertsize, v1); 363 364 /* If smooth shading, draw like a trifan which gives better 365 * rasterization. Otherwise draw as two triangles with provoking 366 * vertex in third position as required for flat shading. 367 */ 368 if (intel->ctx.Light.ShadeModel == GL_FLAT) { 369 COPY_DWORDS(j, vb, vertsize, v3); 370 COPY_DWORDS(j, vb, vertsize, v1); 371 } 372 else { 373 COPY_DWORDS(j, vb, vertsize, v2); 374 COPY_DWORDS(j, vb, vertsize, v0); 375 } 376 377 COPY_DWORDS(j, vb, vertsize, v2); 378 COPY_DWORDS(j, vb, vertsize, v3); 379} 380 381static void 382intel_draw_triangle(struct intel_context *intel, 383 intelVertexPtr v0, intelVertexPtr v1, intelVertexPtr v2) 384{ 385 GLuint vertsize = intel->vertex_size; 386 GLuint *vb = intel_get_prim_space(intel, 3); 387 int j; 388 389 COPY_DWORDS(j, vb, vertsize, v0); 390 COPY_DWORDS(j, vb, vertsize, v1); 391 COPY_DWORDS(j, vb, vertsize, v2); 392} 393 394 395static void 396intel_draw_line(struct intel_context *intel, 397 intelVertexPtr v0, intelVertexPtr v1) 398{ 399 GLuint vertsize = intel->vertex_size; 400 GLuint *vb = intel_get_prim_space(intel, 2); 401 int j; 402 403 COPY_DWORDS(j, vb, vertsize, v0); 404 COPY_DWORDS(j, vb, vertsize, v1); 405} 406 407 408static void 409intel_draw_point(struct intel_context *intel, intelVertexPtr v0) 410{ 411 GLuint vertsize = intel->vertex_size; 412 GLuint *vb = intel_get_prim_space(intel, 1); 413 int j; 414 415 /* Adjust for sub pixel position -- still required for conform. */ 416 *(float *) &vb[0] = v0->v.x; 417 *(float *) &vb[1] = v0->v.y; 418 for (j = 2; j < vertsize; j++) 419 vb[j] = v0->ui[j]; 420} 421 422 423 424/*********************************************************************** 425 * Fixup for ARB_point_parameters * 426 ***********************************************************************/ 427 428/* Currently not working - VERT_ATTRIB_POINTSIZE isn't correctly 429 * represented in the fragment program InputsRead field. 430 */ 431static void 432intel_atten_point(struct intel_context *intel, intelVertexPtr v0) 433{ 434 GLcontext *ctx = &intel->ctx; 435 GLfloat psz[4], col[4], restore_psz, restore_alpha; 436 437 _tnl_get_attr(ctx, v0, _TNL_ATTRIB_POINTSIZE, psz); 438 _tnl_get_attr(ctx, v0, _TNL_ATTRIB_COLOR0, col); 439 440 restore_psz = psz[0]; 441 restore_alpha = col[3]; 442 443 if (psz[0] >= ctx->Point.Threshold) { 444 psz[0] = MIN2(psz[0], ctx->Point.MaxSize); 445 } 446 else { 447 GLfloat dsize = psz[0] / ctx->Point.Threshold; 448 psz[0] = MAX2(ctx->Point.Threshold, ctx->Point.MinSize); 449 col[3] *= dsize * dsize; 450 } 451 452 if (psz[0] < 1.0) 453 psz[0] = 1.0; 454 455 if (restore_psz != psz[0] || restore_alpha != col[3]) { 456 _tnl_set_attr(ctx, v0, _TNL_ATTRIB_POINTSIZE, psz); 457 _tnl_set_attr(ctx, v0, _TNL_ATTRIB_COLOR0, col); 458 459 intel_draw_point(intel, v0); 460 461 psz[0] = restore_psz; 462 col[3] = restore_alpha; 463 464 _tnl_set_attr(ctx, v0, _TNL_ATTRIB_POINTSIZE, psz); 465 _tnl_set_attr(ctx, v0, _TNL_ATTRIB_COLOR0, col); 466 } 467 else 468 intel_draw_point(intel, v0); 469} 470 471 472 473 474 475/*********************************************************************** 476 * Fixup for I915 WPOS texture coordinate * 477 ***********************************************************************/ 478 479 480 481static void 482intel_wpos_triangle(struct intel_context *intel, 483 intelVertexPtr v0, intelVertexPtr v1, intelVertexPtr v2) 484{ 485 GLuint offset = intel->wpos_offset; 486 GLuint size = intel->wpos_size; 487 GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset); 488 GLfloat *v1_wpos = (GLfloat *)((char *)v1 + offset); 489 GLfloat *v2_wpos = (GLfloat *)((char *)v2 + offset); 490 491 __memcpy(v0_wpos, v0, size); 492 __memcpy(v1_wpos, v1, size); 493 __memcpy(v2_wpos, v2, size); 494 495 v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h; 496 v1_wpos[1] = -v1_wpos[1] + intel->driDrawable->h; 497 v2_wpos[1] = -v2_wpos[1] + intel->driDrawable->h; 498 499 500 intel_draw_triangle(intel, v0, v1, v2); 501} 502 503 504static void 505intel_wpos_line(struct intel_context *intel, 506 intelVertexPtr v0, intelVertexPtr v1) 507{ 508 GLuint offset = intel->wpos_offset; 509 GLuint size = intel->wpos_size; 510 GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset); 511 GLfloat *v1_wpos = (GLfloat *)((char *)v1 + offset); 512 513 __memcpy(v0_wpos, v0, size); 514 __memcpy(v1_wpos, v1, size); 515 516 v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h; 517 v1_wpos[1] = -v1_wpos[1] + intel->driDrawable->h; 518 519 intel_draw_line(intel, v0, v1); 520} 521 522 523static void 524intel_wpos_point(struct intel_context *intel, intelVertexPtr v0) 525{ 526 GLuint offset = intel->wpos_offset; 527 GLuint size = intel->wpos_size; 528 GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset); 529 530 __memcpy(v0_wpos, v0, size); 531 v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h; 532 533 intel_draw_point(intel, v0); 534} 535 536 537 538 539 540 541/*********************************************************************** 542 * Macros for t_dd_tritmp.h to draw basic primitives * 543 ***********************************************************************/ 544 545#define TRI( a, b, c ) \ 546do { \ 547 if (DO_FALLBACK) \ 548 intel->draw_tri( intel, a, b, c ); \ 549 else \ 550 intel_draw_triangle( intel, a, b, c ); \ 551} while (0) 552 553#define QUAD( a, b, c, d ) \ 554do { \ 555 if (DO_FALLBACK) { \ 556 intel->draw_tri( intel, a, b, d ); \ 557 intel->draw_tri( intel, b, c, d ); \ 558 } else \ 559 intel_draw_quad( intel, a, b, c, d ); \ 560} while (0) 561 562#define LINE( v0, v1 ) \ 563do { \ 564 if (DO_FALLBACK) \ 565 intel->draw_line( intel, v0, v1 ); \ 566 else \ 567 intel_draw_line( intel, v0, v1 ); \ 568} while (0) 569 570#define POINT( v0 ) \ 571do { \ 572 if (DO_FALLBACK) \ 573 intel->draw_point( intel, v0 ); \ 574 else \ 575 intel_draw_point( intel, v0 ); \ 576} while (0) 577 578 579/*********************************************************************** 580 * Build render functions from dd templates * 581 ***********************************************************************/ 582 583#define INTEL_OFFSET_BIT 0x01 584#define INTEL_TWOSIDE_BIT 0x02 585#define INTEL_UNFILLED_BIT 0x04 586#define INTEL_FALLBACK_BIT 0x08 587#define INTEL_MAX_TRIFUNC 0x10 588 589 590static struct 591{ 592 tnl_points_func points; 593 tnl_line_func line; 594 tnl_triangle_func triangle; 595 tnl_quad_func quad; 596} rast_tab[INTEL_MAX_TRIFUNC]; 597 598 599#define DO_FALLBACK (IND & INTEL_FALLBACK_BIT) 600#define DO_OFFSET (IND & INTEL_OFFSET_BIT) 601#define DO_UNFILLED (IND & INTEL_UNFILLED_BIT) 602#define DO_TWOSIDE (IND & INTEL_TWOSIDE_BIT) 603#define DO_FLAT 0 604#define DO_TRI 1 605#define DO_QUAD 1 606#define DO_LINE 1 607#define DO_POINTS 1 608#define DO_FULL_QUAD 1 609 610#define HAVE_RGBA 1 611#define HAVE_SPEC 1 612#define HAVE_BACK_COLORS 0 613#define HAVE_HW_FLATSHADE 1 614#define VERTEX intelVertex 615#define TAB rast_tab 616 617/* Only used to pull back colors into vertices (ie, we know color is 618 * floating point). 619 */ 620#define INTEL_COLOR( dst, src ) \ 621do { \ 622 UNCLAMPED_FLOAT_TO_UBYTE((dst)[0], (src)[2]); \ 623 UNCLAMPED_FLOAT_TO_UBYTE((dst)[1], (src)[1]); \ 624 UNCLAMPED_FLOAT_TO_UBYTE((dst)[2], (src)[0]); \ 625 UNCLAMPED_FLOAT_TO_UBYTE((dst)[3], (src)[3]); \ 626} while (0) 627 628#define INTEL_SPEC( dst, src ) \ 629do { \ 630 UNCLAMPED_FLOAT_TO_UBYTE((dst)[0], (src)[2]); \ 631 UNCLAMPED_FLOAT_TO_UBYTE((dst)[1], (src)[1]); \ 632 UNCLAMPED_FLOAT_TO_UBYTE((dst)[2], (src)[0]); \ 633} while (0) 634 635 636#define DEPTH_SCALE intel->polygon_offset_scale 637#define UNFILLED_TRI unfilled_tri 638#define UNFILLED_QUAD unfilled_quad 639#define VERT_X(_v) _v->v.x 640#define VERT_Y(_v) _v->v.y 641#define VERT_Z(_v) _v->v.z 642#define AREA_IS_CCW( a ) (a > 0) 643#define GET_VERTEX(e) (intel->verts + (e * intel->vertex_size * sizeof(GLuint))) 644 645#define VERT_SET_RGBA( v, c ) if (coloroffset) INTEL_COLOR( v->ub4[coloroffset], c ) 646#define VERT_COPY_RGBA( v0, v1 ) if (coloroffset) v0->ui[coloroffset] = v1->ui[coloroffset] 647#define VERT_SAVE_RGBA( idx ) if (coloroffset) color[idx] = v[idx]->ui[coloroffset] 648#define VERT_RESTORE_RGBA( idx ) if (coloroffset) v[idx]->ui[coloroffset] = color[idx] 649 650#define VERT_SET_SPEC( v, c ) if (specoffset) INTEL_SPEC( v->ub4[specoffset], c ) 651#define VERT_COPY_SPEC( v0, v1 ) if (specoffset) COPY_3V(v0->ub4[specoffset], v1->ub4[specoffset]) 652#define VERT_SAVE_SPEC( idx ) if (specoffset) spec[idx] = v[idx]->ui[specoffset] 653#define VERT_RESTORE_SPEC( idx ) if (specoffset) v[idx]->ui[specoffset] = spec[idx] 654 655#define LOCAL_VARS(n) \ 656 struct intel_context *intel = intel_context(ctx); \ 657 GLuint color[n] = { 0, }, spec[n] = { 0, }; \ 658 GLuint coloroffset = intel->coloroffset; \ 659 GLboolean specoffset = intel->specoffset; \ 660 (void) color; (void) spec; (void) coloroffset; (void) specoffset; 661 662 663/*********************************************************************** 664 * Helpers for rendering unfilled primitives * 665 ***********************************************************************/ 666 667static const GLuint hw_prim[GL_POLYGON + 1] = { 668 PRIM3D_POINTLIST, 669 PRIM3D_LINELIST, 670 PRIM3D_LINELIST, 671 PRIM3D_LINELIST, 672 PRIM3D_TRILIST, 673 PRIM3D_TRILIST, 674 PRIM3D_TRILIST, 675 PRIM3D_TRILIST, 676 PRIM3D_TRILIST, 677 PRIM3D_TRILIST 678}; 679 680#define RASTERIZE(x) intelRasterPrimitive( ctx, x, hw_prim[x] ) 681#define RENDER_PRIMITIVE intel->render_primitive 682#define TAG(x) x 683#define IND INTEL_FALLBACK_BIT 684#include "tnl_dd/t_dd_unfilled.h" 685#undef IND 686 687/*********************************************************************** 688 * Generate GL render functions * 689 ***********************************************************************/ 690 691#define IND (0) 692#define TAG(x) x 693#include "tnl_dd/t_dd_tritmp.h" 694 695#define IND (INTEL_OFFSET_BIT) 696#define TAG(x) x##_offset 697#include "tnl_dd/t_dd_tritmp.h" 698 699#define IND (INTEL_TWOSIDE_BIT) 700#define TAG(x) x##_twoside 701#include "tnl_dd/t_dd_tritmp.h" 702 703#define IND (INTEL_TWOSIDE_BIT|INTEL_OFFSET_BIT) 704#define TAG(x) x##_twoside_offset 705#include "tnl_dd/t_dd_tritmp.h" 706 707#define IND (INTEL_UNFILLED_BIT) 708#define TAG(x) x##_unfilled 709#include "tnl_dd/t_dd_tritmp.h" 710 711#define IND (INTEL_OFFSET_BIT|INTEL_UNFILLED_BIT) 712#define TAG(x) x##_offset_unfilled 713#include "tnl_dd/t_dd_tritmp.h" 714 715#define IND (INTEL_TWOSIDE_BIT|INTEL_UNFILLED_BIT) 716#define TAG(x) x##_twoside_unfilled 717#include "tnl_dd/t_dd_tritmp.h" 718 719#define IND (INTEL_TWOSIDE_BIT|INTEL_OFFSET_BIT|INTEL_UNFILLED_BIT) 720#define TAG(x) x##_twoside_offset_unfilled 721#include "tnl_dd/t_dd_tritmp.h" 722 723#define IND (INTEL_FALLBACK_BIT) 724#define TAG(x) x##_fallback 725#include "tnl_dd/t_dd_tritmp.h" 726 727#define IND (INTEL_OFFSET_BIT|INTEL_FALLBACK_BIT) 728#define TAG(x) x##_offset_fallback 729#include "tnl_dd/t_dd_tritmp.h" 730 731#define IND (INTEL_TWOSIDE_BIT|INTEL_FALLBACK_BIT) 732#define TAG(x) x##_twoside_fallback 733#include "tnl_dd/t_dd_tritmp.h" 734 735#define IND (INTEL_TWOSIDE_BIT|INTEL_OFFSET_BIT|INTEL_FALLBACK_BIT) 736#define TAG(x) x##_twoside_offset_fallback 737#include "tnl_dd/t_dd_tritmp.h" 738 739#define IND (INTEL_UNFILLED_BIT|INTEL_FALLBACK_BIT) 740#define TAG(x) x##_unfilled_fallback 741#include "tnl_dd/t_dd_tritmp.h" 742 743#define IND (INTEL_OFFSET_BIT|INTEL_UNFILLED_BIT|INTEL_FALLBACK_BIT) 744#define TAG(x) x##_offset_unfilled_fallback 745#include "tnl_dd/t_dd_tritmp.h" 746 747#define IND (INTEL_TWOSIDE_BIT|INTEL_UNFILLED_BIT|INTEL_FALLBACK_BIT) 748#define TAG(x) x##_twoside_unfilled_fallback 749#include "tnl_dd/t_dd_tritmp.h" 750 751#define IND (INTEL_TWOSIDE_BIT|INTEL_OFFSET_BIT|INTEL_UNFILLED_BIT| \ 752 INTEL_FALLBACK_BIT) 753#define TAG(x) x##_twoside_offset_unfilled_fallback 754#include "tnl_dd/t_dd_tritmp.h" 755 756 757static void 758init_rast_tab(void) 759{ 760 init(); 761 init_offset(); 762 init_twoside(); 763 init_twoside_offset(); 764 init_unfilled(); 765 init_offset_unfilled(); 766 init_twoside_unfilled(); 767 init_twoside_offset_unfilled(); 768 init_fallback(); 769 init_offset_fallback(); 770 init_twoside_fallback(); 771 init_twoside_offset_fallback(); 772 init_unfilled_fallback(); 773 init_offset_unfilled_fallback(); 774 init_twoside_unfilled_fallback(); 775 init_twoside_offset_unfilled_fallback(); 776} 777 778 779/*********************************************************************** 780 * Rasterization fallback helpers * 781 ***********************************************************************/ 782 783 784/* This code is hit only when a mix of accelerated and unaccelerated 785 * primitives are being drawn, and only for the unaccelerated 786 * primitives. 787 */ 788static void 789intel_fallback_tri(struct intel_context *intel, 790 intelVertex * v0, intelVertex * v1, intelVertex * v2) 791{ 792 GLcontext *ctx = &intel->ctx; 793 SWvertex v[3]; 794 795 if (0) 796 fprintf(stderr, "\n%s\n", __FUNCTION__); 797 798 INTEL_FIREVERTICES(intel); 799 800 _swsetup_Translate(ctx, v0, &v[0]); 801 _swsetup_Translate(ctx, v1, &v[1]); 802 _swsetup_Translate(ctx, v2, &v[2]); 803 intelSpanRenderStart(ctx); 804 _swrast_Triangle(ctx, &v[0], &v[1], &v[2]); 805 intelSpanRenderFinish(ctx); 806} 807 808 809static void 810intel_fallback_line(struct intel_context *intel, 811 intelVertex * v0, intelVertex * v1) 812{ 813 GLcontext *ctx = &intel->ctx; 814 SWvertex v[2]; 815 816 if (0) 817 fprintf(stderr, "\n%s\n", __FUNCTION__); 818 819 INTEL_FIREVERTICES(intel); 820 821 _swsetup_Translate(ctx, v0, &v[0]); 822 _swsetup_Translate(ctx, v1, &v[1]); 823 intelSpanRenderStart(ctx); 824 _swrast_Line(ctx, &v[0], &v[1]); 825 intelSpanRenderFinish(ctx); 826} 827 828static void 829intel_fallback_point(struct intel_context *intel, 830 intelVertex * v0) 831{ 832 GLcontext *ctx = &intel->ctx; 833 SWvertex v[1]; 834 835 if (0) 836 fprintf(stderr, "\n%s\n", __FUNCTION__); 837 838 INTEL_FIREVERTICES(intel); 839 840 _swsetup_Translate(ctx, v0, &v[0]); 841 intelSpanRenderStart(ctx); 842 _swrast_Point(ctx, &v[0]); 843 intelSpanRenderFinish(ctx); 844} 845 846 847/**********************************************************************/ 848/* Render unclipped begin/end objects */ 849/**********************************************************************/ 850 851#define IND 0 852#define V(x) (intelVertex *)(vertptr + ((x)*vertsize*sizeof(GLuint))) 853#define RENDER_POINTS( start, count ) \ 854 for ( ; start < count ; start++) POINT( V(ELT(start)) ); 855#define RENDER_LINE( v0, v1 ) LINE( V(v0), V(v1) ) 856#define RENDER_TRI( v0, v1, v2 ) TRI( V(v0), V(v1), V(v2) ) 857#define RENDER_QUAD( v0, v1, v2, v3 ) QUAD( V(v0), V(v1), V(v2), V(v3) ) 858#define INIT(x) intelRenderPrimitive( ctx, x ) 859#undef LOCAL_VARS 860#define LOCAL_VARS \ 861 struct intel_context *intel = intel_context(ctx); \ 862 GLubyte *vertptr = (GLubyte *)intel->verts; \ 863 const GLuint vertsize = intel->vertex_size; \ 864 const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \ 865 (void) elt; 866#define RESET_STIPPLE 867#define RESET_OCCLUSION 868#define PRESERVE_VB_DEFS 869#define ELT(x) x 870#define TAG(x) intel_##x##_verts 871#include "tnl/t_vb_rendertmp.h" 872#undef ELT 873#undef TAG 874#define TAG(x) intel_##x##_elts 875#define ELT(x) elt[x] 876#include "tnl/t_vb_rendertmp.h" 877 878/**********************************************************************/ 879/* Render clipped primitives */ 880/**********************************************************************/ 881 882 883 884static void 885intelRenderClippedPoly(GLcontext * ctx, const GLuint * elts, GLuint n) 886{ 887 struct intel_context *intel = intel_context(ctx); 888 TNLcontext *tnl = TNL_CONTEXT(ctx); 889 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; 890 GLuint prim = intel->render_primitive; 891 892 /* Render the new vertices as an unclipped polygon. 893 */ 894 { 895 GLuint *tmp = VB->Elts; 896 VB->Elts = (GLuint *) elts; 897 tnl->Driver.Render.PrimTabElts[GL_POLYGON] (ctx, 0, n, 898 PRIM_BEGIN | PRIM_END); 899 VB->Elts = tmp; 900 } 901 902 /* Restore the render primitive 903 */ 904 if (prim != GL_POLYGON) 905 tnl->Driver.Render.PrimitiveNotify(ctx, prim); 906} 907 908static void 909intelRenderClippedLine(GLcontext * ctx, GLuint ii, GLuint jj) 910{ 911 TNLcontext *tnl = TNL_CONTEXT(ctx); 912 913 tnl->Driver.Render.Line(ctx, ii, jj); 914} 915 916static void 917intelFastRenderClippedPoly(GLcontext * ctx, const GLuint * elts, GLuint n) 918{ 919 struct intel_context *intel = intel_context(ctx); 920 const GLuint vertsize = intel->vertex_size; 921 GLuint *vb = intel_get_prim_space(intel, (n - 2) * 3); 922 GLubyte *vertptr = (GLubyte *) intel->verts; 923 const GLuint *start = (const GLuint *) V(elts[0]); 924 int i, j; 925 926 for (i = 2; i < n; i++) { 927 COPY_DWORDS(j, vb, vertsize, V(elts[i - 1])); 928 COPY_DWORDS(j, vb, vertsize, V(elts[i])); 929 COPY_DWORDS(j, vb, vertsize, start); 930 } 931} 932 933/**********************************************************************/ 934/* Choose render functions */ 935/**********************************************************************/ 936 937 938 939 940#define ANY_FALLBACK_FLAGS (DD_LINE_STIPPLE | DD_TRI_STIPPLE | DD_POINT_ATTEN | DD_POINT_SMOOTH | DD_TRI_SMOOTH) 941#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE | DD_TRI_OFFSET | DD_TRI_UNFILLED) 942 943void 944intelChooseRenderState(GLcontext * ctx) 945{ 946 TNLcontext *tnl = TNL_CONTEXT(ctx); 947 struct intel_context *intel = intel_context(ctx); 948 GLuint flags = ctx->_TriangleCaps; 949 const struct gl_fragment_program *fprog = ctx->FragmentProgram._Current; 950 GLboolean have_wpos = (fprog && (fprog->Base.InputsRead & FRAG_BIT_WPOS)); 951 GLuint index = 0; 952 953 if (INTEL_DEBUG & DEBUG_STATE) 954 fprintf(stderr, "\n%s\n", __FUNCTION__); 955 956 if ((flags & (ANY_FALLBACK_FLAGS | ANY_RASTER_FLAGS)) || have_wpos) { 957 958 if (flags & ANY_RASTER_FLAGS) { 959 if (flags & DD_TRI_LIGHT_TWOSIDE) 960 index |= INTEL_TWOSIDE_BIT; 961 if (flags & DD_TRI_OFFSET) 962 index |= INTEL_OFFSET_BIT; 963 if (flags & DD_TRI_UNFILLED) 964 index |= INTEL_UNFILLED_BIT; 965 } 966 967 if (have_wpos) { 968 intel->draw_point = intel_wpos_point; 969 intel->draw_line = intel_wpos_line; 970 intel->draw_tri = intel_wpos_triangle; 971 972 /* Make sure these get called: 973 */ 974 index |= INTEL_FALLBACK_BIT; 975 } 976 else { 977 intel->draw_point = intel_draw_point; 978 intel->draw_line = intel_draw_line; 979 intel->draw_tri = intel_draw_triangle; 980 } 981 982 /* Hook in fallbacks for specific primitives. 983 */ 984 if (flags & ANY_FALLBACK_FLAGS) { 985 if (flags & DD_LINE_STIPPLE) 986 intel->draw_line = intel_fallback_line; 987 988 if ((flags & DD_TRI_STIPPLE) && !intel->hw_stipple) 989 intel->draw_tri = intel_fallback_tri; 990 991 if (flags & DD_TRI_SMOOTH) { 992 if (intel->conformance_mode > 0) 993 intel->draw_tri = intel_fallback_tri; 994 } 995 996 if (flags & DD_POINT_ATTEN) { 997 if (0) 998 intel->draw_point = intel_atten_point; 999 else 1000 intel->draw_point = intel_fallback_point; 1001 } 1002 1003 if (flags & DD_POINT_SMOOTH) { 1004 if (intel->conformance_mode > 0) 1005 intel->draw_point = intel_fallback_point; 1006 } 1007 1008 index |= INTEL_FALLBACK_BIT; 1009 } 1010 } 1011 1012 if (intel->RenderIndex != index) { 1013 intel->RenderIndex = index; 1014 1015 tnl->Driver.Render.Points = rast_tab[index].points; 1016 tnl->Driver.Render.Line = rast_tab[index].line; 1017 tnl->Driver.Render.Triangle = rast_tab[index].triangle; 1018 tnl->Driver.Render.Quad = rast_tab[index].quad; 1019 1020 if (index == 0) { 1021 tnl->Driver.Render.PrimTabVerts = intel_render_tab_verts; 1022 tnl->Driver.Render.PrimTabElts = intel_render_tab_elts; 1023 tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */ 1024 tnl->Driver.Render.ClippedPolygon = intelFastRenderClippedPoly; 1025 } 1026 else { 1027 tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; 1028 tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; 1029 tnl->Driver.Render.ClippedLine = intelRenderClippedLine; 1030 tnl->Driver.Render.ClippedPolygon = intelRenderClippedPoly; 1031 } 1032 } 1033} 1034 1035static const GLenum reduced_prim[GL_POLYGON + 1] = { 1036 GL_POINTS, 1037 GL_LINES, 1038 GL_LINES, 1039 GL_LINES, 1040 GL_TRIANGLES, 1041 GL_TRIANGLES, 1042 GL_TRIANGLES, 1043 GL_TRIANGLES, 1044 GL_TRIANGLES, 1045 GL_TRIANGLES 1046}; 1047 1048 1049/**********************************************************************/ 1050/* High level hooks for t_vb_render.c */ 1051/**********************************************************************/ 1052 1053 1054 1055 1056static void 1057intelRunPipeline(GLcontext * ctx) 1058{ 1059 struct intel_context *intel = intel_context(ctx); 1060 1061 _mesa_lock_context_textures(ctx); 1062 1063 if (ctx->NewState) 1064 _mesa_update_state_locked(ctx); 1065 1066 if (intel->NewGLState) { 1067 if (intel->NewGLState & _NEW_TEXTURE) { 1068 intel->vtbl.update_texture_state(intel); 1069 } 1070 1071 if (!intel->Fallback) { 1072 if (intel->NewGLState & _INTEL_NEW_RENDERSTATE) 1073 intelChooseRenderState(ctx); 1074 } 1075 1076 intel->NewGLState = 0; 1077 } 1078 1079 intel_map_vertex_shader_textures(ctx); 1080 _tnl_run_pipeline(ctx); 1081 intel_unmap_vertex_shader_textures(ctx); 1082 1083 _mesa_unlock_context_textures(ctx); 1084} 1085 1086static void 1087intelRenderStart(GLcontext * ctx) 1088{ 1089 struct intel_context *intel = intel_context(ctx); 1090 1091 intel_check_front_buffer_rendering(intel); 1092 intel->vtbl.render_start(intel_context(ctx)); 1093 intel->vtbl.emit_state(intel); 1094} 1095 1096static void 1097intelRenderFinish(GLcontext * ctx) 1098{ 1099 struct intel_context *intel = intel_context(ctx); 1100 1101 if (intel->RenderIndex & INTEL_FALLBACK_BIT) 1102 _swrast_flush(ctx); 1103 1104 INTEL_FIREVERTICES(intel); 1105} 1106 1107 1108 1109 1110 /* System to flush dma and emit state changes based on the rasterized 1111 * primitive. 1112 */ 1113static void 1114intelRasterPrimitive(GLcontext * ctx, GLenum rprim, GLuint hwprim) 1115{ 1116 struct intel_context *intel = intel_context(ctx); 1117 1118 if (0) 1119 fprintf(stderr, "%s %s %x\n", __FUNCTION__, 1120 _mesa_lookup_enum_by_nr(rprim), hwprim); 1121 1122 intel->vtbl.reduced_primitive_state(intel, rprim); 1123 1124 /* Start a new primitive. Arrange to have it flushed later on. 1125 */ 1126 if (hwprim != intel->prim.primitive) { 1127 INTEL_FIREVERTICES(intel); 1128 1129 intel_set_prim(intel, hwprim); 1130 } 1131} 1132 1133 1134 /* 1135 */ 1136static void 1137intelRenderPrimitive(GLcontext * ctx, GLenum prim) 1138{ 1139 struct intel_context *intel = intel_context(ctx); 1140 1141 if (0) 1142 fprintf(stderr, "%s %s\n", __FUNCTION__, _mesa_lookup_enum_by_nr(prim)); 1143 1144 /* Let some clipping routines know which primitive they're dealing 1145 * with. 1146 */ 1147 intel->render_primitive = prim; 1148 1149 /* Shortcircuit this when called from t_dd_rendertmp.h for unfilled 1150 * triangles. The rasterized primitive will always be reset by 1151 * lower level functions in that case, potentially pingponging the 1152 * state: 1153 */ 1154 if (reduced_prim[prim] == GL_TRIANGLES && 1155 (ctx->_TriangleCaps & DD_TRI_UNFILLED)) 1156 return; 1157 1158 /* Set some primitive-dependent state and Start? a new primitive. 1159 */ 1160 intelRasterPrimitive(ctx, reduced_prim[prim], hw_prim[prim]); 1161} 1162 1163 1164 /**********************************************************************/ 1165 /* Transition to/from hardware rasterization. */ 1166 /**********************************************************************/ 1167 1168static char *fallbackStrings[] = { 1169 [0] = "Draw buffer", 1170 [1] = "Read buffer", 1171 [2] = "Depth buffer", 1172 [3] = "Stencil buffer", 1173 [4] = "User disable", 1174 [5] = "Render mode", 1175 1176 [12] = "Texture", 1177 [13] = "Color mask", 1178 [14] = "Stencil", 1179 [15] = "Stipple", 1180 [16] = "Program", 1181 [17] = "Logic op", 1182 [18] = "Smooth polygon", 1183 [19] = "Smooth point", 1184}; 1185 1186 1187static char * 1188getFallbackString(GLuint bit) 1189{ 1190 int i = 0; 1191 while (bit > 1) { 1192 i++; 1193 bit >>= 1; 1194 } 1195 return fallbackStrings[i]; 1196} 1197 1198 1199 1200/** 1201 * Enable/disable a fallback flag. 1202 * \param bit one of INTEL_FALLBACK_x flags. 1203 */ 1204void 1205intelFallback(struct intel_context *intel, GLbitfield bit, GLboolean mode) 1206{ 1207 GLcontext *ctx = &intel->ctx; 1208 TNLcontext *tnl = TNL_CONTEXT(ctx); 1209 const GLbitfield oldfallback = intel->Fallback; 1210 1211 if (mode) { 1212 intel->Fallback |= bit; 1213 if (oldfallback == 0) { 1214 intelFlush(ctx); 1215 if (INTEL_DEBUG & DEBUG_FALLBACKS) 1216 fprintf(stderr, "ENTER FALLBACK %x: %s\n", 1217 bit, getFallbackString(bit)); 1218 _swsetup_Wakeup(ctx); 1219 intel->RenderIndex = ~0; 1220 } 1221 } 1222 else { 1223 intel->Fallback &= ~bit; 1224 if (oldfallback == bit) { 1225 _swrast_flush(ctx); 1226 if (INTEL_DEBUG & DEBUG_FALLBACKS) 1227 fprintf(stderr, "LEAVE FALLBACK %s\n", getFallbackString(bit)); 1228 tnl->Driver.Render.Start = intelRenderStart; 1229 tnl->Driver.Render.PrimitiveNotify = intelRenderPrimitive; 1230 tnl->Driver.Render.Finish = intelRenderFinish; 1231 tnl->Driver.Render.BuildVertices = _tnl_build_vertices; 1232 tnl->Driver.Render.CopyPV = _tnl_copy_pv; 1233 tnl->Driver.Render.Interp = _tnl_interp; 1234 1235 _tnl_invalidate_vertex_state(ctx, ~0); 1236 _tnl_invalidate_vertices(ctx, ~0); 1237 _tnl_install_attrs(ctx, 1238 intel->vertex_attrs, 1239 intel->vertex_attr_count, 1240 intel->ViewportMatrix.m, 0); 1241 1242 intel->NewGLState |= _INTEL_NEW_RENDERSTATE; 1243 } 1244 } 1245} 1246 1247union fi 1248{ 1249 GLfloat f; 1250 GLint i; 1251}; 1252 1253 1254/**********************************************************************/ 1255/* Used only with the metaops callbacks. */ 1256/**********************************************************************/ 1257static void 1258intel_meta_draw_poly(struct intel_context *intel, 1259 GLuint n, 1260 GLfloat xy[][2], 1261 GLfloat z, GLuint color, GLfloat tex[][2]) 1262{ 1263 union fi *vb; 1264 GLint i; 1265 unsigned int saved_vertex_size = intel->vertex_size; 1266 1267 LOCK_HARDWARE(intel); 1268 1269 intel->vertex_size = 6; 1270 1271 /* All 3d primitives should be emitted with LOOP_CLIPRECTS, 1272 * otherwise the drawing origin (DR4) might not be set correctly. 1273 */ 1274 intel_set_prim(intel, PRIM3D_TRIFAN); 1275 vb = (union fi *) intel_get_prim_space(intel, n); 1276 1277 for (i = 0; i < n; i++) { 1278 vb[0].f = xy[i][0]; 1279 vb[1].f = xy[i][1]; 1280 vb[2].f = z; 1281 vb[3].i = color; 1282 vb[4].f = tex[i][0]; 1283 vb[5].f = tex[i][1]; 1284 vb += 6; 1285 } 1286 1287 INTEL_FIREVERTICES(intel); 1288 1289 intel->vertex_size = saved_vertex_size; 1290 1291 UNLOCK_HARDWARE(intel); 1292} 1293 1294static void 1295intel_meta_draw_quad(struct intel_context *intel, 1296 GLfloat x0, GLfloat x1, 1297 GLfloat y0, GLfloat y1, 1298 GLfloat z, 1299 GLuint color, 1300 GLfloat s0, GLfloat s1, GLfloat t0, GLfloat t1) 1301{ 1302 GLfloat xy[4][2]; 1303 GLfloat tex[4][2]; 1304 1305 xy[0][0] = x0; 1306 xy[0][1] = y0; 1307 xy[1][0] = x1; 1308 xy[1][1] = y0; 1309 xy[2][0] = x1; 1310 xy[2][1] = y1; 1311 xy[3][0] = x0; 1312 xy[3][1] = y1; 1313 1314 tex[0][0] = s0; 1315 tex[0][1] = t0; 1316 tex[1][0] = s1; 1317 tex[1][1] = t0; 1318 tex[2][0] = s1; 1319 tex[2][1] = t1; 1320 tex[3][0] = s0; 1321 tex[3][1] = t1; 1322 1323 intel_meta_draw_poly(intel, 4, xy, z, color, tex); 1324} 1325 1326 1327 1328/**********************************************************************/ 1329/* Initialization. */ 1330/**********************************************************************/ 1331 1332 1333void 1334intelInitTriFuncs(GLcontext * ctx) 1335{ 1336 struct intel_context *intel = intel_context(ctx); 1337 TNLcontext *tnl = TNL_CONTEXT(ctx); 1338 static int firsttime = 1; 1339 1340 if (firsttime) { 1341 init_rast_tab(); 1342 firsttime = 0; 1343 } 1344 1345 tnl->Driver.RunPipeline = intelRunPipeline; 1346 tnl->Driver.Render.Start = intelRenderStart; 1347 tnl->Driver.Render.Finish = intelRenderFinish; 1348 tnl->Driver.Render.PrimitiveNotify = intelRenderPrimitive; 1349 tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple; 1350 tnl->Driver.Render.BuildVertices = _tnl_build_vertices; 1351 tnl->Driver.Render.CopyPV = _tnl_copy_pv; 1352 tnl->Driver.Render.Interp = _tnl_interp; 1353 1354 intel->vtbl.meta_draw_quad = intel_meta_draw_quad; 1355} 1356