Skip to content
This repository was archived by the owner on Jun 19, 2024. It is now read-only.

Commit b52021d

Browse files
authored
Merge pull request #46 from LabyMod/fix-gpu-driver
Fix gpu driver
2 parents b451583 + 8e4d7a7 commit b52021d

File tree

53 files changed

+4633
-165
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+4633
-165
lines changed

example/lwjgl3-opengl/build.gradle

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import org.apache.tools.ant.taskdefs.condition.Os
2+
import groovy.json.JsonOutput
3+
24

35
plugins {
46
id 'application'
@@ -20,6 +22,7 @@ def lwjglClassifier = {
2022

2123
repositories {
2224
mavenCentral()
25+
mavenLocal()
2326
}
2427

2528
dependencies {
@@ -34,6 +37,7 @@ dependencies {
3437

3538
implementation group: 'org.lwjgl', name: 'lwjgl-glfw', version: '3.2.2'
3639
runtimeOnly group: 'org.lwjgl', name: 'lwjgl-glfw', version: '3.2.2', classifier: lwjglClassifier()
40+
3741
}
3842

3943
def runDir = file("run")
@@ -70,4 +74,97 @@ task copyResources(type: Copy) {
7074
into runDir
7175
}
7276

77+
task printRunCmd {
78+
doLast {
79+
println tasks.run.commandLine.join(" ")
80+
}
81+
}
82+
7383
run.dependsOn copyResources
84+
85+
86+
def platformExtension() {
87+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
88+
return ".exe"
89+
} else {
90+
return ""
91+
}
92+
}
93+
94+
def findRenderdoc() {
95+
def qRenderdoc = "qrenderdoc${platformExtension()}"
96+
97+
for (String pathEntry : System.getenv("PATH").split(File.pathSeparator)) {
98+
def qRenderdocEntryFile = file("${pathEntry}${File.separator}${qRenderdoc}")
99+
if (qRenderdocEntryFile.exists()) {
100+
return qRenderdocEntryFile.absolutePath
101+
}
102+
}
103+
104+
if (Os.isFamily(Os.FAMILY_UNIX)) {
105+
def qRenderdocDefaultFile = file("/usr/bin/qrenderdoc")
106+
if (qRenderdocDefaultFile.exists()) {
107+
return qRenderdocDefaultFile.absolutePath
108+
}
109+
} else if (Os.isFamily(Os.FAMILY_WINDOWS)) {
110+
def qRenderdocDefaultFile = file("C:\\Program Files\\RenderDoc\\qrenderdoc.exe")
111+
if (qRenderdocDefaultFile.exists()) {
112+
return qRenderdocDefaultFile.absolutePath
113+
}
114+
}
115+
116+
throw new IllegalStateException("Failed to find qrenderdoc, searched PATH and, if available, standard locations")
117+
}
118+
119+
task runWithRenderdoc {
120+
dependsOn build
121+
doLast {
122+
File.createTempFile("temp", ".cap").with { renderdocCaptureFile ->
123+
renderdocCaptureFile.deleteOnExit()
124+
125+
def commandLine = tasks.run.getCommandLine()
126+
def executable = commandLine.get(0)
127+
def args = commandLine.subList(1, commandLine.size())
128+
129+
def environmentVars = tasks.run.getEnvironment().collect { key, value ->
130+
return [
131+
separator: "Platform style",
132+
type : "Set",
133+
value : value,
134+
variable : key
135+
]
136+
}
137+
138+
renderdocCaptureFile.text = JsonOutput.toJson([
139+
rdocCaptureSettings: 1,
140+
settings : [
141+
autoStart : true,
142+
commandLine : "${args.join(" ")}",
143+
environment : environmentVars,
144+
executable : "${executable}",
145+
inject : false,
146+
numQueuedFrames: 0,
147+
options : [
148+
allowFullscreen : true,
149+
allowVSync : true,
150+
apiValidation : false,
151+
captureAllCmdLists : false,
152+
captureCallstacks : false,
153+
captureCallstacksOnlyDraws: false,
154+
debugOutputMute : true,
155+
delayForDebugger : 0,
156+
hookIntoChildren : false,
157+
refAllResources : false,
158+
verifyBufferAccess : false
159+
],
160+
queueFrameCap : 0,
161+
workingDir : "${tasks.run.getWorkingDir().absolutePath}"
162+
]
163+
])
164+
165+
exec {
166+
it.commandLine findRenderdoc(), renderdocCaptureFile.absolutePath
167+
}
168+
}
169+
}
170+
}

example/lwjgl3-opengl/src/main/java/com/labymedia/ultralight/lwjgl3/opengl/ExampleApplication.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*/
4343
public class ExampleApplication {
4444
private final long window;
45-
private final InputAdapter inputAdapter;
45+
private InputAdapter inputAdapter;
4646
private final CursorAdapter cursorManager;
4747
private final WebController webController;
4848

@@ -68,17 +68,8 @@ public ExampleApplication() {
6868

6969
// Set up various internal controllers
7070
this.cursorManager = new CursorAdapter(window);
71-
this.webController = new WebController(cursorManager);
72-
this.inputAdapter = webController.getInputAdapter();
71+
this.webController = new WebController(cursorManager, window);
7372

74-
// Register all the GLFW callbacks required by this application
75-
setCallback(GLFW::glfwSetWindowContentScaleCallback, inputAdapter::windowContentScaleCallback);
76-
setCallback(GLFW::glfwSetKeyCallback, inputAdapter::keyCallback);
77-
setCallback(GLFW::glfwSetCharCallback, inputAdapter::charCallback);
78-
setCallback(GLFW::glfwSetCursorPosCallback, inputAdapter::cursorPosCallback);
79-
setCallback(GLFW::glfwSetMouseButtonCallback, inputAdapter::mouseButtonCallback);
80-
setCallback(GLFW::glfwSetScrollCallback, inputAdapter::scrollCallback);
81-
setCallback(GLFW::glfwSetWindowFocusCallback, inputAdapter::focusCallback);
8273
}
8374

8475
/**
@@ -162,11 +153,25 @@ public void stop() {
162153
public void run() {
163154
// Make the window's OpenGL context the current one
164155
glfwMakeContextCurrent(window);
165-
glfwSwapInterval(1);
156+
glfwSwapInterval(0);
166157

167158
// Initialize OpenGL capabilities
168159
GL.createCapabilities();
169160

161+
webController.initGPUDriver();
162+
163+
this.inputAdapter = webController.getInputAdapter();
164+
165+
// Register all the GLFW callbacks required by this application
166+
setCallback(GLFW::glfwSetWindowContentScaleCallback, inputAdapter::windowContentScaleCallback);
167+
setCallback(GLFW::glfwSetKeyCallback, inputAdapter::keyCallback);
168+
setCallback(GLFW::glfwSetCharCallback, inputAdapter::charCallback);
169+
setCallback(GLFW::glfwSetCursorPosCallback, inputAdapter::cursorPosCallback);
170+
setCallback(GLFW::glfwSetMouseButtonCallback, inputAdapter::mouseButtonCallback);
171+
setCallback(GLFW::glfwSetScrollCallback, inputAdapter::scrollCallback);
172+
setCallback(GLFW::glfwSetWindowFocusCallback, inputAdapter::focusCallback);
173+
174+
170175
// Manually update focus for the first time
171176
inputAdapter.focusCallback(window, glfwGetWindowAttrib(window, GLFW_FOCUSED) != 0);
172177

example/lwjgl3-opengl/src/main/java/com/labymedia/ultralight/lwjgl3/opengl/ExampleMain.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.nio.file.Path;
2929
import java.nio.file.Paths;
3030
import java.nio.file.StandardCopyOption;
31-
import java.util.concurrent.CountDownLatch;
3231

3332
/**
3433
* Entry pointer for the example application.

example/lwjgl3-opengl/src/main/java/com/labymedia/ultralight/lwjgl3/opengl/drawing/OpenGLDrawer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ public class OpenGLDrawer {
3333
public void draw() {
3434
glDisable(GL_DEPTH_TEST);
3535
glEnable(GL_ALPHA_TEST);
36-
36+
glUseProgram(0);
3737
glPushMatrix();
38-
glRotatef(rotation++, 0, 0, 1);
38+
rotation += 0.01;
39+
glRotatef(rotation, 0, 0, 1);
3940
glBegin(GL_TRIANGLES);
4041

4142

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Ultralight Java - Java wrapper for the Ultralight web engine
3+
* Copyright (C) 2020 - 2021 LabyMedia and contributors
4+
*
5+
* This program is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU Lesser General Public
7+
* License as published by the Free Software Foundation; either
8+
* version 3 of the License, or (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this program; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18+
*/
19+
20+
package com.labymedia.ultralight.lwjgl3.opengl.gpu;
21+
22+
public class FBOEntry {
23+
long fboId;
24+
long msaaFboId;
25+
boolean needsResolve;
26+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Ultralight Java - Java wrapper for the Ultralight web engine
3+
* Copyright (C) 2020 - 2021 LabyMedia and contributors
4+
*
5+
* This program is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU Lesser General Public
7+
* License as published by the Free Software Foundation; either
8+
* version 3 of the License, or (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this program; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18+
*/
19+
20+
package com.labymedia.ultralight.lwjgl3.opengl.gpu;
21+
22+
public class GPUContextGL {
23+
private long window;
24+
25+
public boolean msaaEnabled() {
26+
return false;
27+
}
28+
29+
public boolean isEnableOffscreenGl() {
30+
return false;
31+
}
32+
33+
public long getActiveWindow() {
34+
return window;
35+
}
36+
37+
public void setActiveWindow(long window){
38+
this.window = window;
39+
}
40+
}

0 commit comments

Comments
 (0)