On compiling OpenGL shaders Blender lists errors on the console and (with the --debug-gpu-shaders option) will dump source code into the /temp directory. That is not very convenient because it is not in one place and the source code does not contain line numbers. When you use the debug_program() function form the opengl_debug module the output is all on the console and reorganized for readability.
Nicer error listing
For example, with the code below
vs_syntax_error = '''
in vec3 pos;
void main()
{
gl_Position = pos
}
'''
debug_program(vshader=vs_syntax_error, name="Syntax error sample")
The output will be
GL Error: 0 (Syntax error sample:vertexshader)
0(7) : error C1035: assignment of incompatible types
0(8) : error C0000: syntax error, unexpected '}', expecting ',' or ';' at token "}"
[0001] #version 330
[0002]
[0003] in vec3 pos;
[0004]
[0005] void main()
[0006] {
[0007] gl_Position = pos
[0008] }
[0009]
Active attributes and uniforms
Also, when there are syntax errors it shows the remaining active attributes and uniforms. For example, with the code below (assuming you have doneimport debug_program from opengl_debug)
vs_opt = '''
in vec3 pos;
in vec3 pos2;
void main()
{
gl_Position = vec4(pos, 1.0);
}
'''
debug_program(vshader=vs_opt, name="Optimized attribute")
The output will be
active attributes ['GL_FLOAT_VEC3'] pos active uniformsshowing that there are no active uniforms whatsoever and that the
pos2 attribute has been optimized away.
No comments:
Post a Comment