Sign in to follow this  
Quat

d3d10 texture arrays

Recommended Posts

Suppose I have a sequence of frames for a sprite animation, and I want to store them in a texture array. Then I will just increment the index, say, every 30th of a second to flip to the next frame in the animation. What is the best way to fill the texture array at load time? Right now I am just thinking: 1. Call ID3D10Device::CreateTexture2D with number of texture array elements. 2. Call ID3D10Texture2D::Map and fill each texture layer. But, I'm looking for an easier way. Is there a way to load each frame into an ID3D10Texture2D with D3DX10CreateTextureFromFile and then call a D3D10 function to copy a texture into a texture of a texture array? In short, is there a D3D10 function to copy an ID3D10Texture2D onto a texture in a texture array?

Share this post


Link to post
Share on other sites
Try ID3D10Device::CopySubresourceRegion. That should let you copy a whole frame texture into a subresource of a texture array. Refer to the docs for details.

Another option is to save the animation frames into one big, continuous texture like this:
[F1][F2][F3]...[Fn]
instead of a tiled version like this:
[F1][F2]
[F3][F4]

then load the whole thing as a single 2D texture. Finally, create a shader resource view for a 2D texture array. Using parameters something like this:
Format,
D3D10_SRV_DIMENSION_TEXTURE2DARRAY,
Texture2DArray.ArraySize = the frame count in the big texture
...

This will give the best loading performance imo, since you only have to load it once, and the SRV does not create any overhead.

These are just ideas.

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