Android: Add support for OpenGL ES 3
Bug: webrtc:10642 Change-Id: I736e9e2520b364a817228a6599f4008d58165622 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/137424 Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Commit-Queue: Magnus Jedvert <magjed@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27990}
This commit is contained in:
committed by
Commit Bot
parent
b9979a533c
commit
94079f8452
@ -27,6 +27,7 @@ import javax.microedition.khronos.egl.EGLSurface;
|
||||
* and an EGLSurface.
|
||||
*/
|
||||
class EglBase10Impl implements EglBase10 {
|
||||
private static final String TAG = "EglBase10Impl";
|
||||
// This constant is taken from EGL14.EGL_CONTEXT_CLIENT_VERSION.
|
||||
private static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
|
||||
|
||||
@ -64,7 +65,9 @@ class EglBase10Impl implements EglBase10 {
|
||||
this.egl = (EGL10) EGLContext.getEGL();
|
||||
eglDisplay = getEglDisplay();
|
||||
eglConfig = getEglConfig(eglDisplay, configAttributes);
|
||||
eglContext = createEglContext(sharedContext, eglDisplay, eglConfig);
|
||||
final int openGlesVersion = EglBase.getOpenGlesVersionFromConfig(configAttributes);
|
||||
Logging.d(TAG, "Using OpenGL ES version " + openGlesVersion);
|
||||
eglContext = createEglContext(sharedContext, eglDisplay, eglConfig, openGlesVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -309,12 +312,12 @@ class EglBase10Impl implements EglBase10 {
|
||||
}
|
||||
|
||||
// Return an EGLConfig, or die trying.
|
||||
private EGLContext createEglContext(
|
||||
@Nullable EGLContext sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) {
|
||||
private EGLContext createEglContext(@Nullable EGLContext sharedContext, EGLDisplay eglDisplay,
|
||||
EGLConfig eglConfig, int openGlesVersion) {
|
||||
if (sharedContext != null && sharedContext == EGL10.EGL_NO_CONTEXT) {
|
||||
throw new RuntimeException("Invalid sharedContext");
|
||||
}
|
||||
int[] contextAttributes = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE};
|
||||
int[] contextAttributes = {EGL_CONTEXT_CLIENT_VERSION, openGlesVersion, EGL10.EGL_NONE};
|
||||
EGLContext rootContext = sharedContext == null ? EGL10.EGL_NO_CONTEXT : sharedContext;
|
||||
final EGLContext eglContext;
|
||||
synchronized (EglBase.lock) {
|
||||
|
||||
@ -30,7 +30,7 @@ import org.webrtc.EglBase;
|
||||
@SuppressWarnings("ReferenceEquality") // We want to compare to EGL14 constants.
|
||||
@TargetApi(18)
|
||||
class EglBase14Impl implements EglBase14 {
|
||||
private static final String TAG = "EglBase14";
|
||||
private static final String TAG = "EglBase14Impl";
|
||||
private static final int EGLExt_SDK_VERSION = Build.VERSION_CODES.JELLY_BEAN_MR2;
|
||||
private static final int CURRENT_SDK_VERSION = Build.VERSION.SDK_INT;
|
||||
private EGLContext eglContext;
|
||||
@ -73,7 +73,9 @@ class EglBase14Impl implements EglBase14 {
|
||||
public EglBase14Impl(EGLContext sharedContext, int[] configAttributes) {
|
||||
eglDisplay = getEglDisplay();
|
||||
eglConfig = getEglConfig(eglDisplay, configAttributes);
|
||||
eglContext = createEglContext(sharedContext, eglDisplay, eglConfig);
|
||||
final int openGlesVersion = EglBase.getOpenGlesVersionFromConfig(configAttributes);
|
||||
Logging.d(TAG, "Using OpenGL ES version " + openGlesVersion);
|
||||
eglContext = createEglContext(sharedContext, eglDisplay, eglConfig, openGlesVersion);
|
||||
}
|
||||
|
||||
// Create EGLSurface from the Android Surface.
|
||||
@ -262,12 +264,12 @@ class EglBase14Impl implements EglBase14 {
|
||||
}
|
||||
|
||||
// Return an EGLConfig, or die trying.
|
||||
private static EGLContext createEglContext(
|
||||
@Nullable EGLContext sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) {
|
||||
private static EGLContext createEglContext(@Nullable EGLContext sharedContext,
|
||||
EGLDisplay eglDisplay, EGLConfig eglConfig, int openGlesVersion) {
|
||||
if (sharedContext != null && sharedContext == EGL14.EGL_NO_CONTEXT) {
|
||||
throw new RuntimeException("Invalid sharedContext");
|
||||
}
|
||||
int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE};
|
||||
int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, openGlesVersion, EGL14.EGL_NONE};
|
||||
EGLContext rootContext = sharedContext == null ? EGL14.EGL_NO_CONTEXT : sharedContext;
|
||||
final EGLContext eglContext;
|
||||
synchronized (EglBase.lock) {
|
||||
|
||||
Reference in New Issue
Block a user