Entropia posted on May 29 2006 at 11:57 AM said:
Feeblez posted on May 29 2006 at 01:42 PM said:
Entropia posted on May 29 2006 at 09:10 AM said:
I have recently acquired my GP2X and started porting some of my old demoscene effects to it, the problem is ridiculously slow rendering speeds with SDL. I am using Octoate's toolchain and AFAIK it includes Paeryn's HW accelerated SDL libs. I have written a simple "fill every pixel one by one" program using pixelRGBA-function (the only one I could find to replace putpixel). With my surface inited as SW_BUFFER, filling a screen takes over 10 seconds and with HW_BUFFER it's still nearly half a second! :blink: I'm guessing the pixelRGBA isn't the fastest function to use? What should I use/do instead?
You code demoscene effects and using putpixel!? :blink:
Sorry, i don't know anything about SDL, but like DrDerekDoctors said, you should be able to lock the screen buffer and get direct pointer access, that should be a lot faster.
Oldskool! Anyways, I'll try locking my surface before tossing anything on the actual screen.
Accessing a HWSURFACE directly
is slow, that's the price you have to pay for having quick access by the accelerated methods (Blit & FillRect). HWSURFACEs are not cached and can have memory access times of as low as 40% compared to reading/writing to main memory - worse if you only access with 8 or 16 bit values at a time.
The proper way of writing directly to a surface is as said above:
1: Just before you start writing to a surface call SDL_LockSurface() to make sure that SDL has finished any async operations with it.
2: Grab the surface's bitmap address, stride, anything else you need.
3: Do what you want to the surface's pixels, try to make sure you write 32bit values (2 or 4 pixels at a time).
4: Unlock the surface to allow SDL's async functions to resume.
At no time between Lock() and Unlock() should you make calls to BlitSurface() and FillRect(). Ideally you shouldn't make any calls to SDL functions when a surface is locked to avoid entering a deadlock.