From 39313152ba8fc0e8c30b56b40063a2ec3b5dd57b Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Wed, 4 Nov 2015 01:56:02 +0100 Subject: [PATCH] OGL: use StringFromFormat where appropriate --- .../VideoBackends/OGL/ProgramShaderCache.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp index 52baa54523..f5dbfa2b16 100644 --- a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp +++ b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp @@ -40,7 +40,7 @@ UidChecker ProgramShaderCache::pixel_uid_checker; UidChecker ProgramShaderCache::vertex_uid_checker; UidChecker ProgramShaderCache::geometry_uid_checker; -static char s_glsl_header[1024] = ""; +static std::string s_glsl_header = ""; static std::string GetGLSLVersionString() { @@ -91,14 +91,10 @@ void SHADER::SetProgramVariables() // Bind Texture Samplers for (int a = 0; a <= 9; ++a) { - char name[10]; - if (a < 8) - snprintf(name, 8, "samp[%d]", a); - else - snprintf(name, 8, "samp%d", a); + std::string name = StringFromFormat(a < 8 ? "samp[%d]" : "samp%d", a); // Still need to get sampler locations since we aren't binding them statically in the shaders - int loc = glGetUniformLocation(glprogid, name); + int loc = glGetUniformLocation(glprogid, name.c_str()); if (loc != -1) glUniform1i(loc, a); } @@ -129,9 +125,8 @@ void SHADER::SetProgramBindings() for (int i = 0; i < 8; i++) { - char attrib_name[8]; - snprintf(attrib_name, 8, "tex%d", i); - glBindAttribLocation(glprogid, SHADER_TEXTURE0_ATTRIB+i, attrib_name); + std::string attrib_name = StringFromFormat("tex%d", i); + glBindAttribLocation(glprogid, SHADER_TEXTURE0_ATTRIB+i, attrib_name.c_str()); } } @@ -344,7 +339,7 @@ GLuint ProgramShaderCache::CompileSingleShader(GLuint type, const char* code) { GLuint result = glCreateShader(type); - const char *src[] = {s_glsl_header, code}; + const char *src[] = {s_glsl_header.c_str(), code}; glShaderSource(result, 2, src, nullptr); glCompileShader(result); @@ -566,7 +561,7 @@ void ProgramShaderCache::CreateHeader() } } - snprintf(s_glsl_header, sizeof(s_glsl_header), + s_glsl_header = StringFromFormat( "%s\n" "%s\n" // ubo "%s\n" // early-z