Quellcode durchsuchen

renamed DefaultPlatformChooser and moved it to the core, some small fixes

shamanDevel vor 9 Jahren
Ursprung
Commit
60f10bb604

+ 3 - 3
jme3-lwjgl/src/main/java/com/jme3/opencl/lwjgl/PlatformChooserImpl.java → 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<? extends Device> chooseDevices(List<? extends Platform> platforms) {

+ 6 - 2
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 

+ 3 - 1
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<String, Object> {
         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<String, Object> {
      * 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
      */

+ 4 - 2
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
     }

+ 2 - 2
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<? extends Device> choosenDevices = chooser.chooseDevices(platforms);
         List<CLDevice> devices = new ArrayList<>(choosenDevices.size());