KhronosGroup / KhronosGroup/WebGL

Functions that read from out parameters have undefined behavior

Open
#3,628 12 comments 0 reactions 1 assignee Claimed by @kdashg View on GitHub
Dominant language
HTML
Stars
2.9k
Forks
703
Avg merge
2d 9h
Merged PRs (30d)
4

Description

```glsl
void foo(out float a) {
a += 2.0f;
}

void main() {
float x = 5.0f;
foo(x);
gl_FragColor = vec4(x);
}
```

This is not an error, and is undefined behavior, but it works fine on some GPUs because their drivers effectively treat out as inout. However, I've encountered issues with other GPU drivers that are more strict. While we probably can't make it an error due to backcompat, maybe a compiler warning should be emitted for this?

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.