1
0
mirror of https://github.com/microsoft/DirectXTex synced 2024-11-21 20:10:05 +00:00

Minor code review

This commit is contained in:
Chuck Walbourn 2018-01-18 15:02:05 -08:00
parent b872c3840f
commit 46e7ad7020
9 changed files with 19 additions and 19 deletions

View File

@ -115,7 +115,7 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
HRESULT hr = GetMetadataFromDDSFile( lpCmdLine, DDS_FLAGS_NONE, mdata ); HRESULT hr = GetMetadataFromDDSFile( lpCmdLine, DDS_FLAGS_NONE, mdata );
if ( FAILED(hr) ) if ( FAILED(hr) )
{ {
wchar_t buff[2048] = { 0 }; wchar_t buff[2048] = {};
swprintf_s( buff, L"Failed to open texture file\n\nFilename = %ls\nHRESULT %08X", lpCmdLine, hr ); swprintf_s( buff, L"Failed to open texture file\n\nFilename = %ls\nHRESULT %08X", lpCmdLine, hr );
MessageBox( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); MessageBox( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION );
return 0; return 0;
@ -136,7 +136,7 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
{ {
if ( mdata.arraySize > 1 ) if ( mdata.arraySize > 1 )
{ {
wchar_t buff[2048] = { 0 }; wchar_t buff[2048] = {};
swprintf_s( buff, L"Arrays of volume textures are not supported\n\nFilename = %ls\nArray size %Iu", lpCmdLine, mdata.arraySize ); swprintf_s( buff, L"Arrays of volume textures are not supported\n\nFilename = %ls\nArray size %Iu", lpCmdLine, mdata.arraySize );
MessageBox( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); MessageBox( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION );
return 0; return 0;
@ -159,7 +159,7 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
case DXGI_FORMAT_BC7_UNORM_SRGB: case DXGI_FORMAT_BC7_UNORM_SRGB:
if ( g_featureLevel < D3D_FEATURE_LEVEL_11_0 ) if ( g_featureLevel < D3D_FEATURE_LEVEL_11_0 )
{ {
wchar_t buff[2048] = { 0 }; wchar_t buff[2048] = {};
swprintf_s( buff, L"BC6H/BC7 requires DirectX 11 hardware\n\nFilename = %ls\nDXGI Format %d\nFeature Level %d", lpCmdLine, mdata.format, g_featureLevel ); swprintf_s( buff, L"BC6H/BC7 requires DirectX 11 hardware\n\nFilename = %ls\nDXGI Format %d\nFeature Level %d", lpCmdLine, mdata.format, g_featureLevel );
MessageBox( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); MessageBox( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION );
return 0; return 0;
@ -172,7 +172,7 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
hr = g_pd3dDevice->CheckFormatSupport ( mdata.format, &flags ); hr = g_pd3dDevice->CheckFormatSupport ( mdata.format, &flags );
if ( FAILED(hr) || !(flags & (D3D11_FORMAT_SUPPORT_TEXTURE1D|D3D11_FORMAT_SUPPORT_TEXTURE2D|D3D11_FORMAT_SUPPORT_TEXTURE3D)) ) if ( FAILED(hr) || !(flags & (D3D11_FORMAT_SUPPORT_TEXTURE1D|D3D11_FORMAT_SUPPORT_TEXTURE2D|D3D11_FORMAT_SUPPORT_TEXTURE3D)) )
{ {
wchar_t buff[2048] = { 0 }; wchar_t buff[2048] = {};
swprintf_s( buff, L"Format not supported by DirectX hardware\n\nFilename = %ls\nDXGI Format %d\nFeature Level %d\nHRESULT = %08X", lpCmdLine, mdata.format, g_featureLevel, hr ); swprintf_s( buff, L"Format not supported by DirectX hardware\n\nFilename = %ls\nDXGI Format %d\nFeature Level %d\nHRESULT = %08X", lpCmdLine, mdata.format, g_featureLevel, hr );
MessageBox( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); MessageBox( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION );
return 0; return 0;
@ -185,7 +185,7 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
hr = LoadFromDDSFile( lpCmdLine, DDS_FLAGS_NONE, &mdata, image ); hr = LoadFromDDSFile( lpCmdLine, DDS_FLAGS_NONE, &mdata, image );
if ( FAILED(hr) ) if ( FAILED(hr) )
{ {
wchar_t buff[2048] = { 0 }; wchar_t buff[2048] = {};
swprintf_s( buff, L"Failed to load texture file\n\nFilename = %ls\nHRESULT %08X", lpCmdLine, hr ); swprintf_s( buff, L"Failed to load texture file\n\nFilename = %ls\nHRESULT %08X", lpCmdLine, hr );
MessageBox( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); MessageBox( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION );
return 0; return 0;
@ -197,14 +197,14 @@ int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
hr = CreateShaderResourceView( g_pd3dDevice, image.GetImages(), image.GetImageCount(), mdata, &g_pSRV ); hr = CreateShaderResourceView( g_pd3dDevice, image.GetImages(), image.GetImageCount(), mdata, &g_pSRV );
if ( FAILED(hr) ) if ( FAILED(hr) )
{ {
wchar_t buff[2048] = { 0 }; wchar_t buff[2048] = {};
swprintf_s( buff, L"Failed creating texture from file\n\nFilename = %ls\nHRESULT = %08X", lpCmdLine, hr ); swprintf_s( buff, L"Failed creating texture from file\n\nFilename = %ls\nHRESULT = %08X", lpCmdLine, hr );
MessageBox( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION ); MessageBox( nullptr, buff, L"DDSView", MB_OK | MB_ICONEXCLAMATION );
return 0; return 0;
} }
// Main message loop // Main message loop
MSG msg = {0}; MSG msg = {};
while( WM_QUIT != msg.message ) while( WM_QUIT != msg.message )
{ {
if( PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE ) ) if( PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE ) )

View File

@ -550,7 +550,7 @@ HRESULT DirectX::_EncodeDDSHeader(
flags |= DDS_FLAGS_FORCE_DX10_EXT; flags |= DDS_FLAGS_FORCE_DX10_EXT;
} }
DDS_PIXELFORMAT ddpf = { 0 }; DDS_PIXELFORMAT ddpf = {};
if (!(flags & DDS_FLAGS_FORCE_DX10_EXT)) if (!(flags & DDS_FLAGS_FORCE_DX10_EXT))
{ {
switch (metadata.format) switch (metadata.format)

View File

@ -928,7 +928,7 @@ HRESULT DirectX::Resize(
bool usewic = !metadata.IsPMAlpha() && UseWICFiltering(metadata.format, filter); bool usewic = !metadata.IsPMAlpha() && UseWICFiltering(metadata.format, filter);
WICPixelFormatGUID pfGUID = { 0 }; WICPixelFormatGUID pfGUID = {};
bool wicpf = (usewic) ? _DXGIToWIC(metadata.format, pfGUID, true) : false; bool wicpf = (usewic) ? _DXGIToWIC(metadata.format, pfGUID, true) : false;
switch (metadata.dimension) switch (metadata.dimension)

View File

@ -801,7 +801,7 @@ namespace
if (memcmp(&containerFormat, &GUID_ContainerFormatBmp, sizeof(WICPixelFormatGUID)) == 0 && iswic2) if (memcmp(&containerFormat, &GUID_ContainerFormatBmp, sizeof(WICPixelFormatGUID)) == 0 && iswic2)
{ {
// Opt-in to the WIC2 support for writing 32-bit Windows BMP files with an alpha channel // Opt-in to the WIC2 support for writing 32-bit Windows BMP files with an alpha channel
PROPBAG2 option = { 0 }; PROPBAG2 option = {};
option.pstrName = const_cast<wchar_t*>(L"EnableV5Header32bppBGRA"); option.pstrName = const_cast<wchar_t*>(L"EnableV5Header32bppBGRA");
VARIANT varValue; VARIANT varValue;
@ -1043,7 +1043,7 @@ HRESULT DirectX::LoadFromWICMemory(
// Get metadata // Get metadata
TexMetadata mdata; TexMetadata mdata;
WICPixelFormatGUID convertGUID = { 0 }; WICPixelFormatGUID convertGUID = {};
hr = DecodeMetadata(flags, iswic2, decoder.Get(), frame.Get(), mdata, &convertGUID, getMQR); hr = DecodeMetadata(flags, iswic2, decoder.Get(), frame.Get(), mdata, &convertGUID, getMQR);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
@ -1104,7 +1104,7 @@ HRESULT DirectX::LoadFromWICFile(
// Get metadata // Get metadata
TexMetadata mdata; TexMetadata mdata;
WICPixelFormatGUID convertGUID = { 0 }; WICPixelFormatGUID convertGUID = {};
hr = DecodeMetadata(flags, iswic2, decoder.Get(), frame.Get(), mdata, &convertGUID, getMQR); hr = DecodeMetadata(flags, iswic2, decoder.Get(), frame.Get(), mdata, &convertGUID, getMQR);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
@ -1170,7 +1170,7 @@ HRESULT DirectX::SaveToWICMemory(
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
LARGE_INTEGER li = { { 0 } }; LARGE_INTEGER li = {};
hr = stream->Seek(li, STREAM_SEEK_SET, 0); hr = stream->Seek(li, STREAM_SEEK_SET, 0);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
@ -1227,7 +1227,7 @@ HRESULT DirectX::SaveToWICMemory(
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
LARGE_INTEGER li = { { 0 } }; LARGE_INTEGER li = {};
hr = stream->Seek(li, STREAM_SEEK_SET, 0); hr = stream->Seek(li, STREAM_SEEK_SET, 0);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;

View File

@ -2600,7 +2600,7 @@ inline HRESULT D3DX12ParsePipelineStream(const D3D12_PIPELINE_STATE_STREAM_DESC&
return E_INVALIDARG; return E_INVALIDARG;
} }
bool SubobjectSeen[D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MAX_VALID] = {0}; bool SubobjectSeen[D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MAX_VALID] = {};
for (SIZE_T CurOffset = 0, SizeOfSubobject = 0; CurOffset < Desc.SizeInBytes; CurOffset += SizeOfSubobject) for (SIZE_T CurOffset = 0, SizeOfSubobject = 0; CurOffset < Desc.SizeInBytes; CurOffset += SizeOfSubobject)
{ {
BYTE* pStream = static_cast<BYTE*>(Desc.pPipelineStateSubobjectStream)+CurOffset; BYTE* pStream = static_cast<BYTE*>(Desc.pPipelineStateSubobjectStream)+CurOffset;

View File

@ -49,7 +49,7 @@ public:
{ {
if (m_handle) if (m_handle)
{ {
FILE_DISPOSITION_INFO info = { 0 }; FILE_DISPOSITION_INFO info = {};
info.DeleteFile = TRUE; info.DeleteFile = TRUE;
(void)SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); (void)SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info));
} }

View File

@ -211,7 +211,7 @@ namespace
{ {
if (m_handle) if (m_handle)
{ {
FILE_DISPOSITION_INFO info = {0}; FILE_DISPOSITION_INFO info = {};
info.DeleteFile = TRUE; info.DeleteFile = TRUE;
(void)SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); (void)SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info));
} }

View File

@ -526,7 +526,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
DWORD dwFilterOpts = 0; DWORD dwFilterOpts = 0;
DWORD CrossFileType = WIC_CODEC_BMP; DWORD CrossFileType = WIC_CODEC_BMP;
wchar_t szOutputFile[MAX_PATH] = { 0 }; wchar_t szOutputFile[MAX_PATH] = {};
// Initialize COM (needed for WIC) // Initialize COM (needed for WIC)
HRESULT hr = hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); HRESULT hr = hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);

View File

@ -2977,7 +2977,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
int pixely = -1; int pixely = -1;
DXGI_FORMAT diffFormat = DXGI_FORMAT_B8G8R8A8_UNORM; DXGI_FORMAT diffFormat = DXGI_FORMAT_B8G8R8A8_UNORM;
DWORD diffFileType = WIC_CODEC_BMP; DWORD diffFileType = WIC_CODEC_BMP;
wchar_t szOutputFile[MAX_PATH] = { 0 }; wchar_t szOutputFile[MAX_PATH] = {};
// Initialize COM (needed for WIC) // Initialize COM (needed for WIC)
HRESULT hr = hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); HRESULT hr = hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);