Sunday, September 23, 2018

c++ - How to create and populate a 2D Texture Arrays in DirectX11


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.



Answer



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.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...