1
\$\begingroup\$

I have generated a bunch of ID3D11ShaderResourceView that are a 2D textures that have a depth map screen shot for my lights shadows. I would like to take all of these textures and put them into a single 2D Texture Array.

I have seen examples of how to create a 2D Texture array like in this question here but I don't know how to copy the data to the newly created texture array.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

You can use CopySubresourceRegion to copy data between textures. "Subresource" means a combination of mip level and array index, so here you would copy to the subresource corresponding to the desired index in your texture array.

However, it's best to avoid copying data between textures if possible, as it does take time. Instead of rendering to a bunch of 2D textures and copying into the array, it would be faster to render directly to the array. You can do this by creating a render target view that points to a specific subresource in the texture array.

\$\endgroup\$
2
  • \$\begingroup\$ Thank you for the answer. For your second option, do I specify which index in the D3D11_RENDER_TARGET_VIEW_DESC paramter of CreateRenderTargetView? \$\endgroup\$
    – Caesar
    Nov 22, 2013 at 21:22
  • \$\begingroup\$ @Caesar Set ViewDimension to D3D11_RTV_DIMENSION_TEXTURE2DARRAY, then set the members of the Texture2DArray struct in the desc. \$\endgroup\$ Nov 23, 2013 at 2:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .