mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-09 11:40:14 +02:00
Texconv: Fixed case where source image already has mipchain and the tool is supposed to change the number of mip levels
This commit is contained in:
parent
babaf73654
commit
eb48e991f9
@ -864,6 +864,66 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( (!tMips || info.mipLevels != tMips) && ( info.mipLevels != 1 ) )
|
||||||
|
{
|
||||||
|
// Mips generation only works on a single base image, so strip off existing mip levels
|
||||||
|
ScratchImage *timage = new ScratchImage;
|
||||||
|
if ( !timage )
|
||||||
|
{
|
||||||
|
wprintf( L" ERROR: Memory allocation failed\n" );
|
||||||
|
delete image;
|
||||||
|
goto LError;
|
||||||
|
}
|
||||||
|
|
||||||
|
TexMetadata mdata = info;
|
||||||
|
mdata.mipLevels = 1;
|
||||||
|
hr = timage->Initialize( mdata );
|
||||||
|
if ( FAILED(hr) )
|
||||||
|
{
|
||||||
|
wprintf( L" FAILED [copy to single level] (%x)\n", hr);
|
||||||
|
delete timage;
|
||||||
|
delete image;
|
||||||
|
goto LError;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( info.dimension == TEX_DIMENSION_TEXTURE3D )
|
||||||
|
{
|
||||||
|
for( size_t d = 0; d < info.depth; ++d )
|
||||||
|
{
|
||||||
|
hr = CopyRectangle( *image->GetImage( 0, 0, d ), Rect( 0, 0, info.width, info.height ),
|
||||||
|
*timage->GetImage( 0, 0, d ), TEX_FILTER_DEFAULT, 0, 0 );
|
||||||
|
if ( FAILED(hr) )
|
||||||
|
{
|
||||||
|
wprintf( L" FAILED [copy to single level] (%x)\n", hr);
|
||||||
|
delete timage;
|
||||||
|
delete image;
|
||||||
|
goto LError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for( size_t i = 0; i < info.arraySize; ++i )
|
||||||
|
{
|
||||||
|
hr = CopyRectangle( *image->GetImage( 0, i, 0 ), Rect( 0, 0, info.width, info.height ),
|
||||||
|
*timage->GetImage( 0, i, 0 ), TEX_FILTER_DEFAULT, 0, 0 );
|
||||||
|
if ( FAILED(hr) )
|
||||||
|
{
|
||||||
|
wprintf( L" FAILED [copy to single level] (%x)\n", hr);
|
||||||
|
delete timage;
|
||||||
|
delete image;
|
||||||
|
goto LError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete image;
|
||||||
|
image = timage;
|
||||||
|
|
||||||
|
const TexMetadata& tinfo = timage->GetMetadata();
|
||||||
|
info.mipLevels = tinfo.mipLevels;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !tMips || info.mipLevels != tMips )
|
if ( !tMips || info.mipLevels != tMips )
|
||||||
{
|
{
|
||||||
ScratchImage *timage = new ScratchImage;
|
ScratchImage *timage = new ScratchImage;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user