Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer
    
Thank you for the answer. For your second option, do I specify which index in the D3D11_RENDER_TARGET_VIEW_DESC paramter of CreateRenderTargetView? – Caesar Nov 22 '13 at 21:22
    
@Caesar Set ViewDimension to D3D11_RTV_DIMENSION_TEXTURE2DARRAY, then set the members of the Texture2DArray struct in the desc. – Nathan Reed Nov 23 '13 at 2:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.