Jump to content
  • Advertisement
Sign in to follow this  

DX11 Create texture array problem

This topic is 2001 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



I am working on a C++ application using DirectX 11.

I'm trying to create a texture array but I can't get the CreateTexture2D() function to work.


First i'm loading multiple PNG files using :

ZeroMemory(&loadInfo, sizeof(loadInfo));
loadInfo.Width  = D3DX11_FROM_FILE;
loadInfo.Height = D3DX11_FROM_FILE;
loadInfo.Depth  = D3DX11_FROM_FILE;
loadInfo.FirstMipLevel = 0;
loadInfo.MipLevels = D3DX11_FROM_FILE;
loadInfo.Usage = D3D11_USAGE_STAGING;
loadInfo.BindFlags = 0;
loadInfo.CpuAccessFlags = D3D11_CPU_ACCESS_WRITE | D3D11_CPU_ACCESS_READ;
loadInfo.MiscFlags = 0;
loadInfo.Format = DXGI_FORMAT_FROM_FILE;
loadInfo.Filter = D3DX11_FILTER_NONE;
loadInfo.MipFilter = D3DX11_FILTER_LINEAR;
loadInfo.pSrcInfo  = 0;

HRESULT hrat = D3DX11CreateTextureFromFileA(_pDevice, _fileName.c_str(), &loadInfo, NULL, reinterpret_cast<ID3D11Resource **>(&_pArrayTex), NULL);

It works just fine.

Then I put all those textures in a vector and pass it to a function to create the texture array using :

ID3D11Texture2D * pTex = texList[0];

D3D11_TEXTURE2D_DESC texArrayDesc;
ZeroMemory(&texArrayDesc, sizeof(texArrayDesc));
texArrayDesc.Width              = texDesc.Width;
texArrayDesc.Height             = texDesc.Height;
texArrayDesc.MipLevels          = texDesc.MipLevels;
texArrayDesc.ArraySize          = texList.size();
texArrayDesc.Format             = texDesc.Format;
texArrayDesc.SampleDesc.Count   = 1;
texArrayDesc.SampleDesc.Quality = 0;
texArrayDesc.Usage              = D3D11_USAGE_DEFAULT;
texArrayDesc.BindFlags          = D3D11_BIND_SHADER_RESOURCE;
texArrayDesc.CPUAccessFlags     = 0;
texArrayDesc.MiscFlags          = 0;

ID3D11Texture2D * texArray = NULL;
HRESULT hrct = _pDevice->CreateTexture2D(&texArrayDesc, NULL, &texArray);

And this is where it goes wrong, when I try to run my App, I get :


Exception non gérée à 0x000ea133 dans CoreEngine.exe : 0xC0000005: Violation d'accès lors de la lecture de l'emplacement 0x00000000.


It seems like the function is trying to read from pInitialData, but I don't understand why.

I just want to create an empty texture array, the resource will be written later using UpdateSubresource().


Any advice would be nice!



Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!