Skip to content

Commit

Permalink
Always use GLSL ES 100 shaders in swift shaders
Browse files Browse the repository at this point in the history
Summary:
OpenGL ES 3 on rainbow has a bug, which originates from a bug in swiftshaders.

the issue is that swiftshaders is returning -1 when we use
```
glGetActiveUniformsiv(,..,GL_UNIFORM_OFFSET, ...)
```
to query the offset of a member in a uniform buffer. We believe this is a swift shaders bug, so we work around this by always using GLSL es 100 shaders on rainbow

Reviewed By: dmannemela, syeh1

Differential Revision: D49329247

fbshipit-source-id: 54a8245704d932e7984e7521bef9d28367d1e416
  • Loading branch information
AmesingFlank authored and facebook-github-bot committed Sep 15, 2023
1 parent d20c05b commit 9753201
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/igl/opengl/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,13 @@ GLVersion getGLVersion(const char* version, bool constrain) {
}

ShaderVersion getShaderVersion(GLVersion version) {
#if IGL_PLATFORM_LINUX_SWIFTSHADER
// Swiftshader has a bug when it comes to uniform blocks. When calling
// `glGetActiveUniformsiv(,..,GL_UNIFORM_OFFSET, ...)`, it always returns -1. We work around this
// by forcing GLSL ES 100 shaders in swiftshaders.
// TODO(dunfanlu): consider patching swift shaders to fix this.
return {ShaderFamily::GlslEs, 1, 0};
#else
// TODO: Return proper GLSL ES versions
switch (version) {
case GLVersion::v2_0_ES:
Expand Down Expand Up @@ -263,6 +270,7 @@ ShaderVersion getShaderVersion(GLVersion version) {
IGL_ASSERT_NOT_REACHED();
return {};
}
#endif
}

std::string getStringFromShaderVersion(ShaderVersion version) {
Expand Down

0 comments on commit 9753201

Please sign in to comment.