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

define_list_fix
shamanDevel 9 years ago
parent 0c47bf18c9
commit 60f10bb604
  1. 6
      jme3-core/src/main/java/com/jme3/opencl/DefaultPlatformChooser.java
  2. 8
      jme3-core/src/main/java/com/jme3/opencl/OpenCLObjectManager.java
  3. 4
      jme3-core/src/main/java/com/jme3/system/AppSettings.java
  4. 6
      jme3-examples/src/main/java/jme3test/opencl/TestWriteToTexture.java
  5. 4
      jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglContext.java

@ -29,7 +29,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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.Device;
import com.jme3.opencl.Platform; import com.jme3.opencl.Platform;
@ -42,8 +42,8 @@ import java.util.logging.Logger;
* *
* @author Sebastian Weiss * @author Sebastian Weiss
*/ */
public class PlatformChooserImpl implements PlatformChooser { public class DefaultPlatformChooser implements PlatformChooser {
private static final Logger LOG = Logger.getLogger(PlatformChooserImpl.class.getName()); private static final Logger LOG = Logger.getLogger(DefaultPlatformChooser.class.getName());
@Override @Override
public List<? extends Device> chooseDevices(List<? extends Platform> platforms) { public List<? extends Device> chooseDevices(List<? extends Platform> platforms) {

@ -43,8 +43,8 @@ import java.util.logging.Logger;
*/ */
public class OpenCLObjectManager { public class OpenCLObjectManager {
private static final Logger LOG = Logger.getLogger(OpenCLObjectManager.class.getName()); private static final Logger LOG = Logger.getLogger(OpenCLObjectManager.class.getName());
private static final Level LOG_LEVEL1 = Level.INFO; private static final Level LOG_LEVEL1 = Level.FINER;
private static final Level LOG_LEVEL2 = Level.INFO; private static final Level LOG_LEVEL2 = Level.FINE;
/** /**
* Call Runtime.getRuntime().gc() every these frames * Call Runtime.getRuntime().gc() every these frames
*/ */
@ -84,6 +84,10 @@ public class OpenCLObjectManager {
} }
public void deleteUnusedObjects() { public void deleteUnusedObjects() {
if (activeObjects.isEmpty()) {
return; //nothing to do
}
gcCounter++; gcCounter++;
if (gcCounter >= GC_FREQUENCY) { if (gcCounter >= GC_FREQUENCY) {
//The program is that the OpenCLObjects are so small that they are //The program is that the OpenCLObjects are so small that they are

@ -31,6 +31,7 @@
*/ */
package com.jme3.system; package com.jme3.system;
import com.jme3.opencl.DefaultPlatformChooser;
import com.jme3.opencl.PlatformChooser; import com.jme3.opencl.PlatformChooser;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -162,6 +163,7 @@ public final class AppSettings extends HashMap<String, Object> {
defaults.put("Resizable", false); defaults.put("Resizable", false);
defaults.put("SwapBuffers", true); defaults.put("SwapBuffers", true);
defaults.put("OpenCL", false); defaults.put("OpenCL", false);
defaults.put("OpenCLPlatformChooser", DefaultPlatformChooser.class.getName());
// defaults.put("Icons", null); // 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 * Sets a custom platform chooser. This chooser specifies which platform and
* which devices are used for the OpenCL context. * 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 * @param chooser the class of the chooser, must have a default constructor
*/ */

@ -46,7 +46,9 @@ import com.jme3.ui.Picture;
import java.util.logging.Logger; 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 * @author Sebastian Weiss
*/ */
public class TestWriteToTexture extends SimpleApplication implements AnalogListener, ActionListener { public class TestWriteToTexture extends SimpleApplication implements AnalogListener, ActionListener {
@ -67,7 +69,7 @@ public class TestWriteToTexture extends SimpleApplication implements AnalogListe
TestWriteToTexture app = new TestWriteToTexture(); TestWriteToTexture app = new TestWriteToTexture();
AppSettings settings = new AppSettings(true); AppSettings settings = new AppSettings(true);
settings.setOpenCLSupport(true); settings.setOpenCLSupport(true);
settings.setVSync(true); settings.setVSync(false);
app.setSettings(settings); app.setSettings(settings);
app.start(); // start the game app.start(); // start the game
} }

@ -39,7 +39,7 @@ import com.jme3.opencl.Device;
import com.jme3.opencl.PlatformChooser; import com.jme3.opencl.PlatformChooser;
import com.jme3.opencl.lwjgl.LwjglDevice; import com.jme3.opencl.lwjgl.LwjglDevice;
import com.jme3.opencl.lwjgl.LwjglPlatform; 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.Renderer;
import com.jme3.renderer.RendererException; import com.jme3.renderer.RendererException;
import com.jme3.renderer.lwjgl.LwjglGL; import com.jme3.renderer.lwjgl.LwjglGL;
@ -319,7 +319,7 @@ public abstract class LwjglContext implements JmeContext {
} }
} }
if (chooser == null) { if (chooser == null) {
chooser = new PlatformChooserImpl(); chooser = new DefaultPlatformChooser();
} }
List<? extends Device> choosenDevices = chooser.chooseDevices(platforms); List<? extends Device> choosenDevices = chooser.chooseDevices(platforms);
List<CLDevice> devices = new ArrayList<>(choosenDevices.size()); List<CLDevice> devices = new ArrayList<>(choosenDevices.size());

Loading…
Cancel
Save