Merge branch 'mesa_7_5_branch' into mesa_7_6_branch
[mesa.git] / src / mesa / drivers / dri / i915 / intel_tris.c
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
60 static void intelRenderPrimitive(GLcontext * ctx, GLenum prim);
61 static void intelRasterPrimitive(GLcontext * ctx, GLenum rprim,
62 GLuint hwprim);
63
64 static void
65 intel_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
90 static 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
120 static 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
129 static 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. */
150 void 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 */
165 uint32_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. */
202 void 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 */
317 void 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 ) \
334 do { \
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 ) \
344 do { \
345 for ( j = 0 ; j < vertsize ; j++ ) { \
346 vb[j] = ((GLuint *)v)[j]; \
347 } \
348 vb += vertsize; \
349 } while (0)
350 #endif
351
352 static void
353 intel_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
381 static void
382 intel_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
395 static void
396 intel_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
408 static void
409 intel_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 */
431 static void
432 intel_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
481 static void
482 intel_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
504 static void
505 intel_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
523 static void
524 intel_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 ) \
546 do { \
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 ) \
554 do { \
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 ) \
563 do { \
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 ) \
571 do { \
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
590 static 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 ) \
621 do { \
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 ) \
629 do { \
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
667 static 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
757 static void
758 init_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 */
788 static void
789 intel_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
809 static void
810 intel_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
828 static void
829 intel_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
884 static void
885 intelRenderClippedPoly(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
908 static void
909 intelRenderClippedLine(GLcontext * ctx, GLuint ii, GLuint jj)
910 {
911 TNLcontext *tnl = TNL_CONTEXT(ctx);
912
913 tnl->Driver.Render.Line(ctx, ii, jj);
914 }
915
916 static void
917 intelFastRenderClippedPoly(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
943 void
944 intelChooseRenderState(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
1035 static 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
1056 static void
1057 intelRunPipeline(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 _tnl_run_pipeline(ctx);
1080
1081 _mesa_unlock_context_textures(ctx);
1082 }
1083
1084 static void
1085 intelRenderStart(GLcontext * ctx)
1086 {
1087 struct intel_context *intel = intel_context(ctx);
1088
1089 intel->vtbl.render_start(intel_context(ctx));
1090 intel->vtbl.emit_state(intel);
1091 }
1092
1093 static void
1094 intelRenderFinish(GLcontext * ctx)
1095 {
1096 struct intel_context *intel = intel_context(ctx);
1097
1098 if (intel->RenderIndex & INTEL_FALLBACK_BIT)
1099 _swrast_flush(ctx);
1100
1101 INTEL_FIREVERTICES(intel);
1102 }
1103
1104
1105
1106
1107 /* System to flush dma and emit state changes based on the rasterized
1108 * primitive.
1109 */
1110 static void
1111 intelRasterPrimitive(GLcontext * ctx, GLenum rprim, GLuint hwprim)
1112 {
1113 struct intel_context *intel = intel_context(ctx);
1114
1115 if (0)
1116 fprintf(stderr, "%s %s %x\n", __FUNCTION__,
1117 _mesa_lookup_enum_by_nr(rprim), hwprim);
1118
1119 intel->vtbl.reduced_primitive_state(intel, rprim);
1120
1121 /* Start a new primitive. Arrange to have it flushed later on.
1122 */
1123 if (hwprim != intel->prim.primitive) {
1124 INTEL_FIREVERTICES(intel);
1125
1126 intel_set_prim(intel, hwprim);
1127 }
1128 }
1129
1130
1131 /*
1132 */
1133 static void
1134 intelRenderPrimitive(GLcontext * ctx, GLenum prim)
1135 {
1136 struct intel_context *intel = intel_context(ctx);
1137
1138 if (0)
1139 fprintf(stderr, "%s %s\n", __FUNCTION__, _mesa_lookup_enum_by_nr(prim));
1140
1141 /* Let some clipping routines know which primitive they're dealing
1142 * with.
1143 */
1144 intel->render_primitive = prim;
1145
1146 /* Shortcircuit this when called from t_dd_rendertmp.h for unfilled
1147 * triangles. The rasterized primitive will always be reset by
1148 * lower level functions in that case, potentially pingponging the
1149 * state:
1150 */
1151 if (reduced_prim[prim] == GL_TRIANGLES &&
1152 (ctx->_TriangleCaps & DD_TRI_UNFILLED))
1153 return;
1154
1155 /* Set some primitive-dependent state and Start? a new primitive.
1156 */
1157 intelRasterPrimitive(ctx, reduced_prim[prim], hw_prim[prim]);
1158 }
1159
1160
1161 /**********************************************************************/
1162 /* Transition to/from hardware rasterization. */
1163 /**********************************************************************/
1164
1165 static char *fallbackStrings[] = {
1166 [0] = "Draw buffer",
1167 [1] = "Read buffer",
1168 [2] = "Depth buffer",
1169 [3] = "Stencil buffer",
1170 [4] = "User disable",
1171 [5] = "Render mode",
1172
1173 [12] = "Texture",
1174 [13] = "Color mask",
1175 [14] = "Stencil",
1176 [15] = "Stipple",
1177 [16] = "Program",
1178 [17] = "Logic op",
1179 [18] = "Smooth polygon",
1180 [19] = "Smooth point",
1181 };
1182
1183
1184 static char *
1185 getFallbackString(GLuint bit)
1186 {
1187 int i = 0;
1188 while (bit > 1) {
1189 i++;
1190 bit >>= 1;
1191 }
1192 return fallbackStrings[i];
1193 }
1194
1195
1196
1197 void
1198 intelFallback(struct intel_context *intel, GLuint bit, GLboolean mode)
1199 {
1200 GLcontext *ctx = &intel->ctx;
1201 TNLcontext *tnl = TNL_CONTEXT(ctx);
1202 GLuint oldfallback = intel->Fallback;
1203
1204 if (mode) {
1205 intel->Fallback |= bit;
1206 if (oldfallback == 0) {
1207 intelFlush(ctx);
1208 if (INTEL_DEBUG & DEBUG_FALLBACKS)
1209 fprintf(stderr, "ENTER FALLBACK %x: %s\n",
1210 bit, getFallbackString(bit));
1211 _swsetup_Wakeup(ctx);
1212 intel->RenderIndex = ~0;
1213 }
1214 }
1215 else {
1216 intel->Fallback &= ~bit;
1217 if (oldfallback == bit) {
1218 _swrast_flush(ctx);
1219 if (INTEL_DEBUG & DEBUG_FALLBACKS)
1220 fprintf(stderr, "LEAVE FALLBACK %s\n", getFallbackString(bit));
1221 tnl->Driver.Render.Start = intelRenderStart;
1222 tnl->Driver.Render.PrimitiveNotify = intelRenderPrimitive;
1223 tnl->Driver.Render.Finish = intelRenderFinish;
1224 tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
1225 tnl->Driver.Render.CopyPV = _tnl_copy_pv;
1226 tnl->Driver.Render.Interp = _tnl_interp;
1227
1228 _tnl_invalidate_vertex_state(ctx, ~0);
1229 _tnl_invalidate_vertices(ctx, ~0);
1230 _tnl_install_attrs(ctx,
1231 intel->vertex_attrs,
1232 intel->vertex_attr_count,
1233 intel->ViewportMatrix.m, 0);
1234
1235 intel->NewGLState |= _INTEL_NEW_RENDERSTATE;
1236 }
1237 }
1238 }
1239
1240 union fi
1241 {
1242 GLfloat f;
1243 GLint i;
1244 };
1245
1246
1247 /**********************************************************************/
1248 /* Used only with the metaops callbacks. */
1249 /**********************************************************************/
1250 static void
1251 intel_meta_draw_poly(struct intel_context *intel,
1252 GLuint n,
1253 GLfloat xy[][2],
1254 GLfloat z, GLuint color, GLfloat tex[][2])
1255 {
1256 union fi *vb;
1257 GLint i;
1258 unsigned int saved_vertex_size = intel->vertex_size;
1259
1260 LOCK_HARDWARE(intel);
1261
1262 intel->vertex_size = 6;
1263
1264 /* All 3d primitives should be emitted with LOOP_CLIPRECTS,
1265 * otherwise the drawing origin (DR4) might not be set correctly.
1266 */
1267 intel_set_prim(intel, PRIM3D_TRIFAN);
1268 vb = (union fi *) intel_get_prim_space(intel, n);
1269
1270 for (i = 0; i < n; i++) {
1271 vb[0].f = xy[i][0];
1272 vb[1].f = xy[i][1];
1273 vb[2].f = z;
1274 vb[3].i = color;
1275 vb[4].f = tex[i][0];
1276 vb[5].f = tex[i][1];
1277 vb += 6;
1278 }
1279
1280 INTEL_FIREVERTICES(intel);
1281
1282 intel->vertex_size = saved_vertex_size;
1283
1284 UNLOCK_HARDWARE(intel);
1285 }
1286
1287 static void
1288 intel_meta_draw_quad(struct intel_context *intel,
1289 GLfloat x0, GLfloat x1,
1290 GLfloat y0, GLfloat y1,
1291 GLfloat z,
1292 GLuint color,
1293 GLfloat s0, GLfloat s1, GLfloat t0, GLfloat t1)
1294 {
1295 GLfloat xy[4][2];
1296 GLfloat tex[4][2];
1297
1298 xy[0][0] = x0;
1299 xy[0][1] = y0;
1300 xy[1][0] = x1;
1301 xy[1][1] = y0;
1302 xy[2][0] = x1;
1303 xy[2][1] = y1;
1304 xy[3][0] = x0;
1305 xy[3][1] = y1;
1306
1307 tex[0][0] = s0;
1308 tex[0][1] = t0;
1309 tex[1][0] = s1;
1310 tex[1][1] = t0;
1311 tex[2][0] = s1;
1312 tex[2][1] = t1;
1313 tex[3][0] = s0;
1314 tex[3][1] = t1;
1315
1316 intel_meta_draw_poly(intel, 4, xy, z, color, tex);
1317 }
1318
1319
1320
1321 /**********************************************************************/
1322 /* Initialization. */
1323 /**********************************************************************/
1324
1325
1326 void
1327 intelInitTriFuncs(GLcontext * ctx)
1328 {
1329 struct intel_context *intel = intel_context(ctx);
1330 TNLcontext *tnl = TNL_CONTEXT(ctx);
1331 static int firsttime = 1;
1332
1333 if (firsttime) {
1334 init_rast_tab();
1335 firsttime = 0;
1336 }
1337
1338 tnl->Driver.RunPipeline = intelRunPipeline;
1339 tnl->Driver.Render.Start = intelRenderStart;
1340 tnl->Driver.Render.Finish = intelRenderFinish;
1341 tnl->Driver.Render.PrimitiveNotify = intelRenderPrimitive;
1342 tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
1343 tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
1344 tnl->Driver.Render.CopyPV = _tnl_copy_pv;
1345 tnl->Driver.Render.Interp = _tnl_interp;
1346
1347 intel->vtbl.meta_draw_quad = intel_meta_draw_quad;
1348 }