<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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Soon the dp4 is only going to be used for fixed clip planes.<br>
<br>
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_clip_tri.c | 26 ++++++++++++++------------<br>
 1 file changed, 14 insertions(+), 12 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_clip_tri.c b/src/mesa/drivers/dri/i965/brw_clip_tri.c<br>
index daa7a5f..bd3ffb3 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_clip_tri.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_clip_tri.c<br>
@@ -224,17 +224,19 @@ void brw_clip_tri_flat_shade( struct brw_clip_compile *c )<br>
<br>
<br>
 static inline void<br>
-load_vertex_pos(struct brw_clip_compile *c, struct brw_indirect vtx,<br>
-                struct brw_reg dst,<br>
-                GLuint hpos_offset, GLuint clip_offset)<br>
+load_clip_distance(struct brw_clip_compile *c, struct brw_indirect vtx,<br>
+                struct brw_reg dst, GLuint hpos_offset, GLuint clip_offset,<br>
+                int cond)<br></blockquote><div><br></div><div>Can we add a comment above this function explaining what it does?  In particular, it would be nice to have a comment explaining that this function ends with an implicit comparison between the clip distance and zero, using "cond" as a conditional modifier.<br>
<br></div><div>With that fixed, this patch is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

 {<br>
    struct brw_compile *p = &c->func;<br>
<br>
    /*<br>
     * Roughly:<br>
     * dst = (vertex_src_mask & 1) ? src.hpos : src.clipvertex;<br>
+    * dst = dp4(dst, plane)         + set f0 based on `cond`<br>
     */<br>
<br>
+   dst = vec4(dst);<br>
    brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);<br>
    brw_AND(p, vec1(brw_null_reg()), c->reg.vertex_src_mask, brw_imm_ud(1));<br>
    brw_IF(p, BRW_EXECUTE_1);<br>
@@ -246,6 +248,9 @@ load_vertex_pos(struct brw_clip_compile *c, struct brw_indirect vtx,<br>
       brw_MOV(p, dst, deref_4f(vtx, hpos_offset));<br>
    }<br>
    brw_ENDIF(p);<br>
+<br>
+   brw_set_conditionalmod(p, cond);<br>
+   brw_DP4(p, dst, dst, c->reg.plane_equation);<br>
 }<br>
<br>
<br>
@@ -313,17 +318,15 @@ void brw_clip_tri( struct brw_clip_compile *c )<br>
             */<br>
            brw_MOV(p, get_addr_reg(vtx), deref_1uw(inlist_ptr, 0));<br>
<br>
-            load_vertex_pos(c, vtxPrev, vec4(c->reg.dpPrev), hpos_offset, clipvert_offset);<br>
+            load_clip_distance(c, vtxPrev, c->reg.dpPrev, hpos_offset, clipvert_offset,<br>
+                  BRW_CONDITIONAL_L);<br>
            /* IS_NEGATIVE(prev) */<br>
-           brw_set_conditionalmod(p, BRW_CONDITIONAL_L);<br>
-           brw_DP4(p, vec4(c->reg.dpPrev), vec4(c->reg.dpPrev), c->reg.plane_equation);<br>
            brw_IF(p, BRW_EXECUTE_1);<br>
            {<br>
-               load_vertex_pos(c, vtx, vec4(c->reg.dp), hpos_offset, clipvert_offset);<br>
+               load_clip_distance(c, vtx, c->reg.dp, hpos_offset, clipvert_offset,<br>
+                     BRW_CONDITIONAL_GE);<br>
               /* IS_POSITIVE(next)<br>
                */<br>
-              brw_set_conditionalmod(p, BRW_CONDITIONAL_GE);<br>
-              brw_DP4(p, vec4(c->reg.dp), vec4(c->reg.dp), c->reg.plane_equation);<br>
               brw_IF(p, BRW_EXECUTE_1);<br>
               {<br>
<br>
@@ -362,11 +365,10 @@ void brw_clip_tri( struct brw_clip_compile *c )<br>
               brw_ADD(p, get_addr_reg(outlist_ptr), get_addr_reg(outlist_ptr), brw_imm_uw(sizeof(short)));<br>
               brw_ADD(p, c->reg.nr_verts, c->reg.nr_verts, brw_imm_ud(1));<br>
<br>
-               load_vertex_pos(c, vtx, vec4(c->reg.dp), hpos_offset, clipvert_offset);<br>
+               load_clip_distance(c, vtx, c->reg.dp, hpos_offset, clipvert_offset,<br>
+                     BRW_CONDITIONAL_L);<br>
               /* IS_NEGATIVE(next)<br>
                */<br>
-              brw_set_conditionalmod(p, BRW_CONDITIONAL_L);<br>
-              brw_DP4(p, vec4(c->reg.dp), vec4(c->reg.dp), c->reg.plane_equation);<br>
               brw_IF(p, BRW_EXECUTE_1);<br>
               {<br>
                  /* Going out of bounds.  Avoid division by zero as we<br>
<span class="HOEnZb"><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>