diff --git a/DirectXTex/BCDirectCompute.cpp b/DirectXTex/BCDirectCompute.cpp index 6665377..29beb17 100644 --- a/DirectXTex/BCDirectCompute.cpp +++ b/DirectXTex/BCDirectCompute.cpp @@ -352,12 +352,13 @@ HRESULT GPUCompressBC::Compress( const Image& srcImage, const Image& destImage ) } //--- Create input texture -------------------------------------------------------- - // TODO - non-power-of-2 BCs require handling non-multiple of 4 cases - auto pDevice = m_device.Get(); if ( !pDevice ) return E_POINTER; + // We need to avoid the hardware doing additional colorspace conversion + DXGI_FORMAT inputFormat = ( m_srcformat == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB ) ? DXGI_FORMAT_R8G8B8A8_UNORM : m_srcformat; + ScopedObject sourceTex; { D3D11_TEXTURE2D_DESC desc; @@ -366,7 +367,7 @@ HRESULT GPUCompressBC::Compress( const Image& srcImage, const Image& destImage ) desc.Height = static_cast( srcImage.height ); desc.MipLevels = 1; desc.ArraySize = 1; - desc.Format = srcImage.format; + desc.Format = inputFormat; desc.SampleDesc.Count = 1; desc.Usage = D3D11_USAGE_DEFAULT; desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; @@ -388,7 +389,7 @@ HRESULT GPUCompressBC::Compress( const Image& srcImage, const Image& destImage ) D3D11_SHADER_RESOURCE_VIEW_DESC desc; memset( &desc, 0, sizeof(desc) ); desc.Texture2D.MipLevels = 1; - desc.Format = m_srcformat; + desc.Format = inputFormat; desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; HRESULT hr = pDevice->CreateShaderResourceView( sourceTex.Get(), &desc, sourceSRV.ReleaseAndGetAddressOf() ); diff --git a/Texconv/texconv.cpp b/Texconv/texconv.cpp index f94ff81..5d0aec9 100644 --- a/Texconv/texconv.cpp +++ b/Texconv/texconv.cpp @@ -440,18 +440,42 @@ bool CreateDevice( _Outptr_ ID3D11Device** pDevice ) if ( !hwopts.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x ) { + if ( *pDevice ) + { + (*pDevice)->Release(); + *pDevice = nullptr; + } hr = HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); } } } - if ( FAILED(hr) && *pDevice ) + if ( SUCCEEDED(hr) ) { - (*pDevice)->Release(); - *pDevice = nullptr; - } + IDXGIDevice* dxgiDevice = nullptr; + hr = (*pDevice)->QueryInterface( __uuidof( IDXGIDevice ), reinterpret_cast< void** >( &dxgiDevice ) ); + if ( SUCCEEDED(hr) ) + { + IDXGIAdapter* pAdapter = nullptr; + hr = dxgiDevice->GetAdapter( &pAdapter ); + if ( SUCCEEDED(hr) ) + { + DXGI_ADAPTER_DESC desc; + hr = pAdapter->GetDesc( &desc ); + if ( SUCCEEDED(hr) ) + { + wprintf( L"\n[Using DirectCompute on \"%s\"]\n", desc.Description ); + } + pAdapter->Release(); + } - return SUCCEEDED(hr); + dxgiDevice->Release(); + } + + return true; + } + else + return false; }