diff options
| author | Eric Anholt <eric@anholt.net> | 2009-10-20 13:20:55 -0700 | 
|---|---|---|
| committer | Eric Anholt <eric@anholt.net> | 2009-10-20 13:31:55 -0700 | 
| commit | 66d2714f5435944a26685be4210e0e0d7138f3db (patch) | |
| tree | 4323472d689c5063da200394b421da1a28327e6a /libdrm/intel | |
| parent | 67628aa39dd74807989492af5451a3a5c0232e39 (diff) | |
intel: Improve bo_references performance by skipping the tree walk.
If the target we're asking about hasn't ever been used as a relocation
target, then it obviously hasn't been used as a target by the batch's reloc
tree.  This is the common case for good GL programming where you only map
fresh buffers, and gives us a 5% win in cairo-gl.
[ # ]  backend                         test   min(s) median(s) stddev. count
before:
[  0]       gl            firefox-talos-gfx   64.680   64.756   0.06%    3/3
after:
[  0]       gl            firefox-talos-gfx   60.816   60.970   0.29%    3/3
Diffstat (limited to 'libdrm/intel')
| -rw-r--r-- | libdrm/intel/intel_bufmgr_gem.c | 24 | 
1 files changed, 15 insertions, 9 deletions
diff --git a/libdrm/intel/intel_bufmgr_gem.c b/libdrm/intel/intel_bufmgr_gem.c index b8be96d9..739c99bd 100644 --- a/libdrm/intel/intel_bufmgr_gem.c +++ b/libdrm/intel/intel_bufmgr_gem.c @@ -1571,23 +1571,16 @@ drm_intel_gem_bo_disable_reuse(drm_intel_bo *bo)  	return 0;  } -/** - * Clear the flag set by drm_intel_gem_bo_get_aperture_space() so we're ready - * for the next drm_intel_bufmgr_check_aperture_space() call. - */  static int -drm_intel_gem_bo_references(drm_intel_bo *bo, drm_intel_bo *target_bo) +_drm_intel_gem_bo_references(drm_intel_bo *bo, drm_intel_bo *target_bo)  {  	drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;  	int i; -	if (bo == NULL || target_bo == NULL) -		return 0; -  	for (i = 0; i < bo_gem->reloc_count; i++) {  		if (bo_gem->reloc_target_bo[i] == target_bo)  			return 1; -		if (drm_intel_gem_bo_references(bo_gem->reloc_target_bo[i], +		if (_drm_intel_gem_bo_references(bo_gem->reloc_target_bo[i],  						target_bo))  			return 1;  	} @@ -1595,6 +1588,19 @@ drm_intel_gem_bo_references(drm_intel_bo *bo, drm_intel_bo *target_bo)  	return 0;  } +/** Return true if target_bo is referenced by bo's relocation tree. */ +static int +drm_intel_gem_bo_references(drm_intel_bo *bo, drm_intel_bo *target_bo) +{ +	drm_intel_bo_gem *target_bo_gem = (drm_intel_bo_gem *) target_bo; + +	if (bo == NULL || target_bo == NULL) +		return 0; +	if (target_bo_gem->used_as_reloc_target) +		return _drm_intel_gem_bo_references(bo, target_bo); +	return 0; +} +  /**   * Initializes the GEM buffer manager, which uses the kernel to allocate, map,   * and manage map buffer objections.  | 
