Browse Source

Fixed variable shadowing warnings.

Branimir Karadžić 10 years ago
parent
commit
12184e87de
3 changed files with 39 additions and 43 deletions
  1. 13 17
      tools/shaderc/shaderc.cpp
  2. 4 4
      tools/shaderc/shaderc_dx11.cpp
  3. 22 22
      tools/shaderc/shaderc_glsl.cpp

+ 13 - 17
tools/shaderc/shaderc.cpp

@@ -952,22 +952,22 @@ int main(int _argc, const char* _argv[])
 			{
 			{
 				const char* precision = NULL;
 				const char* precision = NULL;
 				const char* interpolation = 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) );
 				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* assign    = parse = bx::strws(bx::strword(parse) );
 				const char* init      = parse = bx::strws((*parse == '=' ? ++parse : parse));
 				const char* init      = parse = bx::strws((*parse == '=' ? ++parse : parse));
 
 
-				if (type < eol
+				if (typen < eol
 				&&  name < eol
 				&&  name < eol
 				&&  column < eol
 				&&  column < eol
 				&&  ':' == *column
 				&&  ':' == *column
@@ -993,7 +993,7 @@ int main(int _argc, const char* _argv[])
 						var.m_interpolation.assign(interpolation, bx::strword(interpolation)-interpolation);
 						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_name.assign(name, bx::strword(name)-name);
 					var.m_semantics.assign(semantics, bx::strword(semantics)-semantics);
 					var.m_semantics.assign(semantics, bx::strword(semantics)-semantics);
 
 
@@ -1101,9 +1101,6 @@ int main(int _argc, const char* _argv[])
 				return EXIT_FAILURE;
 				return EXIT_FAILURE;
 			}
 			}
 
 
-			uint32_t inputHash = 0;
-			uint32_t outputHash = 0;
-
 			if ('f' == shaderType)
 			if ('f' == shaderType)
 			{
 			{
 				bx::write(writer, BGFX_CHUNK_MAGIC_FSH);
 				bx::write(writer, BGFX_CHUNK_MAGIC_FSH);
@@ -1653,7 +1650,6 @@ int main(int _argc, const char* _argv[])
 
 
 						if (0 != glsl)
 						if (0 != glsl)
 						{
 						{
-							const char* profile = cmdLine.findOption('p', "profile");
 							if (NULL == profile)
 							if (NULL == profile)
 							{
 							{
 								writef(&writer
 								writef(&writer

+ 4 - 4
tools/shaderc/shaderc_dx11.cpp

@@ -297,14 +297,14 @@ bool compileHLSLShaderDx11(bx::CommandLine& _cmdLine, const std::string& _code,
 					hr = type->GetDesc(&constDesc);
 					hr = type->GetDesc(&constDesc);
 					if (SUCCEEDED(hr) )
 					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) )
 						&&  0 != (varDesc.uFlags & D3D_SVF_USED) )
 						{
 						{
 							Uniform un;
 							Uniform un;
 							un.name = varDesc.Name;
 							un.name = varDesc.Name;
-							un.type = type;
+							un.type = uniformType;
 							un.num = constDesc.Elements;
 							un.num = constDesc.Elements;
 							un.regIndex = varDesc.StartOffset;
 							un.regIndex = varDesc.StartOffset;
 							un.regCount = BX_ALIGN_16(varDesc.Size)/16;
 							un.regCount = BX_ALIGN_16(varDesc.Size)/16;
@@ -315,7 +315,7 @@ bool compileHLSLShaderDx11(bx::CommandLine& _cmdLine, const std::string& _code,
 								, varDesc.StartOffset
 								, varDesc.StartOffset
 								, varDesc.Size
 								, varDesc.Size
 								, varDesc.uFlags
 								, varDesc.uFlags
-								, type
+								, uniformType
 								);
 								);
 						}
 						}
 						else
 						else

+ 22 - 22
tools/shaderc/shaderc_glsl.cpp

@@ -65,18 +65,18 @@ bool compileGLSLShader(bx::CommandLine& _cmdLine, uint32_t _gles, const std::str
 
 
 	if (0 != _gles)
 	if (0 != _gles)
 	{
 	{
-		char* shader = const_cast<char*>(optimizedShader);
-		strreplace(shader, "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(shader, "shadow2DEXT", "shadow2D");
-		strreplace(shader, "shadow2DProjEXT", "shadow2DProj");
+		char* code = const_cast<char*>(optimizedShader);
+		strreplace(code, "gl_FragDepthEXT", "gl_FragDepth");
+
+		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(code, "shadow2DEXT", "shadow2D");
+		strreplace(code, "shadow2DProjEXT", "shadow2DProj");
 	}
 	}
 
 
 	UniformArray uniforms;
 	UniformArray uniforms;
@@ -110,14 +110,14 @@ bool compileGLSLShader(bx::CommandLine& _cmdLine, uint32_t _gles, const std::str
 				}
 				}
 
 
 				const char* precision = NULL;
 				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);
 				BX_UNUSED(precision);
@@ -125,13 +125,13 @@ bool compileGLSLShader(bx::CommandLine& _cmdLine, uint32_t _gles, const std::str
 				char uniformType[256];
 				char uniformType[256];
 				parse = bx::strword(parse);
 				parse = bx::strword(parse);
 
 
-				if (0 == strncmp(type, "sampler", 7) )
+				if (0 == strncmp(typen, "sampler", 7) )
 				{
 				{
 					strcpy(uniformType, "int");
 					strcpy(uniformType, "int");
 				}
 				}
 				else
 				else
 				{
 				{
-					bx::strlcpy(uniformType, type, parse-type+1);
+					bx::strlcpy(uniformType, typen, parse-typen+1);
 				}
 				}
 
 
 				const char* name = parse = bx::strws(parse);
 				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();
 		uint8_t nameSize = (uint8_t)un.name.size();
 		bx::write(_writer, nameSize);
 		bx::write(_writer, nameSize);
 		bx::write(_writer, un.name.c_str(), 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.num);
 		bx::write(_writer, un.regIndex);
 		bx::write(_writer, un.regIndex);
 		bx::write(_writer, un.regCount);
 		bx::write(_writer, un.regCount);