在 Android 平板电脑上,在 2 个 GLSurfaceView 之间共享 EGL2.0 上下文会导致 EGL_BAD_ACCESS
我尝试通过以下代码共享 EGL 上下文 bwteen 2 GLSurfaceViews:
createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
EGLContext shared = ...; // a cached egl context
int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
EGLContext context = egl.eglCreateContext(display, eglConfig, shared == null ? EGL10.EGL_NO_CONTEXT : shared,
attrib_list);
return context;
}
}
该代码适用于大多数 Android 手机(操作系统>=2.2),但在所有测试的平板电脑上均失败。
01-12 18:33:35.381:E/AndroidRuntime(12171):致命异常:GLThread 11
01-12 18:33:35.381:E / AndroidRuntime(12171):java.lang.RuntimeException:eglMakeCurrent失败:EGL_BAD_ACCESS
01-12 18:33:35.381: E/AndroidRuntime(12171): 在 android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1146)
由于我声明了 LOCAL_LDLIBS:= -lGLESv2,因此 EGL 是 2.0 上下文。
为什么它在平板电脑上失败(xoom、galaxy、lg、sony 等)
任何见解都值得赞赏。
I try to share EGL context bwteen 2 GLSurfaceViews by following code:
createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
EGLContext shared = ...; // a cached egl context
int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
EGLContext context = egl.eglCreateContext(display, eglConfig, shared == null ? EGL10.EGL_NO_CONTEXT : shared,
attrib_list);
return context;
}
}
The code works on most of the android phones (OS>=2.2) but failed on all the tested tablets.
01-12 18:33:35.381: E/AndroidRuntime(12171): FATAL EXCEPTION: GLThread 11
01-12 18:33:35.381: E/AndroidRuntime(12171): java.lang.RuntimeException: eglMakeCurrent failed: EGL_BAD_ACCESS
01-12 18:33:35.381: E/AndroidRuntime(12171): at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1146)
Since I declared the LOCAL_LDLIBS: = -lGLESv2, the EGL is a 2.0 context.
Why it failed on tablets(xoom, galaxy, lg, sony, etc)
Any insight is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
导致此失败的两个可能原因(来自 EGL 规范):
绑定到另一个线程中的上下文,EGL_BAD_ACCESS 错误是
生成的。
实现支持的客户端 API 类型的上下文,
生成 EGL_BAD_ACCESS 错误。
也可能是您在平板电脑上使用的 GPU 不支持共享上下文。
Two possible reasons for this failure (from the EGL spec):
are bound to contexts in another thread, an EGL_BAD_ACCESS error is
generated.
contexts of that client API type supported by the implementation, an
EGL_BAD_ACCESS error is generated.
It could also be that the GPU you are using on tablets does not support shared context.
以下几行很可能是 GLSurfaceView 中错误的原因。
Most probably following lines are reason for the error in GLSurfaceView.