BabylonJS / BabylonJS/BabylonNative

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

Open
#1,745 0 comments 0 reactions 1 assignee Claimed by @bghgary View on GitHub
Dominant language
C++
Stars
919
Forks
162
Avg merge
1d 15h
Merged PRs (30d)
19

Description

[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`:

```glsl
#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()`:

```cpp
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).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.