aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/gpu
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2018-03-21 16:34:56 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-23 19:21:20 +0000
commit22e6e21e7ca139eb288c4f5b7a2615eab37c304e (patch)
treea62769cc8b13c0df228c265b1ead2189e95fa4d0 /tools/gpu
parent1875e053845c4d377a0f64f7233bdb9dc00bdce1 (diff)
Reland "CreatePlatformGLTestContext_egl: Try GLES 3, then GLES 2."
This is a reland of 0593a840b107c1abd312a03ef4000ddb58454f94 New functionality (which doesn't work everywhere) is behind a flag: GR_EGL_TRY_GLES3_THEN_GLES2. Original change's description: > CreatePlatformGLTestContext_egl: Try GLES 3, then GLES 2. > > Also cleanup. > > Change-Id: I186a7d7f509bc7852241c083414495b6182b916c > Reviewed-on: https://skia-review.googlesource.com/115922 > Reviewed-by: Brian Salomon <bsalomon@google.com> > Commit-Queue: Hal Canary <halcanary@google.com> Change-Id: I362079dee9c74f1a2c31d935bcb821201a413923 Reviewed-on: https://skia-review.googlesource.com/116143 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'tools/gpu')
-rw-r--r--tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp75
1 files changed, 42 insertions, 33 deletions
diff --git a/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp b/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp
index 03a211d603..7cc94be80b 100644
--- a/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp
+++ b/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp
@@ -72,6 +72,26 @@ private:
EGLSurface fSurface;
};
+static EGLContext create_gles_egl_context(EGLDisplay display,
+ EGLConfig surfaceConfig,
+ EGLContext eglShareContext,
+ EGLint eglContextClientVersion) {
+ const EGLint contextAttribsForOpenGLES[] = {
+ EGL_CONTEXT_CLIENT_VERSION,
+ eglContextClientVersion,
+ EGL_NONE
+ };
+ return eglCreateContext(display, surfaceConfig, eglShareContext, contextAttribsForOpenGLES);
+}
+static EGLContext create_gl_egl_context(EGLDisplay display,
+ EGLConfig surfaceConfig,
+ EGLContext eglShareContext) {
+ const EGLint contextAttribsForOpenGL[] = {
+ EGL_NONE
+ };
+ return eglCreateContext(display, surfaceConfig, eglShareContext, contextAttribsForOpenGL);
+}
+
EGLGLTestContext::EGLGLTestContext(GrGLStandard forcedGpuAPI, EGLGLTestContext* shareContext)
: fContext(EGL_NO_CONTEXT)
, fDisplay(EGL_NO_DISPLAY)
@@ -79,43 +99,19 @@ EGLGLTestContext::EGLGLTestContext(GrGLStandard forcedGpuAPI, EGLGLTestContext*
EGLContext eglShareContext = shareContext ? shareContext->fContext : nullptr;
- static const EGLint kEGLContextAttribsForOpenGL[] = {
- EGL_NONE
- };
-
- static const EGLint kEGLContextAttribsForOpenGLES[] = {
- EGL_CONTEXT_CLIENT_VERSION, 2,
- EGL_NONE
- };
-
- static const struct {
- const EGLint* fContextAttribs;
- EGLenum fAPI;
- EGLint fRenderableTypeBit;
- GrGLStandard fStandard;
- } kAPIs[] = {
- { // OpenGL
- kEGLContextAttribsForOpenGL,
- EGL_OPENGL_API,
- EGL_OPENGL_BIT,
- kGL_GrGLStandard
- },
- { // OpenGL ES. This seems to work for both ES2 and 3 (when available).
- kEGLContextAttribsForOpenGLES,
- EGL_OPENGL_ES_API,
- EGL_OPENGL_ES2_BIT,
- kGLES_GrGLStandard
- },
+ static const GrGLStandard kStandards[] = {
+ kGL_GrGLStandard,
+ kGLES_GrGLStandard,
};
- size_t apiLimit = SK_ARRAY_COUNT(kAPIs);
+ size_t apiLimit = SK_ARRAY_COUNT(kStandards);
size_t api = 0;
if (forcedGpuAPI == kGL_GrGLStandard) {
apiLimit = 1;
} else if (forcedGpuAPI == kGLES_GrGLStandard) {
api = 1;
}
- SkASSERT(forcedGpuAPI == kNone_GrGLStandard || kAPIs[api].fStandard == forcedGpuAPI);
+ SkASSERT(forcedGpuAPI == kNone_GrGLStandard || kStandards[api] == forcedGpuAPI);
sk_sp<const GrGLInterface> gl;
@@ -132,15 +128,16 @@ EGLGLTestContext::EGLGLTestContext(GrGLStandard forcedGpuAPI, EGLGLTestContext*
SkDebugf("VERSION: %s\n", eglQueryString(fDisplay, EGL_VERSION));
SkDebugf("EXTENSIONS %s\n", eglQueryString(fDisplay, EGL_EXTENSIONS));
#endif
+ bool gles = kGLES_GrGLStandard == kStandards[api];
- if (!eglBindAPI(kAPIs[api].fAPI)) {
+ if (!eglBindAPI(gles ? EGL_OPENGL_ES_API : EGL_OPENGL_API)) {
continue;
}
EGLint numConfigs = 0;
const EGLint configAttribs[] = {
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
- EGL_RENDERABLE_TYPE, kAPIs[api].fRenderableTypeBit,
+ EGL_RENDERABLE_TYPE, gles ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT,
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
@@ -159,8 +156,20 @@ EGLGLTestContext::EGLGLTestContext(GrGLStandard forcedGpuAPI, EGLGLTestContext*
continue;
}
- fContext = eglCreateContext(fDisplay, surfaceConfig, eglShareContext,
- kAPIs[api].fContextAttribs);
+ if (gles) {
+#ifdef GR_EGL_TRY_GLES3_THEN_GLES2
+ // Some older devices (Nexus7/Tegra3) crash when you try this. So it is (for now)
+ // hidden behind this flag.
+ fContext = create_gles_egl_context(fDisplay, surfaceConfig, eglShareContext, 3);
+ if (EGL_NO_CONTEXT == fContext) {
+ fContext = create_gles_egl_context(fDisplay, surfaceConfig, eglShareContext, 2);
+ }
+#else
+ fContext = create_gles_egl_context(fDisplay, surfaceConfig, eglShareContext, 2);
+#endif
+ } else {
+ fContext = create_gl_egl_context(fDisplay, surfaceConfig, eglShareContext);
+ }
if (EGL_NO_CONTEXT == fContext) {
SkDebugf("eglCreateContext failed. EGL Error: 0x%08x\n", eglGetError());
continue;