[DX11]Load Texture2DArray from file

Started by
1 comment, last by pcmaster 11 years, 11 months ago
Hi guys!

Saving texture arrays to DDS files via D3DX11SaveTextureToFile() works well.

If I try to load the very same file using D3DX11CreateShaderResourceViewFromFile(), I only get a Texture2D (NON-array), at least according to the SRV descriptor. However, the resource which the created SRV points to is indeed a texture array, as expected.

D3DX11GetImageInfoFromFile() fills D3DX11_IMAGE_INFO::ArraySize equal to the correct number of array slices. Just the SRV is "broken" and can/must be recreated by hand. It doesn't seem to matter whether I include a D3DX11_IMAGE_INFO instance in D3DX11_IMAGE_LOAD_INFO::pSrcInfo or not, when calling D3DX11CreateShaderResourceViewFromFile().

Is this a bug or Microsoft feature? :-) :-)
Advertisement
Have you tried to load a texture array from a different source? Perhaps there is something special about the file that you are saving, but it doesn't sound like it...
Not really, I don't have any other DDS files with arrays, besides those I create using D3DX functions. Or what did you mean by source? Like from memory or resource? I guess they use the very same loading code for that. D3DX11CreateTextureFromFile() seems to load the file correctly. Weird...

This is the file: http://shell.sh.cvut.../tex2Darray.dds

ID3D11Resource * res = NULL;
D3DX11CreateTextureFromFile(D3DD, L"tex2Darray.dds", NULL, NULL, &res, NULL);
D3D11_TEXTURE2D_DESC tex2Ddesc;
static_cast<ID3D11Texture2D*>(res)->GetDesc(&tex2Ddesc);

ID3D11ShaderResourceView * srv = NULL;
D3DERR_CHECKQ(D3DX11CreateShaderResourceViewFromFile(D3DD, L"tex2Darray.dds", NULL, NULL, &srv, NULL));
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
srv->GetDesc(&srvDesc);
ID3D11Resource * res2 = NULL;
srv->GetResource(&res2);
D3D11_TEXTURE2D_DESC tex2Ddesc2;
static_cast<ID3D11Texture2D*>(res2)->GetDesc(&tex2Ddesc2);

Result:
srvDesc.viewDimension == D3D11_SRV_DIMENSION_TEXTURE2D (wtf)
tex2Ddesc2.ArraySize == 2 (expected)
tex2Ddesc.ArraySize == 2 (expected)

Looks like a bug to me :-)

This topic is closed to new replies.

Advertisement