VS 2017 (15.7) /analyze fixes

This commit is contained in:
Chuck Walbourn 2018-05-02 00:20:07 -07:00
parent b7ebbda239
commit 6f84c81975
6 changed files with 37 additions and 37 deletions

View File

@ -64,7 +64,7 @@ namespace
_Out_ HDRColorA *pX,
_Out_ HDRColorA *pY,
_In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA *pPoints,
size_t cSteps,
uint32_t cSteps,
DWORD flags)
{
static const float fEpsilon = (0.25f / 64.0f) * (0.25f / 64.0f);
@ -252,13 +252,13 @@ namespace
(pPoints[iPoint].b - X.b) * Dir.b;
size_t iStep;
uint32_t iStep;
if (fDot <= 0.0f)
iStep = 0;
else if (fDot >= fSteps)
iStep = cSteps - 1;
else
iStep = static_cast<size_t>(fDot + 0.5f);
iStep = uint32_t(fDot + 0.5f);
HDRColorA Diff;
@ -380,7 +380,7 @@ namespace
static_assert(sizeof(D3DX_BC1) == 8, "D3DX_BC1 should be 8 bytes");
// Determine if we need to colorkey this block
size_t uSteps;
uint32_t uSteps;
if (bColorKey)
{
@ -628,14 +628,14 @@ namespace
}
float fDot = (Clr.r - Step[0].r) * Dir.r + (Clr.g - Step[0].g) * Dir.g + (Clr.b - Step[0].b) * Dir.b;
uint32_t iStep;
uint32_t iStep;
if (fDot <= 0.0f)
iStep = 0;
else if (fDot >= fSteps)
iStep = 1;
else
iStep = static_cast<uint32_t>(pSteps[static_cast<size_t>(fDot + 0.5f)]);
iStep = uint32_t(pSteps[uint32_t(fDot + 0.5f)]);
dw = (iStep << 30) | (dw >> 2);
@ -1023,7 +1023,7 @@ void DirectX::D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags)
}
// Optimize and Quantize Min and Max values
size_t uSteps = ((0.0f == fMinAlpha) || (1.0f == fMaxAlpha)) ? 6 : 8;
uint32_t uSteps = ((0.0f == fMinAlpha) || (1.0f == fMaxAlpha)) ? 6 : 8;
float fAlphaA, fAlphaB;
OptimizeAlpha<false>(&fAlphaA, &fAlphaB, fAlpha, uSteps);
@ -1106,7 +1106,7 @@ void DirectX::D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags)
else if (fDot >= fSteps)
iStep = ((6 == uSteps) && (fAlph >= (fStep[1] + 1.0f) * 0.5f)) ? 7 : 1;
else
iStep = static_cast<uint32_t>(pSteps[static_cast<size_t>(fDot + 0.5f)]);
iStep = uint32_t(pSteps[uint32_t(fDot + 0.5f)]);
dw = (iStep << 21) | (dw >> 3);

View File

