From d277547dc69c9004097afdc2ca56a7aed85c6f54 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 5 May 2009 13:07:33 -0700 Subject: 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 file changed, 17 insertions(+), 1 deletion(-) 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 f646ee7fc3..ad28c78f69 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 */ -- cgit v1.2.3