diff options
Diffstat (limited to 'src/com/jogamp/opencl/util/CLMultiContext.java')
-rw-r--r-- | src/com/jogamp/opencl/util/CLMultiContext.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/com/jogamp/opencl/util/CLMultiContext.java b/src/com/jogamp/opencl/util/CLMultiContext.java index f74c0a35..156a9fa6 100644 --- a/src/com/jogamp/opencl/util/CLMultiContext.java +++ b/src/com/jogamp/opencl/util/CLMultiContext.java @@ -25,6 +25,7 @@ import static com.jogamp.opencl.CLDevice.Type.*; public class CLMultiContext implements CLResource { private final List<CLContext> contexts; + private boolean released; private CLMultiContext() { contexts = new ArrayList<CLContext>(); @@ -41,7 +42,14 @@ public class CLMultiContext implements CLResource { * Creates a multi context with all devices of the specified platforms and types. */ public static CLMultiContext create(CLPlatform[] platforms, CLDevice.Type... types) { - + return create(platforms, CLDeviceFilters.type(types)); + } + + /** + * Creates a multi context with all matching devices of the specified platforms. + */ + public static CLMultiContext create(CLPlatform[] platforms, Filter<CLDevice>... filters) { + if(platforms == null) { throw new NullPointerException("platform list was null"); }else if(platforms.length == 0) { @@ -50,7 +58,7 @@ public class CLMultiContext implements CLResource { List<CLDevice> devices = new ArrayList<CLDevice>(); for (CLPlatform platform : platforms) { - devices.addAll(asList(platform.listCLDevices(types))); + devices.addAll(asList(platform.listCLDevices(filters))); } return create(devices); } @@ -125,7 +133,12 @@ public class CLMultiContext implements CLResource { * Releases all contexts. * @see CLContext#release() */ + @Override public void release() { + if(released) { + throw new RuntimeException(getClass().getSimpleName()+" already released"); + } + released = true; for (CLContext context : contexts) { context.release(); } @@ -147,6 +160,10 @@ public class CLMultiContext implements CLResource { return devices; } + public boolean isReleased() { + return released; + } + @Override public String toString() { return getClass().getSimpleName()+" [" + contexts.size()+" contexts, " |