1
\$\begingroup\$

I'm trying to create a texture2DArray from multiple of images, each of which has different formats, and I got the following error from the DirectX11 debug layer.

D3D11 ERROR: ID3D11DeviceContext::CopySubresourceRegion: Cannot invoke CopySubresourceRegion when the Formats of each Resource are not the same or at least castable to each other, unless one format is compressed

I want to ask you there is any way of creating a texture2d array in Directx 11 with different format?

\$\endgroup\$
3
\$\begingroup\$

No can do; the format and array size are both members of the D3D11_TEXTURE2D_DESC structure, so an ID3D11Texture2D will always have the same format for any value of array size.

Depending on how you use the texture, you could create different shader resource views specifying subranges of the full array, provided the SRV format is compatible with the texture format. Generally that means you'd use a TYPELESS format for your texture and a typed format for your SRV; e.g a textere with DXGI_FORMAT_R32G32B32_TYPELESS could use any R32G32B32 typed format (_FLOAT, _UINT, _SINT).

\$\endgroup\$
  • \$\begingroup\$ I need rendering all the scene in one pass, so I need to wrap all the textures that the scene need. So my idea is to use a texture2Darray. As you said, how can I create an array of shader resource views for passing to the pixel shader? \$\endgroup\$ – khanhhh89 May 14 '14 at 1:19
0
\$\begingroup\$

As noted already, you cannot create a TextureArray with different formats or sizes. They all must have the same for both.

That said, the binding limit for simultaneous textures with Direct3D 11 and Feature Level 10.0 is 128, so you could just bind up to 128 individual SRVs in a single pass. TextureArrays already require Feature Level 10.0, and Feature Level 9.x can only bind up to 8 textures at a time.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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