[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] getShaderInfoLog/getProgramInfoLog format specification



On Wed, Jan 7, 2015 at 1:04 AM, Jeff Gilbert <jgilbert@mozilla.com> wrote:
However, enforcing a strict log format doesn't seem (to me) to have a large value for something which should only be dealt with at debugging time, and seems like a ton of extra work for implementers. 

The issue I'm describing partains to debugging, and it's a ton of work for whoever needs to do it. The reason it's important to be able to reliably figure out which line and column an error comes from, and which are separate error messages in the info log is:
  • In order to map line error messages to files (shaders are often pasted together from separate files by the user)
  • To translate the line number as reported to a line number as it partains to one of the shader source files
  • To shortcut requiring the user to peek at the source to figure out the error (this greatly accelerates fixing issues)
For example. This is how the error arrives from chrome on linux for a shader error (one vec3 argument to a function is wrongly typed)

ERROR: 0:170: 'dot' : no matching overloaded function found 
ERROR: 0:178: 'textureEnv' : no matching overloaded function found 
ERROR: 0:174: 'return' : function return is not matching type: 
ERROR: 0:187: 'getShading' : no matching overloaded function found 
ERROR: 0:188: 'getShading' : no matching overloaded function found 
ERROR: 0:186: '=' :  cannot convert from 'const mediump float' to '3-component vector of float'

I'm employing this function to translate this error:

translateError: (error, lines) ->
    result = ['Shader Compile Error']
    for line, i in error.split('\n')
        match = line.match /ERROR: \d+:(\d+): (.*)/
        if match
            lineno = parseFloat(match[1])-1
            message = match[2]
            sourceline = lines[lineno]
            result.push "File \"#{sourceline.filename}\", Line #{sourceline.lineno}, #{message}"
            result.push "   #{sourceline.source}"
        else
            result.push line

    return result.join('\n')

Which yields this log:

Uncaught Shader Compile Error
File "/display.shader", Line 150, 'dot' : no matching overloaded function found 
           float incidentDot = dot(normal, -eyeDir);
File "/display.shader", Line 158, 'textureEnv' : no matching overloaded function found 
               textureEnv(env, eyeDir, normal, params.envAngle)
File "/display.shader", Line 154, 'return' : function return is not matching type: 
           return (
File "/display.shader", Line 167, 'getShading' : no matching overloaded function found 
               getShading(shading0environ, shading0, eyeDir, normal) +
File "/display.shader", Line 168, 'getShading' : no matching overloaded function found 
               getShading(shading1environ, shading1, eyeDir, normal)
File "/display.shader", Line 166, '=' :  cannot convert from 'const mediump float' to '3-component vector of float'
           vec3 color = (

Of course this breaks down depending on the format of the error message because... different formats/backends/what have you. But it easily shows how the error messages as they come out are nearly useless (they have no other choice to be nearly useless, there's nothing wrong with that), and how to get usable error messages you HAVE to translate them. And since you HAVE to translate them, it's perfectly justified to ask for a standard for doing so, consistently, reliably and vendor independently.