260 likes | 506 Vues
Our Experiences on DirectFB in Embedded Application Development. IGEL Co., Ltd / Renesas Solution Corp. Today’s Topics. DirectFB porting experiences on embedded platforms SH7751 + SM501 SH7770 Missing pieces in DirectFB Functionality missing to write specific applications. Porting DirectFB.
E N D
Our Experiences on DirectFB inEmbedded Application Development IGEL Co., Ltd / Renesas Solution Corp. IGEL Co.,Ltd. / Renesas Solution Corp.
Today’s Topics • DirectFB porting experiences on embedded platforms • SH7751 + SM501 • SH7770 • Missing pieces in DirectFB • Functionality missing to write specific applications IGEL Co.,Ltd. / Renesas Solution Corp.
Porting DirectFB IGEL Co.,Ltd. / Renesas Solution Corp.
DirectFB Architecture DirectFB Application • DirectFB works on a frame buffer device(/dev/fb) and provides the mechanism to use the hardware acceleration effectively. • DirectFB consists of the followings: • Core API Module • Generic GFX Driver • GFX Drivers for Specific Hardware • To bring out the best performance on a specific graphics hardware GFX Drivers for the hardware should be written. • Generic GFX Driver checks whether the hardware acceleration by a GFX driver is available • If yes, it handovers to the GFX driver • If not it uses software rendering engine User Level DirectFB DirectFB Core API Module Generic GFX Driver GFX drivers(※) Device Drivers Frame Buffer Driver(※) Display Unit 2D Graphics Hardware Hardware ※Modules that needs to be developed IGEL Co.,Ltd. / Renesas Solution Corp.
Why do we need GFX drivers? • Embedded CPU and bus are slow compare to Desktop’s CPU • 200-400MHz CPU • 120MHz 32bit Bus • Therefore, handover the rendering tasks to specialized hardware is crucial! IGEL Co.,Ltd. / Renesas Solution Corp.
Effects of Hardware Accelerations The hardware acceleration shows remarkable results. The performance depends on hardware acceleration engine rather than CPU. IGEL Co.,Ltd. / Renesas Solution Corp.
How to write GFX Drivers? • Callback routines needs to be written • GFX Graphics Driver Functions • GFX Graphics Device Functions • Good starting point is gfxdrivers/i810/*.[ch] IGEL Co.,Ltd. / Renesas Solution Corp.
GFX Graphics Driver Functions From core/gfxcard.h: typedef struct { int (*Probe) (GraphicsDevice *device); void (*GetDriverInfo) (GraphicsDevice *device, GraphicsDriverInfo *driver_info); DFBResult (*InitDriver) (GraphicsDevice *device, GraphicsDeviceFuncs *funcs, void *driver_data, void *device_data); DFBResult (*InitDevice) (GraphicsDevice *device, GraphicsDeviceInfo *device_info, void *driver_data, void *device_data); void (*CloseDevice) (GraphicsDevice *device, void *driver_data, void *device_data); void (*CloseDriver) (GraphicsDevice *device, void *driver_data); } GraphicsDriverFuncs; IGEL Co.,Ltd. / Renesas Solution Corp.
From core/gfxcard.h: typedef struct _GraphicsDeviceFuncs { /* * function that is called after variable screeninfo is changed * (used for buggy fbdev drivers, that reinitialize something when * calling FBIO_PUT_VSCREENINFO) */ void (*AfterSetVar)( void *driver_data, void *device_data ); /* * Called after driver->InitDevice() and during dfb_gfxcard_unlock( true ). * The driver should do the one time initialization of the engine, * e.g. writing some registers that are supposed to have a fixed value. * * This happens after mode switching or after returning from * OpenGL state (e.g. DRI driver). */ void (*EngineReset)( void *driver_data, void *device_data ); /* * Makes sure that graphics hardware has finished all operations. * * This method is called before the CPU accesses a surface' buffer * that had been written to by the hardware after this method has been * called the last time. * * It's also called before entering the OpenGL state (e.g. DRI driver). */ void (*EngineSync)( void *driver_data, void *device_data ); /* * after the video memory has been written to by the CPU (e.g. modification * of a texture) make sure the accelerator won't use cached texture data */ void (*FlushTextureCache)( void *driver_data, void *device_data ); /* * Check if the function 'accel' can be accelerated with the 'state'. * If that's true, the function sets the 'accel' bit in 'state->accel'. * Otherwise the function just returns, no need to clear the bit. */ void (*CheckState)( void *driver_data, void *device_data, CardState *state, DFBAccelerationMask accel ); /* * Program card for execution of the function 'accel' with the 'state'. * 'state->modified' contains information about changed entries. * This function has to set at least 'accel' in 'state->set'. * The driver should remember 'state->modified' and clear it. * The driver may modify 'funcs' depending on 'state' settings. */ void (*SetState) ( void *driver_data, void *device_data, struct _GraphicsDeviceFuncs *funcs, CardState *state, DFBAccelerationMask accel ); GFX Graphics Device Functions IGEL Co.,Ltd. / Renesas Solution Corp.
/* * drawing functions */ bool (*FillRectangle) ( void *driver_data, void *device_data, DFBRectangle *rect ); bool (*DrawRectangle) ( void *driver_data, void *device_data, DFBRectangle *rect ); bool (*DrawLine) ( void *driver_data, void *device_data, DFBRegion *line ); bool (*FillTriangle) ( void *driver_data, void *device_data, DFBTriangle *tri ); /* * blitting functions */ bool (*Blit) ( void *driver_data, void *device_data, DFBRectangle *rect, int dx, int dy ); bool (*StretchBlit) ( void *driver_data, void *device_data, DFBRectangle *srect, DFBRectangle *drect ); /* * emit any buffered commands, i.e. trigger processing */ void (*EmitCommands) ( void *driver_data, void *device_data ); } GraphicsDeviceFuncs; GFX Graphics Device Interface(contd.) IGEL Co.,Ltd. / Renesas Solution Corp.
Porting DirectFB on SH7751 + SM501 • Our first development • GFX Driver for SM501 just set registers to issue rendering commands • Issuing command is done on the fly • Callback functions immediately set registers to render • Rendering comes on screen instantly GFX Driver for SM501 SM501 SM501 Registers IGEL Co.,Ltd. / Renesas Solution Corp.
Porting DirectFB on SH7770 • Our second development • GFX Driver for SH7770 creates list of rendering commands, so called Display List • The list is double buffered • The driver fills the list until they’re full, and then pass them to the 2D engine • While the driver is filling one list, the 2D engine reads commands from another list • Once the 2D engine is done with the list, it sends an interrupt, and get the next list • Rendering doesn’t come on screen instantly • Sync mechanism is required to sync with software rendering done by generic GFX driver GFX Driver for SH7770 Display List 1 Display List 2 SH7770 2D Engine Registers IGEL Co.,Ltd. / Renesas Solution Corp.
Missing Pieces in DirectFB IGEL Co.,Ltd. / Renesas Solution Corp.
What’s Missing? • Access multiple layered frame buffer from a process • Recent graphics hardware has multiple frame buffers. • Using ‘scroll’ function on hardware • New feature not covered by DirectFB API • Synchronous rendering and display with VSYNC (QoS, delay handling) • Real-time motion graphics (e.g. game), car navigation, etc. • Synchronize 2D Engine and 3D Engine • Render with 2D and 3D Engine in a single layer • Synchronous display even 2D and 3D are on different layers IGEL Co.,Ltd. / Renesas Solution Corp.
Access Multiple Layered Frame Buffer from a Process • Recent graphics hardware has multiple layered frame buffer. • To coordinate layers efficiently, an application process wants to issue rendering commands and switch on / off display of each layer. Layer #1 (/dev/fb0) Display Unit Application process Layer #2 (/dev/fb1) Layer #3 (/dev/fb2) IGEL Co.,Ltd. / Renesas Solution Corp.
Using ‘Scroll’ Function on Hardware • Use Case: car navigation system, web browser • The ‘Scroll’ function reduces re-rendering cost. Display start position A C B B’ A’ C’ Simple scroll Wraparound scroll IGEL Co.,Ltd. / Renesas Solution Corp.
rendering rendering rendering rendering rendering Fact miss miss miss miss Interrupt signal handling A heavy task was joined. Synchronous Rendering and Display with VSYNC (QoS) • In real-time motion graphics applications, the screen must be updated in sync with the VSYNC signal. • Under the standard (fairly) task scheduling in Linux, rendering might miss display timing (VSYNC) because of signal interrupts or other heavy tasks. y=16.6ms(for NTSC) Other tasks VSYNC Ideal Rendering task keeps needed resources in every VSYNC time slots. IGEL Co.,Ltd. / Renesas Solution Corp.
Synchronous Rendering and Display with VSYNC (Delay Handling) • Real-time motion graphics applications could be optimized for screen rendering, especially for delay handling. • Application needs VSYNC signal timing to notice the delay. IGEL Co.,Ltd. / Renesas Solution Corp.
Delay Handling by Application • Example 1: Skipping the next frame rendering • When an application noticed that display has been delayed, it could skip the next frame and start rendering the frame after the next. Skip the frame #3 y=16.6ms(for NTSC) Catch up the delay VSYNC Frame #2 Frame #4 Rendering Frame #1 Display Frame #1 Frame #1 Frame #2 Frame #4 miss Ideal Frame #1 Frame #2 Frame #3 Frame #4 IGEL Co.,Ltd. / Renesas Solution Corp.
Delay Handling by Application (contd.) • Example 2: Updating screen even if the rendering is not finished • Additionally, application could give priority to rendering operations in case of incomplete frame displaying. Terminate rendering #2 y=16.6ms(for NTSC) VSYNC Frame #2 Frame #3 Frame #4 Rendering Frame #1 Uncompleted frame #2 Display Frame #1 Frame #3 Frame #4 Enforce display #2 Ideal Frame #1 Frame #2 Frame #3 Frame #4 IGEL Co.,Ltd. / Renesas Solution Corp.
Synchronize 2D Engine and 3D Engine • Many 3D graphics applications combine 3D graphics and 2D graphics. • These 2D graphics must be synchronized with 3D graphics. • Some 3D acceleration hardware (nVIDIA, ATI, for example) are separated from 2D hardware. • Synchronization mechanism between 2D and 3D graphics (hardware) is needed. IGEL Co.,Ltd. / Renesas Solution Corp.
Synchronization Problem in 2D Engine and 3D Engine • Situation 1: Rendering 2D graphics and 3D graphics into a single layer simultaneously • 2D engine and 3D engine tries to draw into a frame without any synchronization. They should be serialized. • Issued rendering commands might be performed asynchronously. 2D Engine Layer Application 3D Engine Display IGEL Co.,Ltd. / Renesas Solution Corp.
Synchronization Problem in 2D Engine and 3D Engine • Situation 2: Displaying a 2D graphics layer and a 3D graphics layer synchronously • 2D/3D engines can draw into each independent layer asynchronously if the multiple layered frame buffer is available. • Synchronous display function is still needed. 2D Layer 2D Engine Synchronous display Application 3D Layer 3D Engine IGEL Co.,Ltd. / Renesas Solution Corp.
Conclusion • We need to consider wherther DirectFB API should / could cover all application requirements or not. • We would like to submit proposals and distribute implementations against the issues. IGEL Co.,Ltd. / Renesas Solution Corp.