bad performance on low spec machine

Bug #243352 reported by Thunor
2
Affects Status Importance Assigned to Milestone
Freenukum
Fix Released
Medium
Wolfgang Silbermayr

Bug Description

Hi silwol

The reason freenukum is slow on my machine is because you are requesting a video surface of 24bpp and if SDL cannot give you this it will emulate it! This is very bad; my desktop is 32bpp. If I set FN_COLOR_DEPTH to 32 it's fast with pixelsize=2 :)

Therefore you can do this: pass "SDL_SWSURFACE | SDL_ANYFORMAT" as the flags when settting the video mode and this will use whatever bpp is available, or you can pass 0 as the bpp and SDL will use the desktop bpp. See here -> http://www.libsdl.org/cgi/docwiki.cgi/SDL_SetVideoMode

Now, when you create surfaces for tiles and pictures, you want them to be the same format as the screen otherwise SDL will have to convert the source pixel to the destination pixel format, so instead of FN_COLOR_DEPTH use "screen->format->BitsPerPixel" instead.

Regards

Revision history for this message
Thunor (thunor) wrote :

I hacked my copy of the source. This is what I did :-

Delete FN_COLOR_DEPTH from fn.h

In every function that uses FN_COLOR_DEPTH except main, place "int color_depth = SDL_GetVideoSurface()->format->BitsPerPixel;" at the top and change FN_COLOR_DEPTH to color_depth.

There is one problem: the tiles are loaded before the video mode is set, and fn_tile_load in fn_tile.c creates surfaces and it needs to know the screen bpp! The SDL docs state that SDL_CreateRBGSurface must be called after SDL_SetVideoMode, so you should set the video mode first and then load the tiles -> http://www.libsdl.org/cgi/docwiki.cgi/SDL_CreateRGBSurface

Also I noticed that you are not calling SDL_Quit(), or I can't find it. This is important -> http://www.libsdl.org/cgi/docwiki.cgi/SDL_Quit

Regards

Changed in freenukum:
assignee: nobody → silwol
importance: Undecided → Medium
milestone: none → 0.3
status: New → Confirmed
Revision history for this message
Wolfgang Silbermayr (silwol) wrote :

fn.h now defines FN_SURFACE_FLAGS with SDL_ANYFORMAT and all apis and SDL_CreateSurface calls are now designed in the way that they use the Bits Per Pixel and SDL-Flags which are in the initial screen object.

Changed in freenukum:
status: Confirmed → In Progress
Revision history for this message
Wolfgang Silbermayr (silwol) wrote :

Thunar, could you verify if the changes cause a speedup on your system using the current bzr version?

Revision history for this message
Thunor (thunor) wrote :

I tested the 0.2.6 version, played through 3 levels and it is fast.

Wunderbar :)

Changed in freenukum:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.