mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-09 19:50:13 +02:00
Fixed bug with GenerateMipMaps for WIC-based generation of non-WIC supported formats.
This commit is contained in:
parent
8fe9c87dec
commit
5541a2cbcf
@ -270,9 +270,6 @@ HRESULT ScratchImage::Initialize( const TexMetadata& mdata, DWORD flags )
|
|||||||
if ( !mdata.width || mdata.height != 1 || mdata.depth != 1 || !mdata.arraySize )
|
if ( !mdata.width || mdata.height != 1 || mdata.depth != 1 || !mdata.arraySize )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
if ( IsVideo(mdata.format) )
|
|
||||||
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
|
||||||
|
|
||||||
if ( !_CalculateMipLevels(mdata.width,1,mipLevels) )
|
if ( !_CalculateMipLevels(mdata.width,1,mipLevels) )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
break;
|
break;
|
||||||
@ -285,9 +282,6 @@ HRESULT ScratchImage::Initialize( const TexMetadata& mdata, DWORD flags )
|
|||||||
{
|
{
|
||||||
if ( (mdata.arraySize % 6) != 0 )
|
if ( (mdata.arraySize % 6) != 0 )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
if ( IsVideo(mdata.format) )
|
|
||||||
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !_CalculateMipLevels(mdata.width,mdata.height,mipLevels) )
|
if ( !_CalculateMipLevels(mdata.width,mdata.height,mipLevels) )
|
||||||
@ -298,9 +292,6 @@ HRESULT ScratchImage::Initialize( const TexMetadata& mdata, DWORD flags )
|
|||||||
if ( !mdata.width || !mdata.height || !mdata.depth || mdata.arraySize != 1 )
|
if ( !mdata.width || !mdata.height || !mdata.depth || mdata.arraySize != 1 )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
if ( IsVideo(mdata.format) || IsPlanar(mdata.format) || IsDepthStencil(mdata.format) )
|
|
||||||
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
|
||||||
|
|
||||||
if ( !_CalculateMipLevels3D(mdata.width,mdata.height,mdata.depth,mipLevels) )
|
if ( !_CalculateMipLevels3D(mdata.width,mdata.height,mdata.depth,mipLevels) )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
break;
|
break;
|
||||||
@ -353,9 +344,6 @@ HRESULT ScratchImage::Initialize1D( DXGI_FORMAT fmt, size_t length, size_t array
|
|||||||
if ( !length || !arraySize )
|
if ( !length || !arraySize )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
if ( IsVideo(fmt) )
|
|
||||||
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
|
||||||
|
|
||||||
// 1D is a special case of the 2D case
|
// 1D is a special case of the 2D case
|
||||||
HRESULT hr = Initialize2D( fmt, length, 1, arraySize, mipLevels, flags );
|
HRESULT hr = Initialize2D( fmt, length, 1, arraySize, mipLevels, flags );
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
@ -422,7 +410,7 @@ HRESULT ScratchImage::Initialize3D( DXGI_FORMAT fmt, size_t width, size_t height
|
|||||||
if ( !IsValid(fmt) || !width || !height || !depth )
|
if ( !IsValid(fmt) || !width || !height || !depth )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
if ( IsVideo(fmt) || IsPlanar(fmt) || IsDepthStencil(fmt) )
|
if ( IsPalettized(fmt) )
|
||||||
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
||||||
|
|
||||||
if ( !_CalculateMipLevels3D(width,height,depth,mipLevels) )
|
if ( !_CalculateMipLevels3D(width,height,depth,mipLevels) )
|
||||||
@ -475,9 +463,6 @@ HRESULT ScratchImage::InitializeCube( DXGI_FORMAT fmt, size_t width, size_t heig
|
|||||||
if ( !width || !height || !nCubes )
|
if ( !width || !height || !nCubes )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
if ( IsVideo(fmt) )
|
|
||||||
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
|
||||||
|
|
||||||
// A DirectX11 cubemap is just a 2D texture array that is a multiple of 6 for each cube
|
// A DirectX11 cubemap is just a 2D texture array that is a multiple of 6 for each cube
|
||||||
HRESULT hr = Initialize2D( fmt, width, height, nCubes * 6, mipLevels, flags );
|
HRESULT hr = Initialize2D( fmt, width, height, nCubes * 6, mipLevels, flags );
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
@ -595,9 +580,6 @@ HRESULT ScratchImage::InitializeCubeFromImages( const Image* images, size_t nIma
|
|||||||
if ( ( nImages % 6 ) != 0 )
|
if ( ( nImages % 6 ) != 0 )
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
if ( IsVideo(images[0].format) || IsPalettized(images[0].format) )
|
|
||||||
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
|
||||||
|
|
||||||
HRESULT hr = InitializeArrayFromImages( images, nImages, false, flags );
|
HRESULT hr = InitializeArrayFromImages( images, nImages, false, flags );
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
|
@ -2567,6 +2567,12 @@ HRESULT GenerateMipMaps( const Image& baseImage, DWORD filter, size_t levels, Sc
|
|||||||
return E_POINTER;
|
return E_POINTER;
|
||||||
|
|
||||||
ScratchImage tMipChain;
|
ScratchImage tMipChain;
|
||||||
|
hr = (baseImage.height > 1 || !allow1D)
|
||||||
|
? tMipChain.Initialize2D( DXGI_FORMAT_R32G32B32A32_FLOAT, baseImage.width, baseImage.height, 1, levels )
|
||||||
|
: tMipChain.Initialize1D( DXGI_FORMAT_R32G32B32A32_FLOAT, baseImage.width, 1, levels );
|
||||||
|
if ( FAILED(hr) )
|
||||||
|
return hr;
|
||||||
|
|
||||||
hr = _GenerateMipMapsUsingWIC( *timg, filter, levels, GUID_WICPixelFormat128bppRGBAFloat, tMipChain, 0 );
|
hr = _GenerateMipMapsUsingWIC( *timg, filter, levels, GUID_WICPixelFormat128bppRGBAFloat, tMipChain, 0 );
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user