DirectX surfaces: system memory or video memory?

Started by
6 comments, last by Liquid 23 years, 11 months ago
I''m adding a software rendering component to my existing project, and was wondering if anyone knew from experience what would be a better approach: 1. Create the primary surface in video memory. Create the back buffer surface in system memory since reads/writes are much faster to system memory. Each frame is rendered and then bltted (which would probably be without hardware acceleration) to the primary surface. 2. Create the primary surface and back buffer in video memory and use hw-assisted blts. Now, taking into consideration that missing the VBI can cut your frame rate in half (which most people don''t seem to realize and consequently complain that their frame rate was cut in half when they switched to system memory surfaces) would it be better to render into a system memory buffer and transfer all that data over the system bus or to create both surfaces in video memory and deal with the slower writes and have a blt that returns almost instantly? I''m not bltting from any other surfaces, my code renders directly into the back buffer. thanx, -Liquid
Advertisement
This is for windowed mode rendering, not fullscreen. In windowed mode, you can''t have a flipping chain.

-Liquid
Personnally I like to create both front and back buffers in vidmem. This allows for easy sync''ing to the vertical retrace and if you have borders and such you can use hw accerated blts (vid to vid mem) to copy them to the back buffer once the frame is complete. This means you need a scratch surface in sysmem that is the same size as your back buffer. pushing a whole screens worth od data over the bus can be demanding, if it applies you can use dirty-rects to ease the load.

2-cents.

hebertjo
hebertjo
I think it really depends how much hardware blitting you are doing, as opposed to your own drawing routines.

If you''re not using hardware blitting from offscreen surfaces, but you are writing each pixel individually, then its probably faster to create the backbuffer in system memory. Also, if you''re using Direct3DIM to do any rendering, I think the software renderer will be faster this way.

The best way is usually to add a frame rate counter and test it both ways (it only means changing a flag)!
Unless you are manipulating the surfaces yourself via Lock() and Unlock(), all of your graphics should be in vidmem.

You only want graphics in sysmem if:
1. you are rarely blitting the surface to anywhere
2. you are changing pixel values yourself

I think its best to create all surfaces in video mem, unless its going to be manipulated alot.
-------------I am a Juggalo.
As far as I know the primary surface always has to be in video memory. By specifying the PRIMARY surface flag when creating the surface you tell it to be in video memory and by making a flipping chain in fullscreen you also tell the back surfaces to be in video memory.
I'm not sure what happens in windowed mode.
Correct me if I'm wrong.

Edited by - Mr Cucumber on May 20, 2000 7:43:30 AM
In windowed mode, you don''t use complex surfaces.
You create the primary surface, and then the back buffer separately.

This topic is closed to new replies.

Advertisement