From 4feff1578cbda33daaf5d21e6b3bfceef1356492 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Tue, 7 Jul 2015 14:20:14 -0700 Subject: [PATCH 1/2] Use parallel compression for BC1-BC5 --- Texconv/texconv.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Texconv/texconv.cpp b/Texconv/texconv.cpp index 731bc01..d98501b 100644 --- a/Texconv/texconv.cpp +++ b/Texconv/texconv.cpp @@ -435,6 +435,9 @@ void PrintLogo() { wprintf( L"Microsoft (R) DirectX 11 Texture Converter (DirectXTex version)\n"); wprintf( L"Copyright (C) Microsoft Corp. All rights reserved.\n"); +#ifdef _DEBUG + wprintf( L"*** Debug build ***\n"); +#endif wprintf( L"\n"); } @@ -1649,7 +1652,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) DWORD cflags = dwCompress; #ifdef _OPENMP - if ( bc6hbc7 && !(dwOptions & (DWORD64(1) << OPT_FORCE_SINGLEPROC) ) ) + if ( !(dwOptions & (DWORD64(1) << OPT_FORCE_SINGLEPROC) ) ) { cflags |= TEX_COMPRESS_PARALLEL; } From 847ab8940a5067e4f36867ffaa1b154fbd7fadb3 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Tue, 7 Jul 2015 14:25:48 -0700 Subject: [PATCH 2/2] Fixed round problem with 32-bit RGBA/BGRA formats --- DirectXTex/DirectXTexConvert.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/DirectXTex/DirectXTexConvert.cpp b/DirectXTex/DirectXTexConvert.cpp index 5dd6d2c..abdda07 100644 --- a/DirectXTex/DirectXTexConvert.cpp +++ b/DirectXTex/DirectXTexConvert.cpp @@ -180,6 +180,7 @@ namespace DirectX static const XMVECTORF32 g_Grayscale = { 0.2125f, 0.7154f, 0.0721f, 0.0f }; static const XMVECTORF32 g_HalfMin = { -65504.f, -65504.f, -65504.f, -65504.f }; static const XMVECTORF32 g_HalfMax = { 65504.f, 65504.f, 65504.f, 65504.f }; +static const XMVECTORF32 g_8BitBias = { 0.5f/255.f, 0.5f/255.f, 0.5f/255.f, 0.5f/255.f }; //------------------------------------------------------------------------------------- // Copies an image row with optional clearing of alpha value to 1.0 @@ -1731,7 +1732,18 @@ bool _StoreScanline( LPVOID pDestination, size_t size, DXGI_FORMAT format, case DXGI_FORMAT_R8G8B8A8_UNORM: case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - STORE_SCANLINE( XMUBYTEN4, XMStoreUByteN4 ) + if ( size >= sizeof(XMUBYTEN4) ) + { + XMUBYTEN4 * __restrict dPtr = reinterpret_cast(pDestination); + for( size_t icount = 0; icount < ( size - sizeof(XMUBYTEN4) + 1 ); icount += sizeof(XMUBYTEN4) ) + { + if ( sPtr >= ePtr ) break; + XMVECTOR v = XMVectorAdd( *sPtr++, g_8BitBias ); + XMStoreUByteN4( dPtr++, v ); + } + return true; + } + return false; case DXGI_FORMAT_R8G8B8A8_UINT: STORE_SCANLINE( XMUBYTE4, XMStoreUByte4 ) @@ -2071,6 +2083,7 @@ bool _StoreScanline( LPVOID pDestination, size_t size, DXGI_FORMAT format, XMVECTOR v0 = *sPtr++; XMVECTOR v1 = (sPtr < ePtr) ? XMVectorSplatY( *sPtr++ ) : XMVectorZero(); XMVECTOR v = XMVectorSelect( v1, v0, g_XMSelect1110 ); + v = XMVectorAdd( v, g_8BitBias ); XMStoreUByteN4( dPtr++, v ); } return true; @@ -2089,6 +2102,7 @@ bool _StoreScanline( LPVOID pDestination, size_t size, DXGI_FORMAT format, XMVECTOR v0 = XMVectorSwizzle<1, 0, 3, 2>( *sPtr++ ); XMVECTOR v1 = (sPtr < ePtr) ? XMVectorSplatY( *sPtr++ ) : XMVectorZero(); XMVECTOR v = XMVectorSelect( v1, v0, select1101 ); + v = XMVectorAdd( v, g_8BitBias ); XMStoreUByteN4( dPtr++, v ); } return true; @@ -2138,6 +2152,7 @@ bool _StoreScanline( LPVOID pDestination, size_t size, DXGI_FORMAT format, { if ( sPtr >= ePtr ) break; XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>( *sPtr++ ); + v = XMVectorAdd( v, g_8BitBias ); XMStoreUByteN4( dPtr++, v ); } return true; @@ -2153,6 +2168,7 @@ bool _StoreScanline( LPVOID pDestination, size_t size, DXGI_FORMAT format, { if ( sPtr >= ePtr ) break; XMVECTOR v = XMVectorPermute<2, 1, 0, 7>( *sPtr++, g_XMIdentityR3 ); + v = XMVectorAdd( v, g_8BitBias ); XMStoreUByteN4( dPtr++, v ); } return true;