Sign in to follow this  

Fastest way to write to video memory

This topic is 4838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to write an application that writes directly to video memory. This should be a really easy thing to do so I start out with direct draw but remembers that is now included in direct3d so i switched to d3d9 (can this be a misstake?). The problem is now that there are several ways of accessing (writing to) the video memory. One could use GetDc, LockRect D3DXLoadSurfaceFromMemory and so on. I realize ofcourse that every function has it's own advantages but I guess I have to figure out what it is.. My question is really which is the fastes and best method to use when I want to update the entire screen with a content that is specific per pixel and no texture or built in primitives can be used? An example of such an application is a fractal zoomer. The method I have used so far is locking the surface updating it one pixel after the other and then unlocking it. I guess this is not optimal and would guess it is best to render the content to system memory and then copy it to video memory. Is this a correct assumption? Are there any specifc methods prefered? Or I'm I just out of my mind trying to do this in windows and direct3d?

Share this post


Link to post
Share on other sites
Avoid anything to do with a DC, it's SLOW. For demo style pixel effects it will not fly.

They way I did it for a standard Fire effect is:
1)Create a texture, with the DYNAMIC flag set if it's supported. This is where you'll render. You'll want this relatively small and then stretched to full, you'll have to experiment with the speed/size trade-off.
2)Calculate effect in a system memory array (optional, if the effect doesn't need to read from the array, it's purely write-only then you don't need to do this)
3)Lock the texture
4)Write to the texture
5)Unlock texture
6)Render to backbuffer as a quad
7)Present

Actually you should make 2 textures and double-buffer.

Share this post


Link to post
Share on other sites

This topic is 4838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this