mirror of
https://github.com/microsoft/DirectXTex
synced 2024-12-25 19:01:05 +00:00
Replaced _countof / ARRAYSIZE with std::size
This commit is contained in:
parent
2f8e8120ae
commit
f764da5176
@ -347,7 +347,7 @@ HRESULT InitDevice( const TexMetadata& mdata )
|
||||
D3D_DRIVER_TYPE_WARP,
|
||||
D3D_DRIVER_TYPE_REFERENCE,
|
||||
};
|
||||
UINT numDriverTypes = ARRAYSIZE( driverTypes );
|
||||
constexpr UINT numDriverTypes = static_cast<UINT>(std::size(driverTypes));
|
||||
|
||||
D3D_FEATURE_LEVEL featureLevels[] =
|
||||
{
|
||||
@ -355,7 +355,7 @@ HRESULT InitDevice( const TexMetadata& mdata )
|
||||
D3D_FEATURE_LEVEL_10_1,
|
||||
D3D_FEATURE_LEVEL_10_0,
|
||||
};
|
||||
UINT numFeatureLevels = ARRAYSIZE( featureLevels );
|
||||
constexpr UINT numFeatureLevels = static_cast<UINT>(std::size(featureLevels));
|
||||
|
||||
DXGI_SWAP_CHAIN_DESC sd = {};
|
||||
sd.BufferCount = 1;
|
||||
@ -444,7 +444,7 @@ HRESULT InitDevice( const TexMetadata& mdata )
|
||||
{ "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, sizeof(XMFLOAT4), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
};
|
||||
UINT numElements = ARRAYSIZE( layout );
|
||||
constexpr UINT numElements = static_cast<UINT>(std::size(layout));
|
||||
|
||||
// Create the input layout
|
||||
hr = g_pd3dDevice->CreateInputLayout( layout, numElements, g_VS, sizeof(g_VS), &g_pVertexLayout );
|
||||
@ -574,17 +574,17 @@ HRESULT InitDevice( const TexMetadata& mdata )
|
||||
|
||||
if ( isCubeMap )
|
||||
{
|
||||
nverts = _countof(verticesCube);
|
||||
nverts = static_cast<UINT>(std::size(verticesCube));
|
||||
InitData.pSysMem = verticesCube;
|
||||
}
|
||||
else if ( is1D )
|
||||
{
|
||||
nverts = _countof(vertices1D);
|
||||
nverts = static_cast<UINT>(std::size(vertices1D));
|
||||
InitData.pSysMem = vertices1D;
|
||||
}
|
||||
else
|
||||
{
|
||||
nverts = _countof(vertices);
|
||||
nverts = static_cast<UINT>(std::size(vertices));
|
||||
InitData.pSysMem = vertices;
|
||||
}
|
||||
|
||||
@ -627,12 +627,12 @@ HRESULT InitDevice( const TexMetadata& mdata )
|
||||
|
||||
if ( isCubeMap )
|
||||
{
|
||||
g_iIndices = _countof(indicesCube);
|
||||
g_iIndices = static_cast<UINT>(std::size(indicesCube));
|
||||
InitData.pSysMem = indicesCube;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_iIndices = _countof(indices);
|
||||
g_iIndices = static_cast<UINT>(std::size(indices));
|
||||
InitData.pSysMem = indices;
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <assert.h>
|
||||
#include <DirectXMath.h>
|
||||
#include <DirectXPackedVector.h>
|
||||
|
||||
|
@ -1660,12 +1660,12 @@ void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const noexcept
|
||||
|
||||
if (ms_aModeToInfo[uMode] >= 0)
|
||||
{
|
||||
assert(static_cast<unsigned int>(ms_aModeToInfo[uMode]) < _countof(ms_aInfo));
|
||||
_Analysis_assume_(ms_aModeToInfo[uMode] < _countof(ms_aInfo));
|
||||
assert(static_cast<unsigned int>(ms_aModeToInfo[uMode]) < std::size(ms_aInfo));
|
||||
_Analysis_assume_(ms_aModeToInfo[uMode] < std::size(ms_aInfo));
|
||||
const ModeDescriptor* desc = ms_aDesc[ms_aModeToInfo[uMode]];
|
||||
|
||||
assert(static_cast<unsigned int>(ms_aModeToInfo[uMode]) < _countof(ms_aDesc));
|
||||
_Analysis_assume_(ms_aModeToInfo[uMode] < _countof(ms_aDesc));
|
||||
assert(static_cast<unsigned int>(ms_aModeToInfo[uMode]) < std::size(ms_aDesc));
|
||||
_Analysis_assume_(ms_aModeToInfo[uMode] < std::size(ms_aDesc));
|
||||
const ModeInfo& info = ms_aInfo[ms_aModeToInfo[uMode]];
|
||||
|
||||
INTEndPntPair aEndPts[BC6H_MAX_REGIONS] = {};
|
||||
@ -1811,7 +1811,7 @@ void D3DX_BC6H::Encode(bool bSigned, const HDRColorA* const pIn) noexcept
|
||||
|
||||
EncodeParams EP(pIn, bSigned);
|
||||
|
||||
for (EP.uMode = 0; EP.uMode < ARRAYSIZE(ms_aInfo) && EP.fBestErr > 0; ++EP.uMode)
|
||||
for (EP.uMode = 0; EP.uMode < std::size(ms_aInfo) && EP.fBestErr > 0; ++EP.uMode)
|
||||
{
|
||||
const uint8_t uShapes = ms_aInfo[EP.uMode].uPartitions ? 32u : 1u;
|
||||
// Number of rough cases to look at. reasonable values of this are 1, uShapes/4, and uShapes
|
||||
|
@ -2988,9 +2988,9 @@ uint32_t DirectX::_GetConvertFlags(DXGI_FORMAT format) noexcept
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
// Ensure conversion table is in ascending order
|
||||
assert(_countof(g_ConvertTable) > 0);
|
||||
assert(std::size(g_ConvertTable) > 0);
|
||||
DXGI_FORMAT lastvalue = g_ConvertTable[0].format;
|
||||
for (size_t index = 1; index < _countof(g_ConvertTable); ++index)
|
||||
for (size_t index = 1; index < std::size(g_ConvertTable); ++index)
|
||||
{
|
||||
assert(g_ConvertTable[index].format > lastvalue);
|
||||
lastvalue = g_ConvertTable[index].format;
|
||||
@ -2998,7 +2998,7 @@ uint32_t DirectX::_GetConvertFlags(DXGI_FORMAT format) noexcept
|
||||
#endif
|
||||
|
||||
ConvertData key = { format, 0, 0 };
|
||||
auto in = reinterpret_cast<const ConvertData*>(bsearch_s(&key, g_ConvertTable, _countof(g_ConvertTable), sizeof(ConvertData),
|
||||
auto in = reinterpret_cast<const ConvertData*>(bsearch_s(&key, g_ConvertTable, std::size(g_ConvertTable), sizeof(ConvertData),
|
||||
ConvertCompare, nullptr));
|
||||
return (in) ? in->flags : 0;
|
||||
}
|
||||
@ -3020,9 +3020,9 @@ void DirectX::_ConvertScanline(
|
||||
|
||||
#ifdef _DEBUG
|
||||
// Ensure conversion table is in ascending order
|
||||
assert(_countof(g_ConvertTable) > 0);
|
||||
assert(std::size(g_ConvertTable) > 0);
|
||||
DXGI_FORMAT lastvalue = g_ConvertTable[0].format;
|
||||
for (size_t index = 1; index < _countof(g_ConvertTable); ++index)
|
||||
for (size_t index = 1; index < std::size(g_ConvertTable); ++index)
|
||||
{
|
||||
assert(g_ConvertTable[index].format > lastvalue);
|
||||
lastvalue = g_ConvertTable[index].format;
|
||||
@ -3032,10 +3032,10 @@ void DirectX::_ConvertScanline(
|
||||
// Determine conversion details about source and dest formats
|
||||
ConvertData key = { inFormat, 0, 0 };
|
||||
auto in = reinterpret_cast<const ConvertData*>(
|
||||
bsearch_s(&key, g_ConvertTable, _countof(g_ConvertTable), sizeof(ConvertData), ConvertCompare, nullptr));
|
||||
bsearch_s(&key, g_ConvertTable, std::size(g_ConvertTable), sizeof(ConvertData), ConvertCompare, nullptr));
|
||||
key.format = outFormat;
|
||||
auto out = reinterpret_cast<const ConvertData*>(
|
||||
bsearch_s(&key, g_ConvertTable, _countof(g_ConvertTable), sizeof(ConvertData), ConvertCompare, nullptr));
|
||||
bsearch_s(&key, g_ConvertTable, std::size(g_ConvertTable), sizeof(ConvertData), ConvertCompare, nullptr));
|
||||
if (!in || !out)
|
||||
{
|
||||
assert(false);
|
||||
|
@ -114,6 +114,7 @@
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
|
||||
#include <DirectXPackedVector.h>
|
||||
|
@ -123,7 +123,7 @@ namespace
|
||||
_Use_decl_annotations_
|
||||
DXGI_FORMAT DirectX::_WICToDXGI(const GUID& guid) noexcept
|
||||
{
|
||||
for (size_t i = 0; i < _countof(g_WICFormats); ++i)
|
||||
for (size_t i = 0; i < std::size(g_WICFormats); ++i)
|
||||
{
|
||||
if (memcmp(&g_WICFormats[i].wic, &guid, sizeof(GUID)) == 0)
|
||||
return g_WICFormats[i].format;
|
||||
@ -186,7 +186,7 @@ bool DirectX::_DXGIToWIC(DXGI_FORMAT format, GUID& guid, bool ignoreRGBvsBGR) no
|
||||
#endif
|
||||
|
||||
default:
|
||||
for (size_t i = 0; i < _countof(g_WICFormats); ++i)
|
||||
for (size_t i = 0; i < std::size(g_WICFormats); ++i)
|
||||
{
|
||||
if (g_WICFormats[i].format == format)
|
||||
{
|
||||
@ -205,7 +205,7 @@ TEX_FILTER_FLAGS DirectX::_CheckWICColorSpace(_In_ const GUID& sourceGUID, _In_
|
||||
{
|
||||
TEX_FILTER_FLAGS srgb = TEX_FILTER_DEFAULT;
|
||||
|
||||
for (size_t i = 0; i < _countof(g_WICFormats); ++i)
|
||||
for (size_t i = 0; i < std::size(g_WICFormats); ++i)
|
||||
{
|
||||
if (memcmp(&g_WICFormats[i].wic, &sourceGUID, sizeof(GUID)) == 0)
|
||||
{
|
||||
|
@ -200,7 +200,7 @@ namespace
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t i = 0; i < _countof(g_WICConvert); ++i)
|
||||
for (size_t i = 0; i < std::size(g_WICConvert); ++i)
|
||||
{
|
||||
if (memcmp(&g_WICConvert[i].source, &pixelFormat, sizeof(WICPixelFormatGUID)) == 0)
|
||||
{
|
||||
|
@ -9,8 +9,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <assert.h>
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
|
||||
#include <malloc.h>
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
|
@ -156,7 +156,7 @@ HRESULT LoadAnimatedGif(const wchar_t* szFile, std::vector<std::unique_ptr<Scrat
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
hr = palette->GetColors(_countof(rgbColors), rgbColors, &actualColors);
|
||||
hr = palette->GetColors(static_cast<UINT>(std::size(rgbColors)), rgbColors, &actualColors);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
}
|
||||
|
@ -564,7 +564,7 @@ namespace
|
||||
wchar_t version[32] = {};
|
||||
|
||||
wchar_t appName[_MAX_PATH] = {};
|
||||
if (GetModuleFileNameW(nullptr, appName, _countof(appName)))
|
||||
if (GetModuleFileNameW(nullptr, appName, static_cast<DWORD>(std::size(appName))))
|
||||
{
|
||||
DWORD size = GetFileVersionInfoSizeW(appName, nullptr);
|
||||
if (size > 0)
|
||||
|
@ -701,7 +701,7 @@ namespace
|
||||
wchar_t version[32] = {};
|
||||
|
||||
wchar_t appName[_MAX_PATH] = {};
|
||||
if (GetModuleFileNameW(nullptr, appName, _countof(appName)))
|
||||
if (GetModuleFileNameW(nullptr, appName, static_cast<UINT>(std::size(appName))))
|
||||
{
|
||||
DWORD size = GetFileVersionInfoSizeW(appName, nullptr);
|
||||
if (size > 0)
|
||||
@ -919,7 +919,7 @@ namespace
|
||||
D3D_FEATURE_LEVEL fl;
|
||||
HRESULT hr = s_DynamicD3D11CreateDevice(pAdapter.Get(),
|
||||
(pAdapter) ? D3D_DRIVER_TYPE_UNKNOWN : D3D_DRIVER_TYPE_HARDWARE,
|
||||
nullptr, createDeviceFlags, featureLevels, _countof(featureLevels),
|
||||
nullptr, createDeviceFlags, featureLevels, static_cast<UINT>(std::size(featureLevels)),
|
||||
D3D11_SDK_VERSION, pDevice, &fl, nullptr);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
|
@ -525,7 +525,7 @@ namespace
|
||||
wchar_t version[32] = {};
|
||||
|
||||
wchar_t appName[_MAX_PATH] = {};
|
||||
if (GetModuleFileNameW(nullptr, appName, _countof(appName)))
|
||||
if (GetModuleFileNameW(nullptr, appName, static_cast<DWORD>(std::size(appName))))
|
||||
{
|
||||
DWORD size = GetFileVersionInfoSizeW(appName, nullptr);
|
||||
if (size > 0)
|
||||
|
@ -230,7 +230,7 @@ namespace
|
||||
//---------------------------------------------------------------------------------
|
||||
DXGI_FORMAT _WICToDXGI(const GUID& guid) noexcept
|
||||
{
|
||||
for (size_t i = 0; i < _countof(g_WICFormats); ++i)
|
||||
for (size_t i = 0; i < std::size(g_WICFormats); ++i)
|
||||
{
|
||||
if (memcmp(&g_WICFormats[i].wic, &guid, sizeof(GUID)) == 0)
|
||||
return g_WICFormats[i].format;
|
||||
@ -465,7 +465,7 @@ namespace
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t i = 0; i < _countof(g_WICConvert); ++i)
|
||||
for (size_t i = 0; i < std::size(g_WICConvert); ++i)
|
||||
{
|
||||
if (memcmp(&g_WICConvert[i].source, &pixelFormat, sizeof(WICPixelFormatGUID)) == 0)
|
||||
{
|
||||
|
@ -247,7 +247,7 @@ namespace
|
||||
//---------------------------------------------------------------------------------
|
||||
DXGI_FORMAT _WICToDXGI(const GUID& guid) noexcept
|
||||
{
|
||||
for (size_t i = 0; i < _countof(g_WICFormats); ++i)
|
||||
for (size_t i = 0; i < std::size(g_WICFormats); ++i)
|
||||
{
|
||||
if (memcmp(&g_WICFormats[i].wic, &guid, sizeof(GUID)) == 0)
|
||||
return g_WICFormats[i].format;
|
||||
@ -393,7 +393,7 @@ namespace
|
||||
DXGI_FORMAT format = _WICToDXGI(pixelFormat);
|
||||
if (format == DXGI_FORMAT_UNKNOWN)
|
||||
{
|
||||
for (size_t i = 0; i < _countof(g_WICConvert); ++i)
|
||||
for (size_t i = 0; i < std::size(g_WICConvert); ++i)
|
||||
{
|
||||
if (memcmp(&g_WICConvert[i].source, &pixelFormat, sizeof(WICPixelFormatGUID)) == 0)
|
||||
{
|
||||
|
@ -214,7 +214,7 @@ namespace
|
||||
//---------------------------------------------------------------------------------
|
||||
D3DFORMAT _WICToD3D9(const GUID& guid) noexcept
|
||||
{
|
||||
for (size_t i = 0; i < _countof(g_WICFormats); ++i)
|
||||
for (size_t i = 0; i < std::size(g_WICFormats); ++i)
|
||||
{
|
||||
if (memcmp(&g_WICFormats[i].wic, &guid, sizeof(GUID)) == 0)
|
||||
return g_WICFormats[i].format;
|
||||
@ -331,7 +331,7 @@ namespace
|
||||
D3DFORMAT format = _WICToD3D9(pixelFormat);
|
||||
if (format == D3DFMT_UNKNOWN)
|
||||
{
|
||||
for (size_t i = 0; i < _countof(g_WICConvert); ++i)
|
||||
for (size_t i = 0; i < std::size(g_WICConvert); ++i)
|
||||
{
|
||||
if (memcmp(&g_WICConvert[i].source, &pixelFormat, sizeof(WICPixelFormatGUID)) == 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user