aboutsummaryrefslogtreecommitdiffstats
path: root/src/demos
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-02-17 20:26:10 +0100
committerSven Göthel <[email protected]>2024-02-17 20:26:10 +0100
commit8bb2f6dec8ab731b07387b947715fa1959c680e4 (patch)
tree673236ebd39cc69b05579522c118010571b205f4 /src/demos
parent82288c112e910feae10ef3cfcded50e35395ed2b (diff)
Bug 1489: Lock-Free Double-Buffered 'renderedShapes' causes data-race between rendering & input-edt, use synchronized tripple-buffering
Tripple-buffering _almost_ produces zero data-race collisions, however .. it still does rarely -> hence synchronize on the used ArrayList<>. This adds a minimal chance for blocking the input-EDT, but gives correct code & results. Double-buffered 'renderedShapes' was introduced to resolve Bug 1489 in commit 5f9fb7159fa33bc979e5050d384b6939658049bd This solution is tested by passing '-swapInterval 0' via CommandlineOptions for FontView01, UIMediaGrid01 .., i.e. rendering faster than picking and hence provoking the data-race condition.
Diffstat (limited to 'src/demos')
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java4
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid01.java4
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java4
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java4
-rw-r--r--src/demos/com/jogamp/opengl/demos/util/CommandlineOptions.java6
5 files changed, 21 insertions, 1 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
index 770b1b724..5804c09c0 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
@@ -167,6 +167,10 @@ public class FontView01 {
final Animator animator = new Animator(0 /* w/o AWT */);
animator.setUpdateFPSFrames(1*60, null); // System.err);
final GLWindow window = GLWindow.create(reqCaps);
+ window.invoke(false, (final GLAutoDrawable glad) -> {
+ glad.getGL().setSwapInterval(options.swapInterval);
+ return true;
+ } );
window.setSize(options.surface_width, options.surface_height);
window.setTitle(FontView01.class.getSimpleName()+": "+font.getFullFamilyName()+", "+window.getSurfaceWidth()+" x "+window.getSurfaceHeight());
window.setVisible(true);
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid01.java
index 29ee9ab2c..7b9053ab0 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UIMediaGrid01.java
@@ -216,6 +216,10 @@ public class UIMediaGrid01 {
final Animator animator = new Animator(0 /* w/o AWT */);
animator.setUpdateFPSFrames(1*60, null); // System.err);
final GLWindow window = GLWindow.create(reqCaps);
+ window.invoke(false, (final GLAutoDrawable glad) -> {
+ glad.getGL().setSwapInterval(options.swapInterval);
+ return true;
+ } );
window.setSize(options.surface_width, options.surface_height);
window.setVisible(true);
System.out.println("Chosen: " + window.getChosenGLCapabilities());
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java
index 98ea52771..0e7ddbeb8 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo03.java
@@ -194,6 +194,10 @@ public class UISceneDemo03 {
animator.setUpdateFPSFrames(1 * 60, null); // System.err);
final GLWindow window = GLWindow.create(reqCaps);
+ window.invoke(false, (final GLAutoDrawable glad) -> {
+ glad.getGL().setSwapInterval(options.swapInterval);
+ return true;
+ } );
window.setSize(options.surface_width, options.surface_height);
window.setTitle(UISceneDemo03.class.getSimpleName() + ": " + window.getSurfaceWidth() + " x " + window.getSurfaceHeight());
window.setVisible(true);
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
index 47c84c914..6336bb2bc 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
@@ -155,6 +155,10 @@ public class UISceneDemo20 implements GLEventListener {
System.out.println("Requested: " + caps);
final GLWindow window = GLWindow.create(screen, caps);
+ window.invoke(false, (final GLAutoDrawable glad) -> {
+ glad.getGL().setSwapInterval(options.swapInterval);
+ return true;
+ } );
if( 0 == options.sceneMSAASamples ) {
window.setCapabilitiesChooser(new NonFSAAGLCapsChooser(false));
}
diff --git a/src/demos/com/jogamp/opengl/demos/util/CommandlineOptions.java b/src/demos/com/jogamp/opengl/demos/util/CommandlineOptions.java
index 3a3f2f365..60de2c1f0 100644
--- a/src/demos/com/jogamp/opengl/demos/util/CommandlineOptions.java
+++ b/src/demos/com/jogamp/opengl/demos/util/CommandlineOptions.java
@@ -44,6 +44,7 @@ public class CommandlineOptions {
public boolean wait_to_start = false;
public boolean keepRunning = false;
public boolean stayOpen = false;
+ public int swapInterval = -1; // auto
public float total_duration = 0f; // [s]
static {
@@ -153,6 +154,9 @@ public class CommandlineOptions {
stayOpen = true;
} else if (args[idx[0]].equals("-stay")) {
stayOpen = true;
+ } else if (args[idx[0]].equals("-swapInterval")) {
+ ++idx[0];
+ swapInterval = MiscUtils.atoi(args[idx[0]], swapInterval);
} else if (args[idx[0]].equals("-duration")) {
++idx[0];
total_duration = MiscUtils.atof(args[idx[0]], total_duration);
@@ -180,7 +184,7 @@ public class CommandlineOptions {
return "Options{surface[width "+surface_width+" x "+surface_height+"], glp "+glProfileName+
", renderModes "+Region.getRenderModeString(renderModes)+", aa-q "+graphAAQuality+
", gmsaa "+graphAASamples+", smsaa "+sceneMSAASamples+
- ", exclusiveContext "+exclusiveContext+", wait "+wait_to_start+", keep "+keepRunning+", stay "+stayOpen+", dur "+total_duration+"s"+
+ ", exclusiveContext "+exclusiveContext+", wait "+wait_to_start+", keep "+keepRunning+", stay "+stayOpen+", swap-ival "+swapInterval+", dur "+total_duration+"s"+
"}";
}
}