In fact, I got this problem from this question I posted before. It works under windows 10 with directx 12. But I failed to create Texture2D under windows 7 with directx 11. I created a second texture2d to generate mipmaps like this:
D3D11_TEXTURE2D_DESC textureDesc;
textureDesc.Width = nWidth;//Video width
textureDesc.Height = nHeight;//Video height
textureDesc.MipLevels = 0;//generate a full set of subtextures.
textureDesc.ArraySize = 1;
textureDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
textureDesc.SampleDesc.Count = 1;
textureDesc.Usage = D3D11_USAGE_DEFAULT;
textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
textureDesc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS;
m_pD3dDevice->CreateTexture2D(&textureDesc, NULL, &m_pTexture);
I just got "Invalid arguments" under Windows7. It seems that only DirectX11.1 guarantees this kind of usage according to Extended support for shared Texture2D resources. Bind flags of D3D11_BIND_SHADER_RESOURCE and D3D11_BIND_RENDER_TARGET are not supported under Windows 7(the version of DirectX should be directx11).And without this,ID3D11DeviceContext::GenerateMips method has no effect. My application must support Windows 7, so Is there any alternative solution?