linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]: More optimization for accel_putcs()
@ 2003-02-22  3:32 Antonino Daplas
  2003-02-23 11:07 ` Antonino Daplas
  0 siblings, 1 reply; 3+ messages in thread
From: Antonino Daplas @ 2003-02-22  3:32 UTC (permalink / raw)
  To: James Simmons, Geert Uytterhoeven; +Cc: Linux Fbdev development list

[-- Attachment #1: Type: text/plain, Size: 1109 bytes --]

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



[-- Attachment #2: accel_putcs.diff --]
[-- Type: text/x-patch, Size: 3444 bytes --]

diff -Naur linux-2.5.61-fbdev/drivers/video/console/fbcon.c linux-2.5.61/drivers/video/console/fbcon.c
--- linux-2.5.61-fbdev/drivers/video/console/fbcon.c	2003-02-22 02:34:26.000000000 +0000
+++ linux-2.5.61/drivers/video/console/fbcon.c	2003-02-22 03:16:45.000000000 +0000
@@ -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;
+		}
 	}
 }
 
diff -Naur linux-2.5.61-fbdev/drivers/video/fbmem.c linux-2.5.61/drivers/video/fbmem.c
--- linux-2.5.61-fbdev/drivers/video/fbmem.c	2003-02-22 02:34:26.000000000 +0000
+++ linux-2.5.61/drivers/video/fbmem.c	2003-02-22 02:42:06.000000000 +0000
@@ -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)
 {

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH]: More optimization for accel_putcs()
  2003-02-22  3:32 [PATCH]: More optimization for accel_putcs() Antonino Daplas
@ 2003-02-23 11:07 ` Antonino Daplas
  2003-02-26 19:29   ` James Simmons
  0 siblings, 1 reply; 3+ messages in thread
From: Antonino Daplas @ 2003-02-23 11:07 UTC (permalink / raw)
  To: Antonino Daplas
  Cc: James Simmons, Geert Uytterhoeven, Linux Fbdev development list

On Sat, 2003-02-22 at 11:32, Antonino Daplas wrote:
> 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:
> 

The optimization logic is flawed :-(  Please apply this patch also.

Tony

diff -Naur linux-2.5.61-fbdev/drivers/video/console/fbcon.c linux-2.5.61/drivers/video/console/fbcon.c
--- linux-2.5.61-fbdev/drivers/video/console/fbcon.c	2003-02-23 18:54:32.000000000 +0800
+++ linux-2.5.61/drivers/video/console/fbcon.c	2003-02-23 18:58:05.000000000 +0800
@@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH]: More optimization for accel_putcs()
  2003-02-23 11:07 ` Antonino Daplas
@ 2003-02-26 19:29   ` James Simmons
  0 siblings, 0 replies; 3+ messages in thread
From: James Simmons @ 2003-02-26 19:29 UTC (permalink / raw)
  To: Antonino Daplas; +Cc: Geert Uytterhoeven, Linux Fbdev development list


Applied.




-------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-02-26 19:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-22  3:32 [PATCH]: More optimization for accel_putcs() Antonino Daplas
2003-02-23 11:07 ` Antonino Daplas
2003-02-26 19:29   ` James Simmons

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).