KhronosGroup / KhronosGroup/glslang

HLSL: Initializing constant through global function causes invalid recursion error

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

Description

Compiling the following valid hlsl code as a compute shader:
```hlsl
struct TestConstants {
float a;
};
static TestConstants DefaultConstants() {
TestConstants constants;
constants.a = 1.0f;
return constants;
}
static const TestConstants constants = DefaultConstants();
void main() { }
```

Incorrectly generates the link error:
```
ERROR: Linking compute stage: Recursion detected:
DefaultConstants( calling DefaultConstants(
```

Contributor guide

Open the contributing guide

Research direction

Use the supplied HLSL compute-shader reproducer as the first test and inspect how the compiler and linker handle the global function used to initialize the constant. Done means this valid shader compiles without the false recursive-call linking error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.