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 ...@@ -1167,7 +1167,7 @@ __eglMustCastToProperFunctionPointerType __stdcall eglGetProcAddress(const char
{"", NULL}, {"", 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) if (strcmp(procname, eglExtensions[ext].name) == 0)
{ {
......
...@@ -6942,7 +6942,7 @@ __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char * ...@@ -6942,7 +6942,7 @@ __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *
{"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES}, {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
{"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, }; {"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) if (strcmp(procname, glExtensions[ext].name) == 0)
{ {
......
...@@ -47,7 +47,7 @@ bool Renderer::initializeCompiler() ...@@ -47,7 +47,7 @@ bool Renderer::initializeCompiler()
// Find a D3DCompiler module that had already been loaded based on a predefined list of versions. // Find a D3DCompiler module that had already been loaded based on a predefined list of versions.
static TCHAR* d3dCompilerNames[] = ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES; 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)) if (GetModuleHandleEx(0, d3dCompilerNames[i], &mD3dCompilerModule))
{ {
...@@ -118,9 +118,8 @@ ShaderBlob *Renderer::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, co ...@@ -118,9 +118,8 @@ ShaderBlob *Renderer::compileToBinary(gl::InfoLog &infoLog, const char *hlsl, co
"prefer flow control" "prefer flow control"
}; };
int attempts = (alternateFlags ? sizeof(extraFlags) / sizeof(UINT) : 1); int attempts = alternateFlags ? ArraySize(extraFlags) : 1;
pD3DCompile compileFunc = reinterpret_cast<pD3DCompile>(mD3DCompileFunc); pD3DCompile compileFunc = reinterpret_cast<pD3DCompile>(mD3DCompileFunc);
for (int i = 0; i < attempts; ++i) for (int i = 0; i < attempts; ++i)
{ {
ID3DBlob *errorMessage = NULL; ID3DBlob *errorMessage = NULL;
......
...@@ -144,7 +144,7 @@ EGLint Renderer11::initialize() ...@@ -144,7 +144,7 @@ EGLint Renderer11::initialize()
return EGL_NOT_INITIALIZED; return EGL_NOT_INITIALIZED;
} }
D3D_FEATURE_LEVEL featureLevel[] = D3D_FEATURE_LEVEL featureLevels[] =
{ {
D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_1,
...@@ -159,8 +159,8 @@ EGLint Renderer11::initialize() ...@@ -159,8 +159,8 @@ EGLint Renderer11::initialize()
#else #else
0, 0,
#endif #endif
featureLevel, featureLevels,
sizeof(featureLevel)/sizeof(featureLevel[0]), ArraySize(featureLevels),
D3D11_SDK_VERSION, D3D11_SDK_VERSION,
&mDevice, &mDevice,
&mFeatureLevel, &mFeatureLevel,
...@@ -204,8 +204,8 @@ EGLint Renderer11::initialize() ...@@ -204,8 +204,8 @@ EGLint Renderer11::initialize()
} }
unsigned int maxSupportedSamples = 0; unsigned int maxSupportedSamples = 0;
unsigned int rtFormatCount = sizeof(RenderTargetFormats) / sizeof(DXGI_FORMAT); unsigned int rtFormatCount = ArraySize(RenderTargetFormats);
unsigned int dsFormatCount = sizeof(DepthStencilFormats) / sizeof(DXGI_FORMAT); unsigned int dsFormatCount = ArraySize(DepthStencilFormats);
for (unsigned int i = 0; i < rtFormatCount + dsFormatCount; ++i) for (unsigned int i = 0; i < rtFormatCount + dsFormatCount; ++i)
{ {
DXGI_FORMAT format = (i < rtFormatCount) ? RenderTargetFormats[i] : DepthStencilFormats[i - rtFormatCount]; DXGI_FORMAT format = (i < rtFormatCount) ? RenderTargetFormats[i] : DepthStencilFormats[i - rtFormatCount];
...@@ -359,8 +359,8 @@ void Renderer11::initializeDevice() ...@@ -359,8 +359,8 @@ void Renderer11::initializeDevice()
int Renderer11::generateConfigs(ConfigDesc **configDescList) int Renderer11::generateConfigs(ConfigDesc **configDescList)
{ {
unsigned int numRenderFormats = sizeof(RenderTargetFormats) / sizeof(RenderTargetFormats[0]); unsigned int numRenderFormats = ArraySize(RenderTargetFormats);
unsigned int numDepthFormats = sizeof(DepthStencilFormats) / sizeof(DepthStencilFormats[0]); unsigned int numDepthFormats = ArraySize(DepthStencilFormats);
(*configDescList) = new ConfigDesc[numRenderFormats * numDepthFormats]; (*configDescList) = new ConfigDesc[numRenderFormats * numDepthFormats];
int numConfigs = 0; int numConfigs = 0;
...@@ -1877,7 +1877,7 @@ bool Renderer11::testDeviceResettable() ...@@ -1877,7 +1877,7 @@ bool Renderer11::testDeviceResettable()
return false; return false;
} }
D3D_FEATURE_LEVEL featureLevel[] = D3D_FEATURE_LEVEL featureLevels[] =
{ {
D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_1,
...@@ -1896,8 +1896,8 @@ bool Renderer11::testDeviceResettable() ...@@ -1896,8 +1896,8 @@ bool Renderer11::testDeviceResettable()
#else #else
0, 0,
#endif #endif
featureLevel, featureLevels,
sizeof(featureLevel)/sizeof(featureLevel[0]), ArraySize(featureLevels),
D3D11_SDK_VERSION, D3D11_SDK_VERSION,
&dummyDevice, &dummyDevice,
&dummyFeatureLevel, &dummyFeatureLevel,
......
...@@ -305,7 +305,7 @@ EGLint Renderer9::initialize() ...@@ -305,7 +305,7 @@ EGLint Renderer9::initialize()
} }
int max = 0; 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]; bool *multisampleArray = new bool[D3DMULTISAMPLE_16_SAMPLES + 1];
getMultiSampleSupport(RenderTargetFormats[i], multisampleArray); getMultiSampleSupport(RenderTargetFormats[i], multisampleArray);
...@@ -320,7 +320,7 @@ EGLint Renderer9::initialize() ...@@ -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) if (DepthStencilFormats[i] == D3DFMT_UNKNOWN)
continue; continue;
...@@ -532,8 +532,8 @@ int Renderer9::generateConfigs(ConfigDesc **configDescList) ...@@ -532,8 +532,8 @@ int Renderer9::generateConfigs(ConfigDesc **configDescList)
D3DDISPLAYMODE currentDisplayMode; D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode); mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
unsigned int numRenderFormats = sizeof(RenderTargetFormats) / sizeof(RenderTargetFormats[0]); unsigned int numRenderFormats = ArraySize(RenderTargetFormats);
unsigned int numDepthFormats = sizeof(DepthStencilFormats) / sizeof(DepthStencilFormats[0]); unsigned int numDepthFormats = ArraySize(DepthStencilFormats);
(*configDescList) = new ConfigDesc[numRenderFormats * numDepthFormats]; (*configDescList) = new ConfigDesc[numRenderFormats * numDepthFormats];
int numConfigs = 0; 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