SDL, tearing, X overhead and direct framebuffer gfx

2008-02-17 Thread Tobias Oberstein
Hello tableteers,

I've done some initial experiments hacking my N800/OS2008 and ran into a
couple of issues:

When using the supplied SDL library for doing timer-based frame
rendering, there seems to be

- heavy tearing
- significant overhead due to X server
(rendering pipe is : SDL - X - Framebuffer)

[Note: yes, I'm aware that doing full screen blits is evil on the N800
due to limited framebuffer - video RAM bus bandwidth.]

Q: Is this expected behaviour? What could I do about the tearing? What
about the Xomap overhead?

==

I've read a lot of bits on the web 'bout mplayer, vsync, omapfb etc.
and tried to assemble a minimal example of using direct framebuffer
access for gfx output.

Q: I can't get the tearing away (only fixed at certain line positions).
What am I doing wrong?

Q: Also, frame rate is sluggish, though CPU load is much lower than
SDL/X. Ok, my FB example is not threaded like the SDL timer example ..
is that the reason for framerate even  15/s?

Q: btw - how can I shutdown Maemo Launcher/Hildon/Matchbox/Xomap?
Whenever I do one of

/etc/init.d/maemo-launcher stop
/etc/init.d/x-server stop

the device will automatically reboot.

==

I wondered if there would be any plans to make SDL run directly on
framebuffer .. if not, I'd maybe give it a try.

Q: Where can I find the sources to the OS2008 SDL?

Thx and cheers,

tgo

=
SDL Test

=== Makefile:

##
## produce ARM11 target optimized code
## use hardware FP, but use soft FP ABI for math lib
##
OPT_FLAGS = -O3 -fomit-frame-pointer -mcpu=arm1136j-s -mfpu=vfp
-mfloat-abi=softfp

##
## SDL compile/link flags
##
SDL_FLAGS = `sdl-config --cflags` `sdl-config --libs`

##
## compiler command
##
CC = gcc -Wall $(OPT_FLAGS) $(SDL_FLAGS)


all: sdl_timer

sdl_timer: sdl_timer.c
$(CC) sdl_timer.c -o sdl_timer

=== Source:

//
// minimal timer based SDL fullscreen test for N800
//
// the test seems to indicate 2 problems:
//
//   1) heavy tearing
//   2) significant overhead due to X server (rendering pipe is : SDL -
X - Framebuffer)
//

/*

Mem: 90376K used, 36452K free, 0K shrd, 716K buff, 42956K cached
Load average: 1.01 0.64 0.44
   PID USER STATUS   VSZ  PPID %CPU %MEM COMMAND
   756 root SW11368   338 21.8  8.9 Xomap
  1831 root SW 12532  1365  7.3  9.8 sdl_timer
  1815 root RW  1960  1799  3.0  1.5 top
78 root SW0 6  2.7  0.0 OMAP McSPI/0
  1032 user SW32052   957  2.1 25.2 maemo-launcher
   376 root SW0 6  1.6  0.0 cx3110x
...

*/


#include stdlib.h
#include string.h
#include unistd.h
#include SDL.h

#define HRES  800
#define VRES  480
#define BPP   16


//
// frame render callback
//
Uint32 renderFrame (Uint32 interval, void *param)
{
   static int col = 0;

   // get screen surface from parameter
   SDL_Surface *screen = (SDL_Surface*) param;

   // lock surface if needed
   if (SDL_MUSTLOCK(screen))
   {
 if (SDL_LockSurface(screen)  0)
 {
   fprintf (stderr, unable to lock surface\n);
   exit(1);
 }
   }

   // render whole frame in single color
   memset(screen-pixels, ++col, HRES * BPP / 8 * VRES);

   // unlock surface if needed
   if (SDL_MUSTLOCK(screen))
   {
 SDL_UnlockSurface(screen);
   }

   // update whole screen
   SDL_UpdateRect(screen, 0, 0, HRES, VRES);

   // continue firing
   return interval;
}


int main (int argc, char** argv)
{
   // initialize SDL
   if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER)  0)
   {
 fprintf (stderr, unable to initialize SDL : %s\n, SDL_GetError());
 exit(1);
   }

   // register SDL cleanup
   atexit (SDL_Quit);

   // set mouse pointer invisible
   SDL_ShowCursor (SDL_DISABLE);

   // set video mode to fullscreen
   SDL_Surface *screen = SDL_SetVideoMode(HRES, VRES, BPP, SDL_SWSURFACE
| SDL_FULLSCREEN);

   if (screen == NULL)
   {
 fprintf (stderr, unable to initialize video : %s\n, SDL_GetError());
 exit(1);
   }

   // setup frame renderer at rate 17 frames/s (every 60ms)
   SDL_TimerID tid = SDL_AddTimer (60,
   (SDL_NewTimerCallback) renderFrame,
   screen);

   // run for 60 secs
   sleep (60);


   // shutdown frame renderer
   SDL_bool ret = SDL_RemoveTimer (tid);

   if (!ret)
   {
 fprintf (stderr, could not shutdown timer : %s\n, SDL_GetError());
 exit(1);
   }

   // finished
   return 0;
}
===



