-
Notifications
You must be signed in to change notification settings - Fork 401
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
Disable GL_EXT_texture_array on OpenGL ES 2.0 #1648
Conversation
The Nvidia Tegra 3 driver for Android (used by Ouya) erroneously claims to support the desktop-oriented GL_EXT_texture_array extension. On desktop GPUs using (non ES) OpenGL, the glTexImage3D and similar functions are always present, and the GL_EXT_texture_array extension simply adds support for texture arrays to those functions. On OpenGL ES 2.0, those functions do not exist, and GL_OES_texture_3D is required to define them. Calling glTexImage3D on the Tegra 3 causes a segfault. This change works around the issue by manually setting GLAD_EXT_texture_array to 0 on OpenGL ES 2.0 systems, which causes LÖVE to avoid codepaths that assume that the 3D texture functions are available. It doesn't make sense for any OpenGL ES 2.0 GPU to claim support for GL_EXT_texture_array. Fixes love2d#1647
// The Nvidia Tegra 3 driver (used by Ouya) claims to support GL_EXT_texture_array but | ||
// segfaults if you actually try to use it. OpenGL ES 2.0 devices should use OES_texture_3D. | ||
// GL_EXT_texture_array is for desktops. | ||
GLAD_EXT_texture_array = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put this here because I thought it made sense to keep it near the other OpenGL ES 2.0 texture code, however, there is a check above on line 352 that uses GLAD_EXT_texture_array:
if (GLAD_VERSION_1_0 && GLAD_EXT_texture_array)
fp_glFramebufferTextureLayer = fp_glFramebufferTextureLayerEXT;
This doesn't cause any problems today, but maybe it's still better to be safe and add the new code closer to the top of the function.
@@ -54,7 +54,8 @@ GLSL.SYNTAX = [[ | |||
#define DepthCubeImage samplerCubeShadow | |||
#endif | |||
#define extern uniform | |||
#ifdef GL_EXT_texture_array | |||
#if defined(GL_EXT_texture_array) && (!defined(GL_ES) || __VERSION__ > 100) | |||
#define texture_arrays_enabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure how correct this is. (!defined(GL_ES) || __VERSION__ > 100)
is my attempt to say "if we're not on OpenGL ES 2.0". It works on my Ouya, but I'm not sure if it does what I want elsewhere.
I'm also not sure if the #define texture_arrays_enabled
style is a good idea.
Feedback is welcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need some tweaks to work with how LÖVE does things with OpenGL ES, but the reasoning and changes needed are so obscure that I think I'll just merge this as-is and make the changes after.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
The Nvidia Tegra 3 driver for Android (used by Ouya) erroneously claims
to support the desktop-oriented GL_EXT_texture_array extension. On
desktop GPUs using (non ES) OpenGL, the glTexImage3D and similar
functions are always present, and the GL_EXT_texture_array extension
simply adds support for texture arrays to those functions. On OpenGL ES
2.0, those functions do not exist, and GL_OES_texture_3D is required to
define them.
Calling glTexImage3D on the Tegra 3 causes a segfault. This change works
around the issue by manually setting GLAD_EXT_texture_array to 0 on
OpenGL ES 2.0 systems, which causes LÖVE to avoid codepaths that assume
that the 3D texture functions are available. It doesn't make sense for
any OpenGL ES 2.0 GPU to claim support for GL_EXT_texture_array.
Fixes #1647