<div dir="ltr">On 3 August 2013 19:59, Chris Forbes <span dir="ltr"><<a href="mailto:chrisf@ijw.co.nz" target="_blank">chrisf@ijw.co.nz</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Signed-off-by: Chris Forbes <<a href="mailto:chrisf@ijw.co.nz">chrisf@ijw.co.nz</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 25 ++++++++++++++-----------<br>
1 file changed, 14 insertions(+), 11 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp<br>
index f80777b..c0b5ccd 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp<br>
@@ -2625,7 +2625,6 @@ vec4_visitor::emit_psiz_and_flags(struct brw_reg reg)<br>
dst_reg header1 = dst_reg(this, glsl_type::uvec4_type);<br>
dst_reg header1_w = header1;<br>
header1_w.writemask = WRITEMASK_W;<br>
- GLuint i;<br>
<br>
emit(MOV(header1, 0u));<br>
<br>
@@ -2637,18 +2636,22 @@ vec4_visitor::emit_psiz_and_flags(struct brw_reg reg)<br>
emit(AND(header1_w, src_reg(header1_w), 0x7ff << 8));<br>
}<br>
<br>
- current_annotation = "Clipping flags";<br>
- for (i = 0; i < key->nr_userclip_plane_consts; i++) {<br>
- vec4_instruction *inst;<br>
- gl_varying_slot slot = (prog_data->vue_map.slots_valid & VARYING_BIT_CLIP_VERTEX)<br>
- ? VARYING_SLOT_CLIP_VERTEX : VARYING_SLOT_POS;<br>
+ if (key->userclip_active) {<br>
+ current_annotation = "Clipping flags";<br>
+ dst_reg temp = dst_reg(this, glsl_type::uint_type);<br>
+ dst_reg temp2 = dst_reg(this, glsl_type::uint_type);<br>
<br>
- inst = emit(DP4(dst_null_f(), src_reg(output_reg[slot]),<br>
- src_reg(this->userplane[i])));<br>
- inst->conditional_mod = BRW_CONDITIONAL_L;<br>
+ emit(CMP(temp, src_reg(output_reg[VARYING_SLOT_CLIP_DIST0]), src_reg(0.0f), BRW_CONDITIONAL_L));<br>
+ emit(AND(temp2, src_reg(temp), src_reg(0x0fu)));<br></blockquote><div><br></div><div>I don't think this works. From the i965 PRM (<a href="https://01.org/linuxgraphics/sites/default/files/documentation/965_g35_vol_4_subsystem_core_1.pdf">https://01.org/linuxgraphics/sites/default/files/documentation/965_g35_vol_4_subsystem_core_1.pdf</a>), page 425:<br>
<br>"Destination operand can be a GRF, an MRF or a null register. If it is not null, for the enabled channels, the LSB of the result in the destination channel contains the flag value for the channel. The other bits are undefined."<br>
<br></div><div>You're making use of the lower 4 bits of the result, 3 of which are undefined.<br><br>I believe you can achieve the effect you want by reading from the "flag" register, though you'll have to do some bit swizzling to unpack the values you want, since the flag register stores the result of the comparison for vertex 0 in its lower nibble and the result of the comparison for vertex 1 in its lower nibble.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
- inst = emit(OR(header1_w, src_reg(header1_w), 1u << i));<br>
- inst->predicate = BRW_PREDICATE_NORMAL;<br>
+ emit(CMP(temp, src_reg(output_reg[VARYING_SLOT_CLIP_DIST1]), src_reg(0.0f), BRW_CONDITIONAL_L));<br>
+ emit(AND(temp, src_reg(temp), src_reg(0x0fu)));<br>
+ emit(SHL(temp, src_reg(temp), src_reg(4)));<br>
+ emit(OR(temp2, src_reg(temp2), src_reg(temp)));<br>
+<br>
+ /* mask just the enabled planes */<br>
+ emit(AND(temp2, src_reg(temp2), src_reg(ctx->Transform.ClipPlanesEnabled)));<br>
+ emit(OR(header1_w, src_reg(header1_w), src_reg(temp2)));<br>
}<br>
<br>
/* i965 clipping workaround:<br>
<span class=""><font color="#888888">--<br>
1.8.3.4<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>