From 0ad9bd9725e1ddfa75d3fe12bc9c32588a68c73f Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Wed, 6 Nov 2019 16:11:46 +0100 Subject: [PATCH] app/internal/window: finish GL commands before surface detruction Signed-off-by: Elias Naur --- app/internal/window/egl.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/internal/window/egl.go b/app/internal/window/egl.go index 3c54c086..a301bc15 100644 --- a/app/internal/window/egl.go +++ b/app/internal/window/egl.go @@ -71,11 +71,7 @@ func (c *context) Release() { c.srgbFBO.Release() c.srgbFBO = nil } - if c.eglSurf != nilEGLSurface { - eglMakeCurrent(c.eglCtx.disp, nilEGLSurface, nilEGLSurface, nilEGLContext) - eglDestroySurface(c.eglCtx.disp, c.eglSurf) - c.eglSurf = nilEGLSurface - } + c.destroySurface() c.eglWin = nilEGLNativeWindowType if c.eglCtx != nil { eglDestroyContext(c.eglCtx.disp, c.eglCtx.ctx) @@ -126,6 +122,17 @@ func (c *context) Lock() {} func (c *context) Unlock() {} +func (c *context) destroySurface() { + if c.eglSurf == nilEGLSurface { + return + } + // Make sure any in-flight GL commands are complete. + c.c.Finish() + eglMakeCurrent(c.eglCtx.disp, nilEGLSurface, nilEGLSurface, nilEGLContext) + eglDestroySurface(c.eglCtx.disp, c.eglSurf) + c.eglSurf = nilEGLSurface +} + func (c *context) MakeCurrent() error { win, width, height, err := c.driver.eglWindow(int(c.eglCtx.visualID)) if err != nil { @@ -141,13 +148,7 @@ func (c *context) MakeCurrent() error { c.srgbFBO.Release() c.srgbFBO = nil } - if c.eglSurf != nilEGLSurface { - // Make sure any in-flight GL commands are complete. - c.c.Finish() - eglMakeCurrent(c.eglCtx.disp, nilEGLSurface, nilEGLSurface, nilEGLContext) - eglDestroySurface(c.eglCtx.disp, c.eglSurf) - c.eglSurf = nilEGLSurface - } + c.destroySurface() c.eglWin = win if c.eglWin == nilEGLNativeWindowType { return nil