Jump to content
  • Advertisement
Sign in to follow this  
Hassanbasil

Dynamic Texture Array

This topic is 1501 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

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

Edited by Hassanbasil

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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

 

Cheers!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!