Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Dynamic Texture Array

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
5 replies to this topic

#1 Hassanbasil   Members   

195
Like
0Likes
Like

Posted 13 June 2014 - 08:20 AM

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, 13 June 2014 - 09:47 AM.


#2 MJP   Moderators   

19419
Like
3Likes
Like

Posted 13 June 2014 - 11:21 AM

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.



#3 Hassanbasil   Members   

195
Like
0Likes
Like

Posted 13 June 2014 - 12:27 PM

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?



#4 kauna   Members   

2922
Like
0Likes
Like

Posted 13 June 2014 - 12:29 PM

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

 

Cheers!



#5 MJP   Moderators   

19419
Like
2Likes
Like

Posted 13 June 2014 - 12:32 PM

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



#6 Hassanbasil   Members   

195
Like
0Likes
Like

Posted 13 June 2014 - 04:02 PM

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.






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.