Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SceneShaderGLES2: Program linking failed #50225

Closed
madmiraal opened this issue Jul 6, 2021 · 7 comments
Closed

SceneShaderGLES2: Program linking failed #50225

madmiraal opened this issue Jul 6, 2021 · 7 comments

Comments

@madmiraal
Copy link
Contributor

Godot version

3.4.beta 009aa63

System information

Android emulator Pixel 5.0 1080x1920 420dpi running Android 11.0 x86

Issue description

Running an Android project generates the following errors:

E/godot: ERROR: SceneShaderGLES2: Program linking failed:
    Error: uniform view_index specified with different precision in different shaders.
E/godot:    at: _display_error_with_code (drivers/gles2/shader_gles2.cpp:126) - SceneShaderGLES2: Program linking failed:
    Error: uniform view_index specified with different precision in different shaders.
E/godot: ERROR: Method failed. Returning: nullptr
E/godot:    at: get_current_version (drivers/gles2/shader_gles2.cpp:422) - Method failed. Returning: nullptr
E/godot: ERROR: Condition "!version" is true. Returned: false
E/godot:    at: bind (drivers/gles2/shader_gles2.cpp:87) - Condition "!version" is true. Returned: false

Steps to reproduce

Run an Android project and view the logcat errors.

Minimal reproduction project

Any project will do, but here is a simple one:
HelloAndroid.zip

@Calinou
Copy link
Member

Calinou commented Jul 6, 2021

@madmiraal Can you reproduce this in 3.3.2?

@madmiraal
Copy link
Contributor Author

Can you reproduce this in 3.3.2?

No. It's fine in 3.3.2.

@Calinou Calinou added this to the 3.3 milestone Jul 6, 2021
@akien-mga akien-mga modified the milestones: 3.3, 3.4 Jul 6, 2021
@akien-mga
Copy link
Member

Likely a bug caused by #48011, CC @BastiaanOlij.

@BastiaanOlij
Copy link
Contributor

I think the problem is caused by having this in the vertex shader (drivers/gles2/shaders/scene.glsl):

#ifdef USE_GLES_OVER_GL
#define lowp
#define mediump
#define highp
#else
precision highp float;
precision highp int;
#endif

And this in the fragment shader:

#ifdef USE_GLES_OVER_GL
#define lowp
#define mediump
#define highp
#else
#if defined(USE_HIGHP_PRECISION)
precision highp float;
precision highp int;
#else
precision mediump float;
precision mediump int;
#endif
#endif

This means that the default precision in the vertex shader is highp while the default in the fragment shader is either highp or mediump depending on settings.

As view_index is declared as uniform int view_index; it will use the default precision.

The easy fix is to change it to uniform highp int view_index; but I also feel that the default precision should match between vertex and fragment shader. Not 100% sure about that one though.

@reduz
Copy link
Member

reduz commented Jul 6, 2021

@BastiaanOlij The ifdef block is intended, highp on shaders on mobile is too much, so unless needed mediump needs to remain default. What most likely happened is that an uniform or a varying did not have the right precision specified on both fragment and vertex.

@BastiaanOlij
Copy link
Contributor

@BastiaanOlij The ifdef block is intended, highp on shaders on mobile is too much, so unless needed mediump needs to remain default. What most likely happened is that an uniform or a varying did not have the right precision specified on both fragment and vertex.

Thanks for clarifying that, I'll add some remarks in there for the next person who scratched their head :)

And indeed, the issue is most likely the missing permission on the view_index uniform I introduced so I'll add that in too.

@akien-mga
Copy link
Member

Fixed by #50237.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants