Accessing video memory quickly with DDraw
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.
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.
- 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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement