: More optimization for accel_putcs()
Subsystems (2)
PATCH 1/1 : More optimization for accel_putcs()
Geert, James,
Here's a patch for linux-2.5.61 + James' fbdev.diff so accel_putcs() will do only 1 fb_imageblit() at the end when fontwidth is not divisible by 8. Tested on 4x6 and 12x22 fonts. There should be a significant performance increase even with the generic functions, however, the greatest gain can be seen on drivers with accelerated fb_imageblit(). Here are some numbers:
no accel
scrollmode: yredraw
font: 12x22
visual: packed pixels
time cat /usr/src/linux/MAINTAINERS
linux-2.5.62 (old -- 1 fb_imageblit/character)
bpp8
----
real 0m5.247s user 0m0.001s sys 0m5.245s
bpp16
-----
real 0m9.640s user 0m0.001s sys 0m9.591s
bpp24
-----
real 0m15.943s user 0m0.001s sys 0m15.944s
bpp32
-----
real 0m19.653s user 0m0.002s sys 0m19.651s
linux-2.5.62 (new - 1 fb_imageblit at the end)
bpp8
----
real 0m3.867s user 0m0.000s sys 0m3.866s
bpp16
-----
real 0m5.894s user 0m0.001s sys 0m5.892s
bpp24
-----
real 0m13.669s user 0m0.000s sys 0m13.670s
bpp32
-----
real 0m11.053s user 0m0.001s sys 0m11.054s
Tony
drivers/video/console/fbcon.c +49 -13
@@ -332,16 +332,22 @@ }#define FB_PIXMAPSIZE 8192 +/* +* FIXME: Break up this function, it's becoming too long... +*/ void accel_putcs (struct vc_data *vc,struct display *p,const unsigned short *s,int count,int yy,int xx) { +static u8 pixmap[FB_PIXMAPSIZE ]; +struct fb_image image;struct fb_info *info = p->fb_info;unsigned short charmask = p->charmask;unsigned int width = ((vc->vc_font.width +7 )/8 );unsigned int cellsize = vc->vc_font.height * width; -struct fb_image image; +unsigned int pitch, cnt, i, j, k; +unsigned int maxcnt =FB_PIXMAPSIZE /cellsize; +u8 *src, *dst, *dst0;u16 c =scr_readw (s); -static u8 pixmap[FB_PIXMAPSIZE ]; image.fg_color =attr_fgcol (p, c); image.bg_color =attr_bgcol (p, c);
@@ -349,13 +355,9 @@ image.dy = yy * vc->vc_font.height; image.height = vc->vc_font.height; image.depth =0 ; + image.data = pixmap;if (!(vc->vc_font.width &7 )) { -unsigned int pitch, cnt, i, j, k; -unsigned int maxcnt =FB_PIXMAPSIZE /cellsize; -char *src, *dst, *dst0; - - image.data = pixmap;while (count) {if (count > maxcnt) cnt = k = maxcnt;
@@ -381,14 +383,48 @@ image.dx += cnt * vc->vc_font.width; count -= cnt; } + }else { - image.width = vc->vc_font.width; -while (count--) { - image.data = p->fontdata + - (scr_readw (s++) & charmask) * cellsize; +unsigned int shift_low =0 , mod = vc->vc_font.width %8 ; +unsigned int shift_high =8 ; +unsigned idx = vc->vc_font.width/8 ; +u8 mask; + +while (count) { +if (count > maxcnt) + cnt = k = maxcnt; +else + cnt = k = count; + + dst0 = pixmap; + image.width = vc->vc_font.width * cnt; + pitch = (image.width +7 )/8 ; +while (k--) { + src = p->fontdata + (scr_readw (s++)&charmask)* + cellsize; + dst = dst0; + mask = (u8) (0xfff << shift_high); +for (i = image.height; i--; ) { +for (j =0 ; j < idx; j++) { + dst[j] &= mask; + dst[j] |= *src >> shift_low; + dst[j+1 ] = *src << shift_high; + src++; + } + dst[idx] &= mask; + dst[idx] |= *src++ >> shift_low; + dst += pitch; + } + shift_low += mod; + shift_low &=7 ; + shift_high =8 - shift_low; + dst0 += (shift_low) ? width -1 : width; + } + info->fbops->fb_imageblit (info, &image); - image.dx += vc->vc_font.width; - } + image.dx += cnt * vc->vc_font.width; + count -= cnt; + } } }
drivers/video/fbmem.c +3 -3
@@ -363,14 +363,14 @@static int ofonly__initdata =0 ;#endif +#ifdef CONFIG_LOGO +#include <linux/linux_logo.h> +static inline unsigned safe_shift (unsigned d,int n) {return n <0 ? d >> -n : d << n; } -#ifdef CONFIG_FB_LOGO -#include <linux/linux_logo.h> -static void __init fb_set_logocmap (struct fb_info *info,const struct linux_logo *logo) {
Quoted 9 lines · Antonino Daplas
Geert, James,
Here's a patch for linux-2.5.61 + James' fbdev.diff so
accel_putcs()will do only 1fb_imageblit()at the end when fontwidth is not divisible by 8. Tested on 4x6 and 12x22 fonts. There should be a significant performance increase even with the generic functions, however, the greatest gain can be seen on drivers with acceleratedfb_imageblit(). Here are some numbers:
The optimization logic is flawed :-( Please apply this patch also.
Tony
drivers/video/console/fbcon.c +7 -4
@@ -400,7 +400,7 @@ image.width = vc->vc_font.width * cnt; pitch = (image.width +7 )/8 ;while (k--) { - src = p->fontdata + (scr_readw (s++)&charmask)* + src = p->fontdata + (scr_readw (s++)&charmask)* cellsize; dst = dst0; mask = (u8) (0xfff << shift_high);
@@ -412,15 +412,18 @@ src++; } dst[idx] &= mask; - dst[idx] |= *src++ >> shift_low; + dst[idx] |= *src >> shift_low; +if (shift_high < mod) + dst[idx+1 ] = *src << shift_high; + src++; dst += pitch; } shift_low += mod; + dst0 += (shift_low >=8 ) ? width : width -1 ; shift_low &=7 ; shift_high =8 - shift_low; - dst0 += (shift_low) ? width -1 : width; } - + info->fbops->fb_imageblit (info, &image); image.dx += cnt * vc->vc_font.width; count -= cnt;
-------------------------------------------------------
This SF.net email is sponsored by: SlickEdit Inc. Develop an edge. The most comprehensive and flexible code editor you can use. Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial. www.slickedit.com/sourceforge
James Simmons
AppliedApplied.
-------------------------------------------------------
This SF.net email is sponsored by: Scholarships for Techies! Can't afford IT training? All 2003 ictp students receive scholarships. Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more. www.ictp.com/training/sourceforge.asp