Accessing video memory quickly with DDraw

Started by
1 comment, last by narfidoo 23 years, 8 months ago
I''m using directdraw and I do many per pixel calculations. This is always very slow unless I specify DDSCAPS_SYSTEMMEMORY when creating the surfaces. But then, all blits are extremely slow. Is there a way I can make accessing video memory faster? Thanks.
Advertisement
Accessing video memory is always a bit slow. I dont''t know what exactly you are trying to do but here are a few tips:

- use DDLOCK_NOSYSLOCK flag when locking the surface (no use if you lock the primary surface)
- use the DDLOCK_WRITEONLY or DDLOCK_READONLY flag if possible

Try not to make your calculations directly with the surface. Allocate a normal memory block, do your calculations there and write the data once per frame to the surface (This is only useful if you have to access a certain pixel several times).

This will however not work good if you try to write a software alpha blitter or a fader or something like that, but it worked fine for my fire effect.
I keep all of my surfaces in client memory, but I blt directly to video memory. I use asm blts, so colorkeys are still fast.

I can''t give better suggestions without knowing what you''re doing. Use MMX, since you can work with more than one pixel at a time then.
For a good time hit Alt-F4! Go ahead try it, all the cool people are doing it.

This topic is closed to new replies.

Advertisement