Mesa (master): i965: Don't create constant buffers if they won't be used.

Eric Anholt anholt at kemper.freedesktop.org
Wed May 6 13:46:44 UTC 2009


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

Author: Eric Anholt <eric at anholt.net>
Date:   Tue May  5 13:07:33 2009 -0700

i965: Don't create constant buffers if they won't be used.

Really, the creation and upload of constants should be in the same place,
since they should only happen together, and a state flag should be
triggered by them so that we don't thrash state around so much for just
updating constants.  But this still recovers openarena performance by
another 19%, leaving us 16% behind Mesa 7.4 branch.

---

 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index f646ee7..ad28c78 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -396,6 +396,14 @@ brw_update_wm_constant_surface( GLcontext *ctx,
    struct brw_surface_key key;
    struct intel_context *intel = &brw->intel;
    const int size = params->NumParameters * 4 * sizeof(GLfloat);
+   struct brw_fragment_program *fp =
+      (struct brw_fragment_program *) brw->fragment_program;
+
+   if (!fp->use_const_buffer) {
+      dri_bo_unreference(const_buffer);
+      brw->wm.surf_bo[surf] = NULL;
+      return NULL;
+   }
 
    /* free old const buffer if too small */
    if (const_buffer && const_buffer->size < size) {
@@ -455,6 +463,8 @@ brw_update_vs_constant_surface( GLcontext *ctx,
    struct brw_surface_key key;
    struct intel_context *intel = &brw->intel;
    const int size = params->NumParameters * 4 * sizeof(GLfloat);
+   struct brw_vertex_program *vp =
+      (struct brw_vertex_program *) brw->vertex_program;
 
    assert(surf == 0);
 
@@ -463,6 +473,11 @@ brw_update_vs_constant_surface( GLcontext *ctx,
     */
    dri_bo_unreference(const_buffer);
 
+   if (!vp->use_const_buffer) {
+      brw->vs.surf_bo[surf] = NULL;
+      return NULL;
+   }
+
    /* alloc new buffer */
    const_buffer =
       drm_intel_bo_alloc(intel->bufmgr, "vp_const_buffer", size, 64);
@@ -703,7 +718,8 @@ static void prepare_wm_surfaces(struct brw_context *brw )
          brw_update_wm_constant_surface(ctx, surf, fp->const_buffer,
                                      fp->program.Base.Parameters);
 
-      brw->wm.nr_surfaces = surf + 1;
+      if (fp->const_buffer != NULL)
+	 brw->wm.nr_surfaces = surf + 1;
    }
 
    /* Update surfaces for textures */




More information about the mesa-commit mailing list