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 e15688a43..1a28eada3 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 @@ -35,6 +35,7 @@ package com.jme3.system.lwjgl; import com.jme3.input.lwjgl.JInputJoyInput; import com.jme3.input.lwjgl.LwjglKeyInput; import com.jme3.input.lwjgl.LwjglMouseInput; +import com.jme3.opencl.Context; import com.jme3.opencl.lwjgl.LwjglCL; import com.jme3.renderer.Renderer; import com.jme3.renderer.RendererException; @@ -63,9 +64,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.lwjgl.LWJGLException; import org.lwjgl.Sys; -import org.lwjgl.opencl.CL; -import org.lwjgl.opencl.CL10; -import org.lwjgl.opencl.CLPlatform; +import org.lwjgl.opencl.*; import org.lwjgl.opengl.*; /** @@ -90,7 +89,7 @@ public abstract class LwjglContext implements JmeContext { protected LwjglCL clImpl; protected CLPlatform clPlatform; - protected com.jme3.opencl.Context context; + protected com.jme3.opencl.Context clContext; public void setSystemListener(SystemListener listener) { this.listener = listener; @@ -268,6 +267,7 @@ public abstract class LwjglContext implements JmeContext { return; } + //load platforms List platforms = CLPlatform.getPlatforms(); StringBuilder platformInfos = new StringBuilder(); platformInfos.append("Available OpenCL platforms:\n"); @@ -282,6 +282,7 @@ public abstract class LwjglContext implements JmeContext { boolean supportsInterop = platform.getInfoString(CL10.CL_PLATFORM_EXTENSIONS).contains("cl_khr_gl_sharing"); platformInfos.append(" * Supports Interop: ").append(supportsInterop).append("\n"); if (supportsInterop) { + possiblePlatforms.add(i); } } @@ -291,9 +292,47 @@ public abstract class LwjglContext implements JmeContext { return; } int platformIndex = possiblePlatforms.get(0); + //TODO: add API to choose the platform logger.info("Choose platform with index "+(platformIndex+1)); + clPlatform = platforms.get(platformIndex); + //load devices + List devices = clPlatform.getDevices(CL10.CL_DEVICE_TYPE_GPU); + StringBuilder deviceInfos = new StringBuilder(); + deviceInfos.append("Available OpenCL devices:\n"); + ArrayList possibleDevices = new ArrayList(); + for (int i=0; i