Mesa (master): i965/clip: Track offset into the vertex for clipdistance

Chris Forbes chrisf at kemper.freedesktop.org
Thu Aug 15 10:23:55 UTC 2013


Module: Mesa
Branch: master
Commit: 265336e75a12e03be456b1a672532c7724c8d144
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=265336e75a12e03be456b1a672532c7724c8d144

Author: Chris Forbes <chrisf at ijw.co.nz>
Date:   Sun Aug  4 05:20:17 2013 +1200

i965/clip: Track offset into the vertex for clipdistance

Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
Reviewed-by: Paul Berry <stereotype441 at gmail.com>

---

 src/mesa/drivers/dri/i965/brw_clip.h     |    3 +++
 src/mesa/drivers/dri/i965/brw_clip_tri.c |    9 +++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_clip.h b/src/mesa/drivers/dri/i965/brw_clip.h
index 2b02f85..1f6ef39 100644
--- a/src/mesa/drivers/dri/i965/brw_clip.h
+++ b/src/mesa/drivers/dri/i965/brw_clip.h
@@ -109,6 +109,9 @@ struct brw_clip_compile {
        * defined clipping plane.
        */
       struct brw_reg vertex_src_mask;
+
+      /* Offset into the vertex of the current plane's clipdistance value */
+      struct brw_reg clipdistance_offset;
    } reg;
 
    /* Number of registers storing VUE data */
diff --git a/src/mesa/drivers/dri/i965/brw_clip_tri.c b/src/mesa/drivers/dri/i965/brw_clip_tri.c
index 19179c1..dd750f5 100644
--- a/src/mesa/drivers/dri/i965/brw_clip_tri.c
+++ b/src/mesa/drivers/dri/i965/brw_clip_tri.c
@@ -120,6 +120,7 @@ void brw_clip_tri_alloc_regs( struct brw_clip_compile *c,
    }
 
    c->reg.vertex_src_mask = retype(brw_vec1_grf(i, 0), BRW_REGISTER_TYPE_UD);
+   c->reg.clipdistance_offset = retype(brw_vec1_grf(i, 1), BRW_REGISTER_TYPE_W);
    i++;
 
    if (brw->gen == 5) {
@@ -264,6 +265,9 @@ void brw_clip_tri( struct brw_clip_compile *c )
    GLuint clipvert_offset = brw_clip_have_varying(c, VARYING_SLOT_CLIP_VERTEX)
       ? brw_varying_to_offset(&c->vue_map, VARYING_SLOT_CLIP_VERTEX)
       : hpos_offset;
+   GLint clipdist0_offset = c->key.nr_userclip
+      ? brw_varying_to_offset(&c->vue_map, VARYING_SLOT_CLIP_DIST0)
+      : 0;
 
    brw_MOV(p, get_addr_reg(vtxPrev),     brw_address(c->reg.vertex[2]) );
    brw_MOV(p, get_addr_reg(plane_ptr),   brw_clip_plane0_address(c));
@@ -277,6 +281,10 @@ void brw_clip_tri( struct brw_clip_compile *c )
     */
    brw_MOV(p, c->reg.vertex_src_mask, brw_imm_ud(0xfc0));
 
+   /* Set the initial clipdistance offset to be 6 floats before gl_ClipDistance[0].
+    * We'll increment 6 times before we start hitting actual user clipping. */
+   brw_MOV(p, c->reg.clipdistance_offset, brw_imm_d(clipdist0_offset - 6*sizeof(float)));
+
    brw_DO(p, BRW_EXECUTE_1);
    {
       /* if (planemask & 1)
@@ -432,6 +440,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
       brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
       brw_SHR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(1));
       brw_SHR(p, c->reg.vertex_src_mask, c->reg.vertex_src_mask, brw_imm_ud(1));
+      brw_ADD(p, c->reg.clipdistance_offset, c->reg.clipdistance_offset, brw_imm_w(sizeof(float)));
    }
    brw_WHILE(p);
 }




More information about the mesa-commit mailing list