Commit 67946766 by Olli Etuaho Committed by Commit Bot

Improve info log length checks

Extend the info log length checks to shader_utils used by tests, and treat info log with length 1 as empty, since it can only include the null terminator. At least the Intel GL driver may generate "\0" as info log in some situations, for example when compiling a user-defined function with 50000 parameters. BUG=angleproject:1323 Change-Id: I00f2965539ec235cb949c80c2a9e1d063d32fa15 Reviewed-on: https://chromium-review.googlesource.com/331461Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 9a7e8cab
......@@ -118,7 +118,10 @@ LinkResult ProgramGL::link(const gl::Data &data, gl::InfoLog &infoLog)
mFunctions->getProgramiv(mProgramID, GL_INFO_LOG_LENGTH, &infoLogLength);
std::string warning;
if (infoLogLength > 0)
// Info log length includes the null terminator, so 1 means that the info log is an empty
// string.
if (infoLogLength > 1)
{
std::vector<char> buf(infoLogLength);
mFunctions->getProgramInfoLog(mProgramID, infoLogLength, nullptr, &buf[0]);
......
......@@ -77,7 +77,9 @@ bool ShaderGL::postTranslateCompile(gl::Compiler *compiler, std::string *infoLog
GLint infoLogLength = 0;
mFunctions->getShaderiv(mShaderID, GL_INFO_LOG_LENGTH, &infoLogLength);
if (infoLogLength > 0)
// Info log length includes the null terminator, so 1 means that the info log is an empty
// string.
if (infoLogLength > 1)
{
std::vector<char> buf(infoLogLength);
mFunctions->getShaderInfoLog(mShaderID, infoLogLength, nullptr, &buf[0]);
......
......@@ -46,7 +46,9 @@ GLuint CompileShader(GLenum type, const std::string &source)
GLint infoLogLength;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);
if (infoLogLength > 0)
// Info log length includes the null terminator, so 1 means that the info log is an empty
// string.
if (infoLogLength > 1)
{
std::vector<GLchar> infoLog(infoLogLength);
glGetShaderInfoLog(shader, static_cast<GLsizei>(infoLog.size()), NULL, &infoLog[0]);
......@@ -123,10 +125,19 @@ GLuint CompileProgramWithTransformFeedback(
GLint infoLogLength;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength);
std::vector<GLchar> infoLog(infoLogLength);
glGetProgramInfoLog(program, static_cast<GLsizei>(infoLog.size()), NULL, &infoLog[0]);
// Info log length includes the null terminator, so 1 means that the info log is an empty
// string.
if (infoLogLength > 1)
{
std::vector<GLchar> infoLog(infoLogLength);
glGetProgramInfoLog(program, static_cast<GLsizei>(infoLog.size()), nullptr, &infoLog[0]);
std::cerr << "program link failed: " << &infoLog[0];
std::cerr << "program link failed: " << &infoLog[0];
}
else
{
std::cerr << "program link failed. <Empty log message>";
}
glDeleteProgram(program);
return 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