I've been trying to implement a skybox for some time now and there's probably only a tiny problem left to solve. When I load a texture using DirectXTK's CreateDDSTextureFromFileEx with a TEXTURECUBE flag, the resulting shader resource has its view dimension set to Texture2D and not TextureCube, which means I can't treat it as a TextureCube in HLSL. Also the file I'm loading contains all six faces. Here's the code where the texture is loaded:

// Loading the texture
HRESULT hr = DirectX::CreateDDSTextureFromFileEx(device, filename, 0, D3D11_USAGE_IMMUTABLE, D3D11_BIND_SHADER_RESOURCE, 
    0, D3D11_RESOURCE_MISC_TEXTURECUBE, false, &texture, &mSkyboxSRV);

This is the error message being output by DirectX:

D3D11 ERROR: ID3D11DeviceContext::Draw: The Shader Resource View dimension declared in the shader code (TEXTURECUBE) does not match the view type bound to slot 0 of the Pixel Shader unit (TEXTURE2D). This mismatch is invalid if the shader actually uses the view (e.g. it is not skipped due to shader code branching). [ EXECUTION ERROR #354: DEVICE_DRAW_VIEW_DIMENSION_MISMATCH]

I've also tried this:

ID3D11Texture2D* texture = nullptr;

HRESULT hr = DirectX::CreateDDSTextureFromFileEx(device, filename, 0, D3D11_USAGE_IMMUTABLE, D3D11_BIND_SHADER_RESOURCE, 
0, D3D11_RESOURCE_MISC_TEXTURECUBE, false, (ID3D11Resource**)&texture, nullptr);



srvDesc.TextureCube.MipLevels = texDesc.MipLevels;
srvDesc.TextureCube.MostDetailedMip = 0;
srvDesc.Format = texDesc.Format;
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;

hr = device->CreateShaderResourceView(texture, &srvDesc, &mSkyboxSRV);

But that gives me an error message saying the texture's view dimension and the srv's view dimension are not the same:

D3D11 ERROR: ID3D11Device::CreateShaderResourceView: Resources created without D3D11_RESOURCE_MISC_TEXTURECUBE may not be treated as cubemap ShaderResourceViews. [ STATE_CREATION ERROR #126: CREATESHADERRESOURCEVIEW_INVALIDDESC]

Does anyone have any ideas on what to do? Any help is much appreciated!

  • \$\begingroup\$ Does the DDS you are using actually contain a cubemap or does it contain a texture 2D array? If you can share a link to the DDS, I can take a look. \$\endgroup\$ Commented Aug 5, 2018 at 19:04
  • \$\begingroup\$ Note that one immediate problem here is that you shouldn't do the cast you did above in the second code block which is not safe for COM interfaces. You should use ID3D11Resource* and then use QueryInterface to convert to a ID3D11Texture2D*. ComPtr makes this a lot easier. See the DirectXTK wiki for a more complete code sample that can also help in diagnosing your problem. \$\endgroup\$ Commented Aug 5, 2018 at 19:06
  • \$\begingroup\$ The DDSTextureLoader also ignores the D3D11_RESOURCE_MISC_TEXTURECUBE flag as a parameter. I should probably not clear it out in the case of a 2D texture array DDS if it has a multiple of 6 array entries... Otherwise it's not valid or it's set anyhow if the DDS is actually a cube map. \$\endgroup\$ Commented Aug 5, 2018 at 19:12

1 Answer 1


When trying to debug failing DDS loads, you should do the following:

  • Verify the DDS contains what you think it should. See DDSDump.cpp as a useful first-step.

  • If you are getting a SUCCESS HRESULT back from the loader, then use the ID3D11Resource** parameter and use the code on the wiki to validate it is what you think it should be.

  • Otherwise, step into the DDSTextureLoader code line-by-line to see where it is failing...

UPDATE: As of the August 2018 release of DirectX Tool Kit, if you call CreateDDSTextureFromFileEx with the D3D11_RESOURCE_MISC_TEXTURECUBE flag in the parameters -and- the DDS contains a 2D texture array with a multiple of six entries, then I'll pass it along as if it's a cubemap.

See this commit

  • \$\begingroup\$ Again, thanks Chuck. It was the file lacking a header. \$\endgroup\$
    – Theo
    Commented Aug 6, 2018 at 19:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .