Skip to content

Commit 720ea79

Browse files
authored
Merge pull request #1582 from catilac/run-webgpu-in-pde
Run WEBGPU sketches in PDE
2 parents be0ee82 + da0b932 commit 720ea79

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

‎java/src/processing/mode/java/runner/Runner.java‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,18 @@ public boolean launchVirtualMachine(boolean present, String[] args) {
294294
}
295295

296296

297+
// the results of `build.sketchRunner()` returns a string without being checked so this is actually a code-smell.
298+
// This function should not exist.
299+
// In a better world as I understand it now, we should be making some fixes in the PreProcessor
300+
// There are two things to consider at this moment:
301+
// When we use the constant P2D or P3D there is actually no check for converting this into the PConstant.* value.
302+
// So it doesn't actually do anything. WEBGPU actually does do something which led to this function.
303+
// TODO: Lets try to remove this function, or create something that considers P2D and P3D
304+
// This will lead to cleaning up the PreProcessor and help us learn its architecture so we can move towards a healthy refactor.
305+
static private boolean isWebGPU(String renderer) {
306+
return "WEBGPU".equals(renderer) || PConstants.WEBGPU.equals(renderer);
307+
}
308+
297309
protected StringList getMachineParams() {
298310
StringList params = new StringList();
299311

@@ -343,7 +355,7 @@ protected StringList getMachineParams() {
343355
//params.append("-Dcom.apple.mrj.application.apple.menu.about.name=" +
344356
// build.getSketchClassName());
345357

346-
if (PConstants.WEBGPU.equals(build.getSketchRenderer())) {
358+
if (isWebGPU(build.getSketchRenderer())) {
347359
params.append("-XstartOnFirstThread");
348360
}
349361
}
@@ -518,7 +530,7 @@ protected StringList getSketchParams(boolean present, String[] args) {
518530
// Only disable AWT for the WebGPU renderer, which uses GLFW and
519531
// cannot coexist with AWT. All other renderers still depend on AWT
520532
// for display detection, displayWidth/displayHeight, pixelDensity(), etc.
521-
if (PConstants.WEBGPU.equals(build.getSketchRenderer())) {
533+
if (isWebGPU(build.getSketchRenderer())) {
522534
params.append(PApplet.ARGS_DISABLE_AWT);
523535
}
524536

0 commit comments

Comments
 (0)