summaryrefslogtreecommitdiffstats
path: root/src/com/jogamp/opencl
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2011-06-18 03:01:20 +0200
committerMichael Bien <[email protected]>2011-06-18 03:01:20 +0200
commit00096ac5b2c824fc7e8d7203229c8f246caf833c (patch)
treeff26ced1eabf20ee92aed0eb46bd6ce0cb597feb /src/com/jogamp/opencl
parent4373f933333ecee50dea9686403b6f81759e3b07 (diff)
added another factory method to CLMultiContext.
Diffstat (limited to 'src/com/jogamp/opencl')
-rw-r--r--src/com/jogamp/opencl/util/CLDeviceFilters.java8
-rw-r--r--src/com/jogamp/opencl/util/CLMultiContext.java11
2 files changed, 14 insertions, 5 deletions
diff --git a/src/com/jogamp/opencl/util/CLDeviceFilters.java b/src/com/jogamp/opencl/util/CLDeviceFilters.java
index 045d4c7f..a5057fb6 100644
--- a/src/com/jogamp/opencl/util/CLDeviceFilters.java
+++ b/src/com/jogamp/opencl/util/CLDeviceFilters.java
@@ -32,6 +32,7 @@ import com.jogamp.opencl.CLCommandQueue.Mode;
import com.jogamp.opencl.CLDevice;
import java.nio.ByteOrder;
import java.util.Arrays;
+import java.util.EnumSet;
import java.util.List;
/**
@@ -45,13 +46,14 @@ public class CLDeviceFilters {
/**
* Accepts all devices of the given type.
*/
- public static Filter<CLDevice> type(final CLDevice.Type type) {
+ public static Filter<CLDevice> type(final CLDevice.Type... types) {
return new Filter<CLDevice>() {
+ private final EnumSet<CLDevice.Type> set = EnumSet.copyOf(Arrays.asList(types));
public boolean accept(CLDevice item) {
- if(type.equals(CLDevice.Type.ALL)) {
+ if(set.contains(CLDevice.Type.ALL)) {
return true;
}
- return item.getType().equals(type);
+ return set.contains(item.getType());
}
};
}
diff --git a/src/com/jogamp/opencl/util/CLMultiContext.java b/src/com/jogamp/opencl/util/CLMultiContext.java
index f74c0a35..eb42092e 100644
--- a/src/com/jogamp/opencl/util/CLMultiContext.java
+++ b/src/com/jogamp/opencl/util/CLMultiContext.java
@@ -41,7 +41,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 +57,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);
}