@ -170,7 +170,7 @@ struct D3DX_BC3
//-------------------------------------------------------------------------------------
#pragma warning(push)
#pragma warning(disable : 4127)
template <bool bRange> void OptimizeAlpha(float *pX, float *pY, const float *pPoints, size_t cSteps)
template <bool bRange> void OptimizeAlpha(float *pX, float *pY, const float *pPoints, uint32_t cSteps)
{
static const float pC6[] = { 5.0f / 5.0f, 4.0f / 5.0f, 3.0f / 5.0f, 2.0f / 5.0f, 1.0f / 5.0f, 0.0f / 5.0f };
static const float pD6[] = { 0.0f / 5.0f, 1.0f / 5.0f, 2.0f / 5.0f, 3.0f / 5.0f, 4.0f / 5.0f, 5.0f / 5.0f };
@ -247,14 +247,13 @@ template <bool bRange> void OptimizeAlpha(float *pX, float *pY, const float *pPo
{
float fDot = (pPoints[iPoint] - fX) * fScale;
size_t iStep;
uint32_t iStep;
if (fDot <= 0.0f)
iStep = ((6 == cSteps) && (pPoints[iPoint] <= fX * 0.5f)) ? 6 : 0;
else if (fDot >= fSteps)
iStep = ((6 == cSteps) && (pPoints[iPoint] >= (fY + 1.0f) * 0.5f)) ? 7 : (cSteps - 1);
else
iStep = static_cast<int32_t>(fDot + 0.5f);
iStep = uint32_t(fDot + 0.5f);
if (iStep < cSteps)

View File

@ -512,9 +512,9 @@ namespace
INTColor& SignExtend(_In_ const LDRColorA& Prec)
{
r = SIGN_EXTEND(r, Prec.r);
g = SIGN_EXTEND(g, Prec.g);
b = SIGN_EXTEND(b, Prec.b);
r = SIGN_EXTEND(r, int(Prec.r));
g = SIGN_EXTEND(g, int(Prec.g));
b = SIGN_EXTEND(b, int(Prec.b));
return *this;
}
@ -1188,7 +1188,7 @@ namespace
_In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pPoints,
_Out_ HDRColorA* pX,
_Out_ HDRColorA* pY,
_In_range_(3, 4) size_t cSteps,
_In_range_(3, 4) uint32_t cSteps,
size_t cPixels,
_In_reads_(cPixels) const size_t* pIndex)
{
@ -1320,13 +1320,13 @@ namespace
(pPoints[pIndex[iPoint]].g - X.g) * Dir.g +
(pPoints[pIndex[iPoint]].b - X.b) * Dir.b;
size_t iStep;
uint32_t iStep;
if (fDot <= 0.0f)
iStep = 0;
if (fDot >= fSteps)
iStep = cSteps - 1;
else
iStep = size_t(fDot + 0.5f);
iStep = uint32_t(fDot + 0.5f);
HDRColorA Diff;
Diff.r = pSteps[iStep].r - pPoints[pIndex[iPoint]].r;
@ -1384,7 +1384,7 @@ namespace
_In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pPoints,
_Out_ HDRColorA* pX,
_Out_ HDRColorA* pY,
_In_range_(3, 4) size_t cSteps,
_In_range_(3, 4) uint32_t cSteps,
size_t cPixels,
_In_reads_(cPixels) const size_t* pIndex)
{
@ -1505,13 +1505,14 @@ namespace
for (size_t iPoint = 0; iPoint < cPixels; ++iPoint)
{
float fDot = (pPoints[pIndex[iPoint]] - X) * Dir;
size_t iStep;
uint32_t iStep;
if (fDot <= 0.0f)
iStep = 0;
if (fDot >= fSteps)
iStep = cSteps - 1;
else
iStep = size_t(fDot + 0.5f);
iStep = uint32_t(fDot + 0.5f);
HDRColorA Diff = pSteps[iStep] - pPoints[pIndex[iPoint]];
float fC = pC[iStep] * (1.0f / 8.0f);
@ -2538,7 +2539,7 @@ void D3DX_BC7::Decode(HDRColorA* pOut) const
const uint8_t uIndexPrec = ms_aInfo[uMode].uIndexPrec;
const uint8_t uIndexPrec2 = ms_aInfo[uMode].uIndexPrec2;
size_t i;
size_t uStartBit = uMode + 1;
size_t uStartBit = size_t(uMode) + 1;
uint8_t P[6];
uint8_t uShape = GetBits(uStartBit, ms_aInfo[uMode].uPartitionBits);
assert(uShape < BC7_MAX_SHAPES);
@ -3161,7 +3162,7 @@ void D3DX_BC7::EmitBlock(const EncodeParams* pEP, size_t uShape, size_t uRotatio
if (uPBits)
{
const size_t uNumEP = size_t(1 + uPartitions) << 1;
const size_t uNumEP = (size_t(uPartitions) + 1) << 1;
uint8_t aPVote[BC7_MAX_REGIONS << 1] = { 0,0,0,0,0,0 };
uint8_t aCount[BC7_MAX_REGIONS << 1] = { 0,0,0,0,0,0 };
for (uint8_t ch = 0; ch < BC7_NUM_CHANNELS; ch++)

View File

@ -477,7 +477,7 @@ namespace
enc[1] = *spanPtr;
enc += 2;
encSize += 2;
spanPtr += spanLen * 4;
spanPtr += size_t(spanLen) * 4;
pixelCount += spanLen;
}
else
@ -501,8 +501,8 @@ namespace
*enc++ = runLen;
memcpy(enc, scan, runLen);
enc += runLen;
encSize += runLen + 1;
spanPtr += runLen * 4;
encSize += size_t(runLen) + 1;
spanPtr += size_t(runLen) * 4;
pixelCount += runLen;
}
}
@ -647,7 +647,7 @@ HRESULT DirectX::LoadFromHDRMemory(const void* pSource, size_t size, TexMetadata
if (inColor[0] == 2 && inColor[1] == 2 && inColor[2] < 128)
{
// Adaptive Run Length Encoding (RLE)
if (size_t((inColor[2] << 8) + inColor[3]) != mdata.width)
if (size_t((size_t(inColor[2]) << 8) + inColor[3]) != mdata.width)
{
image.Release();
return E_FAIL;
@ -686,7 +686,7 @@ HRESULT DirectX::LoadFromHDRMemory(const void* pSource, size_t size, TexMetadata
sourcePtr += 2;
pixelLen -= 2;
}
else if ((size < size_t(runLen + 1)) || ((pixelCount + runLen) > mdata.width))
else if ((size < size_t(runLen) + 1) || ((pixelCount + size_t(runLen)) > mdata.width))
{
image.Release();
return E_FAIL;
@ -701,7 +701,7 @@ HRESULT DirectX::LoadFromHDRMemory(const void* pSource, size_t size, TexMetadata
pixelLoc += 4;
}
pixelCount += runLen;
pixelLen -= runLen + 1;
pixelLen -= size_t(runLen) + 1;
}
}
}

View File

@ -301,7 +301,7 @@ namespace
if (*sPtr & 0x80)
{
// Repeat
size_t j = (*sPtr & 0x7F) + 1;
size_t j = size_t(*sPtr & 0x7F) + 1;
if (++sPtr >= endPtr)
return E_FAIL;
@ -323,7 +323,7 @@ namespace
else
{
// Literal
size_t j = (*sPtr & 0x7F) + 1;
size_t j = size_t(*sPtr & 0x7F) + 1;
++sPtr;
if (sPtr + j > endPtr)
@ -367,7 +367,7 @@ namespace
if (*sPtr & 0x80)
{
// Repeat
size_t j = (*sPtr & 0x7F) + 1;
size_t j = size_t(*sPtr & 0x7F) + 1;
++sPtr;
if (sPtr + 1 >= endPtr)
@ -394,7 +394,7 @@ namespace
else
{
// Literal
size_t j = (*sPtr & 0x7F) + 1;
size_t j = size_t(*sPtr & 0x7F) + 1;
++sPtr;
if (sPtr + (j * 2) > endPtr)
@ -450,7 +450,7 @@ namespace
if (*sPtr & 0x80)
{
// Repeat
size_t j = (*sPtr & 0x7F) + 1;
size_t j = size_t(*sPtr & 0x7F) + 1;
++sPtr;
DWORD t;
@ -499,7 +499,7 @@ namespace
else
{
// Literal
size_t j = (*sPtr & 0x7F) + 1;
size_t j = size_t(*sPtr & 0x7F) + 1;
++sPtr;
if (convFlags & CONV_FLAGS_EXPAND)

View File

@ -263,8 +263,8 @@ namespace TriangleFilter
float src = float(u) - 0.5f;
float destMin = src * scale;
float destMax = destMin + scale;
totalSize += TF_FROM_SIZE + TF_TO_SIZE + size_t(destMax - destMin + repeat + 1.f) * TF_TO_SIZE * 2;
float t = destMax - destMin + repeat + 1.f;
totalSize += TF_FROM_SIZE + TF_TO_SIZE + size_t(t) * TF_TO_SIZE * 2;
}
uint8_t* pFilter = nullptr;