Question

Is there a way of taking an array of ID3D11Texture2D* objects and putting them together in a single ID3D11Texture2D* (with an appropriate ArraySize value) that will allow me to use a Texture2DArray in HLSL with them?

At the very least, how do you pass in the individual textures when creating a new ID3D11Texture2D object after you have set ArraySize to greater than 1? Do you need to pass in an array of SUBRESOURCE_DATA structs with each pointing to a texture to the CreateTexture2D function? I've been looking around for an answer to this, but the documentation seems severely lacking.

Thanks for any help you can provide.

Was it helpful?

Solution

To copy existing textures to a texture array, you can use CopySubresourceRegion using the destination subresource index described below.

To create a new texture array with initial data, you specify multiple subresources (array slices / mip levels) using an array of SUBRESOURCE_DATA structures. Subresource index is defined as mip slice + array slice * mip leves. So for a 2-slice 3-MIP texture array, you would have the following subresources:

[0]: slice 0 mip 0
[1]: slice 0 mip 1
[2]: slice 0 mip 2
[3]: slice 1 mip 0
[4]: slice 1 mip 1
[5]: slice 1 mip 2

This is described in more detail at the following page: https://learn.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-resources-subresources

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top