Dynamic Texture Array

Started by
4 comments, last by Hassanbasil 9 years, 10 months ago

Hello,

I'm trying to create a texture array that I want to update per frame. So I want to use D3D11_USAGE_DYNAMIC and ArraySize>1. but I get this error: D3D11 ERROR: ID3D11Device::CreateTexture2D: A D3D11_USAGE_DYNAMIC Resource must have ArraySize equal to 1. [ STATE_CREATION ERROR #101: CREATETEXTURE2D_INVALIDDIMENSIONS]

Why is that even a thing? Is there anything wrong with a dynamic texture array?

EDIT: I also tried 3D textures, there seems to be a minimum for the size of a row (128 in my case)? creating a 1x1x1 3D texture and then using Map gives RowPitch=128 (although format is 4 bytes per texel). Is this documented anywhere? there is not even a warning, using small textures messes up everything.

Regards,

Hasan Al-Jawaheri

Advertisement

D3D11 doesn't support dynamic textures with mipmaps or multiple array slices, which is why CreateTexture2D is failing. This is what you can do instead:

  • Create your Texture2D Array using D3D11_USAGE_DEFAULT
  • Create an identical Texture2D using D3D11_USAGE_STAGING
  • When you want to update the texture array, call Map with the STAGING texture and fill the memory
  • Use CopyResource to copy the contents from the STAGING texture to the DEFAULT texture

If you only want to update one slice at a time, you can do that as well by using CopySubresourceRegion.

D3D11 doesn't support dynamic textures with mipmaps or multiple array slices, which is why CreateTexture2D is failing. This is what you can do instead:

  • Create your Texture2D Array using D3D11_USAGE_DEFAULT
  • Create an identical Texture2D using D3D11_USAGE_STAGING
  • When you want to update the texture array, call Map with the STAGING texture and fill the memory
  • Use CopyResource to copy the contents from the STAGING texture to the DEFAULT texture

If you only want to update one slice at a time, you can do that as well by using CopySubresourceRegion.

I see. Would it be more efficient (performance and memory wise) to use a 3D texture instead?

Texture2DArray and 3D texture aren't same thing. The OP didn't specify the exact purpose for the texture array.

Cheers!

You probably don't want to use a 3D texture unless you need to filter between the different slices.

I'm using the texture to implement geometric clipmap based terrain. Basically, the texture is used by a Load call in the vertex shader. I thought, ignoring the "intuitive usage" of the texture, one ID3D11DeviceContext::Map for a 3D texture would be faster than a Map on a staging texture and a CopyResource. Plus it's probably using less memory.

This topic is closed to new replies.

Advertisement