From 12184e87debf48d3a6c7eb8f61df882dd41de393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Thu, 2 Apr 2015 23:31:28 -0700 Subject: [PATCH] Fixed variable shadowing warnings. --- tools/shaderc/shaderc.cpp | 30 +++++++++++-------------- tools/shaderc/shaderc_dx11.cpp | 8 +++---- tools/shaderc/shaderc_glsl.cpp | 40 +++++++++++++++++----------------- 3 files changed, 37 insertions(+), 41 deletions(-) diff --git a/tools/shaderc/shaderc.cpp b/tools/shaderc/shaderc.cpp index f25a0382..93f4fe1f 100644 --- a/tools/shaderc/shaderc.cpp +++ b/tools/shaderc/shaderc.cpp @@ -952,22 +952,22 @@ int main(int _argc, const char* _argv[]) { const char* precision = NULL; const char* interpolation = NULL; - const char* type = parse; + const char* typen = parse; - if (0 == strncmp(type, "lowp", 4) - || 0 == strncmp(type, "mediump", 7) - || 0 == strncmp(type, "highp", 5) ) + if (0 == strncmp(typen, "lowp", 4) + || 0 == strncmp(typen, "mediump", 7) + || 0 == strncmp(typen, "highp", 5) ) { - precision = type; - type = parse = bx::strws(bx::strword(parse) ); + precision = typen; + typen = parse = bx::strws(bx::strword(parse) ); } - if (0 == strncmp(type, "flat", 4) - || 0 == strncmp(type, "smooth", 6) - || 0 == strncmp(type, "noperspective", 13) ) + if (0 == strncmp(typen, "flat", 4) + || 0 == strncmp(typen, "smooth", 6) + || 0 == strncmp(typen, "noperspective", 13) ) { - interpolation = type; - type = parse = bx::strws(bx::strword(parse) ); + interpolation = typen; + typen = parse = bx::strws(bx::strword(parse) ); } const char* name = parse = bx::strws(bx::strword(parse) ); @@ -976,7 +976,7 @@ int main(int _argc, const char* _argv[]) const char* assign = parse = bx::strws(bx::strword(parse) ); const char* init = parse = bx::strws((*parse == '=' ? ++parse : parse)); - if (type < eol + if (typen < eol && name < eol && column < eol && ':' == *column @@ -993,7 +993,7 @@ int main(int _argc, const char* _argv[]) var.m_interpolation.assign(interpolation, bx::strword(interpolation)-interpolation); } - var.m_type.assign(type, bx::strword(type)-type); + var.m_type.assign(typen, bx::strword(typen)-typen); var.m_name.assign(name, bx::strword(name)-name); var.m_semantics.assign(semantics, bx::strword(semantics)-semantics); @@ -1101,9 +1101,6 @@ int main(int _argc, const char* _argv[]) return EXIT_FAILURE; } - uint32_t inputHash = 0; - uint32_t outputHash = 0; - if ('f' == shaderType) { bx::write(writer, BGFX_CHUNK_MAGIC_FSH); @@ -1653,7 +1650,6 @@ int main(int _argc, const char* _argv[]) if (0 != glsl) { - const char* profile = cmdLine.findOption('p', "profile"); if (NULL == profile) { writef(&writer diff --git a/tools/shaderc/shaderc_dx11.cpp b/tools/shaderc/shaderc_dx11.cpp index e1f0d90e..23075800 100644 --- a/tools/shaderc/shaderc_dx11.cpp +++ b/tools/shaderc/shaderc_dx11.cpp @@ -297,14 +297,14 @@ bool compileHLSLShaderDx11(bx::CommandLine& _cmdLine, const std::string& _code, hr = type->GetDesc(&constDesc); if (SUCCEEDED(hr) ) { - UniformType::Enum type = findUniformTypeDx11(constDesc); + UniformType::Enum uniformType = findUniformTypeDx11(constDesc); - if (UniformType::Count != type + if (UniformType::Count != uniformType && 0 != (varDesc.uFlags & D3D_SVF_USED) ) { Uniform un; un.name = varDesc.Name; - un.type = type; + un.type = uniformType; un.num = constDesc.Elements; un.regIndex = varDesc.StartOffset; un.regCount = BX_ALIGN_16(varDesc.Size)/16; @@ -315,7 +315,7 @@ bool compileHLSLShaderDx11(bx::CommandLine& _cmdLine, const std::string& _code, , varDesc.StartOffset , varDesc.Size , varDesc.uFlags - , type + , uniformType ); } else diff --git a/tools/shaderc/shaderc_glsl.cpp b/tools/shaderc/shaderc_glsl.cpp index 57fa39af..f0e5cec8 100644 --- a/tools/shaderc/shaderc_glsl.cpp +++ b/tools/shaderc/shaderc_glsl.cpp @@ -65,18 +65,18 @@ bool compileGLSLShader(bx::CommandLine& _cmdLine, uint32_t _gles, const std::str if (0 != _gles) { - char* shader = const_cast(optimizedShader); - strreplace(shader, "gl_FragDepthEXT", "gl_FragDepth"); + char* code = const_cast(optimizedShader); + strreplace(code, "gl_FragDepthEXT", "gl_FragDepth"); - strreplace(shader, "texture2DLodEXT", "texture2DLod"); - strreplace(shader, "texture2DProjLodEXT", "texture2DProjLod"); - strreplace(shader, "textureCubeLodEXT", "textureCubeLod"); - strreplace(shader, "texture2DGradEXT", "texture2DGrad"); - strreplace(shader, "texture2DProjGradEXT", "texture2DProjGrad"); - strreplace(shader, "textureCubeGradEXT", "textureCubeGrad"); + strreplace(code, "texture2DLodEXT", "texture2DLod"); + strreplace(code, "texture2DProjLodEXT", "texture2DProjLod"); + strreplace(code, "textureCubeLodEXT", "textureCubeLod"); + strreplace(code, "texture2DGradEXT", "texture2DGrad"); + strreplace(code, "texture2DProjGradEXT", "texture2DProjGrad"); + strreplace(code, "textureCubeGradEXT", "textureCubeGrad"); - strreplace(shader, "shadow2DEXT", "shadow2D"); - strreplace(shader, "shadow2DProjEXT", "shadow2DProj"); + strreplace(code, "shadow2DEXT", "shadow2D"); + strreplace(code, "shadow2DProjEXT", "shadow2DProj"); } UniformArray uniforms; @@ -110,14 +110,14 @@ bool compileGLSLShader(bx::CommandLine& _cmdLine, uint32_t _gles, const std::str } const char* precision = NULL; - const char* type = parse; + const char* typen = parse; - if (0 == strncmp(type, "lowp", 4) - || 0 == strncmp(type, "mediump", 7) - || 0 == strncmp(type, "highp", 5) ) + if (0 == strncmp(typen, "lowp", 4) + || 0 == strncmp(typen, "mediump", 7) + || 0 == strncmp(typen, "highp", 5) ) { - precision = type; - type = parse = bx::strws(bx::strword(parse) ); + precision = typen; + typen = parse = bx::strws(bx::strword(parse) ); } BX_UNUSED(precision); @@ -125,13 +125,13 @@ bool compileGLSLShader(bx::CommandLine& _cmdLine, uint32_t _gles, const std::str char uniformType[256]; parse = bx::strword(parse); - if (0 == strncmp(type, "sampler", 7) ) + if (0 == strncmp(typen, "sampler", 7) ) { strcpy(uniformType, "int"); } else { - bx::strlcpy(uniformType, type, parse-type+1); + bx::strlcpy(uniformType, typen, parse-typen+1); } const char* name = parse = bx::strws(parse); @@ -181,8 +181,8 @@ bool compileGLSLShader(bx::CommandLine& _cmdLine, uint32_t _gles, const std::str uint8_t nameSize = (uint8_t)un.name.size(); bx::write(_writer, nameSize); bx::write(_writer, un.name.c_str(), nameSize); - uint8_t type = un.type; - bx::write(_writer, type); + uint8_t uniformType = un.type; + bx::write(_writer, uniformType); bx::write(_writer, un.num); bx::write(_writer, un.regIndex); bx::write(_writer, un.regCount);