Merge branch 'mesa_7_7_branch'
[mesa.git] / src / gallium / drivers / i965 / brw_sf_emit.c
1 /*
2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
4 develop this 3D driver.
5
6 Permission is hereby granted, free of charge, to any person obtaining
7 a 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, sublicense, 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
16 portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
26 **********************************************************************/
27 /*
28 * Authors:
29 * Keith Whitwell <keith@tungstengraphics.com>
30 */
31
32
33 #include "brw_batchbuffer.h"
34
35 #include "brw_defines.h"
36 #include "brw_context.h"
37 #include "brw_eu.h"
38 #include "brw_util.h"
39 #include "brw_sf.h"
40
41
42 static struct brw_reg get_vert_attr(struct brw_sf_compile *c,
43 struct brw_reg vert,
44 GLuint attr)
45 {
46 GLuint off = attr / 2;
47 GLuint sub = attr % 2;
48
49 return brw_vec4_grf(vert.nr + off, sub * 4);
50 }
51
52
53 /***********************************************************************
54 * Twoside lighting
55 */
56 static void copy_bfc( struct brw_sf_compile *c,
57 struct brw_reg vert )
58 {
59 struct brw_compile *p = &c->func;
60
61 if (c->key.attr_col0 && c->key.attr_bfc0)
62 brw_MOV(p,
63 get_vert_attr(c, vert, c->key.attr_col0),
64 get_vert_attr(c, vert, c->key.attr_bfc0));
65
66 if (c->key.attr_col1 && c->key.attr_bfc1)
67 brw_MOV(p,
68 get_vert_attr(c, vert, c->key.attr_col1),
69 get_vert_attr(c, vert, c->key.attr_bfc1));
70 }
71
72
73 static void do_twoside_color( struct brw_sf_compile *c )
74 {
75 struct brw_compile *p = &c->func;
76 struct brw_instruction *if_insn;
77 GLuint backface_conditional = c->key.frontface_ccw ? BRW_CONDITIONAL_G : BRW_CONDITIONAL_L;
78
79 /* Already done in clip program:
80 */
81 if (c->key.primitive == SF_UNFILLED_TRIS)
82 return;
83
84 /* XXX: What happens if BFC isn't present? This could only happen
85 * for user-supplied vertex programs, as t_vp_build.c always does
86 * the right thing.
87 */
88 if (!(c->key.attr_col0 && c->key.attr_bfc0) &&
89 !(c->key.attr_col1 && c->key.attr_bfc1))
90 return;
91
92 /* Need to use BRW_EXECUTE_4 and also do an 4-wide compare in order
93 * to get all channels active inside the IF. In the clipping code
94 * we run with NoMask, so it's not an option and we can use
95 * BRW_EXECUTE_1 for all comparisions.
96 */
97 brw_push_insn_state(p);
98 brw_CMP(p, vec4(brw_null_reg()), backface_conditional, c->det, brw_imm_f(0));
99 if_insn = brw_IF(p, BRW_EXECUTE_4);
100 {
101 switch (c->nr_verts) {
102 case 3: copy_bfc(c, c->vert[2]);
103 case 2: copy_bfc(c, c->vert[1]);
104 case 1: copy_bfc(c, c->vert[0]);
105 }
106 }
107 brw_ENDIF(p, if_insn);
108 brw_pop_insn_state(p);
109 }
110
111
112
113 /***********************************************************************
114 * Flat shading
115 */
116
117 #define VERT_RESULT_COLOR_BITS ((1<<VERT_RESULT_COL0) | \
118 (1<<VERT_RESULT_COL1))
119
120 static void copy_colors( struct brw_sf_compile *c,
121 struct brw_reg dst,
122 struct brw_reg src)
123 {
124 struct brw_compile *p = &c->func;
125
126 if (c->key.attr_col0)
127 brw_MOV(p,
128 get_vert_attr(c, dst, c->key.attr_col0),
129 get_vert_attr(c, src, c->key.attr_col0));
130
131 if (c->key.attr_col1)
132 brw_MOV(p,
133 get_vert_attr(c, dst, c->key.attr_col1),
134 get_vert_attr(c, src, c->key.attr_col1));
135
136 }
137
138
139
140 /* Need to use a computed jump to copy flatshaded attributes as the
141 * vertices are ordered according to y-coordinate before reaching this
142 * point, so the PV could be anywhere.
143 */
144 static void do_flatshade_triangle( struct brw_sf_compile *c )
145 {
146 struct brw_compile *p = &c->func;
147 struct brw_reg ip = brw_ip_reg();
148 GLuint jmpi = 1;
149 GLuint nr = 0;
150
151 if (c->key.attr_col0)
152 nr++;
153
154 if (c->key.attr_col1)
155 nr++;
156
157 if (nr == 0)
158 return;
159
160 /* Already done in clip program:
161 */
162 if (c->key.primitive == SF_UNFILLED_TRIS)
163 return;
164
165 if (BRW_IS_IGDNG(p->brw))
166 jmpi = 2;
167
168 brw_push_insn_state(p);
169
170 brw_MUL(p, c->pv, c->pv, brw_imm_d(jmpi*(nr*2+1)));
171 brw_JMPI(p, ip, ip, c->pv);
172
173 copy_colors(c, c->vert[1], c->vert[0]);
174 copy_colors(c, c->vert[2], c->vert[0]);
175 brw_JMPI(p, ip, ip, brw_imm_d(jmpi*(nr*4+1)));
176
177 copy_colors(c, c->vert[0], c->vert[1]);
178 copy_colors(c, c->vert[2], c->vert[1]);
179 brw_JMPI(p, ip, ip, brw_imm_d(jmpi*nr*2));
180
181 copy_colors(c, c->vert[0], c->vert[2]);
182 copy_colors(c, c->vert[1], c->vert[2]);
183
184 brw_pop_insn_state(p);
185 }
186
187
188 static void do_flatshade_line( struct brw_sf_compile *c )
189 {
190 struct brw_compile *p = &c->func;
191 struct brw_reg ip = brw_ip_reg();
192 GLuint jmpi = 1;
193 GLuint nr = 0;
194
195 if (c->key.attr_col0)
196 nr++;
197
198 if (c->key.attr_col1)
199 nr++;
200
201 if (nr == 0)
202 return;
203
204 /* Already done in clip program:
205 */
206 if (c->key.primitive == SF_UNFILLED_TRIS)
207 return;
208
209 if (BRW_IS_IGDNG(p->brw))
210 jmpi = 2;
211
212 brw_push_insn_state(p);
213
214 brw_MUL(p, c->pv, c->pv, brw_imm_d(jmpi*(nr+1)));
215 brw_JMPI(p, ip, ip, c->pv);
216 copy_colors(c, c->vert[1], c->vert[0]);
217
218 brw_JMPI(p, ip, ip, brw_imm_ud(jmpi*nr));
219 copy_colors(c, c->vert[0], c->vert[1]);
220
221 brw_pop_insn_state(p);
222 }
223
224
225
226 /***********************************************************************
227 * Triangle setup.
228 */
229
230
231 static void alloc_regs( struct brw_sf_compile *c )
232 {
233 GLuint reg, i;
234
235 /* Values computed by fixed function unit:
236 */
237 c->pv = retype(brw_vec1_grf(1, 1), BRW_REGISTER_TYPE_D);
238 c->det = brw_vec1_grf(1, 2);
239 c->dx0 = brw_vec1_grf(1, 3);
240 c->dx2 = brw_vec1_grf(1, 4);
241 c->dy0 = brw_vec1_grf(1, 5);
242 c->dy2 = brw_vec1_grf(1, 6);
243
244 /* z and 1/w passed in seperately:
245 */
246 c->z[0] = brw_vec1_grf(2, 0);
247 c->inv_w[0] = brw_vec1_grf(2, 1);
248 c->z[1] = brw_vec1_grf(2, 2);
249 c->inv_w[1] = brw_vec1_grf(2, 3);
250 c->z[2] = brw_vec1_grf(2, 4);
251 c->inv_w[2] = brw_vec1_grf(2, 5);
252
253 /* The vertices:
254 */
255 reg = 3;
256 for (i = 0; i < c->nr_verts; i++) {
257 c->vert[i] = brw_vec8_grf(reg, 0);
258 reg += c->nr_attr_regs;
259 }
260
261 /* Temporaries, allocated after last vertex reg.
262 */
263 c->inv_det = brw_vec1_grf(reg, 0); reg++;
264 c->a1_sub_a0 = brw_vec8_grf(reg, 0); reg++;
265 c->a2_sub_a0 = brw_vec8_grf(reg, 0); reg++;
266 c->tmp = brw_vec8_grf(reg, 0); reg++;
267
268 /* Note grf allocation:
269 */
270 c->prog_data.total_grf = reg;
271
272
273 /* Outputs of this program - interpolation coefficients for
274 * rasterization:
275 */
276 c->m1Cx = brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE, 1, 0);
277 c->m2Cy = brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE, 2, 0);
278 c->m3C0 = brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE, 3, 0);
279 }
280
281
282 static void copy_z_inv_w( struct brw_sf_compile *c )
283 {
284 struct brw_compile *p = &c->func;
285 GLuint i;
286
287 brw_push_insn_state(p);
288
289 /* Copy both scalars with a single MOV:
290 */
291 for (i = 0; i < c->nr_verts; i++)
292 brw_MOV(p, vec2(suboffset(c->vert[i], 2)), vec2(c->z[i]));
293
294 brw_pop_insn_state(p);
295 }
296
297
298 static void invert_det( struct brw_sf_compile *c)
299 {
300 /* Looks like we invert all 8 elements just to get 1/det in
301 * position 2 !?!
302 */
303 brw_math(&c->func,
304 c->inv_det,
305 BRW_MATH_FUNCTION_INV,
306 BRW_MATH_SATURATE_NONE,
307 0,
308 c->det,
309 BRW_MATH_DATA_SCALAR,
310 BRW_MATH_PRECISION_FULL);
311
312 }
313
314
315 /* Two attributes packed into a wide register. Figure out if either
316 * or both of them need linear/perspective interpolation. Constant
317 * regs are left as-is.
318 */
319 static GLboolean calculate_masks( struct brw_sf_compile *c,
320 GLuint reg,
321 GLushort *pc,
322 GLushort *pc_persp,
323 GLushort *pc_linear)
324 {
325 GLboolean is_last_attr = (reg == c->nr_setup_regs - 1);
326 GLuint persp_mask = c->key.persp_attrs;
327 GLuint linear_mask = (c->key.persp_attrs | c->key.linear_attrs);
328
329 *pc_persp = 0;
330 *pc_linear = 0;
331 *pc = 0xf;
332
333 if (persp_mask & (1 << (reg*2)))
334 *pc_persp = 0xf;
335
336 if (linear_mask & (1 << (reg*2)))
337 *pc_linear = 0xf;
338
339 /* Maybe only processs one attribute on the final round:
340 */
341 if (reg*2+1 < c->nr_setup_attrs) {
342 *pc |= 0xf0;
343
344 if (persp_mask & (1 << (reg*2+1)))
345 *pc_persp |= 0xf0;
346
347 if (linear_mask & (1 << (reg*2+1)))
348 *pc_linear |= 0xf0;
349 }
350
351 return is_last_attr;
352 }
353
354
355 void brw_emit_null_setup( struct brw_sf_compile *c )
356 {
357 struct brw_compile *p = &c->func;
358
359 /* m0 is implicitly copied from r0 in the send instruction:
360 */
361 brw_urb_WRITE(p,
362 brw_null_reg(),
363 0,
364 brw_vec8_grf(0, 0), /* r0, will be copied to m0 */
365 0, /* allocate */
366 1, /* used */
367 1, /* msg len */
368 0, /* response len */
369 1, /* eot */
370 1, /* writes complete */
371 0, /* offset */
372 BRW_URB_SWIZZLE_TRANSPOSE);
373 }
374
375 void brw_emit_tri_setup( struct brw_sf_compile *c, GLboolean allocate)
376 {
377 struct brw_compile *p = &c->func;
378 GLuint i;
379
380 c->nr_verts = 3;
381
382 if (allocate)
383 alloc_regs(c);
384
385 invert_det(c);
386 copy_z_inv_w(c);
387
388 if (c->key.do_twoside_color)
389 do_twoside_color(c);
390
391 if (c->key.do_flat_shading)
392 do_flatshade_triangle(c);
393
394
395 for (i = 0; i < c->nr_setup_regs; i++)
396 {
397 /* Pair of incoming attributes:
398 */
399 struct brw_reg a0 = offset(c->vert[0], i);
400 struct brw_reg a1 = offset(c->vert[1], i);
401 struct brw_reg a2 = offset(c->vert[2], i);
402 GLushort pc, pc_persp, pc_linear;
403 GLboolean last = calculate_masks(c, i, &pc, &pc_persp, &pc_linear);
404
405 if (pc_persp)
406 {
407 brw_set_predicate_control_flag_value(p, pc_persp);
408 brw_MUL(p, a0, a0, c->inv_w[0]);
409 brw_MUL(p, a1, a1, c->inv_w[1]);
410 brw_MUL(p, a2, a2, c->inv_w[2]);
411 }
412
413
414 /* Calculate coefficients for interpolated values:
415 */
416 if (pc_linear)
417 {
418 brw_set_predicate_control_flag_value(p, pc_linear);
419
420 brw_ADD(p, c->a1_sub_a0, a1, negate(a0));
421 brw_ADD(p, c->a2_sub_a0, a2, negate(a0));
422
423 /* calculate dA/dx
424 */
425 brw_MUL(p, brw_null_reg(), c->a1_sub_a0, c->dy2);
426 brw_MAC(p, c->tmp, c->a2_sub_a0, negate(c->dy0));
427 brw_MUL(p, c->m1Cx, c->tmp, c->inv_det);
428
429 /* calculate dA/dy
430 */
431 brw_MUL(p, brw_null_reg(), c->a2_sub_a0, c->dx0);
432 brw_MAC(p, c->tmp, c->a1_sub_a0, negate(c->dx2));
433 brw_MUL(p, c->m2Cy, c->tmp, c->inv_det);
434 }
435
436 {
437 brw_set_predicate_control_flag_value(p, pc);
438 /* start point for interpolation
439 */
440 brw_MOV(p, c->m3C0, a0);
441
442 /* Copy m0..m3 to URB. m0 is implicitly copied from r0 in
443 * the send instruction:
444 */
445 brw_urb_WRITE(p,
446 brw_null_reg(),
447 0,
448 brw_vec8_grf(0, 0), /* r0, will be copied to m0 */
449 0, /* allocate */
450 1, /* used */
451 4, /* msg len */
452 0, /* response len */
453 last, /* eot */
454 last, /* writes complete */
455 i*4, /* offset */
456 BRW_URB_SWIZZLE_TRANSPOSE); /* XXX: Swizzle control "SF to windower" */
457 }
458 }
459 }
460
461
462
463 void brw_emit_line_setup( struct brw_sf_compile *c, GLboolean allocate)
464 {
465 struct brw_compile *p = &c->func;
466 GLuint i;
467
468
469 c->nr_verts = 2;
470
471 if (allocate)
472 alloc_regs(c);
473
474 invert_det(c);
475 copy_z_inv_w(c);
476
477 if (c->key.do_flat_shading)
478 do_flatshade_line(c);
479
480 for (i = 0; i < c->nr_setup_regs; i++)
481 {
482 /* Pair of incoming attributes:
483 */
484 struct brw_reg a0 = offset(c->vert[0], i);
485 struct brw_reg a1 = offset(c->vert[1], i);
486 GLushort pc, pc_persp, pc_linear;
487 GLboolean last = calculate_masks(c, i, &pc, &pc_persp, &pc_linear);
488
489 if (pc_persp)
490 {
491 brw_set_predicate_control_flag_value(p, pc_persp);
492 brw_MUL(p, a0, a0, c->inv_w[0]);
493 brw_MUL(p, a1, a1, c->inv_w[1]);
494 }
495
496 /* Calculate coefficients for position, color:
497 */
498 if (pc_linear) {
499 brw_set_predicate_control_flag_value(p, pc_linear);
500
501 brw_ADD(p, c->a1_sub_a0, a1, negate(a0));
502
503 brw_MUL(p, c->tmp, c->a1_sub_a0, c->dx0);
504 brw_MUL(p, c->m1Cx, c->tmp, c->inv_det);
505
506 brw_MUL(p, c->tmp, c->a1_sub_a0, c->dy0);
507 brw_MUL(p, c->m2Cy, c->tmp, c->inv_det);
508 }
509
510 {
511 brw_set_predicate_control_flag_value(p, pc);
512
513 /* start point for interpolation
514 */
515 brw_MOV(p, c->m3C0, a0);
516
517 /* Copy m0..m3 to URB.
518 */
519 brw_urb_WRITE(p,
520 brw_null_reg(),
521 0,
522 brw_vec8_grf(0, 0),
523 0, /* allocate */
524 1, /* used */
525 4, /* msg len */
526 0, /* response len */
527 last, /* eot */
528 last, /* writes complete */
529 i*4, /* urb destination offset */
530 BRW_URB_SWIZZLE_TRANSPOSE);
531 }
532 }
533 }
534
535 void brw_emit_point_sprite_setup( struct brw_sf_compile *c, GLboolean allocate)
536 {
537 struct brw_compile *p = &c->func;
538 GLuint i;
539
540 c->nr_verts = 1;
541
542 if (allocate)
543 alloc_regs(c);
544
545 copy_z_inv_w(c);
546
547 for (i = 0; i < c->nr_setup_regs; i++)
548 {
549 /* XXX: only seems to check point_coord_replace_attrs for every
550 * second attribute?!?
551 */
552 boolean coord_replace = !!(c->key.point_coord_replace_attrs & (1<<(2*i)));
553 struct brw_reg a0 = offset(c->vert[0], i);
554 GLushort pc, pc_persp, pc_linear;
555 GLboolean last = calculate_masks(c, i, &pc, &pc_persp, &pc_linear);
556
557 if (pc_persp)
558 {
559 if (coord_replace) {
560 brw_set_predicate_control_flag_value(p, pc_persp);
561 brw_MUL(p, a0, a0, c->inv_w[0]);
562 }
563 }
564
565 if (coord_replace) {
566 /* Caculate 1.0/PointWidth */
567 brw_math(&c->func,
568 c->tmp,
569 BRW_MATH_FUNCTION_INV,
570 BRW_MATH_SATURATE_NONE,
571 0,
572 c->dx0,
573 BRW_MATH_DATA_SCALAR,
574 BRW_MATH_PRECISION_FULL);
575
576 if (c->key.sprite_origin_lower_left) {
577 brw_MUL(p, c->m1Cx, c->tmp, c->inv_w[0]);
578 brw_MOV(p, vec1(suboffset(c->m1Cx, 1)), brw_imm_f(0.0));
579 brw_MUL(p, c->m2Cy, c->tmp, negate(c->inv_w[0]));
580 brw_MOV(p, vec1(suboffset(c->m2Cy, 0)), brw_imm_f(0.0));
581 }
582 else {
583 brw_MUL(p, c->m1Cx, c->tmp, c->inv_w[0]);
584 brw_MOV(p, vec1(suboffset(c->m1Cx, 1)), brw_imm_f(0.0));
585 brw_MUL(p, c->m2Cy, c->tmp, c->inv_w[0]);
586 brw_MOV(p, vec1(suboffset(c->m2Cy, 0)), brw_imm_f(0.0));
587 }
588 }
589 else {
590 brw_MOV(p, c->m1Cx, brw_imm_ud(0));
591 brw_MOV(p, c->m2Cy, brw_imm_ud(0));
592 }
593
594 {
595 brw_set_predicate_control_flag_value(p, pc);
596 if (coord_replace) {
597 if (c->key.sprite_origin_lower_left) {
598 brw_MUL(p, c->m3C0, c->inv_w[0], brw_imm_f(1.0));
599 brw_MOV(p, vec1(suboffset(c->m3C0, 0)), brw_imm_f(0.0));
600 }
601 else {
602 brw_MOV(p, c->m3C0, brw_imm_f(0.0));
603 }
604 }
605 else {
606 brw_MOV(p, c->m3C0, a0); /* constant value */
607 }
608
609 /* Copy m0..m3 to URB.
610 */
611 brw_urb_WRITE(p,
612 brw_null_reg(),
613 0,
614 brw_vec8_grf(0, 0),
615 0, /* allocate */
616 1, /* used */
617 4, /* msg len */
618 0, /* response len */
619 last, /* eot */
620 last, /* writes complete */
621 i*4, /* urb destination offset */
622 BRW_URB_SWIZZLE_TRANSPOSE);
623 }
624 }
625 }
626
627 /* Points setup - several simplifications as all attributes are
628 * constant across the face of the point (point sprites excluded!)
629 */
630 void brw_emit_point_setup( struct brw_sf_compile *c, GLboolean allocate)
631 {
632 struct brw_compile *p = &c->func;
633 GLuint i;
634
635 c->nr_verts = 1;
636
637 if (allocate)
638 alloc_regs(c);
639
640 copy_z_inv_w(c);
641
642 brw_MOV(p, c->m1Cx, brw_imm_ud(0)); /* zero - move out of loop */
643 brw_MOV(p, c->m2Cy, brw_imm_ud(0)); /* zero - move out of loop */
644
645 for (i = 0; i < c->nr_setup_regs; i++)
646 {
647 struct brw_reg a0 = offset(c->vert[0], i);
648 GLushort pc, pc_persp, pc_linear;
649 GLboolean last = calculate_masks(c, i, &pc, &pc_persp, &pc_linear);
650
651 if (pc_persp)
652 {
653 /* This seems odd as the values are all constant, but the
654 * fragment shader will be expecting it:
655 */
656 brw_set_predicate_control_flag_value(p, pc_persp);
657 brw_MUL(p, a0, a0, c->inv_w[0]);
658 }
659
660
661 /* The delta values are always zero, just send the starting
662 * coordinate. Again, this is to fit in with the interpolation
663 * code in the fragment shader.
664 */
665 {
666 brw_set_predicate_control_flag_value(p, pc);
667
668 brw_MOV(p, c->m3C0, a0); /* constant value */
669
670 /* Copy m0..m3 to URB.
671 */
672 brw_urb_WRITE(p,
673 brw_null_reg(),
674 0,
675 brw_vec8_grf(0, 0),
676 0, /* allocate */
677 1, /* used */
678 4, /* msg len */
679 0, /* response len */
680 last, /* eot */
681 last, /* writes complete */
682 i*4, /* urb destination offset */
683 BRW_URB_SWIZZLE_TRANSPOSE);
684 }
685 }
686 }
687
688 void brw_emit_anyprim_setup( struct brw_sf_compile *c )
689 {
690 struct brw_compile *p = &c->func;
691 struct brw_reg ip = brw_ip_reg();
692 struct brw_reg payload_prim = brw_uw1_reg(BRW_GENERAL_REGISTER_FILE, 1, 0);
693 struct brw_reg payload_attr = get_element_ud(brw_vec1_reg(BRW_GENERAL_REGISTER_FILE, 1, 0), 0);
694 struct brw_reg primmask;
695 struct brw_instruction *jmp;
696 struct brw_reg v1_null_ud = vec1(retype(brw_null_reg(), BRW_REGISTER_TYPE_UD));
697
698 GLuint saveflag;
699
700 c->nr_verts = 3;
701 alloc_regs(c);
702
703 primmask = retype(get_element(c->tmp, 0), BRW_REGISTER_TYPE_UD);
704
705 brw_MOV(p, primmask, brw_imm_ud(1));
706 brw_SHL(p, primmask, primmask, payload_prim);
707
708 brw_set_conditionalmod(p, BRW_CONDITIONAL_Z);
709 brw_AND(p, v1_null_ud, primmask, brw_imm_ud((1<<_3DPRIM_TRILIST) |
710 (1<<_3DPRIM_TRISTRIP) |
711 (1<<_3DPRIM_TRIFAN) |
712 (1<<_3DPRIM_TRISTRIP_REVERSE) |
713 (1<<_3DPRIM_POLYGON) |
714 (1<<_3DPRIM_RECTLIST) |
715 (1<<_3DPRIM_TRIFAN_NOSTIPPLE)));
716 jmp = brw_JMPI(p, ip, ip, brw_imm_d(0));
717 {
718 saveflag = p->flag_value;
719 brw_push_insn_state(p);
720 brw_emit_tri_setup( c, GL_FALSE );
721 brw_pop_insn_state(p);
722 p->flag_value = saveflag;
723 /* note - thread killed in subroutine, so must
724 * restore the flag which is changed when building
725 * the subroutine. fix #13240
726 */
727 }
728 brw_land_fwd_jump(p, jmp);
729
730 brw_set_conditionalmod(p, BRW_CONDITIONAL_Z);
731 brw_AND(p, v1_null_ud, primmask, brw_imm_ud((1<<_3DPRIM_LINELIST) |
732 (1<<_3DPRIM_LINESTRIP) |
733 (1<<_3DPRIM_LINELOOP) |
734 (1<<_3DPRIM_LINESTRIP_CONT) |
735 (1<<_3DPRIM_LINESTRIP_BF) |
736 (1<<_3DPRIM_LINESTRIP_CONT_BF)));
737 jmp = brw_JMPI(p, ip, ip, brw_imm_d(0));
738 {
739 saveflag = p->flag_value;
740 brw_push_insn_state(p);
741 brw_emit_line_setup( c, GL_FALSE );
742 brw_pop_insn_state(p);
743 p->flag_value = saveflag;
744 /* note - thread killed in subroutine */
745 }
746 brw_land_fwd_jump(p, jmp);
747
748 brw_set_conditionalmod(p, BRW_CONDITIONAL_Z);
749 brw_AND(p, v1_null_ud, payload_attr, brw_imm_ud(1<<BRW_SPRITE_POINT_ENABLE));
750 jmp = brw_JMPI(p, ip, ip, brw_imm_d(0));
751 {
752 saveflag = p->flag_value;
753 brw_push_insn_state(p);
754 brw_emit_point_sprite_setup( c, GL_FALSE );
755 brw_pop_insn_state(p);
756 p->flag_value = saveflag;
757 }
758 brw_land_fwd_jump(p, jmp);
759
760 brw_emit_point_setup( c, GL_FALSE );
761 }
762
763
764
765