So what is the fastest way to get data computed on the CPU into a surface? I feel that pixel plotting would be too slow so I figured I could speed things up if I computed pixels for an entire line (possibly more) before writing the results to video memory.
I was thinking that there would be something Blt() which would be able to transfer memory from a buffer in main memory to video memory but I've been unable to find something like that without first going through some HBITMAP or something like that.
Many thanks.
Main Topics
Browse All Topics





by: thegilbPosted on 2007-05-22 at 05:33:54ID: 19133288
Some of your pseudo-code is a little bit sketchy on the details which are important but there are a few things to think about:
1.) Memory; It's faster to keep your data in a surface than in an array. If you can keep your data in the surface then do that instead of just using it as an intermediate data storage.
2.) Alignment; It looks as though you are working with a surface which has a linear memory layout. On some hardware it is faster to create a non-linear surface (One where the pitch and stride need to be used to plot a pixel). Other than that working with 128 bytes is a nice round number (In binary :-)
3.) Hardware support for 4bpp display mode is uncommon (8bpp is the norm) then you may find you need to convert your data to the correct format (8bpp) before flipping. You may find this to be quite costly and it would be faster to store your data in 8bpp (1byte = 1pixel) but just use the first 16 palette entries.
4.) CPU cycles are a valuable resource on a PPC device, beware of CPU wastage. Also embedded chipsets tend not to be as advanced as desktop counterparts so old-skool optimisation tricks will work well to save those cycles on these devices.
Hope that helps! Good luck!