Bug 23510

Summary: XvPutImage uses oversized buffers when rendering sub-regions of source YUV buffers
Product: xorg Reporter: Hugo Jacques <hugo.jacques>
Component: Driver/intelAssignee: haihao <haihao.xiang>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: enhancement    
Priority: medium Keywords: patch
Version: 7.4 (2008.09)   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
patch to dramatically reduce CPU usage none

Description Hugo Jacques 2009-08-25 10:15:14 UTC
Created attachment 28900 [details] [review]
patch to dramatically reduce CPU usage

I recently noticed that X seemed to take far more CPU when displaying a YV12 small rectangle (say 704x480) out of a large YUV source buffer (say 2048x1088)using XvShmPutImage than it was when the source YUV buffer was 704x480.

Looking at the code in i830PutImage (i830_video.c), I realized that the destination buffer for I830CopyPlanarData and the likes was way too large in the case I just described.
In fact, it was the same size (+/- pitch alignment) as the whole source YUV buffer.

Attached is a patch that sizes it as the source sub-rectangle within the whole source YUB buffer, adjusted for clipping and pitch alignment.

Performance improvement were dramatic: 30 frames/second of 704x480 from a 2048x1088 source used to have X take 10% of the CPU. Now it merely takes 3%.

Please review (I'm not an Intel video driver guru and I might have overlooked some issues. Plus I could not test all the possible cases.) and commit for everybody's enjoyment :)

i810PutImage might eventually also benefit from this type of improvement.

Hugo
Comment 1 Gordon Jin 2009-08-25 18:13:37 UTC
haihao, can you review?
Comment 2 Chris Wilson 2010-07-17 07:01:51 UTC
The current code is using nlines and npixels to trim the copied region.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.