summaryrefslogtreecommitdiff
path: root/libdrm
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2009-02-27 13:46:31 -0800
committerEric Anholt <eric@anholt.net>2009-02-27 14:12:54 -0800
commit7ce8d4c1fec618ac2578ea0ddb8915b1b41ab9cb (patch)
tree4de8cd2903df92f4cc7a72831fbbc003c94e630b /libdrm
parentab582f64fd54565f66eba866972f0fe2c313f000 (diff)
intel: Update reloc_tree_size of the first buffer when we count the tree size.
This helps avoid the n^2 performance cost of counting tree size when we get a lot of relocations into our batch buffer. rgb10text on keithp's laptop went from 136k glyphs/sec to 234k glyphs/sec.
Diffstat (limited to 'libdrm')
-rw-r--r--libdrm/intel/intel_bufmgr_gem.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/libdrm/intel/intel_bufmgr_gem.c b/libdrm/intel/intel_bufmgr_gem.c
index 6ddecf4a..9e49d7c9 100644
--- a/libdrm/intel/intel_bufmgr_gem.c
+++ b/libdrm/intel/intel_bufmgr_gem.c
@@ -1260,8 +1260,21 @@ drm_intel_gem_compute_batch_space(drm_intel_bo **bo_array, int count)
int i;
unsigned int total = 0;
- for (i = 0; i < count; i++)
+ for (i = 0; i < count; i++) {
total += drm_intel_gem_bo_get_aperture_space(bo_array[i]);
+ /* For the first buffer object in the array, we get an accurate count
+ * back for its reloc_tree size (since nothing had been flagged as
+ * being counted yet). We can save that value out as a more
+ * conservative reloc_tree_size that avoids double-counting target
+ * buffers. Since the first buffer happens to usually be the batch
+ * buffer in our callers, this can pull us back from doing the tree
+ * walk on every new batch emit.
+ */
+ if (i == 0) {
+ drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo_array[i];
+ bo_gem->reloc_tree_size = total;
+ }
+ }
for (i = 0; i < count; i++)
drm_intel_gem_bo_clear_aperture_space_flag(bo_array[i]);