Use ArraySize to determine size of static arrays.

TRAC #22558 Signed-off-by: Nicolas Capens Signed-off-by: Shannon Woods Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1943 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent e1602ae7
......@@ -1167,7 +1167,7 @@ __eglMustCastToProperFunctionPointerType __stdcall eglGetProcAddress(const char
{"", NULL},
};
for (int ext = 0; ext < sizeof(eglExtensions) / sizeof(Extension); ext++)
for (unsigned int ext = 0; ext < ArraySize(eglExtensions); ext++)
{
if (strcmp(procname, eglExtensions[ext].name) == 0)
{
......
......@@ -6942,7 +6942,7 @@ __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *
{"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
{"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, };
for (int ext = 0; ext < sizeof(glExtensions) / sizeof(Extension); ext++)
for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
{
if (strcmp(procname, glExtensions[ext].name) == 0)
{
......
......@@ -47,7 +47,7 @@ bool Renderer::initializeCompiler()
// Find a D3DCompiler module that had already been loaded based on a predefined list of versions.
static TCHAR* d3dCompilerNames[] = ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES;
for (int i = 0; i < sizeof(d3dCompilerNames) / sizeof(*d3dCompilerNames); ++i)
for (int i = 0; i < ArraySize(d3dCompilerNames); ++i)
{
if (GetModuleHandleEx(0, d3dCompilerNames[i], &mD3dCompilerModule))
{
......@@ -118,9 +118,8 @@ ShaderBlob *Renderer::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, co
"prefer flow control"
};
int attempts = (alternateFlags ? sizeof(extraFlags) / sizeof(UINT) : 1);
int attempts = alternateFlags ? ArraySize(extraFlags) : 1;
pD3DCompile compileFunc = reinterpret_cast<pD3DCompile>(mD3DCompileFunc);
for (int i = 0; i < attempts; ++i)
{
ID3DBlob *errorMessage = NULL;
......
......@@ -144,7 +144,7 @@ EGLint Renderer11::initialize()
return EGL_NOT_INITIALIZED;
}
D3D_FEATURE_LEVEL featureLevel[] =
D3D_FEATURE_LEVEL featureLevels[] =
{
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
......@@ -159,8 +159,8 @@ EGLint Renderer11::initialize()
#else
0,
#endif
featureLevel,
sizeof(featureLevel)/sizeof(featureLevel[0]),
featureLevels,
ArraySize(featureLevels),
D3D11_SDK_VERSION,
&mDevice,
&mFeatureLevel,
......@@ -204,8 +204,8 @@ EGLint Renderer11::initialize()
}
unsigned int maxSupportedSamples = 0;
unsigned int rtFormatCount = sizeof(RenderTargetFormats) / sizeof(DXGI_FORMAT);
unsigned int dsFormatCount = sizeof(DepthStencilFormats) / sizeof(DXGI_FORMAT);
unsigned int rtFormatCount = ArraySize(RenderTargetFormats);
unsigned int dsFormatCount = ArraySize(DepthStencilFormats);
for (unsigned int i = 0; i < rtFormatCount + dsFormatCount; ++i)
{
DXGI_FORMAT format = (i < rtFormatCount) ? RenderTargetFormats[i] : DepthStencilFormats[i - rtFormatCount];
......@@ -359,8 +359,8 @@ void Renderer11::initializeDevice()
int Renderer11::generateConfigs(ConfigDesc **configDescList)
{
unsigned int numRenderFormats = sizeof(RenderTargetFormats) / sizeof(RenderTargetFormats[0]);
unsigned int numDepthFormats = sizeof(DepthStencilFormats) / sizeof(DepthStencilFormats[0]);
unsigned int numRenderFormats = ArraySize(RenderTargetFormats);
unsigned int numDepthFormats = ArraySize(DepthStencilFormats);
(*configDescList) = new ConfigDesc[numRenderFormats * numDepthFormats];
int numConfigs = 0;
......@@ -1877,7 +1877,7 @@ bool Renderer11::testDeviceResettable()
return false;
}
D3D_FEATURE_LEVEL featureLevel[] =
D3D_FEATURE_LEVEL featureLevels[] =
{
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
......@@ -1896,8 +1896,8 @@ bool Renderer11::testDeviceResettable()
#else
0,
#endif
featureLevel,
sizeof(featureLevel)/sizeof(featureLevel[0]),
featureLevels,
ArraySize(featureLevels),
D3D11_SDK_VERSION,
&dummyDevice,
&dummyFeatureLevel,
......
......@@ -305,7 +305,7 @@ EGLint Renderer9::initialize()
}
int max = 0;
for (int i = 0; i < sizeof(RenderTargetFormats) / sizeof(D3DFORMAT); ++i)
for (unsigned int i = 0; i < ArraySize(RenderTargetFormats); ++i)
{
bool *multisampleArray = new bool[D3DMULTISAMPLE_16_SAMPLES + 1];
getMultiSampleSupport(RenderTargetFormats[i], multisampleArray);
......@@ -320,7 +320,7 @@ EGLint Renderer9::initialize()
}
}
for (int i = 0; i < sizeof(DepthStencilFormats) / sizeof(D3DFORMAT); ++i)
for (unsigned int i = 0; i < ArraySize(DepthStencilFormats); ++i)
{
if (DepthStencilFormats[i] == D3DFMT_UNKNOWN)
continue;
......@@ -532,8 +532,8 @@ int Renderer9::generateConfigs(ConfigDesc **configDescList)
D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
unsigned int numRenderFormats = sizeof(RenderTargetFormats) / sizeof(RenderTargetFormats[0]);
unsigned int numDepthFormats = sizeof(DepthStencilFormats) / sizeof(DepthStencilFormats[0]);
unsigned int numRenderFormats = ArraySize(RenderTargetFormats);
unsigned int numDepthFormats = ArraySize(DepthStencilFormats);
(*configDescList) = new ConfigDesc[numRenderFormats * numDepthFormats];
int numConfigs = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment