KhronosGroup / KhronosGroup/glslang

`glslang_shader_preprocess` fails to preprocess GLSL shaders with `#include` directives

Open
#3,867 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
3.6k
Forks
989
Avg merge
1d 2h
Merged PRs (30d)
31

Description

Doing GLSL compilation via C API [as elaborated](https://github.com/KhronosGroup/glslang?tab=readme-ov-file#c-functional-interface-new) in the README, with the following `glslang_input_t`:

```c
const glslang_input_t input = {
.language = GLSLANG_SOURCE_GLSL,
.stage = stage,
.client = GLSLANG_CLIENT_VULKAN,
.client_version = GLSLANG_TARGET_VULKAN_1_4,
.target_language = GLSLANG_TARGET_SPV,
.target_language_version = GLSLANG_TARGET_SPV_1_6,
.code = shaderSource,
.default_version = 460,
.default_profile = GLSLANG_NO_PROFILE,
.force_default_version_and_profile = false,
.forward_compatible = false,
.messages = GLSLANG_MSG_DEFAULT_BIT,
.resource = glslang_default_resource(),
};
```

For a shader starting like so:

```glsl
#version 460

#extension GL_GOOGLE_include_directive : require
#include "mesh.incl.glsl"
```

Upon `glslang_shader_preprocess` failing, printing `glslang_shader_get_info_log` and `glslang_shader_get_info_debug_log` produces:

```
ERROR: 0:4: '#include' : Could not process include directive for header name: mesh.incl.glsl
ERROR: 1 compilation errors. No code generated.
```

Contributor guide

Open the contributing guide

Research direction

Start with the C functional interface in the README and the glslang_shader_preprocess entry point, then trace how the supplied glslang_input_t handles the shown #include directive. Reproduce the failure with the provided shader and inspect the info and debug logs; done means preprocessing succeeds for an included GLSL file and the behavior is verified by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.