Skip to contentSkip to conversation

Added support to optimize fills and blits.

PATCH In review Vesa Jääskeläinen 3 participants 3 messages Mar 29, 2006 – Mar 31, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Added support to optimize fills and blits.

Hi,

Here is patch attached that adds support to video subsystem so fills and blits could be optimized. It contains sample implementation for VBE driver (it is not fastest possible, but gives some performance improvement over previous one).

Thanks,
Vesa Jääskeläinen

Index: ChangeLog
===================================================================
RCS file: /sources/grub/grub2/ChangeLog,v
retrieving revision 1.226

ChangeLog +38 -0
diff -u -r1.226 ChangeLog
@@ -1,3 +1,41 @@
+2006-03-30  Vesa Jaaskelainen  <[email protected]>
+
+	* DISTLIST: Added include/grub/i386/pc/vbeblit.h,
+	include/grub/i386/pc/vbefill.h, video/i386/pc/vbeblit.c,
+	video/i386/pc/vbefill.c.
+
+	* conf/i386-pc.rmk (vbe_mod_SOURCES): Added video/i386/pc/vbeblit.c,
+	video/i386/pc/vbefill.c.
+
+	* include/grub/video.h (grub_video_blit_format): New enum.
+	(grub_video_mode_info): Added new member blit_format.
+	(grub_video_get_blit_format): New function prototype.
+
+	* include/grub/i386/pc/vbe.h (grub_video_vbe_get_video_ptr): New
+	function prototype.
+	(grub_video_vbe_map_rgb): Likewise.
+	(grub_video_vbe_unmap_color): Likewise.
+
+	* include/grub/i386/pc/vbeblit.h: New file.
+
+	* include/grub/i386/pc/vbefill.h: New file.
+
+	* video/video.c (grub_video_get_blit_format): New function.
+	(grub_video_vbe_get_video_ptr): Re-declared as non-static.
+	(grub_video_vbe_map_rgb): Likewise.
+	(grub_video_vbe_unmap_color): Likewise.
+
+	* video/i386/pc/vbe.c (grub_video_vbe_fill_rect): Changed to use more
+	optimized fills.
+	(grub_video_vbe_blit_render_target): Changed to use more optimized
+	blits.
+	(grub_video_vbe_setup): Added detection for optimized settings.
+	(grub_video_vbe_create_render_target): Likewise.
+
+	* video/i386/pc/vbeblit.c: New file.
+
+	* video/i386/pc/vbefill.c: New file.
+
 2006-03-14  Vesa Jaaskelainen  <[email protected]>
 
 	* DISTLIST: Added include/grub/video.h, term/gfxterm.c,

Index: DISTLIST
===================================================================
RCS file: /sources/grub/grub2/DISTLIST,v
retrieving revision 1.24

DISTLIST +4 -0
diff -u -r1.24 DISTLIST
@@ -124,6 +124,8 @@
 include/grub/i386/pc/serial.h
 include/grub/i386/pc/time.h
 include/grub/i386/pc/vbe.h
+include/grub/i386/pc/vbeblit.h
+include/grub/i386/pc/vbefill.h
 include/grub/i386/pc/vga.h
 include/grub/i386/pc/util/biosdisk.h
 include/grub/ieee1275/ieee1275.h
@@ -235,3 +237,5 @@
 util/powerpc/ieee1275/misc.c
 video/video.c
 video/i386/pc/vbe.c
+video/i386/pc/vbeblit.c
+video/i386/pc/vbefill.c

Index: conf/i386-pc.rmk
===================================================================
RCS file: /sources/grub/grub2/conf/i386-pc.rmk,v
retrieving revision 1.59

i386-pc.rmk +2 -1
diff -u -r1.59 i386-pc.rmk
@@ -174,7 +174,8 @@
 multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
 # For vbe.mod.
-vbe_mod_SOURCES = video/i386/pc/vbe.c
+vbe_mod_SOURCES = video/i386/pc/vbe.c video/i386/pc/vbeblit.c \
+		  video/i386/pc/vbefill.c
 vbe_mod_CFLAGS = $(COMMON_CFLAGS)
 vbe_mod_LDFLAGS = $(COMMON_LDFLAGS)
 

Index: include/grub/video.h
===================================================================
RCS file: /sources/grub/grub2/include/grub/video.h,v retrieving revision 1.1

grub/video.h +20 -0
diff -u -r1.1 video.h
@@ -46,6 +46,21 @@
 #define GRUB_VIDEO_RENDER_TARGET_FRONT_BUFFER	((struct grub_video_render_target *) 0)
 #define GRUB_VIDEO_RENDER_TARGET_BACK_BUFFER	((struct grub_video_render_target *) 1)
 
