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] 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);