Hi, I'm not able to get it to work. I'm not even sure if it's generating the mips.
ID3D11Texture2D* texture;
ID3D11ShaderResourceView* resourceview;
// create texture
D3D11_TEXTURE2D_DESC textureDesc;
ZeroMemory(&textureDesc, sizeof(textureDesc));
textureDesc.Width = 512;
textureDesc.Height = 512;
textureDesc.MipLevels = 0;
textureDesc.ArraySize = 1;
textureDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
textureDesc.SampleDesc.Count = 1;
textureDesc.SampleDesc.Quality = 0;
textureDesc.Usage = D3D11_USAGE_DEFAULT;
textureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
textureDesc.CPUAccessFlags = 0;
textureDesc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS;
if(FAILED(d3d_device->CreateTexture2D(&textureDesc, nullptr, &texture)))
return E_FAIL;
// create shader resource
if(FAILED(d3d_device->CreateShaderResourceView(texture, nullptr, &resourceview)))
return E_FAIL;
// generate mips
d3d_context->GenerateMips(resourceview);
Nothing fails but I can't tell if the mips were created or are being used (I thought I could but now I'm not so sure).
If I add D3D11_RESOURCE_MISC_RESOURCE_CLAMP to textureDesc.MiscFlags then CreateTexture2D() fails with E_INVAIDARG.
I am using NULL for the second argument to CreateShaderResourceView() to keep things less complicated while getting the mips set up, then I'll try what Buckeye suggested above.
Thanks guys.