KhronosGroup / KhronosGroup/glslang
Redefining built-in function causing error in Vulkan environment.
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
Compiling the following test fragment shader is fine using "opengl" target environment, but fails using vulkan environment.
```
#version 450
layout(location = 0) out vec4 outColor;
layout(location = 0) in vec3 normal;
layout(location = 1) in vec3 incident;
vec3 refract(vec3 i, vec3 n, float eta)
{
float cosi = dot(-i, n);
float cost2 = 1.0 - eta * eta * (1.0 - cosi*cosi);
vec3 t = eta*i + ((eta*cosi - sqrt(abs(cost2))) * n);
return t * vec3(cost2 > 0.0);
}
void main(void)
{
outColor.rgb = refract(incident, normal, 1.0);
outColor.a = 1.0;
}
```
Error message:
```
ERROR: D:\test.frag:7: 'highp' : overloaded functions must have the same parameter precision qualifiers for argument 1
ERROR: D:\test.frag:7: 'highp' : overloaded functions must have the same parameter precision qualifiers for argument 2
ERROR: D:\test.frag:7: 'highp' : overloaded functions must have the same parameter precision qualifiers for argument 3
ERROR: D:\test.frag:8: '' : compilation terminated
ERROR: 4 compilation errors. No code generated.
```
Upon debugging (in TParseContext::handleFunctionDeclarator in ParseHelper.cpp), it turns out that the redefining function in Vulkan environment has "highp" precision qualifier (EpqHigh) automatically attached to it, while in OpenGL environment has none (EpqNone). But the built-in function has EpqNone in both environments. The inconsistence is making it impossible to redefine a built-in function in Vulkan environment.
Contributor guide
Assessment
This issue has not been assessed yet.