Skip to content

ShaderTool reports only error count, not per-line diagnostics, on shader compile failure #1745

Description

@bghgary

[Filed by Copilot on behalf of @bghgary]

Summary

When a shader fails to compile, ShaderTool (and the underlying ShaderCompiler) reports only glslang's summary line and discards the per-line diagnostics. This makes shader compile failures very hard to debug — there is no line number, no offending identifier, and no indication of which shader (vertex vs fragment) failed.

Repro

Compile a fragment shader containing a compile error (here, an undeclared identifier uLayer) with ShaderTool:

#define SHADER_NAME fragment:composition
precision highp float;
uniform sampler2D plane0Sampler;
in vec2 vUV;
layout(location = 0) out vec4 glFragColor;
void main() { glFragColor = texture(plane0Sampler, vec3(vUV, uLayer)); }
ShaderTool -o out.bin vertex.fx fragment.fx

Observed

Compiling: vertex.fx + fragment.fx
Error: ERROR: 3 compilation errors.  No code generated.

That summary line is the entire error output. glslang clearly detected 3 specific errors but none of the per-line detail is surfaced.

Expected

The per-line glslang diagnostics, e.g.:

ERROR: 0:6: 'uLayer' : undeclared identifier
ERROR: 0:6: 'texture' : no matching overloaded function found
ERROR: 0:6: '=' : cannot convert ...

…plus which shader stage / file the failure came from.

Where

Plugins/ShaderCompiler/Source/ShaderCompiler{DXBC,DXIL,Metal,OpenGL,Vulkan}.cpp, AddShader():

if (!shader.parse(defaultTBuiltInResource, 310, EProfile::EEsProfile, true, true, EShMsgDefault))
{
    throw std::runtime_error{shader.getInfoLog()};
}

In this case shader.getInfoLog() returns only the summary line. Worth investigating whether the per-line detail is available via getInfoDebugLog() and/or a different EShMessages flag, and including the failing shader stage/path in the thrown message (the Compiling: … line in ShaderTool is the only hint today, and even that doesn't disambiguate vertex vs fragment).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions