i965: get rid of clip plane compaction
authorChris Forbes <chrisf@ijw.co.nz>
Sun, 7 Jul 2013 15:46:55 +0000 (03:46 +1200)
committerChris Forbes <chrisf@ijw.co.nz>
Thu, 15 Aug 2013 19:24:56 +0000 (07:24 +1200)
Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/mesa/drivers/dri/i965/brw_clip.c
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
src/mesa/drivers/dri/i965/brw_vs.c
src/mesa/drivers/dri/i965/brw_vs.h

index de5ff11b41f5366873ddd6f633c90175de6b65ba..95b7d15a4273220a251452fdd2ca39e1742edd2b 100644 (file)
@@ -158,7 +158,8 @@ brw_upload_clip_prog(struct brw_context *brw)
    /* _NEW_LIGHT */
    key.pv_first = (ctx->Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION);
    /* _NEW_TRANSFORM (also part of VUE map)*/
-   key.nr_userclip = _mesa_bitcount_64(ctx->Transform.ClipPlanesEnabled);
+   if (ctx->Transform.ClipPlanesEnabled)
+      key.nr_userclip = _mesa_logbase2(ctx->Transform.ClipPlanesEnabled) + 1;
 
    if (brw->gen == 5)
        key.clip_mode = BRW_CLIPMODE_KERNEL_CLIP;
index fa32e4a6848dea037511c3c55daf2aa8e4075dd1..454ec38feead12103a6ef7ab14b44d603455d862 100644 (file)
@@ -662,40 +662,14 @@ vec4_visitor::setup_uniform_clipplane_values()
 {
    gl_clip_plane *clip_planes = brw_select_clip_planes(ctx);
 
-   if (brw->gen < 6) {
-      /* Pre-Gen6, we compact clip planes.  For example, if the user
-       * enables just clip planes 0, 1, and 3, we will enable clip planes
-       * 0, 1, and 2 in the hardware, and we'll move clip plane 3 to clip
-       * plane 2.  This simplifies the implementation of the Gen6 clip
-       * thread.
-       */
-      int compacted_clipplane_index = 0;
-      for (int i = 0; i < MAX_CLIP_PLANES; ++i) {
-        if (!(key->userclip_planes_enabled_gen_4_5 & (1 << i)))
-           continue;
-
-        this->uniform_vector_size[this->uniforms] = 4;
-        this->userplane[compacted_clipplane_index] = dst_reg(UNIFORM, this->uniforms);
-        this->userplane[compacted_clipplane_index].type = BRW_REGISTER_TYPE_F;
-        for (int j = 0; j < 4; ++j) {
-           prog_data->param[this->uniforms * 4 + j] = &clip_planes[i][j];
-        }
-        ++compacted_clipplane_index;
-        ++this->uniforms;
-      }
-   } else {
-      /* In Gen6 and later, we don't compact clip planes, because this
-       * simplifies the implementation of gl_ClipDistance.
-       */
-      for (int i = 0; i < key->nr_userclip_plane_consts; ++i) {
-        this->uniform_vector_size[this->uniforms] = 4;
-        this->userplane[i] = dst_reg(UNIFORM, this->uniforms);
-        this->userplane[i].type = BRW_REGISTER_TYPE_F;
-        for (int j = 0; j < 4; ++j) {
-           prog_data->param[this->uniforms * 4 + j] = &clip_planes[i][j];
-        }
-        ++this->uniforms;
+   for (int i = 0; i < key->nr_userclip_plane_consts; ++i) {
+      this->uniform_vector_size[this->uniforms] = 4;
+      this->userplane[i] = dst_reg(UNIFORM, this->uniforms);
+      this->userplane[i].type = BRW_REGISTER_TYPE_F;
+      for (int j = 0; j < 4; ++j) {
+         prog_data->param[this->uniforms * 4 + j] = &clip_planes[i][j];
       }
+      ++this->uniforms;
    }
 }
 
index f909fb53e73be369d474d067a0476adefc60f51d..b26a7a5f01b29c134cadd58a692088bf0e0a8ccd 100644 (file)
@@ -394,9 +394,6 @@ brw_vs_debug_recompile(struct brw_context *brw,
 
    found |= key_debug(brw, "clip distance enable",
                       old_key->base.uses_clip_distance, key->base.uses_clip_distance);
-   found |= key_debug(brw, "clip plane enable bitfield",
-                      old_key->base.userclip_planes_enabled_gen_4_5,
-                      key->base.userclip_planes_enabled_gen_4_5);
    found |= key_debug(brw, "copy edgeflag",
                       old_key->copy_edgeflag, key->copy_edgeflag);
    found |= key_debug(brw, "PointCoord replace",
@@ -431,15 +428,8 @@ static void brw_upload_vs_prog(struct brw_context *brw)
    key.base.userclip_active = (ctx->Transform.ClipPlanesEnabled != 0);
    key.base.uses_clip_distance = vp->program.UsesClipDistance;
    if (key.base.userclip_active && !key.base.uses_clip_distance) {
-      if (brw->gen < 6) {
-         key.base.nr_userclip_plane_consts
-            = _mesa_bitcount_64(ctx->Transform.ClipPlanesEnabled);
-         key.base.userclip_planes_enabled_gen_4_5
-            = ctx->Transform.ClipPlanesEnabled;
-      } else {
-         key.base.nr_userclip_plane_consts
-            = _mesa_logbase2(ctx->Transform.ClipPlanesEnabled) + 1;
-      }
+      key.base.nr_userclip_plane_consts
+         = _mesa_logbase2(ctx->Transform.ClipPlanesEnabled) + 1;
    }
 
    /* _NEW_POLYGON */
index ba83f6d81532b2489222a06def1b5050e7d140f6..3d0b8521579ebcdd4bf751b0ff0ef682ce78f548 100644 (file)
@@ -71,15 +71,6 @@ struct brw_vec4_prog_key {
     */
    GLuint uses_clip_distance:1;
 
-   /**
-    * For pre-Gen6 hardware, a bitfield indicating which clipping planes are
-    * enabled.  This is used to compact clip planes.
-    *
-    * For Gen6 and later hardware, clip planes are not compacted, so this
-    * value is zero to avoid provoking unnecessary shader recompiles.
-    */
-   GLuint userclip_planes_enabled_gen_4_5:MAX_CLIP_PLANES;
-
    GLuint clamp_vertex_color:1;
 
    struct brw_sampler_prog_key_data tex;