When supplying pInitialData ID3D11Device::CreateTexture2D() crashes in atidxx32.dll!5517c4d0()
Hi I am modifying Tutorial 7 of the June 2010 DirectX SDK to create a texture from a custom array of data. If I create the texture without supplying subresource data and manually load each mip level via ID3D11DeviceContext::UpdateSubresource() it works fine. When I supply the texture data in ID3D11Device::CreateTexture2D() it crashes with an access violation at atidxx32.dll!5517c4d0(). This happens when creating both immutable and default pool textures with mipmaps. If I set the number of mip levels to 1 then it works fine.
I am running win7 x64 on a laptop with an ATI Radeon Mobility 4650. After first encountering this problem with the October 2010 drivers I updated to the December 14th drivers and it still occurs. Unfortunately I don't have another machine to try and reproduce the problem on. Here is the stack trace:
atidxx32.dll!5517c4d0()
[Frames below may be incorrect and/or missing, no symbols loaded for atidxx32.dll]
atidxx32.dll!54f7cd10()
atidxx32.dll!54f7c45a()
atidxx32.dll!54f7bdec()
atidxx32.dll!54f4a9a9()
atidxx32.dll!54f42ff9()
atidxx32.dll!54f4594a()
atidxx32.dll!54f45369()
atidxx32.dll!54f49c41()
atidxx32.dll!54f524aa()
atiuxpag.dll!5c741c5e()
d3d11.dll!CResource<ID3D11Buffer>::CLS::FinalConstruct() + 0x18e bytes
d3d11.dll!CTexture2D::CLS::FinalConstruct() + 0x35 bytes
d3d11.dll!TCLSWrappers<CTexture2D>::CLSFinalConstructFn() + 0x13 bytes
d3d11.dll!CLayeredObjectWithCLS<CTexture1D>::FinalConstruct() + 0x61 bytes
d3d11.dll!CLayeredObjectWithCLS<CTexture2D>::CreateInstance() + 0x68 bytes
d3d11.dll!CDevice::CreateLayeredChild() + 0x135 bytes
d3d11.dll!CBridgeImpl<ID3D11LayeredDevice,ID3D11LayeredDevice,CLayeredObject<CDevice> >::CreateLayeredChild() + 0x22 bytes
d3d11.dll!CD3D11LayeredChild<ID3D11DeviceChild,NDXGI::CDevice,64>::FinalConstruct() + 0x2a bytes
d3d11.dll!NDXGI::CDeviceChild<IDXGISurface>::FinalConstruct() + 0x1b bytes
d3d11.dll!NDXGI::CResource::FinalConstruct() + 0x23 bytes
d3d11.dll!CLayeredObject<NDXGI::CResource>::CreateInstance() + 0x68 bytes
d3d11.dll!NDXGI::CDevice::CreateLayeredChild() + 0x135 bytes
d3d11.dll!CBridgeImpl<ID3D11LayeredDevice,ID3D11LayeredDevice,CLayeredObject<NDXGI::CDevice> >::CreateLayeredChild() + 0x22 bytes
D3D11SDKLayers.dll!CD3D11LayeredChild<ID3D11DepthStencilState,NDebug::CDevice,32>::FinalConstruct() + 0x2d bytes
D3D11SDKLayers.dll!NDebug::CDeviceChild<ID3D11Counter>::FinalConstruct() + 0x50 bytes
D3D11SDKLayers.dll!NDebug::CResource<ID3D11Texture2D>::FinalConstruct() + 0x1d bytes
D3D11SDKLayers.dll!NDebug::CTexture2D::FinalConstruct() + 0x15 bytes
D3D11SDKLayers.dll!CLayeredObject<NDebug::CTexture2D>::CreateInstance() + 0x53 bytes
D3D11SDKLayers.dll!NDebug::CDevice::CreateLayeredChild() + 0x100 bytes
D3D11SDKLayers.dll!CBridgeImpl<ID3D11LayeredDevice,ID3D11LayeredDevice,CLayeredObject<NDebug::CDevice> >::CreateLayeredChild() + 0x22 bytes
d3d11.dll!NOutermost::CDeviceChild::FinalConstruct() + 0x29 bytes
d3d11.dll!CUseCountedObject<NOutermost::CDeviceChild>::CUseCountedObject<NOutermost::CDeviceChild>() + 0x48 bytes
d3d11.dll!CUseCountedObject<NOutermost::CDeviceChild>::CreateInstance() + 0x6e bytes
d3d11.dll!NOutermost::CDevice::CreateLayeredChild() + 0xd0 bytes
d3d11.dll!CDevice::CreateTexture2D_Worker() + 0x12b bytes
d3d11.dll!CDevice::CreateTexture2D() + 0x1a bytes
D3D11SDKLayers.dll!NDebug::CDevice::CreateTexture2D() + 0x18b bytes
> Tutorial07.exe!InitDevice() Line 518 + 0x2a bytes C++
Here is the segment of code that creates the texture:
static const DWORD textureData[] =
{
//4x4 red
0xff0000ff,
0xff0000ff,
0xff0000ff,
0xff0000ff,
0xff0000ff,
0xff0000ff,
0xff0000ff,
0xff0000ff,
0xff0000ff,
0xff0000ff,
0xff0000ff,
0xff0000ff,
0xff0000ff,
0xff0000ff,
0xff0000ff,
0xff0000ff,
//2x2 green
0xff00ff00,
0xff00ff00,
0xff00ff00,
0xff00ff00,
// 1x1 blue
0xffff0000,
};
D3D11_TEXTURE2D_DESC descTex;
descTex.ArraySize = 1;
descTex.BindFlags = D3D11_BIND_SHADER_RESOURCE;
descTex.CPUAccessFlags = 0;
descTex.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
descTex.MiscFlags = 0;
descTex.Usage = D3D11_USAGE_IMMUTABLE;
descTex.SampleDesc.Count = 1;
descTex.SampleDesc.Quality = 0;
descTex.Width = 4;
descTex.Height = 4;
descTex.MipLevels = 3;
D3D11_SUBRESOURCE_DATA rsrc;
rsrc.pSysMem = textureData;
rsrc.SysMemPitch = 4 * sizeof(DWORD);
rsrc.SysMemSlicePitch = 0;
D3D11_SHADER_RESOURCE_VIEW_DESC vdesc;
vdesc.Format = descTex.Format;
vdesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
vdesc.Texture2D.MipLevels = -1;
vdesc.Texture2D.MostDetailedMip = 0;
// Load the Texture
ID3D11Texture2D *pTex = NULL;
hr = g_pd3dDevice->CreateTexture2D(&descTex, &rsrc, &pTex);