Cleaned up clang warnings in DDSTextureLoader, ScreenGrab, WICTextureLoader

This commit is contained in:
Chuck Walbourn
2019-07-31 17:05:23 -07:00
parent 5dcfb90b9e
commit bc0325b806
11 changed files with 204 additions and 158 deletions

View File

@@ -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 )