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:
@@ -20,8 +20,9 @@
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
|
||||
#pragma comment(lib,"dxguid.lib")
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wcovered-switch-default"
|
||||
#pragma clang diagnostic ignored "-Wswitch-enum"
|
||||
#endif
|
||||
|
||||
using namespace DirectX;
|
||||
@@ -65,7 +66,6 @@ struct DDS_PIXELFORMAT
|
||||
#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH
|
||||
|
||||
#define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT
|
||||
#define DDS_WIDTH 0x00000004 // DDSD_WIDTH
|
||||
|
||||
#define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX
|
||||
#define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX
|
||||
@@ -189,7 +189,7 @@ namespace
|
||||
|
||||
// setup the pointers in the process request
|
||||
*header = hdr;
|
||||
ptrdiff_t offset = sizeof(uint32_t)
|
||||
auto offset = sizeof(uint32_t)
|
||||
+ sizeof(DDS_HEADER)
|
||||
+ (bDXT10Header ? sizeof(DDS_HEADER_DXT10) : 0);
|
||||
*bitData = ddsData + offset;
|
||||
@@ -309,7 +309,7 @@ namespace
|
||||
|
||||
// setup the pointers in the process request
|
||||
*header = hdr;
|
||||
ptrdiff_t offset = sizeof(uint32_t) + sizeof(DDS_HEADER)
|
||||
auto offset = sizeof(uint32_t) + sizeof(DDS_HEADER)
|
||||
+ (bDXT10Header ? sizeof(DDS_HEADER_DXT10) : 0);
|
||||
*bitData = ddsData.get() + offset;
|
||||
*bitSize = fileInfo.EndOfFile.LowPart - offset;
|
||||
@@ -950,7 +950,7 @@ namespace
|
||||
|
||||
assert(index < mipCount * arraySize);
|
||||
_Analysis_assume_(index < mipCount * arraySize);
|
||||
initData[index].pSysMem = (const void*)pSrcBits;
|
||||
initData[index].pSysMem = pSrcBits;
|
||||
initData[index].SysMemPitch = static_cast<UINT>(RowBytes);
|
||||
initData[index].SysMemSlicePitch = static_cast<UINT>(NumBytes);
|
||||
++index;
|
||||
@@ -1032,7 +1032,7 @@ namespace
|
||||
desc.Usage = usage;
|
||||
desc.BindFlags = bindFlags;
|
||||
desc.CPUAccessFlags = cpuAccessFlags;
|
||||
desc.MiscFlags = miscFlags & ~D3D11_RESOURCE_MISC_TEXTURECUBE;
|
||||
desc.MiscFlags = miscFlags & ~static_cast<unsigned int>(D3D11_RESOURCE_MISC_TEXTURECUBE);
|
||||
|
||||
ID3D11Texture1D* tex = nullptr;
|
||||
hr = d3dDevice->CreateTexture1D(&desc,
|
||||
@@ -1049,13 +1049,13 @@ namespace
|
||||
if (arraySize > 1)
|
||||
{
|
||||
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1DARRAY;
|
||||
SRVDesc.Texture1DArray.MipLevels = (!mipCount) ? -1 : desc.MipLevels;
|
||||
SRVDesc.Texture1DArray.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
|
||||
SRVDesc.Texture1DArray.ArraySize = static_cast<UINT>(arraySize);
|
||||
}
|
||||
else
|
||||
{
|
||||
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D;
|
||||
SRVDesc.Texture1D.MipLevels = (!mipCount) ? -1 : desc.MipLevels;
|
||||
SRVDesc.Texture1D.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
|
||||
}
|
||||
|
||||
hr = d3dDevice->CreateShaderResourceView(tex,
|
||||
@@ -1101,7 +1101,7 @@ namespace
|
||||
}
|
||||
else
|
||||
{
|
||||
desc.MiscFlags = miscFlags & ~D3D11_RESOURCE_MISC_TEXTURECUBE;
|
||||
desc.MiscFlags = miscFlags & ~static_cast<unsigned int>(D3D11_RESOURCE_MISC_TEXTURECUBE);
|
||||
}
|
||||
|
||||
ID3D11Texture2D* tex = nullptr;
|
||||
@@ -1121,7 +1121,7 @@ namespace
|
||||
if (arraySize > 6)
|
||||
{
|
||||
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBEARRAY;
|
||||
SRVDesc.TextureCubeArray.MipLevels = (!mipCount) ? -1 : desc.MipLevels;
|
||||
SRVDesc.TextureCubeArray.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
|
||||
|
||||
// Earlier we set arraySize to (NumCubes * 6)
|
||||
SRVDesc.TextureCubeArray.NumCubes = static_cast<UINT>(arraySize / 6);
|
||||
@@ -1129,19 +1129,19 @@ namespace
|
||||
else
|
||||
{
|
||||
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
|
||||
SRVDesc.TextureCube.MipLevels = (!mipCount) ? -1 : desc.MipLevels;
|
||||
SRVDesc.TextureCube.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
|
||||
}
|
||||
}
|
||||
else if (arraySize > 1)
|
||||
{
|
||||
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
|
||||
SRVDesc.Texture2DArray.MipLevels = (!mipCount) ? -1 : desc.MipLevels;
|
||||
SRVDesc.Texture2DArray.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
|
||||
SRVDesc.Texture2DArray.ArraySize = static_cast<UINT>(arraySize);
|
||||
}
|
||||
else
|
||||
{
|
||||
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||
SRVDesc.Texture2D.MipLevels = (!mipCount) ? -1 : desc.MipLevels;
|
||||
SRVDesc.Texture2D.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
|
||||
}
|
||||
|
||||
hr = d3dDevice->CreateShaderResourceView(tex,
|
||||
@@ -1179,7 +1179,7 @@ namespace
|
||||
desc.Usage = usage;
|
||||
desc.BindFlags = bindFlags;
|
||||
desc.CPUAccessFlags = cpuAccessFlags;
|
||||
desc.MiscFlags = miscFlags & ~D3D11_RESOURCE_MISC_TEXTURECUBE;
|
||||
desc.MiscFlags = miscFlags & ~static_cast<unsigned int>(D3D11_RESOURCE_MISC_TEXTURECUBE);
|
||||
|
||||
ID3D11Texture3D* tex = nullptr;
|
||||
hr = d3dDevice->CreateTexture3D(&desc,
|
||||
@@ -1194,7 +1194,7 @@ namespace
|
||||
SRVDesc.Format = format;
|
||||
|
||||
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D;
|
||||
SRVDesc.Texture3D.MipLevels = (!mipCount) ? -1 : desc.MipLevels;
|
||||
SRVDesc.Texture3D.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
|
||||
|
||||
hr = d3dDevice->CreateShaderResourceView(tex,
|
||||
&SRVDesc,
|
||||
@@ -1260,7 +1260,7 @@ namespace
|
||||
if ((header->ddspf.flags & DDS_FOURCC) &&
|
||||
(MAKEFOURCC('D', 'X', '1', '0') == header->ddspf.fourCC))
|
||||
{
|
||||
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>((const char*)header + sizeof(DDS_HEADER));
|
||||
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>(reinterpret_cast<const uint8_t*>(header) + sizeof(DDS_HEADER));
|
||||
|
||||
arraySize = d3d10ext->arraySize;
|
||||
if (arraySize == 0)
|
||||
@@ -1604,7 +1604,7 @@ namespace
|
||||
{
|
||||
if (MAKEFOURCC('D', 'X', '1', '0') == header->ddspf.fourCC)
|
||||
{
|
||||
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>((const char*)header + sizeof(DDS_HEADER));
|
||||
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>(reinterpret_cast<const uint8_t*>(header) + sizeof(DDS_HEADER));
|
||||
auto mode = static_cast<DDS_ALPHA_MODE>(d3d10ext->miscFlags2 & DDS_MISC_FLAGS2_ALPHA_MODE_MASK);
|
||||
switch (mode)
|
||||
{
|
||||
@@ -1613,6 +1613,10 @@ namespace
|
||||
case DDS_ALPHA_MODE_OPAQUE:
|
||||
case DDS_ALPHA_MODE_CUSTOM:
|
||||
return mode;
|
||||
|
||||
case DDS_ALPHA_MODE_UNKNOWN:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ((MAKEFOURCC('D', 'X', 'T', '2') == header->ddspf.fourCC)
|
||||
|
||||
@@ -126,4 +126,4 @@ namespace DirectX
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,14 @@
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#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 namespace DirectX;
|
||||
@@ -63,7 +71,6 @@ struct DDS_PIXELFORMAT
|
||||
#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH
|
||||
|
||||
#define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT
|
||||
#define DDS_WIDTH 0x00000004 // DDSD_WIDTH
|
||||
|
||||
#define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX
|
||||
#define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX
|
||||
@@ -203,7 +210,7 @@ namespace
|
||||
|
||||
// setup the pointers in the process request
|
||||
*header = hdr;
|
||||
ptrdiff_t offset = sizeof(uint32_t)
|
||||
auto offset = sizeof(uint32_t)
|
||||
+ sizeof(DDS_HEADER)
|
||||
+ (bDXT10Header ? sizeof(DDS_HEADER_DXT10) : 0);
|
||||
*bitData = ddsData + offset;
|
||||
@@ -313,7 +320,7 @@ namespace
|
||||
|
||||
// setup the pointers in the process request
|
||||
*header = hdr;
|
||||
ptrdiff_t offset = sizeof(uint32_t) + sizeof(DDS_HEADER)
|
||||
auto offset = sizeof(uint32_t) + sizeof(DDS_HEADER)
|
||||
+ (bDXT10Header ? sizeof(DDS_HEADER_DXT10) : 0);
|
||||
*bitData = ddsData.get() + offset;
|
||||
*bitSize = fileInfo.EndOfFile.LowPart - offset;
|
||||
@@ -938,13 +945,13 @@ namespace
|
||||
if (!slicePlane)
|
||||
{
|
||||
// Plane 0
|
||||
res.SlicePitch = res.RowPitch * height;
|
||||
res.SlicePitch = res.RowPitch * static_cast<LONG>(height);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Plane 1
|
||||
res.pData = reinterpret_cast<const uint8_t*>(res.pData) + res.RowPitch * height;
|
||||
res.SlicePitch = res.RowPitch * ((height + 1) >> 1);
|
||||
res.pData = reinterpret_cast<const uint8_t*>(res.pData) + uintptr_t(res.RowPitch) * height;
|
||||
res.SlicePitch = res.RowPitch * ((static_cast<LONG>(height) + 1) >> 1);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -952,14 +959,14 @@ namespace
|
||||
if (!slicePlane)
|
||||
{
|
||||
// Plane 0
|
||||
res.SlicePitch = res.RowPitch * height;
|
||||
res.SlicePitch = res.RowPitch * static_cast<LONG>(height);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Plane 1
|
||||
res.pData = reinterpret_cast<const uint8_t*>(res.pData) + res.RowPitch * height;
|
||||
res.pData = reinterpret_cast<const uint8_t*>(res.pData) + uintptr_t(res.RowPitch) * height;
|
||||
res.RowPitch = (res.RowPitch >> 1);
|
||||
res.SlicePitch = res.RowPitch * height;
|
||||
res.SlicePitch = res.RowPitch * static_cast<LONG>(height);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1116,7 +1123,7 @@ namespace
|
||||
&desc,
|
||||
D3D12_RESOURCE_STATE_COPY_DEST,
|
||||
nullptr,
|
||||
IID_PPV_ARGS(texture));
|
||||
IID_ID3D12Resource, reinterpret_cast<void**>(texture));
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
_Analysis_assume_(*texture != nullptr);
|
||||
@@ -1159,7 +1166,7 @@ namespace
|
||||
if ((header->ddspf.flags & DDS_FOURCC) &&
|
||||
(MAKEFOURCC('D', 'X', '1', '0') == header->ddspf.fourCC))
|
||||
{
|
||||
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>((const char*)header + sizeof(DDS_HEADER));
|
||||
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>(reinterpret_cast<const uint8_t*>(header) + sizeof(DDS_HEADER));
|
||||
|
||||
arraySize = d3d10ext->arraySize;
|
||||
if (arraySize == 0)
|
||||
@@ -1388,7 +1395,7 @@ namespace
|
||||
{
|
||||
if ( MAKEFOURCC( 'D', 'X', '1', '0' ) == header->ddspf.fourCC )
|
||||
{
|
||||
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>( (const char*)header + sizeof(DDS_HEADER) );
|
||||
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>(reinterpret_cast<const uint8_t*>(header) + sizeof(DDS_HEADER));
|
||||
auto mode = static_cast<DDS_ALPHA_MODE>( d3d10ext->miscFlags2 & DDS_MISC_FLAGS2_ALPHA_MODE_MASK );
|
||||
switch( mode )
|
||||
{
|
||||
@@ -1397,6 +1404,10 @@ namespace
|
||||
case DDS_ALPHA_MODE_OPAQUE:
|
||||
case DDS_ALPHA_MODE_CUSTOM:
|
||||
return mode;
|
||||
|
||||
case DDS_ALPHA_MODE_UNKNOWN:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( ( MAKEFOURCC( 'D', 'X', 'T', '2' ) == header->ddspf.fourCC )
|
||||
|
||||
Reference in New Issue
Block a user