=
Framebuffer Test

=== Makefile:

##
## produce ARM11 target optimized code
## use hardware FP, but use soft FP ABI for math lib
##
OPT_FLAGS = -O3 -fomit-frame-pointer -mcpu=arm1136j-s -mfpu=vfp
-mfloat-abi=softfp

##
## compiler command
##
CC = gcc -Wall $(OPT_FLAGS) -lX11


all: fb_minimal

fb_minimal: fb_minimal.c
$(CC) fb_minimal.c -o fb_minimal

=== Source:

//
//
// Test for direct framebuffer graphics bypassing X. (tested on N800)
//

Re: SDL, tearing, X overhead and direct framebuffer gfx

2008-02-17 Thread Tobias Oberstein
  Q: btw - how can I shutdown Maemo Launcher/Hildon/Matchbox/Xomap?
  Whenever I do one of
 
  /etc/init.d/maemo-launcher stop
  /etc/init.d/x-server stop
 
  the device will automatically reboot.
  There is a watchdog in place. I believe you can disable it with the
  flasher utility...
 
  Never tried but I think it should be possible to stop (almost)
  everything in reverse order without triggering reboot. In this case
  reboot may mean x-server was stopped before stopping other services that
  depend on it. Try to go over /etc/rc2.d/ and stop stuff in reverse order.

good idea! unfort. it doesn't work;(

I can do:

#/etc/init.d/zzinitdone stop
/etc/init.d/ttyusb0 stop
/etc/init.d/metalayer-crawler0 stop
/etc/init.d/mediaplayer-daemon stop
/etc/init.d/hulda stop
/etc/init.d/hildon-update-notifier stop
/etc/init.d/alarmd stop
/etc/init.d/obexsrv stop
/etc/init.d/osso-systemui stop
/etc/init.d/af-base-apps stop
#/etc/init.d/osso-ic stop
#/etc/init.d/wlancond stop
/etc/init.d/btcond stop
/etc/init.d/bluez-utils stop
/etc/init.d/libgpsbt stop
/etc/init.d/gpsdriver stop
/etc/init.d/dnsmasq stop
/etc/init.d/hildon-desktop stop
/etc/init.d/af-startup stop
/etc/init.d/maemo-launcher stop
/etc/init.d/product-code stop
/etc/init.d/ke-recv stop
/etc/init.d/osso-systemui-early stop
/etc/init.d/esd stop
/etc/init.d/multimediad stop
/etc/init.d/bme-dbus-proxy stop
/etc/init.d/dsp-init stop

all fine (osso-ic/wlancond I had to keep running, since I'm ssh'ing via 
WLAN into the device). but then, when I

Nokia-N800-50-2:~# /etc/init.d/af-services stop
Protecting UIDs 30001
30002
3 from the memory allocation denial.
Stopping media-server
Stopping Matchbox window manager
Stopping Sapwood image server
Stopping D-BUS session bus daemon
Stopping GConf daemon
sh: cannot kill pid 752: Operation not permitted
Stopping Periodical temporary file purging daemon
Nokia-N800-50-2:~#

and the device will reboot. The rest of reverse init would have been

/etc/init.d/x-server stop
/etc/init.d/mce stop
#/etc/init.d/ssh stop
/etc/init.d/osso-applet-display stop
/etc/init.d/dbus stop
/etc/init.d/fb-progress.sh stop
#/etc/init.d/zzinitdone stop

greets
tgo



___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Re: SDL, tearing, X overhead and direct framebuffer gfx

2008-02-17 Thread Tobias Oberstein
 sorry can't say much about the other things...
 
 Q: btw - how can I shutdown Maemo Launcher/Hildon/Matchbox/Xomap?
 Whenever I do one of

 /etc/init.d/maemo-launcher stop
 /etc/init.d/x-server stop

 the device will automatically reboot.
 
 There is a watchdog in place. I believe you can disable it with the
 flasher utility... 

Ah, ok. I'll check that out as soon as I got started with the flasher 
tool ..

greets,
tgo
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers