diff --git a/jme3-lwjgl/src/main/java/com/jme3/opencl/lwjgl/PlatformChooserImpl.java b/jme3-core/src/main/java/com/jme3/opencl/DefaultPlatformChooser.java similarity index 94% rename from jme3-lwjgl/src/main/java/com/jme3/opencl/lwjgl/PlatformChooserImpl.java rename to jme3-core/src/main/java/com/jme3/opencl/DefaultPlatformChooser.java index fd3a7147b..e07bdf4e1 100644 --- a/jme3-lwjgl/src/main/java/com/jme3/opencl/lwjgl/PlatformChooserImpl.java +++ b/jme3-core/src/main/java/com/jme3/opencl/DefaultPlatformChooser.java @@ -29,7 +29,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package com.jme3.opencl.lwjgl; +package com.jme3.opencl; import com.jme3.opencl.Device; import com.jme3.opencl.Platform; @@ -42,8 +42,8 @@ import java.util.logging.Logger; * * @author Sebastian Weiss */ -public class PlatformChooserImpl implements PlatformChooser { - private static final Logger LOG = Logger.getLogger(PlatformChooserImpl.class.getName()); +public class DefaultPlatformChooser implements PlatformChooser { + private static final Logger LOG = Logger.getLogger(DefaultPlatformChooser.class.getName()); @Override public List chooseDevices(List platforms) { diff --git a/jme3-core/src/main/java/com/jme3/opencl/OpenCLObjectManager.java b/jme3-core/src/main/java/com/jme3/opencl/OpenCLObjectManager.java index 2ba4293ef..7eebf4bb8 100644 --- a/jme3-core/src/main/java/com/jme3/opencl/OpenCLObjectManager.java +++ b/jme3-core/src/main/java/com/jme3/opencl/OpenCLObjectManager.java @@ -43,8 +43,8 @@ import java.util.logging.Logger; */ public class OpenCLObjectManager { private static final Logger LOG = Logger.getLogger(OpenCLObjectManager.class.getName()); - private static final Level LOG_LEVEL1 = Level.INFO; - private static final Level LOG_LEVEL2 = Level.INFO; + private static final Level LOG_LEVEL1 = Level.FINER; + private static final Level LOG_LEVEL2 = Level.FINE; /** * Call Runtime.getRuntime().gc() every these frames */ @@ -84,6 +84,10 @@ public class OpenCLObjectManager { } public void deleteUnusedObjects() { + if (activeObjects.isEmpty()) { + return; //nothing to do + } + gcCounter++; if (gcCounter >= GC_FREQUENCY) { //The program is that the OpenCLObjects are so small that they are diff --git a/jme3-core/src/main/java/com/jme3/system/AppSettings.java b/jme3-core/src/main/java/com/jme3/system/AppSettings.java index 991854ebf..4fc23a32e 100644 --- a/jme3-core/src/main/java/com/jme3/system/AppSettings.java +++ b/jme3-core/src/main/java/com/jme3/system/AppSettings.java @@ -31,6 +31,7 @@ */ package com.jme3.system; +import com.jme3.opencl.DefaultPlatformChooser; import com.jme3.opencl.PlatformChooser; import java.io.IOException; import java.io.InputStream; @@ -162,6 +163,7 @@ public final class AppSettings extends HashMap { defaults.put("Resizable", false); defaults.put("SwapBuffers", true); defaults.put("OpenCL", false); + defaults.put("OpenCLPlatformChooser", DefaultPlatformChooser.class.getName()); // defaults.put("Icons", null); } @@ -1039,7 +1041,7 @@ public final class AppSettings extends HashMap { * Sets a custom platform chooser. This chooser specifies which platform and * which devices are used for the OpenCL context. * - * Default: not set, an implementation defined one is used. + * Default: an implementation defined one. * * @param chooser the class of the chooser, must have a default constructor */ diff --git a/jme3-examples/src/main/java/jme3test/opencl/TestWriteToTexture.java b/jme3-examples/src/main/java/jme3test/opencl/TestWriteToTexture.java index 87b6f6b68..f453c4fd2 100644 --- a/jme3-examples/src/main/java/jme3test/opencl/TestWriteToTexture.java +++ b/jme3-examples/src/main/java/jme3test/opencl/TestWriteToTexture.java @@ -46,7 +46,9 @@ import com.jme3.ui.Picture; import java.util.logging.Logger; /** - * This test class tests the capability to write to a GL texture from OpenCL + * This test class tests the capability to write to a GL texture from OpenCL. + * Move the mouse around while pressing the left mouse key to modify the fractal. + * * @author Sebastian Weiss */ public class TestWriteToTexture extends SimpleApplication implements AnalogListener, ActionListener { @@ -67,7 +69,7 @@ public class TestWriteToTexture extends SimpleApplication implements AnalogListe TestWriteToTexture app = new TestWriteToTexture(); AppSettings settings = new AppSettings(true); settings.setOpenCLSupport(true); - settings.setVSync(true); + settings.setVSync(false); app.setSettings(settings); app.start(); // start the game } diff --git a/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglContext.java b/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglContext.java index 32767fa9b..68d46b1c7 100644 --- a/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglContext.java +++ b/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglContext.java @@ -39,7 +39,7 @@ import com.jme3.opencl.Device; import com.jme3.opencl.PlatformChooser; import com.jme3.opencl.lwjgl.LwjglDevice; import com.jme3.opencl.lwjgl.LwjglPlatform; -import com.jme3.opencl.lwjgl.PlatformChooserImpl; +import com.jme3.opencl.DefaultPlatformChooser; import com.jme3.renderer.Renderer; import com.jme3.renderer.RendererException; import com.jme3.renderer.lwjgl.LwjglGL; @@ -319,7 +319,7 @@ public abstract class LwjglContext implements JmeContext { } } if (chooser == null) { - chooser = new PlatformChooserImpl(); + chooser = new DefaultPlatformChooser(); } List choosenDevices = chooser.chooseDevices(platforms); List devices = new ArrayList<>(choosenDevices.size());