i am implementing Mipmapping for my texture for the first time.
i have 2 questions
- HOW TO CHECK IF MIPMAP IS DONE PROPERLY ?
- HOW TO SET MIPMAP FOR TEXTURE FROM FILE ?
First one. i implemented texture in application.
ID3D11Texture2D* TEX;
D3D11_TEXTURE2D_DESC DESC;
DESC.ArraySize = 1;
DESC.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
DESC.CPUAccessFlags = 0;
DESC.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
DESC.Width = 256;
DESC.Height = 256;
DESC.MipLevels = 9;
DESC.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS;
DESC.SampleDesc.Count = 1;
DESC.SampleDesc.Quality = 0;
DESC.Usage = D3D11_USAGE_DEFAULT;
r_assert(graphic->Device()->CreateTexture2D(&DESC, nullptr, &TEX));
ID3D11ShaderResourceView* TEXV;
D3D11_SHADER_RESOURCE_VIEW_DESC TEXVDESC;
TEXVDESC.Format = DESC.Format;
TEXVDESC.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
TEXVDESC.Texture2D.MipLevels = -1;
TEXVDESC.Texture2D.MostDetailedMip = 0;
r_assert(graphic->Device()->CreateShaderResourceView(TEX, &TEXVDESC, &TEXV));
graphic->DContext()->GenerateMips(TEXV);
D3D11_TEXTURE2D_DESC desc;
TEX->GetDesc(&desc);
not sure, but i think i generate Mipmap for TEX
and i just want to know the ways how to check/debug if mipmap actually done well.
Second.
i am also using DirectX::CreateWICTextureFromFileEx
to create texture from file.
resource=nullptr;
newSRV=nullptr;
r_assert(
DirectX::CreateWICTextureFromFileEx(
graphic->Device(),
(L"Data\\Texture\\" + fileName).c_str(),
0,
D3D11_USAGE_DEFAULT,
D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE,
0,
D3D11_RESOURCE_MISC_GENERATE_MIPS,
DirectX::WIC_LOADER_DEFAULT,
&resource,
&newSRV)
);
graphic->DContext()->GenerateMips(newSRV);
ID3D11Texture2D* tex = nullptr;
r_assert(
resource->QueryInterface(IID_ID3D11Texture2D, (void**)&tex)
);
D3D11_TEXTURE2D_DESC desc;
tex->GetDesc(&desc);
and i checked desc.MipLevels
is 1, which means there is no mipmapping.
so wonder how to generate mipmap when using WIC function?
any advice would be appreciated^