diff --git a/DirectXTex/BC.cpp b/DirectXTex/BC.cpp index bee33a5..2d7b8f6 100644 --- a/DirectXTex/BC.cpp +++ b/DirectXTex/BC.cpp @@ -430,9 +430,9 @@ namespace Clr.b += Error[i].b; } - Color[i].r = static_cast(static_cast(Clr.r * 31.0f + 0.5f) * (1.0f / 31.0f)); - Color[i].g = static_cast(static_cast(Clr.g * 63.0f + 0.5f) * (1.0f / 63.0f)); - Color[i].b = static_cast(static_cast(Clr.b * 31.0f + 0.5f) * (1.0f / 31.0f)); + Color[i].r = static_cast(static_cast(Clr.r * 31.0f + 0.5f)) * (1.0f / 31.0f); + Color[i].g = static_cast(static_cast(Clr.g * 63.0f + 0.5f)) * (1.0f / 63.0f); + Color[i].b = static_cast(static_cast(Clr.b * 31.0f + 0.5f)) * (1.0f / 31.0f); #ifdef COLOR_WEIGHTS Color[i].a = pColor[i].a; @@ -918,12 +918,12 @@ void DirectX::D3DXDecodeBC3(XMVECTOR *pColor, const uint8_t *pBC) noexcept if (pBC3->alpha[0] > pBC3->alpha[1]) { for (size_t i = 1; i < 7; ++i) - fAlpha[i + 1] = (fAlpha[0] * (7 - i) + fAlpha[1] * i) * (1.0f / 7.0f); + fAlpha[i + 1] = (fAlpha[0] * float(7u - i) + fAlpha[1] * float(i)) * (1.0f / 7.0f); } else { for (size_t i = 1; i < 5; ++i) - fAlpha[i + 1] = (fAlpha[0] * (5 - i) + fAlpha[1] * i) * (1.0f / 5.0f); + fAlpha[i + 1] = (fAlpha[0] * float(5u - i) + fAlpha[1] * float(i)) * (1.0f / 5.0f); fAlpha[6] = 0.0f; fAlpha[7] = 1.0f; @@ -969,7 +969,7 @@ void DirectX::D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) n if (flags & BC_FLAGS_DITHER_A) fAlph += fError[i]; - fAlpha[i] = static_cast(fAlph * 255.0f + 0.5f) * (1.0f / 255.0f); + fAlpha[i] = static_cast(static_cast(fAlph * 255.0f + 0.5f)) * (1.0f / 255.0f); if (fAlpha[i] < fMinAlpha) fMinAlpha = fAlpha[i]; @@ -1062,7 +1062,7 @@ void DirectX::D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) n fStep[1] = fAlphaB; for (size_t i = 1; i < 5; ++i) - fStep[i + 1] = (fStep[0] * (5 - i) + fStep[1] * i) * (1.0f / 5.0f); + fStep[i + 1] = (fStep[0] * float(5u - i) + fStep[1] * float(i)) * (1.0f / 5.0f); fStep[6] = 0.0f; fStep[7] = 1.0f; @@ -1078,7 +1078,7 @@ void DirectX::D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, DWORD flags) n fStep[1] = fAlphaA; for (size_t i = 1; i < 7; ++i) - fStep[i + 1] = (fStep[0] * (7 - i) + fStep[1] * i) * (1.0f / 7.0f); + fStep[i + 1] = (fStep[0] * float(7u - i) + fStep[1] * float(i)) * (1.0f / 7.0f); pSteps = pSteps8; } diff --git a/DirectXTex/BC4BC5.cpp b/DirectXTex/BC4BC5.cpp index a2cce90..9dc4d85 100644 --- a/DirectXTex/BC4BC5.cpp +++ b/DirectXTex/BC4BC5.cpp @@ -55,7 +55,7 @@ namespace if (red_0 > red_1) { uIndex -= 1; - return (fred_0 * (7 - uIndex) + fred_1 * uIndex) / 7.0f; + return (fred_0 * float(7u - uIndex) + fred_1 * float(uIndex)) / 7.0f; } else { @@ -64,7 +64,7 @@ namespace if (uIndex == 7) return 1.0f; uIndex -= 1; - return (fred_0 * (5 - uIndex) + fred_1 * uIndex) / 5.0f; + return (fred_0 * float(5u - uIndex) + fred_1 * float(uIndex)) / 5.0f; } } @@ -114,7 +114,7 @@ namespace if (red_0 > red_1) { uIndex -= 1; - return (fred_0 * (7 - uIndex) + fred_1 * uIndex) / 7.0f; + return (fred_0 * float(7u - uIndex) + fred_1 * float(uIndex)) / 7.0f; } else { @@ -123,7 +123,7 @@ namespace if (uIndex == 7) return 1.0f; uIndex -= 1; - return (fred_0 * (5 - uIndex) + fred_1 * uIndex) / 5.0f; + return (fred_0 * float(5u - uIndex) + fred_1 * float(uIndex)) / 5.0f; } } diff --git a/DirectXTex/DirectXTexConvert.cpp b/DirectXTex/DirectXTexConvert.cpp index c9f9b81..9a5372e 100644 --- a/DirectXTex/DirectXTexConvert.cpp +++ b/DirectXTex/DirectXTexConvert.cpp @@ -1297,7 +1297,7 @@ _Use_decl_annotations_ bool DirectX::_LoadScanline( *(dPtr++) = XMVectorSet(float(std::min(std::max(r, 0), 255)) / 255.f, float(std::min(std::max(g, 0), 255)) / 255.f, float(std::min(std::max(b, 0), 255)) / 255.f, - float(a / 255.f)); + float(a) / 255.f); } return true; } @@ -1333,7 +1333,7 @@ _Use_decl_annotations_ bool DirectX::_LoadScanline( *(dPtr++) = XMVectorSet(float(std::min(std::max(r, 0), 1023)) / 1023.f, float(std::min(std::max(g, 0), 1023)) / 1023.f, float(std::min(std::max(b, 0), 1023)) / 1023.f, - float(a / 3.f)); + float(a) / 3.f); } return true; } diff --git a/DirectXTex/DirectXTexMipmaps.cpp b/DirectXTex/DirectXTexMipmaps.cpp index 1fc3785..36ff4f7 100644 --- a/DirectXTex/DirectXTexMipmaps.cpp +++ b/DirectXTex/DirectXTexMipmaps.cpp @@ -191,12 +191,12 @@ namespace { for (size_t sy = 0; sy < N; ++sy) { - const float fy = (sy + 0.5f) / N; + const float fy = (float(sy) + 0.5f) / float(N); const float ify = 1.0f - fy; for (size_t sx = 0; sx < N; ++sx) { - const float fx = (sx + 0.5f) / N; + const float fx = (float(sx) + 0.5f) / float(N); const float ifx = 1.0f - fx; // [0]=(x+0, y+0), [1]=(x+0, y+1), [2]=(x+1, y+0), [3]=(x+1, y+1) @@ -303,7 +303,6 @@ namespace { float minAlphaScale = 0.0f; float maxAlphaScale = 4.0f; - float bestAlphaScale = 1.0f; float bestError = FLT_MAX; // Determine desired scale using a binary search. Hardcoded to 10 steps max. @@ -322,7 +321,6 @@ namespace if (error < bestError) { bestError = error; - bestAlphaScale = alphaScale; } if (currentCoverage < targetCoverage)