From 1c7113ab7ca79be4d4988303053a6b5cae9120f7 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 18 Nov 2018 10:27:07 -0500 Subject: [PATCH 1/2] gpu: destroy glcontext on shutdown --- .../net/runelite/client/plugins/gpu/GpuPlugin.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java index 94153a5b59..a470079f5f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java @@ -120,6 +120,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks private Canvas canvas; private JAWTWindow jawtWindow; private GL4 gl; + private GLContext glContext; private GLDrawable glDrawable; private int glProgram; @@ -240,7 +241,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks glDrawable = glDrawableFactory.createGLDrawable(jawtWindow); glDrawable.setRealized(true); - GLContext glContext = glDrawable.createContext(null); + glContext = glDrawable.createContext(null); int res = glContext.makeCurrent(); if (res == GLContext.CONTEXT_NOT_CURRENT) { @@ -331,6 +332,13 @@ public class GpuPlugin extends Plugin implements DrawCallbacks shutdownProgram(); shutdownVao(); + glContext.destroy(); + + jawtWindow = null; + gl = null; + glDrawable = null; + glContext = null; + vertexBuffer = null; uvBuffer = null; modelBufferSmall = null; From a696b498aaa2a2b06c1c4324b4bfaff9a7f831bf Mon Sep 17 00:00:00 2001 From: Whitehooder <831317+whitehooder@users.noreply.github.com> Date: Sun, 18 Nov 2018 10:27:20 -0500 Subject: [PATCH 2/2] Fix GPU rendering on Linux - Unlock surface after making context current - Lock surface on shutdown --- runelite-client/pom.xml | 29 ++++++++++++++++++- .../client/plugins/gpu/GpuPlugin.java | 20 +++++++++---- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/runelite-client/pom.xml b/runelite-client/pom.xml index 33062c504b..dddb9719db 100644 --- a/runelite-client/pom.xml +++ b/runelite-client/pom.xml @@ -110,11 +110,24 @@ natives-windows-i586 runtime + + org.jogamp.jogl + jogl-all + ${jogl.version} + natives-linux-amd64 + runtime + + + org.jogamp.jogl + jogl-all + ${jogl.version} + natives-linux-i586 + runtime + org.jogamp.gluegen gluegen-rt ${jogl.version} - runtime org.jogamp.gluegen @@ -130,6 +143,20 @@ natives-windows-i586 runtime + + org.jogamp.gluegen + gluegen-rt + ${jogl.version} + natives-linux-amd64 + runtime + + + org.jogamp.gluegen + gluegen-rt + ${jogl.version} + natives-linux-i586 + runtime + net.runelite diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java index a470079f5f..39c4aaa82c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java @@ -26,8 +26,7 @@ package net.runelite.client.plugins.gpu; import com.google.common.eventbus.Subscribe; import com.google.inject.Provides; -import com.jogamp.nativewindow.AbstractGraphicsConfiguration; -import com.jogamp.nativewindow.NativeWindowFactory; +import com.jogamp.nativewindow.NativeSurface; import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; import com.jogamp.nativewindow.awt.JAWTWindow; import com.jogamp.opengl.GL; @@ -50,6 +49,7 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.util.function.Function; import javax.inject.Inject; +import jogamp.newt.awt.NewtFactoryAWT; import lombok.extern.slf4j.Slf4j; import net.runelite.api.BufferProvider; import net.runelite.api.Client; @@ -231,10 +231,10 @@ public class GpuPlugin extends Plugin implements DrawCallbacks GLProfile glProfile = GLProfile.get(GLProfile.GL4bc); GLCapabilities glCaps = new GLCapabilities(glProfile); - AbstractGraphicsConfiguration config = AWTGraphicsConfiguration.create(canvas.getGraphicsConfiguration(), - glCaps, glCaps); + AWTGraphicsConfiguration config = AWTGraphicsConfiguration.create(canvas.getGraphicsConfiguration(), glCaps, glCaps); - jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(canvas, config); + jawtWindow = NewtFactoryAWT.getNativeWindow(canvas, config); + canvas.setFocusable(true); GLDrawableFactory glDrawableFactory = GLDrawableFactory.getFactory(glProfile); @@ -248,6 +248,11 @@ public class GpuPlugin extends Plugin implements DrawCallbacks throw new GLException("Unable to make context current"); } + if (jawtWindow.getLock().isLocked()) + { + jawtWindow.unlockSurface(); + } + this.gl = glContext.getGL().getGL4(); gl.setSwapInterval(0); @@ -316,6 +321,11 @@ public class GpuPlugin extends Plugin implements DrawCallbacks client.setGpu(false); client.setDrawCallbacks(null); + if (jawtWindow.getLock().getHoldCount() != NativeSurface.LOCK_SURFACE_NOT_READY) + { + jawtWindow.lockSurface(); + } + if (bufferId != -1) { GLUtil.glDeleteBuffer(gl, bufferId);