Commit 3ae6465f by Austin Kinross Committed by Geoff Lang

Fix lots of variable shadowing in ANGLE

BUG=angle:877 Change-Id: I3df0fffb19f5ecbe439fbc2a8d6d239a5dc6b638 Reviewed-on: https://chromium-review.googlesource.com/243334Tested-by: 's avatarAustin Kinross <aukinros@microsoft.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 1be8870b
......@@ -423,25 +423,25 @@ void TCompiler::clearResults()
nameMap.clear();
}
bool TCompiler::detectCallDepth(TIntermNode* root, TInfoSink& infoSink, bool limitCallStackDepth)
bool TCompiler::detectCallDepth(TIntermNode* inputRoot, TInfoSink& inputInfoSink, bool limitCallStackDepth)
{
DetectCallDepth detect(infoSink, limitCallStackDepth, maxCallStackDepth);
root->traverse(&detect);
DetectCallDepth detect(inputInfoSink, limitCallStackDepth, maxCallStackDepth);
inputRoot->traverse(&detect);
switch (detect.detectCallDepth())
{
case DetectCallDepth::kErrorNone:
return true;
case DetectCallDepth::kErrorMissingMain:
infoSink.info.prefix(EPrefixError);
infoSink.info << "Missing main()";
inputInfoSink.info.prefix(EPrefixError);
inputInfoSink.info << "Missing main()";
return false;
case DetectCallDepth::kErrorRecursion:
infoSink.info.prefix(EPrefixError);
infoSink.info << "Function recursion detected";
inputInfoSink.info.prefix(EPrefixError);
inputInfoSink.info << "Function recursion detected";
return false;
case DetectCallDepth::kErrorMaxDepthExceeded:
infoSink.info.prefix(EPrefixError);
infoSink.info << "Function call stack too deep";
inputInfoSink.info.prefix(EPrefixError);
inputInfoSink.info << "Function call stack too deep";
return false;
default:
UNREACHABLE();
......
......@@ -33,7 +33,7 @@ int DetectCallDepth::FunctionNode::detectCallDepth(DetectCallDepth* detectCallDe
ASSERT(visit == PreVisit);
ASSERT(detectCallDepth);
int maxDepth = depth;
int retMaxDepth = depth;
visit = InVisit;
for (size_t i = 0; i < callees.size(); ++i) {
switch (callees[i]->visit) {
......@@ -52,7 +52,7 @@ int DetectCallDepth::FunctionNode::detectCallDepth(DetectCallDepth* detectCallDe
detectCallDepth->getInfoSink().info << "<-" << callees[i]->getName();
return callDepth;
}
maxDepth = std::max(callDepth, maxDepth);
retMaxDepth = std::max(callDepth, retMaxDepth);
break;
}
default:
......@@ -61,7 +61,7 @@ int DetectCallDepth::FunctionNode::detectCallDepth(DetectCallDepth* detectCallDe
}
}
visit = PostVisit;
return maxDepth;
return retMaxDepth;
}
void DetectCallDepth::FunctionNode::reset()
......
......@@ -651,11 +651,11 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node)
for (TIntermSequence::const_iterator iter = node->getSequence()->begin();
iter != node->getSequence()->end(); ++iter)
{
TIntermNode *node = *iter;
ASSERT(node != NULL);
node->traverse(this);
TIntermNode *curNode = *iter;
ASSERT(curNode != NULL);
curNode->traverse(this);
if (isSingleStatement(node))
if (isSingleStatement(curNode))
out << ";\n";
}
decrementDepth();
......
......@@ -1077,14 +1077,14 @@ const TVariable *TParseContext::getNamedVariable(const TSourceLoc &location,
//
// Return the function symbol if found, otherwise 0.
//
const TFunction* TParseContext::findFunction(const TSourceLoc& line, TFunction* call, int shaderVersion, bool *builtIn)
const TFunction* TParseContext::findFunction(const TSourceLoc& line, TFunction* call, int inputShaderVersion, bool *builtIn)
{
// First find by unmangled name to check whether the function name has been
// hidden by a variable name or struct typename.
// If a function is found, check for one with a matching argument list.
const TSymbol* symbol = symbolTable.find(call->getName(), shaderVersion, builtIn);
const TSymbol* symbol = symbolTable.find(call->getName(), inputShaderVersion, builtIn);
if (symbol == 0 || symbol->isFunction()) {
symbol = symbolTable.find(call->getMangledName(), shaderVersion, builtIn);
symbol = symbolTable.find(call->getMangledName(), inputShaderVersion, builtIn);
}
if (symbol == 0) {
......
......@@ -120,7 +120,7 @@ struct TParseContext {
bool containsSampler(TType& type);
bool areAllChildConst(TIntermAggregate* aggrNode);
const TFunction* findFunction(const TSourceLoc& line, TFunction* pfnCall, int shaderVersion, bool *builtIn = 0);
const TFunction* findFunction(const TSourceLoc& line, TFunction* pfnCall, int inputShaderVersion, bool *builtIn = 0);
bool executeInitializer(const TSourceLoc& line, const TString& identifier, TPublicType& pType,
TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0);
......
......@@ -49,7 +49,7 @@ void TAliveTraverser::visitSymbol(TIntermSymbol* node)
found = true;
}
bool TAliveTraverser::visitSelection(Visit preVisit, TIntermSelection* node)
bool TAliveTraverser::visitSelection(Visit, TIntermSelection*)
{
if (wasFound())
return false;
......
......@@ -86,7 +86,6 @@ bool ShaderVariable::findInfoByMappedName(
// 2) the top variable is an array;
// 3) otherwise.
size_t pos = mappedFullName.find_first_of(".[");
std::string topName;
if (pos == std::string::npos)
{
......
......@@ -274,9 +274,9 @@ void StructureHLSL::addConstructor(const TType &type, const TString &name, const
for (unsigned int parameter = 0; parameter < ctorParameters.size(); parameter++)
{
const TType &type = ctorParameters[parameter];
const TType &paramType = ctorParameters[parameter];
constructor += TypeString(type) + " x" + str(parameter) + ArrayString(type);
constructor += TypeString(paramType) + " x" + str(parameter) + ArrayString(paramType);
if (parameter < ctorParameters.size() - 1)
{
......
......@@ -46,9 +46,9 @@ void TranslatorESSL::translate(TIntermNode* root) {
void TranslatorESSL::writeExtensionBehavior() {
TInfoSinkBase& sink = getInfoSink().obj;
const TExtensionBehavior& extensionBehavior = getExtensionBehavior();
for (TExtensionBehavior::const_iterator iter = extensionBehavior.begin();
iter != extensionBehavior.end(); ++iter) {
const TExtensionBehavior& extBehavior = getExtensionBehavior();
for (TExtensionBehavior::const_iterator iter = extBehavior.begin();
iter != extBehavior.end(); ++iter) {
if (iter->second != EBhUndefined) {
if (getResources().NV_shader_framebuffer_fetch && iter->first == "GL_EXT_shader_framebuffer_fetch") {
sink << "#extension GL_NV_shader_framebuffer_fetch : "
......
......@@ -64,9 +64,9 @@ void TranslatorGLSL::writeVersion(TIntermNode *root)
void TranslatorGLSL::writeExtensionBehavior() {
TInfoSinkBase& sink = getInfoSink().obj;
const TExtensionBehavior& extensionBehavior = getExtensionBehavior();
for (TExtensionBehavior::const_iterator iter = extensionBehavior.begin();
iter != extensionBehavior.end(); ++iter) {
const TExtensionBehavior& extBehavior = getExtensionBehavior();
for (TExtensionBehavior::const_iterator iter = extBehavior.begin();
iter != extBehavior.end(); ++iter) {
if (iter->second == EBhUndefined)
continue;
......
......@@ -178,11 +178,12 @@ size_t TType::getObjectSize() const
if (isArray())
{
size_t arraySize = getArraySize();
if (arraySize > INT_MAX / totalSize)
// TODO: getArraySize() returns an int, not a size_t
size_t currentArraySize = getArraySize();
if (currentArraySize > INT_MAX / totalSize)
totalSize = INT_MAX;
else
totalSize *= arraySize;
totalSize *= currentArraySize;
}
return totalSize;
......
......@@ -560,18 +560,18 @@ const InternalFormat &GetInternalFormatInfo(GLenum internalFormat)
}
}
GLuint InternalFormat::computeRowPitch(GLenum type, GLsizei width, GLint alignment) const
GLuint InternalFormat::computeRowPitch(GLenum formatType, GLsizei width, GLint alignment) const
{
ASSERT(alignment > 0 && isPow2(alignment));
return rx::roundUp(computeBlockSize(type, width, 1), static_cast<GLuint>(alignment));
return rx::roundUp(computeBlockSize(formatType, width, 1), static_cast<GLuint>(alignment));
}
GLuint InternalFormat::computeDepthPitch(GLenum type, GLsizei width, GLsizei height, GLint alignment) const
GLuint InternalFormat::computeDepthPitch(GLenum formatType, GLsizei width, GLsizei height, GLint alignment) const
{
return computeRowPitch(type, width, alignment) * height;
return computeRowPitch(formatType, width, alignment) * height;
}
GLuint InternalFormat::computeBlockSize(GLenum type, GLsizei width, GLsizei height) const
GLuint InternalFormat::computeBlockSize(GLenum formatType, GLsizei width, GLsizei height) const
{
if (compressed)
{
......@@ -581,7 +581,7 @@ GLuint InternalFormat::computeBlockSize(GLenum type, GLsizei width, GLsizei heig
}
else
{
const Type &typeInfo = GetTypeInfo(type);
const Type &typeInfo = GetTypeInfo(formatType);
if (typeInfo.specialInterpretation)
{
return typeInfo.bytes * width * height;
......
......@@ -64,9 +64,9 @@ struct InternalFormat
SupportCheckFunction renderSupport;
SupportCheckFunction filterSupport;
GLuint computeRowPitch(GLenum type, GLsizei width, GLint alignment) const;
GLuint computeDepthPitch(GLenum type, GLsizei width, GLsizei height, GLint alignment) const;
GLuint computeBlockSize(GLenum type, GLsizei width, GLsizei height) const;
GLuint computeRowPitch(GLenum formatType, GLsizei width, GLint alignment) const;
GLuint computeDepthPitch(GLenum formatType, GLsizei width, GLsizei height, GLint alignment) const;
GLuint computeBlockSize(GLenum formatType, GLsizei width, GLsizei height) const;
};
const InternalFormat &GetInternalFormatInfo(GLenum internalFormat);
......
......@@ -229,9 +229,9 @@ void ShaderD3D::compileToHLSL(ShHandle compiler, const std::string &source)
if (uniform.staticUse)
{
unsigned int index = -1;
bool result = ShGetUniformRegister(compiler, uniform.name, &index);
UNUSED_ASSERTION_VARIABLE(result);
ASSERT(result);
bool getUniformRegisterResult = ShGetUniformRegister(compiler, uniform.name, &index);
UNUSED_ASSERTION_VARIABLE(getUniformRegisterResult);
ASSERT(getUniformRegisterResult);
mUniformRegisterMap[uniform.name] = index;
}
......@@ -246,9 +246,9 @@ void ShaderD3D::compileToHLSL(ShHandle compiler, const std::string &source)
if (interfaceBlock.staticUse)
{
unsigned int index = -1;
bool result = ShGetInterfaceBlockRegister(compiler, interfaceBlock.name, &index);
UNUSED_ASSERTION_VARIABLE(result);
ASSERT(result);
bool blockRegisterResult = ShGetInterfaceBlockRegister(compiler, interfaceBlock.name, &index);
UNUSED_ASSERTION_VARIABLE(blockRegisterResult);
ASSERT(blockRegisterResult);
mInterfaceBlockRegisterMap[interfaceBlock.name] = index;
}
......
......@@ -166,8 +166,6 @@ gl::Error TextureD3D::setImage(const gl::ImageIndex &index, GLenum type, const g
if (pixelData != NULL)
{
gl::Error error(GL_NO_ERROR);
if (shouldUseSetData(image))
{
error = mTexStorage->setData(index, image, NULL, type, unpack, pixelData);
......@@ -210,7 +208,7 @@ gl::Error TextureD3D::subImage(const gl::ImageIndex &index, const gl::Box &area,
return mTexStorage->setData(index, image, &area, type, unpack, pixelData);
}
gl::Error error = image->loadData(area, unpack.alignment, type, pixelData);
error = image->loadData(area, unpack.alignment, type, pixelData);
if (error.isError())
{
return error;
......@@ -245,7 +243,7 @@ gl::Error TextureD3D::setCompressedImage(const gl::ImageIndex &index, const gl::
ASSERT(image);
gl::Box fullImageArea(0, 0, 0, image->getWidth(), image->getHeight(), image->getDepth());
gl::Error error = image->loadCompressedData(fullImageArea, pixelData);
error = image->loadCompressedData(fullImageArea, pixelData);
if (error.isError())
{
return error;
......@@ -272,7 +270,7 @@ gl::Error TextureD3D::subImageCompressed(const gl::ImageIndex &index, const gl::
ImageD3D *image = getImage(index);
ASSERT(image);
gl::Error error = image->loadCompressedData(area, pixelData);
error = image->loadCompressedData(area, pixelData);
if (error.isError())
{
return error;
......@@ -752,7 +750,7 @@ gl::Error TextureD3D_2D::copyImage(GLenum target, size_t level, const gl::Rectan
if (sourceArea.width != 0 && sourceArea.height != 0 && isValidLevel(level))
{
gl::Error error = mRenderer->copyImage2D(source, sourceArea, internalFormat, destOffset, mTexStorage, level);
error = mRenderer->copyImage2D(source, sourceArea, internalFormat, destOffset, mTexStorage, level);
if (error.isError())
{
return error;
......@@ -1682,11 +1680,11 @@ void TextureD3D_Cube::redefineImage(int faceIndex, GLint level, GLenum internalf
size.height != storageHeight ||
internalformat != storageFormat) // Discard mismatched storage
{
for (int level = 0; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
for (int dirtyLevel = 0; dirtyLevel < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; dirtyLevel++)
{
for (int faceIndex = 0; faceIndex < 6; faceIndex++)
for (int dirtyFace = 0; dirtyFace < 6; dirtyFace++)
{
mImageArray[faceIndex][level]->markDirty();
mImageArray[dirtyFace][dirtyLevel]->markDirty();
}
}
......@@ -2811,11 +2809,11 @@ void TextureD3D_2DArray::redefineImage(GLint level, GLenum internalformat, const
size.depth != storageDepth ||
internalformat != storageFormat) // Discard mismatched storage
{
for (int level = 0; level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
for (int dirtyLevel = 0; dirtyLevel < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS; dirtyLevel++)
{
for (int layer = 0; layer < mLayerCounts[level]; layer++)
for (int dirtyLayer = 0; dirtyLayer < mLayerCounts[dirtyLevel]; dirtyLayer++)
{
mImageArray[level][layer]->markDirty();
mImageArray[dirtyLevel][dirtyLayer]->markDirty();
}
}
......
......@@ -305,8 +305,8 @@ gl::Error VertexDataManager::storeAttribute(const gl::VertexAttribute &attrib,
int totalCount = ElementsInBuffer(attrib, storage->getSize());
int startIndex = attrib.offset / ComputeVertexAttributeStride(attrib);
gl::Error error = staticBuffer->storeVertexAttributes(attrib, currentValue, -startIndex, totalCount,
0, &streamOffset);
error = staticBuffer->storeVertexAttributes(attrib, currentValue, -startIndex, totalCount,
0, &streamOffset);
if (error.isError())
{
return error;
......
......@@ -534,13 +534,13 @@ ID3D11BlendState *Clear11::getBlendState(const std::vector<MaskedRenderTarget>&
blendDesc.AlphaToCoverageEnable = FALSE;
blendDesc.IndependentBlendEnable = (rts.size() > 1) ? TRUE : FALSE;
for (unsigned int i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
for (unsigned int j = 0; j < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; j++)
{
blendDesc.RenderTarget[i].BlendEnable = FALSE;
blendDesc.RenderTarget[i].RenderTargetWriteMask = gl_d3d11::ConvertColorMask(blendKey.maskChannels[i][0],
blendKey.maskChannels[i][1],
blendKey.maskChannels[i][2],
blendKey.maskChannels[i][3]);
blendDesc.RenderTarget[j].BlendEnable = FALSE;
blendDesc.RenderTarget[j].RenderTargetWriteMask = gl_d3d11::ConvertColorMask(blendKey.maskChannels[j][0],
blendKey.maskChannels[j][1],
blendKey.maskChannels[j][2],
blendKey.maskChannels[j][3]);
}
ID3D11Device *device = mRenderer->getDevice();
......
......@@ -179,7 +179,7 @@ gl::Error FenceSync11::clientWait(GLbitfield flags, GLuint64 timeout, GLenum *ou
while (currentCounter.QuadPart < endCounter && !result)
{
ScheduleYield();
BOOL success = QueryPerformanceCounter(&currentCounter);
success = QueryPerformanceCounter(&currentCounter);
UNUSED_ASSERTION_VARIABLE(success);
ASSERT(success);
......
......@@ -216,7 +216,6 @@ gl::Error InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl
{
gl::VertexFormat shaderInputLayout[gl::MAX_VERTEX_ATTRIBS];
GetInputLayout(attributes, shaderInputLayout);
ProgramD3D *programD3D = ProgramD3D::makeProgramD3D(program->getImplementation());
ShaderExecutableD3D *shader = NULL;
gl::Error error = programD3D->getVertexExecutableForInputLayout(shaderInputLayout, &shader, nullptr);
......
......@@ -379,8 +379,6 @@ gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, u
}
else
{
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mTextureFormat);
D3D11_BOX srcBox;
srcBox.left = copyArea.x;
srcBox.top = copyArea.y;
......@@ -788,7 +786,6 @@ gl::Error TextureStorage11_2D::copyToStorage(TextureStorage *destStorage)
return error;
}
TextureStorage11 *dest11 = TextureStorage11::makeTextureStorage11(destStorage);
ID3D11Resource *destResource = NULL;
error = dest11->getResource(&destResource);
if (error.isError())
......
......@@ -124,7 +124,7 @@ gl::Error VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &attri
if (buffer)
{
BufferD3D *storage = BufferD3D::makeFromBuffer(buffer);
gl::Error error = storage->getData(&input);
error = storage->getData(&input);
if (error.isError())
{
return error;
......
......@@ -237,8 +237,8 @@ static gl::TextureCaps GenerateTextureFormatCaps(GLenum internalFormat, ID3D11De
UINT formatSupport;
if (SUCCEEDED(device->CheckFormatSupport(formatInfo.texFormat, &formatSupport)))
{
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0)
const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(internalFormat);
if (internalFormatInfo.depthBits > 0 || internalFormatInfo.stencilBits > 0)
{
textureCaps.texturable = ((formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE2D) != 0);
}
......
......@@ -395,7 +395,7 @@ gl::Error Image9::copyToStorage(TextureStorage *storage, const gl::ImageIndex &i
if (index.type == GL_TEXTURE_2D)
{
TextureStorage9_2D *storage9 = TextureStorage9_2D::makeTextureStorage9_2D(storage);
gl::Error error = storage9->getSurfaceLevel(index.mipIndex, true, &destSurface);
error = storage9->getSurfaceLevel(index.mipIndex, true, &destSurface);
if (error.isError())
{
return error;
......@@ -405,7 +405,7 @@ gl::Error Image9::copyToStorage(TextureStorage *storage, const gl::ImageIndex &i
{
ASSERT(gl::IsCubeMapTextureTarget(index.type));
TextureStorage9_Cube *storage9 = TextureStorage9_Cube::makeTextureStorage9_Cube(storage);
gl::Error error = storage9->getCubeMapSurface(index.type, index.mipIndex, true, &destSurface);
error = storage9->getCubeMapSurface(index.type, index.mipIndex, true, &destSurface);
if (error.isError())
{
return error;
......
......@@ -99,7 +99,7 @@ gl::Error VertexBuffer9::storeVertexAttributes(const gl::VertexAttribute &attrib
{
BufferD3D *storage = BufferD3D::makeFromBuffer(buffer);
ASSERT(storage);
gl::Error error = storage->getData(&input);
error = storage->getData(&input);
if (error.isError())
{
return error;
......
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