Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

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).

share|improve this answer
    
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? –  khanhhh89 May 14 at 1:19
add comment

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.

share|improve this answer
add comment

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.