From af7856c1e3c2a96cdeb53f32b7f2b42e0cf227b9 Mon Sep 17 00:00:00 2001 From: walbourn_cp Date: Fri, 12 Jul 2013 15:12:03 -0700 Subject: [PATCH] texconv: Enable multithreaded BC6H/BC7 compression using OpenMP - Added '-singleproc' command-line to turn off MT usage. --- Texconv/Texconv_Desktop_2010.vcxproj | 12 +++++----- Texconv/Texconv_Desktop_2010_SDK80.vcxproj | 12 +++++----- Texconv/Texconv_Desktop_2012.vcxproj | 12 +++++----- Texconv/Texconv_Desktop_2013.vcxproj | 12 +++++----- Texconv/texconv.cpp | 26 +++++++++++++++++++++- 5 files changed, 49 insertions(+), 25 deletions(-) diff --git a/Texconv/Texconv_Desktop_2010.vcxproj b/Texconv/Texconv_Desktop_2010.vcxproj index 18b842e..51adb67 100644 --- a/Texconv/Texconv_Desktop_2010.vcxproj +++ b/Texconv/Texconv_Desktop_2010.vcxproj @@ -129,7 +129,7 @@ Level4 Disabled MultiThreadedDebugDLL - false + true true Fast StreamingSIMDExtensions2 @@ -169,7 +169,7 @@ Level4 Disabled MultiThreadedDebugDLL - false + true true Fast Sync @@ -207,7 +207,7 @@ Level4 MaxSpeed MultiThreadedDLL - false + true true true Fast @@ -248,7 +248,7 @@ Level4 MaxSpeed MultiThreadedDLL - false + true true true Fast @@ -288,7 +288,7 @@ Level4 MaxSpeed MultiThreadedDLL - false + true true true Fast @@ -329,7 +329,7 @@ Level4 MaxSpeed MultiThreadedDLL - false + true true true Fast diff --git a/Texconv/Texconv_Desktop_2010_SDK80.vcxproj b/Texconv/Texconv_Desktop_2010_SDK80.vcxproj index 8bbcd75..dc2f243 100644 --- a/Texconv/Texconv_Desktop_2010_SDK80.vcxproj +++ b/Texconv/Texconv_Desktop_2010_SDK80.vcxproj @@ -117,7 +117,7 @@ Level4 Disabled MultiThreadedDebugDLL - false + true true Fast StreamingSIMDExtensions2 @@ -157,7 +157,7 @@ Level4 Disabled MultiThreadedDebugDLL - false + true true Fast Sync @@ -195,7 +195,7 @@ Level4 MaxSpeed MultiThreadedDLL - false + true true true Fast @@ -236,7 +236,7 @@ Level4 MaxSpeed MultiThreadedDLL - false + true true true Fast @@ -276,7 +276,7 @@ Level4 MaxSpeed MultiThreadedDLL - false + true true true Fast @@ -317,7 +317,7 @@ Level4 MaxSpeed MultiThreadedDLL - false + true true true Fast diff --git a/Texconv/Texconv_Desktop_2012.vcxproj b/Texconv/Texconv_Desktop_2012.vcxproj index 7980edd..ffb67ca 100644 --- a/Texconv/Texconv_Desktop_2012.vcxproj +++ b/Texconv/Texconv_Desktop_2012.vcxproj @@ -136,7 +136,7 @@ Level4 Disabled MultiThreadedDebugDLL - false + true true Fast StreamingSIMDExtensions2 @@ -176,7 +176,7 @@ Level4 Disabled MultiThreadedDebugDLL - false + true true Fast Sync @@ -214,7 +214,7 @@ Level4 MaxSpeed MultiThreadedDLL - false + true true true Fast @@ -255,7 +255,7 @@ Level4 MaxSpeed MultiThreadedDLL - false + true true true Fast @@ -295,7 +295,7 @@ Level4 MaxSpeed MultiThreadedDLL - false + true true true Fast @@ -336,7 +336,7 @@ Level4 MaxSpeed MultiThreadedDLL - false + true true true Fast diff --git a/Texconv/Texconv_Desktop_2013.vcxproj b/Texconv/Texconv_Desktop_2013.vcxproj index 5e255f8..3dfe0a5 100644 --- a/Texconv/Texconv_Desktop_2013.vcxproj +++ b/Texconv/Texconv_Desktop_2013.vcxproj @@ -136,7 +136,7 @@ Level4 Disabled MultiThreadedDebugDLL - false + true true Fast StreamingSIMDExtensions2 @@ -176,7 +176,7 @@ Level4 Disabled MultiThreadedDebugDLL - false + true true Fast Sync @@ -214,7 +214,7 @@ Level4 MaxSpeed MultiThreadedDLL - false + true true true Fast @@ -255,7 +255,7 @@ Level4 MaxSpeed MultiThreadedDLL - false + true true true Fast @@ -295,7 +295,7 @@ Level4 MaxSpeed MultiThreadedDLL - false + true true true Fast @@ -336,7 +336,7 @@ Level4 MaxSpeed MultiThreadedDLL - false + true true true Fast diff --git a/Texconv/texconv.cpp b/Texconv/texconv.cpp index 0a5ed1a..0c42012 100644 --- a/Texconv/texconv.cpp +++ b/Texconv/texconv.cpp @@ -42,6 +42,7 @@ enum OPTIONS // Note: dwOptions below assumes 32 or less options. OPT_EXPAND_LUMINANCE, OPT_TA_WRAP, OPT_TA_MIRROR, + OPT_FORCE_SINGLEPROC, }; struct SConversion @@ -88,6 +89,7 @@ SValue g_pOptions[] = { L"xlum", OPT_EXPAND_LUMINANCE }, { L"wrap", OPT_TA_WRAP }, { L"mirror", OPT_TA_MIRROR }, + { L"singleproc", OPT_FORCE_SINGLEPROC }, { nullptr, 0 } }; @@ -366,6 +368,9 @@ void PrintUsage() wprintf( L"\n (DDS output only)\n"); wprintf( L" -dx10 Force use of 'DX10' extended header\n"); wprintf( L"\n -nologo suppress copyright message\n"); +#ifdef _OPENMP + wprintf( L" -singleproc Do not use multi-threaded compression\n"); +#endif wprintf( L"\n"); wprintf( L" : "); @@ -448,6 +453,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) if( (OPT_NOLOGO != dwOption) && (OPT_TYPELESS_UNORM != dwOption) && (OPT_TYPELESS_FLOAT != dwOption) && (OPT_SEPALPHA != dwOption) && (OPT_PREMUL_ALPHA != dwOption) && (OPT_EXPAND_LUMINANCE != dwOption) && (OPT_TA_WRAP != dwOption) && (OPT_TA_MIRROR != dwOption) + && (OPT_FORCE_SINGLEPROC != dwOption) && (OPT_SRGB != dwOption) && (OPT_SRGBI != dwOption) && (OPT_SRGBO != dwOption) && (OPT_HFLIP != dwOption) && (OPT_VFLIP != dwOption) && (OPT_DDS_DWORD_ALIGN != dwOption) && (OPT_USE_DX10 != dwOption) ) @@ -1087,7 +1093,25 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) goto LError; } - hr = Compress( img, nimg, info, tformat, TEX_COMPRESS_DEFAULT, 0.5f, *timage ); + DWORD cflags = TEX_COMPRESS_DEFAULT; +#ifdef _OPENMP + switch( tformat ) + { + case DXGI_FORMAT_BC6H_TYPELESS: + case DXGI_FORMAT_BC6H_UF16: + case DXGI_FORMAT_BC6H_SF16: + case DXGI_FORMAT_BC7_TYPELESS: + case DXGI_FORMAT_BC7_UNORM: + case DXGI_FORMAT_BC7_UNORM_SRGB: + if ( !(dwOptions & (1 << OPT_FORCE_SINGLEPROC) ) ) + { + cflags |= TEX_COMPRESS_PARALLEL; + } + break; + } +#endif + + hr = Compress( img, nimg, info, tformat, cflags, 0.5f, *timage ); if ( FAILED(hr) ) { wprintf( L" FAILED [compress] (%x)\n", hr);