I managed to add mipmapping to the BC1 encoded DDS cubemaps. Here's what I do:
1) Create a texture using the CreateDDSTextureFromFile function
ID3D11Resource* Texture = nullptr;
HRESULT hr = CreateDDSTextureFromFile(mDevice, inPath, &Texture, &mShaderResourceView);
2) Get the resolution
D3D11_TEXTURE2D_DESC d;
ZeroMemory(&d, sizeof(d));
Texture->GetDesc(&d);
mWidth = d.Width;
mHeight = d.Height;
3) Create a new cubemap texture with the same resolution
mFormat = DXGI_FORMAT_B8G8R8A8_UNORM;
D3D11_TEXTURE2D_DESC d;
ZeroMemory(&d, sizeof(d));
d.Width = mWidth;
d.Height = mHeight;
d.MipLevels = 0;
d.ArraySize = 6;
d.Format = mFormat;
d.SampleDesc.Count = 1;
d.SampleDesc.Quality = 0;
d.Usage = D3D11_USAGE_DEFAULT;
d.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
d.CPUAccessFlags = 0;
d.MiscFlags = D3D11_RESOURCE_MISC_TEXTURECUBE | D3D11_RESOURCE_MISC_GENERATE_MIPS;
HRESULT hr = mDevice->GetDevice()->CreateTexture2D(&d, nullptr, &mTexture);
4) Create a shader resource view
D3D11_SHADER_RESOURCE_VIEW_DESC d;
ZeroMemory(&d, sizeof(d));
d.Format = mFormat;
d.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE
d.Texture2D.MipLevels = -1;
HRESULT hr = mDevice->CreateShaderResourceView(mTexture, &d, &mShaderResourceView);
5) For all 6 faces: create a render target
D3D11_RENDER_TARGET_VIEW_DESC d;
ZeroMemory(&d, sizeof(d));
d.Format = mFormat;
d.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
d.Texture2DArray.ArraySize = 1;
d.Texture2DArray.FirstArraySlice = inFace;
HRESULT hr = mDevice->CreateRenderTargetView(mTexture, &d, &mRenderTargetView);
6) For all 6 faces: select this render target:
mContext->OMSetRenderTargets(1, &mRenderTargetView, nullptr);
7) For all 6 faces, I use my framework to render a square on this render target using the ShaderResourceView created in step 1
When your square mesh has UV coordinates ranging from (0,0) top left to (1,1) bottom right, the pixel shader looks something like this:
float4 PS(VS_OUTPUT input): SV_Target{
float4 c=float4(1,0,0,1);
if(TextureResolution[0].x>0){
float2 uv=input.tex;
float3 v=float3(0,0,0);
int f=round(Prop[0].x);
if(f==0){
//+X
v.x=1;
v.y=1-uv.y*2;
v.z=1-uv.x*2;
}
else if(f==1){
//-X
v.x=-1;
v.y=1-uv.y*2;
v.z=-1+uv.x*2;
}
else if(f==2){
//+Y
v.x=-1+uv.x*2;
v.y=1;
v.z=-1+uv.y*2;
}
else if(f==3){
//-Y
v.x=-1+uv.x*2;
v.y=-1;
v.z=1-uv.y*2;
}
else if(f==4){
//+Z
v.x=-1+uv.x*2;
v.y=1-uv.y*2;
v.z=1;
}
else if(f==5){
//-Z
v.x=1-uv.x*2;
v.y=1-uv.y*2;
v.z=-1;
}
c=MyTexture0.Sample(MySampler0,normalize(v));
}
return c;
}
8) After rendering all 6 faces, create the mipmaps
mDevice->GenerateMips(mShaderResourceView);
That's it. Thanks to MJP for pointing me to the right direction!