Check each mipmap of a texture2D?

Started by
2 comments, last by pnt1614 8 years, 6 months ago

I follow the book "Introduction to 3D Game Programming with DIRECTX 11" to load several textures and its mipmaps, then copy into a texture array. But there is a problem with mipmaps. I am not sure the reason so now I want to check each mipmap of each loaded texture 2D by saving each mipmap to a file, but I do not know how to do that.

The following source code is used to load 2D textures and its mipmap (automatically generated by GPU):


        D3DX11_IMAGE_LOAD_INFO loadInfo;
	loadInfo.Width = 1024;
	loadInfo.Height = 1024;
	loadInfo.Depth = 0;
	loadInfo.FirstMipLevel = 0;
	loadInfo.MipLevels = 0;
	loadInfo.Usage = D3D11_USAGE_STAGING;
	loadInfo.BindFlags = 0;
	loadInfo.CpuAccessFlags = D3D10_CPU_ACCESS_WRITE | D3D10_CPU_ACCESS_READ;
	loadInfo.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS;
	loadInfo.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
	loadInfo.Filter = D3DX11_FILTER_NONE;
	loadInfo.MipFilter = D3DX11_FILTER_NONE;
	loadInfo.pSrcInfo = 0;

	vector<string> m_sTextureNames;

	m_sTextureNames.push_back("MovingBox/metalcrate-L.jpg");

	UINT iNumOfMaterials = (UINT)m_sTextureNames.size();
	g_pTexture2Ds.resize(iNumOfMaterials);

	for (UINT i = 0; i<iNumOfMaterials; i++)
	{
		if (m_sTextureNames[i].compare("") != 0)
		{
			V(D3DX11CreateTextureFromFileA(pd3dDevice, m_sTextureNames[i].c_str(),
				&loadInfo, 0, (ID3D11Resource**)&g_pTexture2Ds[i], 0));
		}
	}

Is there anyone know to save a mipmap of a 2D texture to a file?

Advertisement
Trying to save them to a file is only creating more potential for errors that could distract you.
Draw each mipmap to the screen. Take a screenshot if you want to put them into Photoshop or etc.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Or use a GPU debugger that can show you details of the texture from a runtime capture (e.g. Renderdoc, or the one built in to the new visual studio, etc...).

Thanks guys, I did it.

This topic is closed to new replies.

Advertisement