+/* Defined blitting formats.  */
+enum grub_video_blit_format
+  {
+    /* Follow exactly field & mask information.  */
+    GRUB_VIDEO_BLIT_FORMAT_RGBA,
+    /* Make optimization assumption.  */
+    GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8,
+    /* Follow exactly field & mask information.  */
+    GRUB_VIDEO_BLIT_FORMAT_RGB,
+    /* Make optimization assumption.  */
+    GRUB_VIDEO_BLIT_FORMAT_R8G8B8,
+    /* When needed, decode color or just use value as is.  */
+    GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR
+  };
+
 struct grub_video_mode_info
 {
   /* Width of the screen.  */
@@ -70,6 +85,9 @@
   /* In index color mode, number of colors.  In RGB mode this is 256.  */
   unsigned int number_of_colors;
 
+  /* Optimization hint how binary data is coded.  */
+  enum grub_video_blit_format blit_format;
+
   /* How many bits are reserved for red color.  */
   unsigned int red_mask_size;
 
@@ -235,6 +253,8 @@
 
 grub_err_t EXPORT_FUNC(grub_video_get_info) (struct grub_video_mode_info *mode_info);
 
+enum grub_video_blit_format EXPORT_FUNC(grub_video_get_blit_format) (struct grub_video_mode_info *mode_info);
+
 grub_err_t EXPORT_FUNC(grub_video_set_palette) (unsigned int start,
 						unsigned int count,
 						struct grub_video_palette_data *palette_data);

Index: include/grub/i386/pc/vbe.h
===================================================================
RCS file: /sources/grub/grub2/include/grub/i386/pc/vbe.h,v retrieving revision 1.4

grub/i386/pc/vbe.h +16 -1
diff -u -r1.4 vbe.h
@@ -1,6 +1,6 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2005  Free Software Foundation, Inc.
+ *  Copyright (C) 2005,2006  Free Software Foundation, Inc.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -23,6 +23,7 @@
 #include <grub/symbol.h>
 #include <grub/types.h>
 #include <grub/err.h>
+#include <grub/video.h>
 
 /* Default video mode to be used.  */
 #define GRUB_VBE_DEFAULT_VIDEO_MODE     0x101
@@ -203,4 +204,18 @@
 grub_err_t grub_vbe_get_video_mode_info (grub_uint32_t mode,
                                          struct grub_vbe_mode_info_block *mode_info);
 
+/* VBE module internal prototypes (should not be used from elsewhere).  */
+grub_uint8_t * grub_video_vbe_get_video_ptr (struct grub_video_render_target *source,
+                                             grub_uint32_t x,
+                                             grub_uint32_t y);
+
+grub_video_color_t grub_video_vbe_map_rgb (grub_uint8_t red, 
+                                           grub_uint8_t green,
+                                           grub_uint8_t blue);
+
+void grub_video_vbe_unmap_color (struct grub_video_render_target * source,
+                                 grub_video_color_t color, grub_uint8_t *red,
+                                 grub_uint8_t *green, grub_uint8_t *blue,
+                                 grub_uint8_t *alpha);
+
 #endif /* ! GRUB_VBE_MACHINE_HEADER */

Index: include/grub/i386/pc/vbeblit.h
===================================================================
RCS file: include/grub/i386/pc/vbeblit.h

grub/i386/pc/vbeblit.h new file +66 -0

66 lines not on this page · raw message

Index: include/grub/i386/pc/vbefill.h
===================================================================
RCS file: include/grub/i386/pc/vbefill.h

grub/i386/pc/vbefill.h new file +40 -0
diff -N include/grub/i386/pc/vbefill.h
@@ -0,0 +1,40 @@
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2006  Free Software Foundation, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef GRUB_VBEFILL_MACHINE_HEADER
+#define GRUB_VBEFILL_MACHINE_HEADER	1
+
+#include <grub/video.h>
+
+void
+grub_video_i386_vbefill_R8G8B8A8 (struct grub_video_render_target *dst,
+                                  grub_video_color_t color,  int x, int y,
+                                  int width, int height);
+
+void
+grub_video_i386_vbefill_R8G8B8 (struct grub_video_render_target *dst,
+                                grub_video_color_t color, int x, int y,
+                                int width, int height);
+
+void
+grub_video_i386_vbefill_index (struct grub_video_render_target *dst,
+                               grub_video_color_t color, int x, int y,
+                               int width, int height);
+
+#endif /* ! GRUB_VBEFILL_MACHINE_HEADER */

Index: video/video.c
===================================================================
RCS file: /sources/grub/grub2/video/video.c,v
retrieving revision 1.1

video.c +47 -0

53 lines not on this page · raw message

Index: video/i386/pc/vbe.c
===================================================================
RCS file: /sources/grub/grub2/video/i386/pc/vbe.c,v retrieving revision 1.5

i386/pc/vbe.c +99 -15

171 lines not on this page · raw message

Index: video/i386/pc/vbeblit.c
===================================================================
RCS file: video/i386/pc/vbeblit.c

i386/pc/vbeblit.c new file +369 -0

369 lines not on this page · raw message

Index: video/i386/pc/vbefill.c
===================================================================
RCS file: video/i386/pc/vbefill.c

i386/pc/vbefill.c new file +101 -0

101 lines not on this page · raw message

#1 lore raw
Quoted 4 lines · Vesa Jääskeläinen

Here is patch attached that adds support to video subsystem so fills and blits could be optimized. It contains sample implementation for VBE driver (it is not fastest possible, but gives some performance improvement over previous one).

It looks good to me. Please go ahead. :)

Okuji

#2 lore raw
In reply to Vesa Jääskeläinen

Vesa Jääskeläinen <[email protected]> writes:

Hi Vesa,

Quoted 4 lines

Here is patch attached that adds support to video subsystem so fills and blits could be optimized. It contains sample implementation for VBE driver (it is not fastest possible, but gives some performance improvement over previous one).

Nice!

Can you replace the C++ style comments into the C comments we usually use and make sure the lines are not too long?

Thanks,
Marco