intel: add a new interface drm_intel_bo_alloc_direct
PATCH 1/1 intel: add a new interface drm_intel_bo_alloc_direct
This interface is the same as drm_intel_bo_alloc except the allocated size isn't rounded up, so it bypasses the cache bucket.
The size of the BO created by drm_intel_bo_alloc for a 1920x800,4:2:0 YUV planar surface is 4M, it is about 2.2M if using drm_intel_bo_alloc_direct.
--- intel/intel_bufmgr.c | 9 +++++++++ intel/intel_bufmgr.h | 3 +++ intel/intel_bufmgr_gem.c | 21 ++++++++++++++++++--- intel/intel_bufmgr_priv.h | 8 ++++++++ 4 files changed, 38 insertions(+), 3 deletions(-)
intel/intel_bufmgr.c +9 -0
@@ -50,6 +50,15 @@ drm_intel_bo *drm_intel_bo_alloc(drm_intel_bufmgr *bufmgr, const char *name,return bufmgr->bo_alloc (bufmgr, name, size, alignment); } +drm_intel_bo *drm_intel_bo_alloc_direct (drm_intel_bufmgr *bufmgr,const char *name, +unsigned long size,unsigned int alignment) +{ +if (bufmgr->bo_alloc_direct) +return bufmgr->bo_alloc_direct (bufmgr, name, size, alignment); + +return NULL ; +} + drm_intel_bo *drm_intel_bo_alloc_for_render(drm_intel_bufmgr *bufmgr, const char *name, unsigned long size,
intel/intel_bufmgr.h +3 -0
@@ -78,9 +78,12 @@ struct _drm_intel_bo { };#define BO_ALLOC_FOR_RENDER (1<<0) +#define BO_ALLOC_DIRECT (1<<1)drm_intel_bo *drm_intel_bo_alloc (drm_intel_bufmgr *bufmgr,const char *name,unsigned long size,unsigned int alignment); +drm_intel_bo *drm_intel_bo_alloc_direct (drm_intel_bufmgr *bufmgr,const char *name, +unsigned long size,unsigned int alignment); drm_intel_bo *drm_intel_bo_alloc_for_render(drm_intel_bufmgr *bufmgr, const char *name, unsigned long size,
intel/intel_bufmgr_gem.c +18 -3
@@ -556,17 +556,22 @@ drm_intel_gem_bo_alloc_internal(drm_intel_bufmgr *bufmgr,drm_intel_bo_gem *bo_gem;unsigned int page_size =getpagesize ();int ret; -struct drm_intel_gem_bo_bucket *bucket; +struct drm_intel_gem_bo_bucket *bucket =NULL ;int alloc_from_cache;unsigned long bo_size;int for_render =0 ; +int reusable =1 ;if (flags &BO_ALLOC_FOR_RENDER ) for_render =1 ;/* Round the allocated size up to a power of two number of pages. */ - bucket =drm_intel_gem_bo_bucket_for_size (bufmgr_gem, size); +if (!(flags &BO_ALLOC_DIRECT )) + bucket =drm_intel_gem_bo_bucket_for_size (bufmgr_gem, size); +if (bucket ==NULL ) + reusable =0 ; +/* If we don't have caching at this size, don't actually round the * allocation up. */
@@ -653,7 +658,7 @@ retry: bo_gem->has_error =0 ; bo_gem->tiling_mode =I915_TILING_NONE ; bo_gem->swizzle_mode =I915_BIT_6_SWIZZLE_NONE ; - bo_gem->reusable =1 ; + bo_gem->reusable = reusable;drm_intel_bo_gem_set_in_aperture_size (bufmgr_gem, bo_gem);
@@ -683,6 +688,15 @@ drm_intel_gem_bo_alloc(drm_intel_bufmgr *bufmgr, }static drm_intel_bo * +drm_intel_gem_bo_alloc_direct (drm_intel_bufmgr *bufmgr, +const char *name, +unsigned long size, +unsigned int alignment) +{ +return drm_intel_gem_bo_alloc_internal (bufmgr, name, size,BO_ALLOC_DIRECT ); +} + +static drm_intel_bo *drm_intel_gem_bo_alloc_tiled (drm_intel_bufmgr *bufmgr,const char *name,int x,int y,int cpp,uint32_t *tiling_mode,unsigned long *pitch,unsigned long flags)
@@ -2058,6 +2072,7 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size) bufmgr_gem->max_relocs = batch_size /sizeof (uint32_t ) /2 -2 ; bufmgr_gem->bufmgr.bo_alloc = drm_intel_gem_bo_alloc; + bufmgr_gem->bufmgr.bo_alloc_direct = drm_intel_gem_bo_alloc_direct; bufmgr_gem->bufmgr.bo_alloc_for_render = drm_intel_gem_bo_alloc_for_render; bufmgr_gem->bufmgr.bo_alloc_tiled = drm_intel_gem_bo_alloc_tiled;
intel/intel_bufmgr_priv.h +8 -0
@@ -51,6 +51,14 @@ struct _drm_intel_bufmgr { unsigned long size, unsigned int alignment);/** +* Allocate a buffer object. +* +* This is the same as bo_alloc except it bypasses the cache bucket +*/ +drm_intel_bo *(*bo_alloc_direct) (drm_intel_bufmgr *bufmgr,const char *name, +unsigned long size,unsigned int alignment); + +/** * Allocate a buffer object, hinting that it will be used as a * render target. *
Signature · 1 line
1.6.3.3
Quoted 5 lines · Haihao
This interface is the same as
drm_intel_bo_allocexcept the allocated size isn't rounded up, so it bypasses the cache bucket.The size of the BO created by
drm_intel_bo_allocfor a 1920x800,4:2:0 YUV planar surface is 4M, it is about 2.2M if usingdrm_intel_bo_alloc_direct.
You could just init a cache bucket of that size, and get BO caching with no overhead and no new interfaces.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 9 lines · Eric Anholt
Quoted 5 lines · Haihao
This interface is the same as
drm_intel_bo_allocexcept the allocated size isn't rounded up, so it bypasses the cache bucket.The size of the BO created by
drm_intel_bo_allocfor a 1920x800,4:2:0 YUV planar surface is 4M, it is about 2.2M if usingdrm_intel_bo_alloc_direct.You could just init a cache bucket of that size, and get BO caching with no overhead and no new interfaces.
I ever considered modifying the cache bucket, including a new interface to override the default cache bucket. The problem is that the the size of the surface BO and related BO may vary from case to case, we don't know the right size when initializing cache bucket.
Caching BO can improve performance, user may cache those BOs by itself.
H.264 supports up to 16 reference frames, my testing shows that the new interface can reduce graphics memory footprint. It can help us to support dual HD video playback.
Thanks
Haihao
Quoted 8 lines · Haihao
Quoted 7 lines · Eric Anholt
Quoted 5 lines · Haihao
This interface is the same as
drm_intel_bo_allocexcept the allocated size isn't rounded up, so it bypasses the cache bucket.The size of the BO created by
drm_intel_bo_allocfor a 1920x800,4:2:0 YUV planar surface is 4M, it is about 2.2M if usingdrm_intel_bo_alloc_direct.
Quoted 7 lines
Quoted 2 lines
You could just init a cache bucket of that size, and get BO caching with no overhead and no new interfaces.
I ever considered modifying the cache bucket, including a new interface to override the default cache bucket. The problem is that the the size of the surface BO and related BO may vary from case to case, we don't know the right size when initializing cache bucket.
We should probably just make a bunch more buckets. It's not like video is the only thing that suffers from overallocation. Mipmapped textures will tend to be 1.5 times a power of two in size.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 25 lines
Quoted 25 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Eric Anholt
Sent: 2010年5月28日 2:59
To: Xiang, Haihao
Cc: [email protected]
Subject: Re: [Intel-gfx] [intel-gfx][PATCH] intel: add a new interfacedrm_intel_bo_alloc_directQuoted 2 lines · Haihao
Quoted 1 line · Eric Anholt
On Tue, 25 May 2010 13:06:50 +0800, "Xiang, Haihao"
Quoted 4 lines · <[email protected]> wrote:
Quoted 4 lines
Quoted 4 lines
This interface is the same as
drm_intel_bo_allocexcept the allocated size isn't rounded up, so it bypasses the cache bucket.The size of the BO created by
drm_intel_bo_allocfor a 1920x800,4:2:0YUV
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
planar surface is 4M, it is about 2.2M if using
drm_intel_bo_alloc_direct.You could just init a cache bucket of that size, and get BO caching with no overhead and no new interfaces.
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
I ever considered modifying the cache bucket, including a new interface to override the default cache bucket. The problem is that the the size of the surface BO and related BO may vary from case to case, we don't know the right size when initializing cache bucket.
We should probably just make a bunch more buckets. It's not like video is the only thing that suffers from overallocation. Mipmapped textures will tend to be 1.5 times a power of two in size.
Maybe a new API to create a new size of bucket, because sizes of buckets in libdrm can not precisely match app's requests.
Another issue to use the built-in buckets in libdrm for H.264 is that libdrm is doing too much caching than necessary.
Thanks
Zou Nan hai
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 5 lines · Haihao
This interface is the same as
drm_intel_bo_allocexcept the allocated size isn't rounded up, so it bypasses the cache bucket.The size of the BO created by
drm_intel_bo_allocfor a 1920x800,4:2:0 YUV planar surface is 4M, it is about 2.2M if usingdrm_intel_bo_alloc_direct.
Have you tried either Chris Wilson's or my fair-lru eviction patches? They should help quite a lot, especially for many big objects of exactly the same size like libva uses.
Cause even 2*23*4M = 184 should decently fit into a 256M aperture - which is what I have here for my ilk machine. Dunno whether that 23 for the number of reference framse is correct, but it's certainly an upper bound.
Yours, Daniel
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mbile: +41 (0)79 365 57 48
Quoted 10 lines · Daniel Vetter
Quoted 5 lines · Haihao
This interface is the same as
drm_intel_bo_allocexcept the allocated size isn't rounded up, so it bypasses the cache bucket.The size of the BO created by
drm_intel_bo_allocfor a 1920x800,4:2:0 YUV planar surface is 4M, it is about 2.2M if usingdrm_intel_bo_alloc_direct.Have you tried either Chris Wilson's or my fair-lru eviction patches? They should help quite a lot, especially for many big objects of exactly the same size like libva uses.
Get the following errors when applying your fair-lru eviction patches
Applying: drm/i915: prepare for fair lru eviction
error: patch failed: drivers/gpu/drm/i915/i915_gem.c:2203
error: drivers/gpu/drm/i915/i915_gem.c: patch does not apply
I am using drm-intel-next branch.
Thanks
Haihao
Quoted 5 lines
Cause even 2*23*4M = 184 should decently fit into a 256M aperture - which is what I have here for my ilk machine. Dunno whether that 23 for the number of reference framse is correct, but it's certainly an upper bound.
Yours, Daniel
Quoted 11 lines · Haihao
Quoted 10 lines · Daniel Vetter
Quoted 5 lines · Haihao
This interface is the same as
drm_intel_bo_allocexcept the allocated size isn't rounded up, so it bypasses the cache bucket.The size of the BO created by
drm_intel_bo_allocfor a 1920x800,4:2:0 YUV planar surface is 4M, it is about 2.2M if usingdrm_intel_bo_alloc_direct.Have you tried either Chris Wilson's or my fair-lru eviction patches? They should help quite a lot, especially for many big objects of exactly the same size like libva uses.
Quoted 7 lines
Get the following errors when applying your fair-lru eviction patches
Applying: drm/i915: prepare for fair lru eviction
error: patch failed:drivers/gpu/drm/i915/i915_gem.c:2203
error:drivers/gpu/drm/i915/i915_gem.c: patch does not applyI am using drm-intel-next branch.
Kinda expected - the patch series was against drm-intel-next before your bsd ring stuff was merged ;) So either fixup the conflicts yourself (conflicts are probably just due to the bsd merge, so you already know the code) or prod Chris Wilson into implementing his single-scan patch for i915 atop my generic fair-lru drm patches. Or simply wait till I get around to rebase this stuff. But don't hold your breath, that won't happen soon, unfortunately. Too busy atm.
Cheers, Daniel
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mobile: +41 (0)79 365 57 48