mirror of
https://github.com/microsoft/DirectXTex.git
synced 2026-02-04 04:16:12 +01:00
Cleaned up clang warnings in DDSTextureLoader, ScreenGrab, WICTextureLoader
This commit is contained in:
@@ -80,9 +80,6 @@ namespace
|
||||
#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH
|
||||
#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE
|
||||
|
||||
#define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT
|
||||
#define DDS_WIDTH 0x00000004 // DDSD_WIDTH
|
||||
|
||||
#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
|
||||
|
||||
typedef struct
|
||||
@@ -213,7 +210,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void clear() { m_handle = 0; }
|
||||
void clear() { m_handle = nullptr; }
|
||||
|
||||
private:
|
||||
HANDLE m_handle;
|
||||
@@ -225,7 +222,7 @@ namespace
|
||||
class auto_delete_file_wic
|
||||
{
|
||||
public:
|
||||
auto_delete_file_wic(ComPtr<IWICStream>& hFile, const wchar_t* szFile) : m_handle(hFile), m_filename(szFile) {}
|
||||
auto_delete_file_wic(ComPtr<IWICStream>& hFile, const wchar_t* szFile) : m_filename(szFile), m_handle(hFile) {}
|
||||
~auto_delete_file_wic()
|
||||
{
|
||||
if (m_filename)
|
||||
@@ -235,7 +232,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void clear() { m_filename = 0; }
|
||||
void clear() { m_filename = nullptr; }
|
||||
|
||||
private:
|
||||
const wchar_t* m_filename;
|
||||
@@ -627,7 +624,7 @@ namespace
|
||||
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
||||
|
||||
ComPtr<ID3D11Texture2D> pTexture;
|
||||
HRESULT hr = pSource->QueryInterface(IID_PPV_ARGS(pTexture.GetAddressOf()));
|
||||
HRESULT hr = pSource->QueryInterface(IID_ID3D11Texture2D, reinterpret_cast<void**>(pTexture.GetAddressOf()));
|
||||
if ( FAILED(hr) )
|
||||
return hr;
|
||||
|
||||
@@ -711,49 +708,53 @@ namespace
|
||||
//--------------------------------------------------------------------------------------
|
||||
bool g_WIC2 = false;
|
||||
|
||||
BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID* ifactory) noexcept
|
||||
{
|
||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
|
||||
HRESULT hr = CoCreateInstance(
|
||||
CLSID_WICImagingFactory2,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
__uuidof(IWICImagingFactory2),
|
||||
ifactory
|
||||
);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
// WIC2 is available on Windows 10, Windows 8.x, and Windows 7 SP1 with KB 2670838 installed
|
||||
g_WIC2 = true;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
hr = CoCreateInstance(
|
||||
CLSID_WICImagingFactory1,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
__uuidof(IWICImagingFactory),
|
||||
ifactory
|
||||
);
|
||||
return SUCCEEDED(hr) ? TRUE : FALSE;
|
||||
}
|
||||
#else
|
||||
return SUCCEEDED(CoCreateInstance(
|
||||
CLSID_WICImagingFactory,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
__uuidof(IWICImagingFactory),
|
||||
ifactory)) ? TRUE : FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
IWICImagingFactory* _GetWIC()
|
||||
{
|
||||
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
|
||||
|
||||
IWICImagingFactory* factory = nullptr;
|
||||
InitOnceExecuteOnce(&s_initOnce,
|
||||
[](PINIT_ONCE, PVOID, LPVOID *ifactory) -> BOOL
|
||||
{
|
||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
|
||||
HRESULT hr = CoCreateInstance(
|
||||
CLSID_WICImagingFactory2,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
__uuidof(IWICImagingFactory2),
|
||||
ifactory
|
||||
);
|
||||
|
||||
if ( SUCCEEDED(hr) )
|
||||
{
|
||||
// WIC2 is available on Windows 10, Windows 8.x, and Windows 7 SP1 with KB 2670838 installed
|
||||
g_WIC2 = true;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
hr = CoCreateInstance(
|
||||
CLSID_WICImagingFactory1,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
__uuidof(IWICImagingFactory),
|
||||
ifactory
|
||||
);
|
||||
return SUCCEEDED(hr) ? TRUE : FALSE;
|
||||
}
|
||||
#else
|
||||
return SUCCEEDED( CoCreateInstance(
|
||||
CLSID_WICImagingFactory,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
__uuidof(IWICImagingFactory),
|
||||
ifactory) ) ? TRUE : FALSE;
|
||||
#endif
|
||||
}, nullptr, reinterpret_cast<LPVOID*>(&factory));
|
||||
InitializeWICFactory,
|
||||
nullptr,
|
||||
reinterpret_cast<LPVOID*>(&factory));
|
||||
|
||||
return factory;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <d3d11_1.h>
|
||||
|
||||
#include <ocidl.h>
|
||||
#include <OCIdl.h>
|
||||
#include <stdint.h>
|
||||
#include <functional>
|
||||
|
||||
@@ -36,4 +36,4 @@ namespace DirectX
|
||||
_In_z_ const wchar_t* fileName,
|
||||
_In_opt_ const GUID* targetFormat = nullptr,
|
||||
_In_opt_ std::function<void(IPropertyBag2*)> setCustomProps = nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,14 @@
|
||||
|
||||
#include <wrl\client.h>
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wtautological-type-limit-compare"
|
||||
#pragma clang diagnostic ignored "-Wcovered-switch-default"
|
||||
#pragma clang diagnostic ignored "-Wswitch"
|
||||
#pragma clang diagnostic ignored "-Wswitch-enum"
|
||||
#endif
|
||||
|
||||
#define D3DX12_NO_STATE_OBJECT_HELPERS
|
||||
#include "d3dx12.h"
|
||||
|
||||
using Microsoft::WRL::ComPtr;
|
||||
@@ -80,9 +88,6 @@ namespace
|
||||
#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH
|
||||
#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE
|
||||
|
||||
#define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT
|
||||
#define DDS_WIDTH 0x00000004 // DDSD_WIDTH
|
||||
|
||||
#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
|
||||
|
||||
typedef struct
|
||||
@@ -213,7 +218,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void clear() { m_handle = 0; }
|
||||
void clear() { m_handle = nullptr; }
|
||||
|
||||
private:
|
||||
HANDLE m_handle;
|
||||
@@ -225,7 +230,7 @@ namespace
|
||||
class auto_delete_file_wic
|
||||
{
|
||||
public:
|
||||
auto_delete_file_wic(ComPtr<IWICStream>& hFile, LPCWSTR szFile) : m_handle(hFile), m_filename(szFile) {}
|
||||
auto_delete_file_wic(ComPtr<IWICStream>& hFile, LPCWSTR szFile) : m_filename(szFile), m_handle(hFile) {}
|
||||
~auto_delete_file_wic()
|
||||
{
|
||||
if (m_filename)
|
||||
@@ -235,7 +240,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void clear() { m_filename = 0; }
|
||||
void clear() { m_filename = nullptr; }
|
||||
|
||||
private:
|
||||
LPCWSTR m_filename;
|
||||
@@ -676,19 +681,19 @@ namespace
|
||||
|
||||
// Create a command allocator
|
||||
ComPtr<ID3D12CommandAllocator> commandAlloc;
|
||||
hr = device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(commandAlloc.GetAddressOf()));
|
||||
hr = device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_ID3D12CommandAllocator, reinterpret_cast<void**>(commandAlloc.GetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
// Spin up a new command list
|
||||
ComPtr<ID3D12GraphicsCommandList> commandList;
|
||||
hr = device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, commandAlloc.Get(), nullptr, IID_PPV_ARGS(commandList.GetAddressOf()));
|
||||
hr = device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, commandAlloc.Get(), nullptr, IID_ID3D12GraphicsCommandList, reinterpret_cast<void**>(commandList.GetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
// Create a fence
|
||||
ComPtr<ID3D12Fence> fence;
|
||||
hr = device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(fence.GetAddressOf()));
|
||||
hr = device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_ID3D12Fence, reinterpret_cast<void**>(fence.GetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
@@ -726,7 +731,8 @@ namespace
|
||||
&descCopy,
|
||||
D3D12_RESOURCE_STATE_COPY_DEST,
|
||||
nullptr,
|
||||
IID_PPV_ARGS(pTemp.GetAddressOf()));
|
||||
IID_ID3D12Resource,
|
||||
reinterpret_cast<void**>(pTemp.GetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
@@ -761,7 +767,8 @@ namespace
|
||||
&bufferDesc,
|
||||
D3D12_RESOURCE_STATE_COPY_DEST,
|
||||
nullptr,
|
||||
IID_PPV_ARGS(pStaging.ReleaseAndGetAddressOf()));
|
||||
IID_ID3D12Resource,
|
||||
reinterpret_cast<void**>(pStaging.ReleaseAndGetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
@@ -806,21 +813,25 @@ namespace
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID* ifactory) noexcept
|
||||
{
|
||||
return SUCCEEDED(CoCreateInstance(
|
||||
CLSID_WICImagingFactory2,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
__uuidof(IWICImagingFactory2),
|
||||
ifactory)) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
IWICImagingFactory2* _GetWIC()
|
||||
{
|
||||
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
|
||||
|
||||
IWICImagingFactory2* factory = nullptr;
|
||||
(void)InitOnceExecuteOnce(&s_initOnce,
|
||||
[](PINIT_ONCE, PVOID, PVOID *ifactory) -> BOOL
|
||||
{
|
||||
return SUCCEEDED( CoCreateInstance(
|
||||
CLSID_WICImagingFactory2,
|
||||
nullptr,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
__uuidof(IWICImagingFactory2),
|
||||
ifactory) ) ? TRUE : FALSE;
|
||||
}, nullptr, reinterpret_cast<LPVOID*>(&factory));
|
||||
InitializeWICFactory,
|
||||
nullptr,
|
||||
reinterpret_cast<LPVOID*>(&factory));
|
||||
|
||||
return factory;
|
||||
}
|
||||
@@ -840,7 +851,7 @@ HRESULT DirectX::SaveDDSTextureToFile(
|
||||
return E_INVALIDARG;
|
||||
|
||||
ComPtr<ID3D12Device> device;
|
||||
pCommandQ->GetDevice(IID_PPV_ARGS(device.GetAddressOf()));
|
||||
pCommandQ->GetDevice(IID_ID3D12Device, reinterpret_cast<void**>(device.GetAddressOf()));
|
||||
|
||||
// Get the size of the image
|
||||
const auto desc = pSource->GetDesc();
|
||||
@@ -863,7 +874,7 @@ HRESULT DirectX::SaveDDSTextureToFile(
|
||||
&totalResourceSize);
|
||||
|
||||
// Round up the srcPitch to multiples of 256
|
||||
UINT64 dstRowPitch = (fpRowPitch + 255) & ~0xFF;
|
||||
UINT64 dstRowPitch = (fpRowPitch + 255) & ~0xFFu;
|
||||
|
||||
if (dstRowPitch > UINT32_MAX)
|
||||
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
|
||||
@@ -1045,7 +1056,7 @@ HRESULT DirectX::SaveWICTextureToFile(
|
||||
return E_INVALIDARG;
|
||||
|
||||
ComPtr<ID3D12Device> device;
|
||||
pCommandQ->GetDevice(IID_PPV_ARGS(device.GetAddressOf()));
|
||||
pCommandQ->GetDevice(IID_ID3D12Device, reinterpret_cast<void**>(device.GetAddressOf()));
|
||||
|
||||
// Get the size of the image
|
||||
const auto desc = pSource->GetDesc();
|
||||
@@ -1068,7 +1079,7 @@ HRESULT DirectX::SaveWICTextureToFile(
|
||||
&totalResourceSize);
|
||||
|
||||
// Round up the srcPitch to multiples of 256
|
||||
UINT64 dstRowPitch = (fpRowPitch + 255) & ~0xFF;
|
||||
UINT64 dstRowPitch = (fpRowPitch + 255) & ~0xFFu;
|
||||
|
||||
if (dstRowPitch > UINT32_MAX)
|
||||
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <d3d12.h>
|
||||
|
||||
#include <ocidl.h>
|
||||
#include <OCIdl.h>
|
||||
#include <stdint.h>
|
||||
#include <functional>
|
||||
|
||||
@@ -42,4 +42,4 @@ namespace DirectX
|
||||
D3D12_RESOURCE_STATES afterState = D3D12_RESOURCE_STATE_RENDER_TARGET,
|
||||
_In_opt_ const GUID* targetFormat = nullptr,
|
||||
_In_opt_ std::function<void __cdecl(IPropertyBag2*)> setCustomProps = nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user