llvmpipe: enforce fixed memory limit on scenes
[mesa.git] / src / gallium / drivers / llvmpipe / lp_setup_tri.c
1 /**************************************************************************
2 *
3 * Copyright 2007 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 /*
29 * Binning code for triangles
30 */
31
32 #include "util/u_math.h"
33 #include "util/u_memory.h"
34 #include "util/u_rect.h"
35 #include "lp_perf.h"
36 #include "lp_setup_context.h"
37 #include "lp_setup_coef.h"
38 #include "lp_rast.h"
39 #include "lp_state_fs.h"
40
41 #define NUM_CHANNELS 4
42
43
44
45 static INLINE int
46 subpixel_snap(float a)
47 {
48 return util_iround(FIXED_ONE * a);
49 }
50
51 static INLINE float
52 fixed_to_float(int a)
53 {
54 return a * (1.0 / FIXED_ONE);
55 }
56
57
58
59
60
61
62
63 /**
64 * Alloc space for a new triangle plus the input.a0/dadx/dady arrays
65 * immediately after it.
66 * The memory is allocated from the per-scene pool, not per-tile.
67 * \param tri_size returns number of bytes allocated
68 * \param nr_inputs number of fragment shader inputs
69 * \return pointer to triangle space
70 */
71 struct lp_rast_triangle *
72 lp_setup_alloc_triangle(struct lp_scene *scene,
73 unsigned nr_inputs,
74 unsigned nr_planes,
75 unsigned *tri_size)
76 {
77 unsigned input_array_sz = NUM_CHANNELS * (nr_inputs + 1) * sizeof(float);
78 struct lp_rast_triangle *tri;
79 unsigned tri_bytes, bytes;
80 char *inputs;
81
82 tri_bytes = align(Offset(struct lp_rast_triangle, plane[nr_planes]), 16);
83 bytes = tri_bytes + (3 * input_array_sz);
84
85 tri = lp_scene_alloc_aligned( scene, bytes, 16 );
86
87 if (tri) {
88 inputs = ((char *)tri) + tri_bytes;
89 tri->inputs.a0 = (float (*)[4]) inputs;
90 tri->inputs.dadx = (float (*)[4]) (inputs + input_array_sz);
91 tri->inputs.dady = (float (*)[4]) (inputs + 2 * input_array_sz);
92
93 *tri_size = bytes;
94 }
95
96 return tri;
97 }
98
99 void
100 lp_setup_print_vertex(struct lp_setup_context *setup,
101 const char *name,
102 const float (*v)[4])
103 {
104 int i, j;
105
106 debug_printf(" wpos (%s[0]) xyzw %f %f %f %f\n",
107 name,
108 v[0][0], v[0][1], v[0][2], v[0][3]);
109
110 for (i = 0; i < setup->fs.nr_inputs; i++) {
111 const float *in = v[setup->fs.input[i].src_index];
112
113 debug_printf(" in[%d] (%s[%d]) %s%s%s%s ",
114 i,
115 name, setup->fs.input[i].src_index,
116 (setup->fs.input[i].usage_mask & 0x1) ? "x" : " ",
117 (setup->fs.input[i].usage_mask & 0x2) ? "y" : " ",
118 (setup->fs.input[i].usage_mask & 0x4) ? "z" : " ",
119 (setup->fs.input[i].usage_mask & 0x8) ? "w" : " ");
120
121 for (j = 0; j < 4; j++)
122 if (setup->fs.input[i].usage_mask & (1<<j))
123 debug_printf("%.5f ", in[j]);
124
125 debug_printf("\n");
126 }
127 }
128
129
130 /**
131 * Print triangle vertex attribs (for debug).
132 */
133 void
134 lp_setup_print_triangle(struct lp_setup_context *setup,
135 const float (*v0)[4],
136 const float (*v1)[4],
137 const float (*v2)[4])
138 {
139 debug_printf("triangle\n");
140
141 {
142 const float ex = v0[0][0] - v2[0][0];
143 const float ey = v0[0][1] - v2[0][1];
144 const float fx = v1[0][0] - v2[0][0];
145 const float fy = v1[0][1] - v2[0][1];
146
147 /* det = cross(e,f).z */
148 const float det = ex * fy - ey * fx;
149 if (det < 0.0f)
150 debug_printf(" - ccw\n");
151 else if (det > 0.0f)
152 debug_printf(" - cw\n");
153 else
154 debug_printf(" - zero area\n");
155 }
156
157 lp_setup_print_vertex(setup, "v0", v0);
158 lp_setup_print_vertex(setup, "v1", v1);
159 lp_setup_print_vertex(setup, "v2", v2);
160 }
161
162
163 lp_rast_cmd lp_rast_tri_tab[9] = {
164 NULL, /* should be impossible */
165 lp_rast_triangle_1,
166 lp_rast_triangle_2,
167 lp_rast_triangle_3,
168 lp_rast_triangle_4,
169 lp_rast_triangle_5,
170 lp_rast_triangle_6,
171 lp_rast_triangle_7,
172 lp_rast_triangle_8
173 };
174
175
176
177 /**
178 * The primitive covers the whole tile- shade whole tile.
179 *
180 * \param tx, ty the tile position in tiles, not pixels
181 */
182 static boolean
183 lp_setup_whole_tile(struct lp_setup_context *setup,
184 const struct lp_rast_shader_inputs *inputs,
185 int tx, int ty)
186 {
187 struct lp_scene *scene = setup->scene;
188
189 LP_COUNT(nr_fully_covered_64);
190
191 /* if variant is opaque and scissor doesn't effect the tile */
192 if (inputs->opaque) {
193 if (!scene->fb.zsbuf) {
194 /*
195 * All previous rendering will be overwritten so reset the bin.
196 */
197 lp_scene_bin_reset( scene, tx, ty );
198 }
199
200 LP_COUNT(nr_shade_opaque_64);
201 return lp_scene_bin_command( scene, tx, ty,
202 lp_rast_shade_tile_opaque,
203 lp_rast_arg_inputs(inputs) );
204 } else {
205 LP_COUNT(nr_shade_64);
206 return lp_scene_bin_command( scene, tx, ty,
207 lp_rast_shade_tile,
208 lp_rast_arg_inputs(inputs) );
209 }
210 }
211
212
213 /**
214 * Do basic setup for triangle rasterization and determine which
215 * framebuffer tiles are touched. Put the triangle in the scene's
216 * bins for the tiles which we overlap.
217 */
218 static boolean
219 do_triangle_ccw(struct lp_setup_context *setup,
220 const float (*v0)[4],
221 const float (*v1)[4],
222 const float (*v2)[4],
223 boolean frontfacing )
224 {
225 struct lp_scene *scene = lp_setup_get_current_scene(setup);
226 struct lp_fragment_shader_variant *variant = setup->fs.current.variant;
227 struct lp_rast_triangle *tri;
228 int x[3];
229 int y[3];
230 float dy01, dy20;
231 float dx01, dx20;
232 float oneoverarea;
233 struct lp_tri_info info;
234 int area;
235 struct u_rect bbox;
236 unsigned tri_bytes;
237 int i;
238 int nr_planes = 3;
239
240 if (0)
241 lp_setup_print_triangle(setup, v0, v1, v2);
242
243 if (setup->scissor_test) {
244 nr_planes = 7;
245 }
246 else {
247 nr_planes = 3;
248 }
249
250 /* x/y positions in fixed point */
251 x[0] = subpixel_snap(v0[0][0] - setup->pixel_offset);
252 x[1] = subpixel_snap(v1[0][0] - setup->pixel_offset);
253 x[2] = subpixel_snap(v2[0][0] - setup->pixel_offset);
254 y[0] = subpixel_snap(v0[0][1] - setup->pixel_offset);
255 y[1] = subpixel_snap(v1[0][1] - setup->pixel_offset);
256 y[2] = subpixel_snap(v2[0][1] - setup->pixel_offset);
257
258
259 /* Bounding rectangle (in pixels) */
260 {
261 /* Yes this is necessary to accurately calculate bounding boxes
262 * with the two fill-conventions we support. GL (normally) ends
263 * up needing a bottom-left fill convention, which requires
264 * slightly different rounding.
265 */
266 int adj = (setup->pixel_offset != 0) ? 1 : 0;
267
268 bbox.x0 = (MIN3(x[0], x[1], x[2]) + (FIXED_ONE-1)) >> FIXED_ORDER;
269 bbox.x1 = (MAX3(x[0], x[1], x[2]) + (FIXED_ONE-1)) >> FIXED_ORDER;
270 bbox.y0 = (MIN3(y[0], y[1], y[2]) + (FIXED_ONE-1) + adj) >> FIXED_ORDER;
271 bbox.y1 = (MAX3(y[0], y[1], y[2]) + (FIXED_ONE-1) + adj) >> FIXED_ORDER;
272
273 /* Inclusive coordinates:
274 */
275 bbox.x1--;
276 bbox.y1--;
277 }
278
279 if (bbox.x1 < bbox.x0 ||
280 bbox.y1 < bbox.y0) {
281 if (0) debug_printf("empty bounding box\n");
282 LP_COUNT(nr_culled_tris);
283 return FALSE;
284 }
285
286 if (!u_rect_test_intersection(&setup->draw_region, &bbox)) {
287 if (0) debug_printf("offscreen\n");
288 LP_COUNT(nr_culled_tris);
289 return FALSE;
290 }
291
292 u_rect_find_intersection(&setup->draw_region, &bbox);
293
294 tri = lp_setup_alloc_triangle(scene,
295 setup->fs.nr_inputs,
296 nr_planes,
297 &tri_bytes);
298 if (!tri)
299 return FALSE;
300
301 #ifdef DEBUG
302 tri->v[0][0] = v0[0][0];
303 tri->v[1][0] = v1[0][0];
304 tri->v[2][0] = v2[0][0];
305 tri->v[0][1] = v0[0][1];
306 tri->v[1][1] = v1[0][1];
307 tri->v[2][1] = v2[0][1];
308 #endif
309
310 tri->plane[0].dcdy = x[0] - x[1];
311 tri->plane[1].dcdy = x[1] - x[2];
312 tri->plane[2].dcdy = x[2] - x[0];
313
314 tri->plane[0].dcdx = y[0] - y[1];
315 tri->plane[1].dcdx = y[1] - y[2];
316 tri->plane[2].dcdx = y[2] - y[0];
317
318 area = (tri->plane[0].dcdy * tri->plane[2].dcdx -
319 tri->plane[2].dcdy * tri->plane[0].dcdx);
320
321 LP_COUNT(nr_tris);
322
323 /* Cull non-ccw and zero-sized triangles.
324 *
325 * XXX: subject to overflow??
326 */
327 if (area <= 0) {
328 lp_scene_putback_data( scene, tri_bytes );
329 LP_COUNT(nr_culled_tris);
330 return TRUE;
331 }
332
333
334 /*
335 */
336 dx01 = v0[0][0] - v1[0][0];
337 dy01 = v0[0][1] - v1[0][1];
338 dx20 = v2[0][0] - v0[0][0];
339 dy20 = v2[0][1] - v0[0][1];
340 oneoverarea = 1.0f / (dx01 * dy20 - dx20 * dy01);
341
342 info.v0 = v0;
343 info.v1 = v1;
344 info.v2 = v2;
345 info.frontfacing = frontfacing;
346 info.x0_center = v0[0][0] - setup->pixel_offset;
347 info.y0_center = v0[0][1] - setup->pixel_offset;
348 info.dx01_ooa = dx01 * oneoverarea;
349 info.dx20_ooa = dx20 * oneoverarea;
350 info.dy01_ooa = dy01 * oneoverarea;
351 info.dy20_ooa = dy20 * oneoverarea;
352
353 /* Setup parameter interpolants:
354 */
355 lp_setup_tri_coef( setup, &tri->inputs, &info );
356
357 tri->inputs.facing = frontfacing ? 1.0F : -1.0F;
358 tri->inputs.opaque = variant->opaque;
359 tri->inputs.disable = FALSE;
360 tri->inputs.state = setup->fs.stored;
361
362
363
364 for (i = 0; i < 3; i++) {
365 struct lp_rast_plane *plane = &tri->plane[i];
366
367 /* half-edge constants, will be interated over the whole render
368 * target.
369 */
370 plane->c = plane->dcdx * x[i] - plane->dcdy * y[i];
371
372 /* correct for top-left vs. bottom-left fill convention.
373 *
374 * note that we're overloading gl_rasterization_rules to mean
375 * both (0.5,0.5) pixel centers *and* bottom-left filling
376 * convention.
377 *
378 * GL actually has a top-left filling convention, but GL's
379 * notion of "top" differs from gallium's...
380 *
381 * Also, sometimes (in FBO cases) GL will render upside down
382 * to its usual method, in which case it will probably want
383 * to use the opposite, top-left convention.
384 */
385 if (plane->dcdx < 0) {
386 /* both fill conventions want this - adjust for left edges */
387 plane->c++;
388 }
389 else if (plane->dcdx == 0) {
390 if (setup->pixel_offset == 0) {
391 /* correct for top-left fill convention:
392 */
393 if (plane->dcdy > 0) plane->c++;
394 }
395 else {
396 /* correct for bottom-left fill convention:
397 */
398 if (plane->dcdy < 0) plane->c++;
399 }
400 }
401
402 plane->dcdx *= FIXED_ONE;
403 plane->dcdy *= FIXED_ONE;
404
405 /* find trivial reject offsets for each edge for a single-pixel
406 * sized block. These will be scaled up at each recursive level to
407 * match the active blocksize. Scaling in this way works best if
408 * the blocks are square.
409 */
410 plane->eo = 0;
411 if (plane->dcdx < 0) plane->eo -= plane->dcdx;
412 if (plane->dcdy > 0) plane->eo += plane->dcdy;
413
414 /* Calculate trivial accept offsets from the above.
415 */
416 plane->ei = plane->dcdy - plane->dcdx - plane->eo;
417 }
418
419
420 /*
421 * When rasterizing scissored tris, use the intersection of the
422 * triangle bounding box and the scissor rect to generate the
423 * scissor planes.
424 *
425 * This permits us to cut off the triangle "tails" that are present
426 * in the intermediate recursive levels caused when two of the
427 * triangles edges don't diverge quickly enough to trivially reject
428 * exterior blocks from the triangle.
429 *
430 * It's not really clear if it's worth worrying about these tails,
431 * but since we generate the planes for each scissored tri, it's
432 * free to trim them in this case.
433 *
434 * Note that otherwise, the scissor planes only vary in 'C' value,
435 * and even then only on state-changes. Could alternatively store
436 * these planes elsewhere.
437 */
438 if (nr_planes == 7) {
439 tri->plane[3].dcdx = -1;
440 tri->plane[3].dcdy = 0;
441 tri->plane[3].c = 1-bbox.x0;
442 tri->plane[3].ei = 0;
443 tri->plane[3].eo = 1;
444
445 tri->plane[4].dcdx = 1;
446 tri->plane[4].dcdy = 0;
447 tri->plane[4].c = bbox.x1+1;
448 tri->plane[4].ei = -1;
449 tri->plane[4].eo = 0;
450
451 tri->plane[5].dcdx = 0;
452 tri->plane[5].dcdy = 1;
453 tri->plane[5].c = 1-bbox.y0;
454 tri->plane[5].ei = 0;
455 tri->plane[5].eo = 1;
456
457 tri->plane[6].dcdx = 0;
458 tri->plane[6].dcdy = -1;
459 tri->plane[6].c = bbox.y1+1;
460 tri->plane[6].ei = -1;
461 tri->plane[6].eo = 0;
462 }
463
464 return lp_setup_bin_triangle( setup, tri, &bbox, nr_planes );
465 }
466
467
468 boolean
469 lp_setup_bin_triangle( struct lp_setup_context *setup,
470 struct lp_rast_triangle *tri,
471 const struct u_rect *bbox,
472 int nr_planes )
473 {
474 struct lp_scene *scene = setup->scene;
475 int ix0, ix1, iy0, iy1;
476 int i;
477
478 /*
479 * All fields of 'tri' are now set. The remaining code here is
480 * concerned with binning.
481 */
482
483 /* Convert to tile coordinates, and inclusive ranges:
484 */
485 if (nr_planes == 3) {
486 int ix0 = bbox->x0 / 16;
487 int iy0 = bbox->y0 / 16;
488 int ix1 = bbox->x1 / 16;
489 int iy1 = bbox->y1 / 16;
490
491 if (iy0 == iy1 && ix0 == ix1)
492 {
493
494 /* Triangle is contained in a single 16x16 block:
495 */
496 int mask = (ix0 & 3) | ((iy0 & 3) << 4);
497
498 return lp_scene_bin_command( scene, ix0/4, iy0/4,
499 lp_rast_triangle_3_16,
500 lp_rast_arg_triangle(tri, mask) );
501 }
502 }
503
504 ix0 = bbox->x0 / TILE_SIZE;
505 iy0 = bbox->y0 / TILE_SIZE;
506 ix1 = bbox->x1 / TILE_SIZE;
507 iy1 = bbox->y1 / TILE_SIZE;
508
509 /*
510 * Clamp to framebuffer size
511 */
512 assert(ix0 == MAX2(ix0, 0));
513 assert(iy0 == MAX2(iy0, 0));
514 assert(ix1 == MIN2(ix1, scene->tiles_x - 1));
515 assert(iy1 == MIN2(iy1, scene->tiles_y - 1));
516
517 /* Determine which tile(s) intersect the triangle's bounding box
518 */
519 if (iy0 == iy1 && ix0 == ix1)
520 {
521 /* Triangle is contained in a single tile:
522 */
523 return lp_scene_bin_command( scene, ix0, iy0,
524 lp_rast_tri_tab[nr_planes],
525 lp_rast_arg_triangle(tri, (1<<nr_planes)-1) );
526 }
527 else
528 {
529 int c[7];
530 int ei[7];
531 int eo[7];
532 int xstep[7];
533 int ystep[7];
534 int x, y;
535
536 for (i = 0; i < nr_planes; i++) {
537 c[i] = (tri->plane[i].c +
538 tri->plane[i].dcdy * iy0 * TILE_SIZE -
539 tri->plane[i].dcdx * ix0 * TILE_SIZE);
540
541 ei[i] = tri->plane[i].ei << TILE_ORDER;
542 eo[i] = tri->plane[i].eo << TILE_ORDER;
543 xstep[i] = -(tri->plane[i].dcdx << TILE_ORDER);
544 ystep[i] = tri->plane[i].dcdy << TILE_ORDER;
545 }
546
547
548
549 /* Test tile-sized blocks against the triangle.
550 * Discard blocks fully outside the tri. If the block is fully
551 * contained inside the tri, bin an lp_rast_shade_tile command.
552 * Else, bin a lp_rast_triangle command.
553 */
554 for (y = iy0; y <= iy1; y++)
555 {
556 boolean in = FALSE; /* are we inside the triangle? */
557 int cx[7];
558
559 for (i = 0; i < nr_planes; i++)
560 cx[i] = c[i];
561
562 for (x = ix0; x <= ix1; x++)
563 {
564 int out = 0;
565 int partial = 0;
566
567 for (i = 0; i < nr_planes; i++) {
568 int planeout = cx[i] + eo[i];
569 int planepartial = cx[i] + ei[i] - 1;
570 out |= (planeout >> 31);
571 partial |= (planepartial >> 31) & (1<<i);
572 }
573
574 if (out) {
575 /* do nothing */
576 if (in)
577 break; /* exiting triangle, all done with this row */
578 LP_COUNT(nr_empty_64);
579 }
580 else if (partial) {
581 /* Not trivially accepted by at least one plane -
582 * rasterize/shade partial tile
583 */
584 int count = util_bitcount(partial);
585 in = TRUE;
586 if (!lp_scene_bin_command( scene, x, y,
587 lp_rast_tri_tab[count],
588 lp_rast_arg_triangle(tri, partial) ))
589 goto fail;
590
591 LP_COUNT(nr_partially_covered_64);
592 }
593 else {
594 /* triangle covers the whole tile- shade whole tile */
595 LP_COUNT(nr_fully_covered_64);
596 in = TRUE;
597 if (!lp_setup_whole_tile(setup, &tri->inputs, x, y))
598 goto fail;
599 }
600
601 /* Iterate cx values across the region:
602 */
603 for (i = 0; i < nr_planes; i++)
604 cx[i] += xstep[i];
605 }
606
607 /* Iterate c values down the region:
608 */
609 for (i = 0; i < nr_planes; i++)
610 c[i] += ystep[i];
611 }
612 }
613
614 return TRUE;
615
616 fail:
617 /* Need to disable any partially binned triangle. This is easier
618 * than trying to locate all the triangle, shade-tile, etc,
619 * commands which may have been binned.
620 */
621 tri->inputs.disable = TRUE;
622 return FALSE;
623 }
624
625
626 /**
627 * Draw triangle if it's CW, cull otherwise.
628 */
629 static void triangle_cw( struct lp_setup_context *setup,
630 const float (*v0)[4],
631 const float (*v1)[4],
632 const float (*v2)[4] )
633 {
634 if (!do_triangle_ccw( setup, v1, v0, v2, !setup->ccw_is_frontface ))
635 {
636 lp_setup_flush_and_restart(setup);
637
638 if (!do_triangle_ccw( setup, v1, v0, v2, !setup->ccw_is_frontface ))
639 assert(0);
640 }
641 }
642
643
644 /**
645 * Draw triangle if it's CCW, cull otherwise.
646 */
647 static void triangle_ccw( struct lp_setup_context *setup,
648 const float (*v0)[4],
649 const float (*v1)[4],
650 const float (*v2)[4] )
651 {
652 if (!do_triangle_ccw( setup, v0, v1, v2, setup->ccw_is_frontface ))
653 {
654 lp_setup_flush_and_restart(setup);
655 if (!do_triangle_ccw( setup, v0, v1, v2, setup->ccw_is_frontface ))
656 assert(0);
657 }
658 }
659
660
661
662 /**
663 * Draw triangle whether it's CW or CCW.
664 */
665 static void triangle_both( struct lp_setup_context *setup,
666 const float (*v0)[4],
667 const float (*v1)[4],
668 const float (*v2)[4] )
669 {
670 /* edge vectors e = v0 - v2, f = v1 - v2 */
671 const float ex = v0[0][0] - v2[0][0];
672 const float ey = v0[0][1] - v2[0][1];
673 const float fx = v1[0][0] - v2[0][0];
674 const float fy = v1[0][1] - v2[0][1];
675
676 /* det = cross(e,f).z */
677 const float det = ex * fy - ey * fx;
678 if (det < 0.0f)
679 triangle_ccw( setup, v0, v1, v2 );
680 else if (det > 0.0f)
681 triangle_cw( setup, v0, v1, v2 );
682 }
683
684
685 static void triangle_nop( struct lp_setup_context *setup,
686 const float (*v0)[4],
687 const float (*v1)[4],
688 const float (*v2)[4] )
689 {
690 }
691
692
693 void
694 lp_setup_choose_triangle( struct lp_setup_context *setup )
695 {
696 switch (setup->cullmode) {
697 case PIPE_FACE_NONE:
698 setup->triangle = triangle_both;
699 break;
700 case PIPE_FACE_BACK:
701 setup->triangle = setup->ccw_is_frontface ? triangle_ccw : triangle_cw;
702 break;
703 case PIPE_FACE_FRONT:
704 setup->triangle = setup->ccw_is_frontface ? triangle_cw : triangle_ccw;
705 break;
706 default:
707 setup->triangle = triangle_nop;
708 break;
709 }
710 }