Direct3D memory usage

I have a Direct3D 9 application and I would like to track memory usage. Is there a tool to find out how much system and video memory Direct3D is using? Ideally it will also tell you how much is allocated for textures, vertex buffers, index buffers ...

+1


source to share


2 answers


You can use the old DirectDraw interface to query for shared and available memory.

The rooms you get this way are not reliable though .

Free memory can change at any time, and available memory often takes AGP memory into account (which is not strictly video memory). You can use numbers to give a good guess about the default texture resolutions and level of detail for your application / game, but that's it.

You may be wondering why there is no way to get better numbers, as it won't be easy to track resource usage.

From the point of view of the application, this is correct. You might think that video memory just contains surfaces, textures, index and vertex buffers and some shader programs, but this is not the case on the low-level side.



There are many other resources. They are all created and controlled by the Direct3D driver to make rendering as fast as possible. Among other things, there are hierarchical z-buffer acceleration structures, pre-compiled instruction lists (for example, the data needed to render something in a format that the GPU can understand). The driver can also pause render commands for multiple frames ahead of time to flatten frame rates and increase parallelism between GPU and CPU.

The driver also does a lot of work under the hood for you. The heuristic is used to detect callbacks with static geometry and constant render settings. The driver may decide to optimize the geometry in these cases for better cache utilization. All this happens in parallel and under the control of the driver. All of this requires space, so free memory can change at any time.

However, the driver does cache your resources as well, so you really don't need to know resource usage in the first place.

If you need more space than is available, this is not a problem. The driver will move data between system RAM, AGP memory and camcorder for you. In practice, you never have to worry about running out of video memory. Sure - when you need more video memory than is available, performance will suffer, but this life :-)

+7


source


Two suggestions:

You can call GetAvailableTextureMem at different times to get a (rough) estimate of the total memory usage.

Assuming you are developing on nVidia, PerfHUD includes a graphical representation of consumed AGP / VID memory (split).



You probably won't be able to get a nice clean matrix of memory consumers (vertex buffers, etc.) and memory location (AGP, VID, system), as -

(1) the driver has great freedom in transferring resources between memory types and

(2) the actual variety of memory consumers is much greater than the open interfaces of D3D.

+2


source







All Articles