Sign in to follow this  

ImmediateContext.MapSubresource out of memory error

Recommended Posts

rtclawson    168

I am writing to a 3D texture with the format SlimDX.DXGI.Format.R16_UNorm, and using the following call:


DataBox b = _device.ImmediateContext.MapSubresource(_volumeTexture, 0, 0, MapMode.WriteDiscard, MapFlags.None);


For a texture that is 512x512x512, I get an E_OUTOFMEMORY error.  512 * 512 * 512 * 2 = 268?435?456 bytes.


The only other graphics objects that have been created are two small buffers for vertex lists, and a 2D texture that is 512x512.


My graphics card is the AMD FirePro V5900 (FireGL V), which should have at least 2GB of available video memory, and my system has 4GB of RAM. In short, I don't see how it is possible to be out of memory in this case.


How shall I go about debugging this problem? Any common errors I should be looking for?

Share this post

Link to post
Share on other sites
MJP    19754

Dynamic textures get special treatment in drivers. Typically the driver will managed a small-ish, fixed pool of memory from which it will temporarily allocate whenever you map a resource with DISCARD. I'm not surprised that it can't handle such a large 3D texture, since having CPU provide that much data for the is a pretty bad idea in terms of performance. What you can do instead is create your texture in with DEFAULT usage, and then create another buffer with STAGING usage. Then when you want to update the texture you map the staging texture, fill it with data, unmap it, and copy the data to the actual texture. With this method you can also efficiently update only a portion of your texture instead of having to fill the entire resource.

Share this post

Link to post
Share on other sites

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