mirror of
https://github.com/microsoft/DirectXTex
synced 2025-01-03 23:11:05 +00:00
DirectXTex: Special-case optimization when doing RGBA 32bpp resize or 2D mipmap generation
This commit is contained in:
parent
598fedaf35
commit
6323465f1f
@ -867,7 +867,7 @@ HRESULT GenerateMipMaps( const Image& baseImage, DWORD filter, size_t levels, Sc
|
||||
case TEX_FILTER_CUBIC:
|
||||
{
|
||||
WICPixelFormatGUID pfGUID;
|
||||
if ( _DXGIToWIC( baseImage.format, pfGUID ) )
|
||||
if ( _DXGIToWIC( baseImage.format, pfGUID, true ) )
|
||||
{
|
||||
// Case 1: Base image format is supported by Windows Imaging Component
|
||||
HRESULT hr = (baseImage.height > 1 || !allow1D)
|
||||
@ -932,7 +932,7 @@ HRESULT GenerateMipMaps( const Image* srcImages, size_t nimages, const TexMetada
|
||||
case TEX_FILTER_CUBIC:
|
||||
{
|
||||
WICPixelFormatGUID pfGUID;
|
||||
if ( _DXGIToWIC( metadata.format, pfGUID ) )
|
||||
if ( _DXGIToWIC( metadata.format, pfGUID, true ) )
|
||||
{
|
||||
// Case 1: Base image format is supported by Windows Imaging Component
|
||||
TexMetadata mdata2 = metadata;
|
||||
|
@ -65,7 +65,7 @@ namespace DirectX
|
||||
//---------------------------------------------------------------------------------
|
||||
// WIC helper functions
|
||||
DXGI_FORMAT _WICToDXGI( _In_ const GUID& guid );
|
||||
bool _DXGIToWIC( _In_ DXGI_FORMAT format, _Out_ GUID& guid );
|
||||
bool _DXGIToWIC( _In_ DXGI_FORMAT format, _Out_ GUID& guid, _In_ bool ignoreRGBvsBGR = false );
|
||||
|
||||
DWORD _CheckWICColorSpace( _In_ const GUID& sourceGUID, _In_ const GUID& targetGUID );
|
||||
|
||||
|
@ -193,7 +193,7 @@ HRESULT Resize( const Image& srcImage, size_t width, size_t height, DWORD filter
|
||||
// WIC only supports CLAMP
|
||||
|
||||
WICPixelFormatGUID pfGUID;
|
||||
if ( _DXGIToWIC( srcImage.format, pfGUID ) )
|
||||
if ( _DXGIToWIC( srcImage.format, pfGUID, true ) )
|
||||
{
|
||||
// Case 1: Source format is supported by Windows Imaging Component
|
||||
hr = _PerformResizeUsingWIC( srcImage, filter, pfGUID, *rimage );
|
||||
@ -238,7 +238,7 @@ HRESULT Resize( const Image* srcImages, size_t nimages, const TexMetadata& metad
|
||||
return hr;
|
||||
|
||||
WICPixelFormatGUID pfGUID;
|
||||
bool wicpf = _DXGIToWIC( metadata.format, pfGUID );
|
||||
bool wicpf = _DXGIToWIC( metadata.format, pfGUID, true );
|
||||
|
||||
switch ( metadata.dimension )
|
||||
{
|
||||
|
@ -82,12 +82,22 @@ DXGI_FORMAT _WICToDXGI( const GUID& guid )
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
bool _DXGIToWIC( DXGI_FORMAT format, GUID& guid )
|
||||
bool _DXGIToWIC( DXGI_FORMAT format, GUID& guid, bool ignoreRGBvsBGR )
|
||||
{
|
||||
switch( format )
|
||||
{
|
||||
case DXGI_FORMAT_R8G8B8A8_UNORM:
|
||||
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
|
||||
memcpy( &guid, &GUID_WICPixelFormat32bppRGBA, sizeof(GUID) );
|
||||
if ( ignoreRGBvsBGR )
|
||||
{
|
||||
// If we are not doing conversion so don't really care about BGR vs RGB color-order,
|
||||
// we can use the canonical WIC 32bppBGRA format which avoids an extra format conversion when using the WIC scaler
|
||||
memcpy( &guid, &GUID_WICPixelFormat32bppBGRA, sizeof(GUID) );
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy( &guid, &GUID_WICPixelFormat32bppRGBA, sizeof(GUID) );
|
||||
}
|
||||
return true;
|
||||
|
||||
case DXGI_FORMAT_D32_FLOAT:
|
||||
|
Loading…
Reference in New Issue
Block a user