summaryrefslogtreecommitdiff
path: root/libdrm
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2009-10-05 16:35:32 -0700
committerEric Anholt <eric@anholt.net>2009-10-06 13:30:07 -0700
commit3c9bd068e0aa8069f71e8193b82b231d6513ce35 (patch)
treeb2592f4de33a32ab0625a74aa7c1eade46c4d662 /libdrm
parentac34f599eabcfc414d4d3300063988d4749813f4 (diff)
intel: Don't allocate more relocation entries than the BO could support.
This saves 32k of relocation entry storage for many 965 state buffers. No noticeable impact on performance for cairo-gl firefox.
Diffstat (limited to 'libdrm')
-rw-r--r--libdrm/intel/intel_bufmgr_gem.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libdrm/intel/intel_bufmgr_gem.c b/libdrm/intel/intel_bufmgr_gem.c
index 235ec619..cf35c816 100644
--- a/libdrm/intel/intel_bufmgr_gem.c
+++ b/libdrm/intel/intel_bufmgr_gem.c
@@ -304,10 +304,14 @@ drm_intel_setup_reloc_list(drm_intel_bo *bo)
{
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo;
drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo->bufmgr;
+ unsigned int max_relocs = bufmgr_gem->max_relocs;
- bo_gem->relocs = malloc(bufmgr_gem->max_relocs *
+ if (bo->size / 4 < max_relocs)
+ max_relocs = bo->size / 4;
+
+ bo_gem->relocs = malloc(max_relocs *
sizeof(struct drm_i915_gem_relocation_entry));
- bo_gem->reloc_target_bo = malloc(bufmgr_gem->max_relocs *
+ bo_gem->reloc_target_bo = malloc(max_relocs *
sizeof(drm_intel_bo *));
return 0;