2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
4 develop this 3D driver.
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:
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.
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.
26 **********************************************************************/
29 * Keith Whitwell <keith@tungstengraphics.com>
32 #include "brw_defines.h"
33 #include "brw_context.h"
38 static struct brw_reg
get_tmp( struct brw_clip_compile
*c
)
40 struct brw_reg tmp
= brw_vec4_grf(c
->last_tmp
, 0);
42 if (++c
->last_tmp
> c
->prog_data
.total_grf
)
43 c
->prog_data
.total_grf
= c
->last_tmp
;
48 static void release_tmps( struct brw_clip_compile
*c
)
50 c
->last_tmp
= c
->first_tmp
;
54 void brw_clip_tri_alloc_regs( struct brw_clip_compile
*c
,
59 /* Register usage is static, precompute here:
61 c
->reg
.R0
= retype(brw_vec8_grf(i
, 0), BRW_REGISTER_TYPE_UD
); i
++;
63 if (c
->key
.nr_userclip
) {
64 c
->reg
.fixed_planes
= brw_vec4_grf(i
, 0);
65 i
+= (6 + c
->key
.nr_userclip
+ 1) / 2;
67 c
->prog_data
.curb_read_length
= (6 + c
->key
.nr_userclip
+ 1) / 2;
70 c
->prog_data
.curb_read_length
= 0;
73 /* Payload vertices plus space for more generated vertices:
75 for (j
= 0; j
< nr_verts
; j
++) {
76 c
->reg
.vertex
[j
] = brw_vec4_grf(i
, 0);
80 if (c
->nr_attrs
& 1) {
81 for (j
= 0; j
< 3; j
++) {
82 unsigned delta
= c
->nr_attrs
*16 + 32;
83 brw_MOV(&c
->func
, byte_offset(c
->reg
.vertex
[j
], delta
), brw_imm_f(0));
87 c
->reg
.t
= brw_vec1_grf(i
, 0);
88 c
->reg
.loopcount
= retype(brw_vec1_grf(i
, 1), BRW_REGISTER_TYPE_UD
);
89 c
->reg
.nr_verts
= retype(brw_vec1_grf(i
, 2), BRW_REGISTER_TYPE_UD
);
90 c
->reg
.planemask
= retype(brw_vec1_grf(i
, 3), BRW_REGISTER_TYPE_UD
);
91 c
->reg
.plane_equation
= brw_vec4_grf(i
, 4);
94 c
->reg
.dpPrev
= brw_vec1_grf(i
, 0); /* fixme - dp4 will clobber r.1,2,3 */
95 c
->reg
.dp
= brw_vec1_grf(i
, 4);
98 c
->reg
.inlist
= brw_uw16_reg(BRW_GENERAL_REGISTER_FILE
, i
, 0);
101 c
->reg
.outlist
= brw_uw16_reg(BRW_GENERAL_REGISTER_FILE
, i
, 0);
104 c
->reg
.freelist
= brw_uw16_reg(BRW_GENERAL_REGISTER_FILE
, i
, 0);
107 if (!c
->key
.nr_userclip
) {
108 c
->reg
.fixed_planes
= brw_vec8_grf(i
, 0);
112 if (c
->key
.do_unfilled
) {
113 c
->reg
.dir
= brw_vec4_grf(i
, 0);
114 c
->reg
.offset
= brw_vec4_grf(i
, 4);
116 c
->reg
.tmp0
= brw_vec4_grf(i
, 0);
117 c
->reg
.tmp1
= brw_vec4_grf(i
, 4);
124 c
->prog_data
.urb_read_length
= c
->nr_regs
; /* ? */
125 c
->prog_data
.total_grf
= i
;
130 void brw_clip_tri_init_vertices( struct brw_clip_compile
*c
)
132 struct brw_compile
*p
= &c
->func
;
133 struct brw_reg tmp0
= c
->reg
.loopcount
; /* handy temporary */
134 struct brw_instruction
*is_rev
;
136 /* Initial list of indices for incoming vertexes:
138 brw_AND(p
, tmp0
, get_element_ud(c
->reg
.R0
, 2), brw_imm_ud(PRIM_MASK
));
140 vec1(brw_null_reg()),
143 brw_imm_ud(_3DPRIM_TRISTRIP_REVERSE
));
145 /* XXX: Is there an easier way to do this? Need to reverse every
146 * second tristrip element: Can ignore sometimes?
148 is_rev
= brw_IF(p
, BRW_EXECUTE_1
);
150 brw_MOV(p
, get_element(c
->reg
.inlist
, 0), brw_address(c
->reg
.vertex
[1]) );
151 brw_MOV(p
, get_element(c
->reg
.inlist
, 1), brw_address(c
->reg
.vertex
[0]) );
152 if (c
->need_direction
)
153 brw_MOV(p
, c
->reg
.dir
, brw_imm_f(-1));
155 is_rev
= brw_ELSE(p
, is_rev
);
157 brw_MOV(p
, get_element(c
->reg
.inlist
, 0), brw_address(c
->reg
.vertex
[0]) );
158 brw_MOV(p
, get_element(c
->reg
.inlist
, 1), brw_address(c
->reg
.vertex
[1]) );
159 if (c
->need_direction
)
160 brw_MOV(p
, c
->reg
.dir
, brw_imm_f(1));
162 brw_ENDIF(p
, is_rev
);
164 brw_MOV(p
, get_element(c
->reg
.inlist
, 2), brw_address(c
->reg
.vertex
[2]) );
165 brw_MOV(p
, brw_vec8_grf(c
->reg
.outlist
.nr
, 0), brw_imm_f(0));
166 brw_MOV(p
, c
->reg
.nr_verts
, brw_imm_ud(3));
171 void brw_clip_tri_flat_shade( struct brw_clip_compile
*c
)
173 struct brw_compile
*p
= &c
->func
;
174 struct brw_instruction
*is_poly
;
175 struct brw_reg tmp0
= c
->reg
.loopcount
; /* handy temporary */
177 brw_AND(p
, tmp0
, get_element_ud(c
->reg
.R0
, 2), brw_imm_ud(PRIM_MASK
));
179 vec1(brw_null_reg()),
182 brw_imm_ud(_3DPRIM_POLYGON
));
184 is_poly
= brw_IF(p
, BRW_EXECUTE_1
);
186 brw_clip_copy_colors(c
, 1, 0);
187 brw_clip_copy_colors(c
, 2, 0);
189 is_poly
= brw_ELSE(p
, is_poly
);
191 brw_clip_copy_colors(c
, 0, 2);
192 brw_clip_copy_colors(c
, 1, 2);
194 brw_ENDIF(p
, is_poly
);
199 /* Use mesa's clipping algorithms, translated to GEN4 assembly.
201 void brw_clip_tri( struct brw_clip_compile
*c
)
204 struct brw_compile
*p
= &c
->func
;
205 struct brw_indirect vtx
= brw_indirect(0, 0);
206 struct brw_indirect vtxPrev
= brw_indirect(1, 0);
207 struct brw_indirect vtxOut
= brw_indirect(2, 0);
208 struct brw_indirect plane_ptr
= brw_indirect(3, 0);
209 struct brw_indirect inlist_ptr
= brw_indirect(4, 0);
210 struct brw_indirect outlist_ptr
= brw_indirect(5, 0);
211 struct brw_indirect freelist_ptr
= brw_indirect(6, 0);
212 struct brw_instruction
*plane_loop
;
213 struct brw_instruction
*plane_active
;
214 struct brw_instruction
*vertex_loop
;
215 struct brw_instruction
*next_test
;
216 struct brw_instruction
*prev_test
;
218 brw_MOV(p
, get_addr_reg(vtxPrev
), brw_address(c
->reg
.vertex
[2]) );
219 brw_MOV(p
, get_addr_reg(plane_ptr
), brw_clip_plane0_address(c
));
220 brw_MOV(p
, get_addr_reg(inlist_ptr
), brw_address(c
->reg
.inlist
));
221 brw_MOV(p
, get_addr_reg(outlist_ptr
), brw_address(c
->reg
.outlist
));
223 brw_MOV(p
, get_addr_reg(freelist_ptr
), brw_address(c
->reg
.vertex
[3]) );
225 plane_loop
= brw_DO(p
, BRW_EXECUTE_1
);
227 /* if (planemask & 1)
229 brw_set_conditionalmod(p
, BRW_CONDITIONAL_NZ
);
230 brw_AND(p
, vec1(brw_null_reg()), c
->reg
.planemask
, brw_imm_ud(1));
232 plane_active
= brw_IF(p
, BRW_EXECUTE_1
);
234 /* vtxOut = freelist_ptr++
236 brw_MOV(p
, get_addr_reg(vtxOut
), get_addr_reg(freelist_ptr
) );
237 brw_ADD(p
, get_addr_reg(freelist_ptr
), get_addr_reg(freelist_ptr
), brw_imm_uw(c
->nr_regs
* REG_SIZE
));
239 if (c
->key
.nr_userclip
)
240 brw_MOV(p
, c
->reg
.plane_equation
, deref_4f(plane_ptr
, 0));
242 brw_MOV(p
, c
->reg
.plane_equation
, deref_4b(plane_ptr
, 0));
244 brw_MOV(p
, c
->reg
.loopcount
, c
->reg
.nr_verts
);
245 brw_MOV(p
, c
->reg
.nr_verts
, brw_imm_ud(0));
247 vertex_loop
= brw_DO(p
, BRW_EXECUTE_1
);
251 brw_MOV(p
, get_addr_reg(vtx
), deref_1uw(inlist_ptr
, 0));
253 /* IS_NEGATIVE(prev) */
254 brw_set_conditionalmod(p
, BRW_CONDITIONAL_L
);
255 brw_DP4(p
, vec4(c
->reg
.dpPrev
), deref_4f(vtxPrev
, c
->offset
[VERT_RESULT_HPOS
]), c
->reg
.plane_equation
);
256 prev_test
= brw_IF(p
, BRW_EXECUTE_1
);
260 brw_set_conditionalmod(p
, BRW_CONDITIONAL_GE
);
261 brw_DP4(p
, vec4(c
->reg
.dp
), deref_4f(vtx
, c
->offset
[VERT_RESULT_HPOS
]), c
->reg
.plane_equation
);
262 next_test
= brw_IF(p
, BRW_EXECUTE_1
);
267 brw_ADD(p
, c
->reg
.t
, c
->reg
.dpPrev
, negate(c
->reg
.dp
));
268 brw_math_invert(p
, c
->reg
.t
, c
->reg
.t
);
269 brw_MUL(p
, c
->reg
.t
, c
->reg
.t
, c
->reg
.dpPrev
);
271 /* If (vtxOut == 0) vtxOut = vtxPrev
273 brw_CMP(p
, vec1(brw_null_reg()), BRW_CONDITIONAL_EQ
, get_addr_reg(vtxOut
), brw_imm_uw(0) );
274 brw_MOV(p
, get_addr_reg(vtxOut
), get_addr_reg(vtxPrev
) );
275 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
277 brw_clip_interp_vertex(c
, vtxOut
, vtxPrev
, vtx
, c
->reg
.t
, FALSE
);
279 /* *outlist_ptr++ = vtxOut;
283 brw_MOV(p
, deref_1uw(outlist_ptr
, 0), get_addr_reg(vtxOut
));
284 brw_ADD(p
, get_addr_reg(outlist_ptr
), get_addr_reg(outlist_ptr
), brw_imm_uw(sizeof(short)));
285 brw_ADD(p
, c
->reg
.nr_verts
, c
->reg
.nr_verts
, brw_imm_ud(1));
286 brw_MOV(p
, get_addr_reg(vtxOut
), brw_imm_uw(0) );
288 brw_ENDIF(p
, next_test
);
291 prev_test
= brw_ELSE(p
, prev_test
);
293 /* *outlist_ptr++ = vtxPrev;
296 brw_MOV(p
, deref_1uw(outlist_ptr
, 0), get_addr_reg(vtxPrev
));
297 brw_ADD(p
, get_addr_reg(outlist_ptr
), get_addr_reg(outlist_ptr
), brw_imm_uw(sizeof(short)));
298 brw_ADD(p
, c
->reg
.nr_verts
, c
->reg
.nr_verts
, brw_imm_ud(1));
302 brw_set_conditionalmod(p
, BRW_CONDITIONAL_L
);
303 brw_DP4(p
, vec4(c
->reg
.dp
), deref_4f(vtx
, c
->offset
[VERT_RESULT_HPOS
]), c
->reg
.plane_equation
);
304 next_test
= brw_IF(p
, BRW_EXECUTE_1
);
306 /* Going out of bounds. Avoid division by zero as we
307 * know dp != dpPrev from DIFFERENT_SIGNS, above.
309 brw_ADD(p
, c
->reg
.t
, c
->reg
.dp
, negate(c
->reg
.dpPrev
));
310 brw_math_invert(p
, c
->reg
.t
, c
->reg
.t
);
311 brw_MUL(p
, c
->reg
.t
, c
->reg
.t
, c
->reg
.dp
);
313 /* If (vtxOut == 0) vtxOut = vtx
315 brw_CMP(p
, vec1(brw_null_reg()), BRW_CONDITIONAL_EQ
, get_addr_reg(vtxOut
), brw_imm_uw(0) );
316 brw_MOV(p
, get_addr_reg(vtxOut
), get_addr_reg(vtx
) );
317 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
319 brw_clip_interp_vertex(c
, vtxOut
, vtx
, vtxPrev
, c
->reg
.t
, TRUE
);
321 /* *outlist_ptr++ = vtxOut;
325 brw_MOV(p
, deref_1uw(outlist_ptr
, 0), get_addr_reg(vtxOut
));
326 brw_ADD(p
, get_addr_reg(outlist_ptr
), get_addr_reg(outlist_ptr
), brw_imm_uw(sizeof(short)));
327 brw_ADD(p
, c
->reg
.nr_verts
, c
->reg
.nr_verts
, brw_imm_ud(1));
328 brw_MOV(p
, get_addr_reg(vtxOut
), brw_imm_uw(0) );
330 brw_ENDIF(p
, next_test
);
332 brw_ENDIF(p
, prev_test
);
337 brw_MOV(p
, get_addr_reg(vtxPrev
), get_addr_reg(vtx
));
338 brw_ADD(p
, get_addr_reg(inlist_ptr
), get_addr_reg(inlist_ptr
), brw_imm_uw(sizeof(short)));
340 /* while (--loopcount != 0)
342 brw_set_conditionalmod(p
, BRW_CONDITIONAL_NZ
);
343 brw_ADD(p
, c
->reg
.loopcount
, c
->reg
.loopcount
, brw_imm_d(-1));
345 brw_WHILE(p
, vertex_loop
);
347 /* vtxPrev = *(outlist_ptr-1) OR: outlist[nr_verts-1]
349 * inlist_ptr = &inlist[0]
350 * outlist_ptr = &outlist[0]
352 brw_ADD(p
, get_addr_reg(outlist_ptr
), get_addr_reg(outlist_ptr
), brw_imm_w(-2));
353 brw_MOV(p
, get_addr_reg(vtxPrev
), deref_1uw(outlist_ptr
, 0));
354 brw_MOV(p
, brw_vec8_grf(c
->reg
.inlist
.nr
, 0), brw_vec8_grf(c
->reg
.outlist
.nr
, 0));
355 brw_MOV(p
, get_addr_reg(inlist_ptr
), brw_address(c
->reg
.inlist
));
356 brw_MOV(p
, get_addr_reg(outlist_ptr
), brw_address(c
->reg
.outlist
));
358 brw_ENDIF(p
, plane_active
);
362 brw_ADD(p
, get_addr_reg(plane_ptr
), get_addr_reg(plane_ptr
), brw_clip_plane_stride(c
));
367 vec1(brw_null_reg()),
372 /* && (planemask>>=1) != 0
374 brw_set_conditionalmod(p
, BRW_CONDITIONAL_NZ
);
375 brw_SHR(p
, c
->reg
.planemask
, c
->reg
.planemask
, brw_imm_ud(1));
377 brw_WHILE(p
, plane_loop
);
385 void brw_clip_tri_emit_polygon(struct brw_clip_compile
*c
)
387 struct brw_compile
*p
= &c
->func
;
388 struct brw_instruction
*loop
, *if_insn
;
390 /* for (loopcount = nr_verts-2; loopcount > 0; loopcount--)
392 brw_set_conditionalmod(p
, BRW_CONDITIONAL_G
);
398 if_insn
= brw_IF(p
, BRW_EXECUTE_1
);
400 struct brw_indirect v0
= brw_indirect(0, 0);
401 struct brw_indirect vptr
= brw_indirect(1, 0);
403 brw_MOV(p
, get_addr_reg(vptr
), brw_address(c
->reg
.inlist
));
404 brw_MOV(p
, get_addr_reg(v0
), deref_1uw(vptr
, 0));
406 brw_clip_emit_vue(c
, v0
, 1, 0, ((_3DPRIM_TRIFAN
<< 2) | R02_PRIM_START
));
408 brw_ADD(p
, get_addr_reg(vptr
), get_addr_reg(vptr
), brw_imm_uw(2));
409 brw_MOV(p
, get_addr_reg(v0
), deref_1uw(vptr
, 0));
411 loop
= brw_DO(p
, BRW_EXECUTE_1
);
413 brw_clip_emit_vue(c
, v0
, 1, 0, (_3DPRIM_TRIFAN
<< 2));
415 brw_ADD(p
, get_addr_reg(vptr
), get_addr_reg(vptr
), brw_imm_uw(2));
416 brw_MOV(p
, get_addr_reg(v0
), deref_1uw(vptr
, 0));
418 brw_set_conditionalmod(p
, BRW_CONDITIONAL_NZ
);
419 brw_ADD(p
, c
->reg
.loopcount
, c
->reg
.loopcount
, brw_imm_d(-1));
423 brw_clip_emit_vue(c
, v0
, 0, 1, ((_3DPRIM_TRIFAN
<< 2) | R02_PRIM_END
));
425 brw_ENDIF(p
, if_insn
);
428 static void do_clip_tri( struct brw_clip_compile
*c
)
430 brw_clip_init_planes(c
);
436 static void maybe_do_clip_tri( struct brw_clip_compile
*c
)
438 struct brw_compile
*p
= &c
->func
;
439 struct brw_instruction
*do_clip
;
441 brw_CMP(p
, vec1(brw_null_reg()), BRW_CONDITIONAL_NZ
, c
->reg
.planemask
, brw_imm_ud(0));
442 do_clip
= brw_IF(p
, BRW_EXECUTE_1
);
446 brw_ENDIF(p
, do_clip
);
449 static void brw_clip_test( struct brw_clip_compile
*c
)
452 struct brw_reg t
= retype(get_tmp(c
), BRW_REGISTER_TYPE_UD
);
453 struct brw_reg t1
= retype(get_tmp(c
), BRW_REGISTER_TYPE_UD
);
454 struct brw_reg t2
= retype(get_tmp(c
), BRW_REGISTER_TYPE_UD
);
455 struct brw_reg t3
= retype(get_tmp(c
), BRW_REGISTER_TYPE_UD
);
457 struct brw_reg v0
= get_tmp(c
);
458 struct brw_reg v1
= get_tmp(c
);
459 struct brw_reg v2
= get_tmp(c
);
461 struct brw_indirect vt0
= brw_indirect(0, 0);
462 struct brw_indirect vt1
= brw_indirect(1, 0);
463 struct brw_indirect vt2
= brw_indirect(2, 0);
465 struct brw_compile
*p
= &c
->func
;
467 brw_MOV(p
, get_addr_reg(vt0
), brw_address(c
->reg
.vertex
[0]));
468 brw_MOV(p
, get_addr_reg(vt1
), brw_address(c
->reg
.vertex
[1]));
469 brw_MOV(p
, get_addr_reg(vt2
), brw_address(c
->reg
.vertex
[2]));
470 brw_MOV(p
, v0
, deref_4f(vt0
, c
->offset
[VERT_RESULT_HPOS
]));
471 brw_MOV(p
, v1
, deref_4f(vt1
, c
->offset
[VERT_RESULT_HPOS
]));
472 brw_MOV(p
, v2
, deref_4f(vt2
, c
->offset
[VERT_RESULT_HPOS
]));
474 /* test nearz, xmin, ymin plane */
475 brw_CMP(p
, t1
, BRW_CONDITIONAL_LE
, negate(v0
), get_element(v0
, 3));
476 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
477 brw_CMP(p
, t2
, BRW_CONDITIONAL_LE
, negate(v1
), get_element(v1
, 3));
478 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
479 brw_CMP(p
, t3
, BRW_CONDITIONAL_LE
, negate(v2
), get_element(v2
, 3));
480 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
481 brw_XOR(p
, t
, t1
, t2
);
482 brw_XOR(p
, t1
, t2
, t3
);
485 brw_CMP(p
, brw_null_reg(), BRW_CONDITIONAL_NZ
,
486 get_element(t
, 0), brw_imm_ud(0));
487 brw_OR(p
, c
->reg
.planemask
, c
->reg
.planemask
, brw_imm_ud((1<<5)));
488 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
489 brw_CMP(p
, brw_null_reg(), BRW_CONDITIONAL_NZ
,
490 get_element(t
, 1), brw_imm_ud(0));
491 brw_OR(p
, c
->reg
.planemask
, c
->reg
.planemask
, brw_imm_ud((1<<3)));
492 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
493 brw_CMP(p
, brw_null_reg(), BRW_CONDITIONAL_NZ
,
494 get_element(t
, 2), brw_imm_ud(0));
495 brw_OR(p
, c
->reg
.planemask
, c
->reg
.planemask
, brw_imm_ud((1<<1)));
496 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
498 /* test farz, xmax, ymax plane */
499 brw_CMP(p
, t1
, BRW_CONDITIONAL_L
, v0
, get_element(v0
, 3));
500 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
501 brw_CMP(p
, t2
, BRW_CONDITIONAL_L
, v1
, get_element(v1
, 3));
502 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
503 brw_CMP(p
, t3
, BRW_CONDITIONAL_L
, v2
, get_element(v2
, 3));
504 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
506 brw_XOR(p
, t
, t1
, t2
);
507 brw_XOR(p
, t1
, t2
, t3
);
510 brw_CMP(p
, brw_null_reg(), BRW_CONDITIONAL_NZ
,
511 get_element(t
, 0), brw_imm_ud(0));
512 brw_OR(p
, c
->reg
.planemask
, c
->reg
.planemask
, brw_imm_ud((1<<4)));
513 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
514 brw_CMP(p
, brw_null_reg(), BRW_CONDITIONAL_NZ
,
515 get_element(t
, 1), brw_imm_ud(0));
516 brw_OR(p
, c
->reg
.planemask
, c
->reg
.planemask
, brw_imm_ud((1<<2)));
517 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
518 brw_CMP(p
, brw_null_reg(), BRW_CONDITIONAL_NZ
,
519 get_element(t
, 2), brw_imm_ud(0));
520 brw_OR(p
, c
->reg
.planemask
, c
->reg
.planemask
, brw_imm_ud((1<<0)));
521 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
530 void brw_emit_tri_clip( struct brw_clip_compile
*c
)
532 struct brw_instruction
*neg_rhw
;
533 struct brw_compile
*p
= &c
->func
;
534 brw_clip_tri_alloc_regs(c
, 3 + c
->key
.nr_userclip
+ 6);
535 brw_clip_tri_init_vertices(c
);
536 brw_clip_init_clipmask(c
);
538 /* if -ve rhw workaround bit is set,
540 brw_set_conditionalmod(p
, BRW_CONDITIONAL_NZ
);
541 brw_AND(p
, brw_null_reg(), get_element_ud(c
->reg
.R0
, 2),
543 neg_rhw
= brw_IF(p
, BRW_EXECUTE_1
);
547 brw_ENDIF(p
, neg_rhw
);
549 /* Can't push into do_clip_tri because with polygon (or quad)
550 * flatshading, need to apply the flatshade here because we don't
551 * respect the PV when converting to trifan for emit:
553 if (c
->key
.do_flat_shading
)
554 brw_clip_tri_flat_shade(c
);
556 if (c
->key
.clip_mode
== BRW_CLIPMODE_NORMAL
)
559 maybe_do_clip_tri(c
);
561 brw_clip_tri_emit_polygon(c
);
563 /* Send an empty message to kill the thread:
565 brw_clip_kill_thread(c
);