diff options
author | Brian Salomon <bsalomon@google.com> | 2018-05-04 11:44:40 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-04 16:27:13 +0000 |
commit | ec54539d3941dd65fef0e8ac04b3de82749b6824 (patch) | |
tree | f3efd1fe1eb33ab7e6a4ad6b046bebdc56f4b05c /tools/sk_app | |
parent | 05cfcff70ced3af834e0c9c5309f98bd6662f851 (diff) |
Make RenderDoc work automatically with GLX viewer
Change-Id: I19769924882c2790cfc862373d6f26508b410eee
Reviewed-on: https://skia-review.googlesource.com/125871
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tools/sk_app')
-rw-r--r-- | tools/sk_app/unix/GLWindowContext_unix.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tools/sk_app/unix/GLWindowContext_unix.cpp b/tools/sk_app/unix/GLWindowContext_unix.cpp index 3a3a4b16d4..d21951cda7 100644 --- a/tools/sk_app/unix/GLWindowContext_unix.cpp +++ b/tools/sk_app/unix/GLWindowContext_unix.cpp @@ -58,6 +58,8 @@ using CreateContextAttribsFn = GLXContext(Display*, GLXFBConfig, GLXContext, Boo sk_sp<const GrGLInterface> GLWindowContext_xlib::onInitializeContext() { SkASSERT(fDisplay); SkASSERT(!fGLContext); + sk_sp<const GrGLInterface> interface; + bool current = false; // We attempt to use glXCreateContextAttribsARB as RenderDoc requires that the context be // created with this rather than glXCreateContext. CreateContextAttribsFn* createContextAttribs = (CreateContextAttribsFn*)glXGetProcAddressARB( @@ -76,6 +78,20 @@ sk_sp<const GrGLInterface> GLWindowContext_xlib::onInitializeContext() { 0 }; fGLContext = createContextAttribs(fDisplay, *fFBConfig, nullptr, True, attribs); + if (fGLContext && profile == GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB && + glXMakeCurrent(fDisplay, fWindow, fGLContext)) { + current = true; + // Look to see if RenderDoc is attached. If so, re-create the context with a + // core profile. + interface = GrGLMakeNativeInterface(); + if (interface && interface->fExtensions.has("GL_EXT_debug_tool")) { + interface.reset(); + glXMakeCurrent(fDisplay, None, nullptr); + glXDestroyContext(fDisplay, fGLContext); + current = false; + fGLContext = nullptr; + } + } if (fGLContext) { break; } @@ -89,7 +105,7 @@ sk_sp<const GrGLInterface> GLWindowContext_xlib::onInitializeContext() { return nullptr; } - if (!glXMakeCurrent(fDisplay, fWindow, fGLContext)) { + if (!current && !glXMakeCurrent(fDisplay, fWindow, fGLContext)) { return nullptr; } glClearStencil(0); @@ -108,7 +124,7 @@ sk_sp<const GrGLInterface> GLWindowContext_xlib::onInitializeContext() { &border_width, &depth); glViewport(0, 0, fWidth, fHeight); - return GrGLMakeNativeInterface(); + return interface ? interface : GrGLMakeNativeInterface(); } GLWindowContext_xlib::~GLWindowContext_xlib() { |