[Intel-gfx] [PATCH]libdrm: avoid round big buffer for gem obj allocation

Shaohua Li shaohua.li at intel.com
Thu Jun 4 05:26:36 CEST 2009


Round big buffer might waste a lot of space, for example, front buffer for
a 1280x1024 display takes 5M, but round gives it 8M. And it appears big
buffer is unlikely reused, which basically is front buffer.
The threshold size is selected arbitrarily, please suggest.

Signed-off-by: Shaohua Li <shaohua.li at intel.com>
---
 libdrm/intel/intel_bufmgr_gem.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: drm/libdrm/intel/intel_bufmgr_gem.c
===================================================================
--- drm.orig/libdrm/intel/intel_bufmgr_gem.c
+++ drm/libdrm/intel/intel_bufmgr_gem.c
@@ -345,7 +345,8 @@ drm_intel_gem_bo_alloc_internal(drm_inte
     unsigned long bo_size;
 
     /* Round the allocated size up to a power of two number of pages. */
-    bo_size = 1 << logbase2(size);
+    if (size <= 1024*1024)
+        bo_size = 1 << logbase2(size);
     if (bo_size < page_size)
 	bo_size = page_size;
     bucket = drm_intel_gem_bo_bucket_for_size(bufmgr_gem, bo_size);



More information about the Intel-gfx mailing list