diff options
author | Michael Bien <[email protected]> | 2011-04-26 15:21:54 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2011-04-26 15:21:54 +0200 |
commit | c00dc66867518f32d6a2615aa8da71a52489d5d8 (patch) | |
tree | e10f0d950f52d9a4d90d6b94f42980c5d217a7dc /src/com | |
parent | 315427ee632ada16ec48174f55f59588f95cd2b0 (diff) |
added glSharing(GLContext context) filter utitlity + code cleanup
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/jogamp/opencl/util/CLDeviceFilters.java | 7 | ||||
-rw-r--r-- | src/com/jogamp/opencl/util/CLPlatformFilters.java | 25 |
2 files changed, 26 insertions, 6 deletions
diff --git a/src/com/jogamp/opencl/util/CLDeviceFilters.java b/src/com/jogamp/opencl/util/CLDeviceFilters.java index a2ba0475..045d4c7f 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.List; /** * Pre-defined filters. @@ -82,8 +83,9 @@ public class CLDeviceFilters { */ public static Filter<CLDevice> extension(final String... extensions) { return new Filter<CLDevice>() { + private final List<String> extensionList = Arrays.asList(extensions); public boolean accept(CLDevice item) { - return item.getExtensions().containsAll(Arrays.asList(extensions)); + return item.getExtensions().containsAll(extensionList); } }; } @@ -93,8 +95,9 @@ public class CLDeviceFilters { */ public static Filter<CLDevice> queueMode(final Mode... modes) { return new Filter<CLDevice>() { + private final List<Mode> modeList = Arrays.asList(modes); public boolean accept(CLDevice item) { - return item.getQueueProperties().containsAll(Arrays.asList(modes)); + return item.getQueueProperties().containsAll(modeList); } }; } diff --git a/src/com/jogamp/opencl/util/CLPlatformFilters.java b/src/com/jogamp/opencl/util/CLPlatformFilters.java index dab7448f..48d20916 100644 --- a/src/com/jogamp/opencl/util/CLPlatformFilters.java +++ b/src/com/jogamp/opencl/util/CLPlatformFilters.java @@ -33,7 +33,8 @@ import com.jogamp.opencl.CLDevice; import com.jogamp.opencl.CLPlatform; import com.jogamp.opencl.CLVersion; import java.util.Arrays; -import java.util.List; +import javax.media.opengl.GL; +import javax.media.opengl.GLContext; /** * Pre-defined filters. @@ -70,10 +71,11 @@ public class CLPlatformFilters { */ public static Filter<CLPlatform> glSharing() { return new Filter<CLPlatform>() { + private final Filter<CLDevice> glFilter = CLDeviceFilters.glSharing(); public boolean accept(CLPlatform item) { CLDevice[] devices = item.listCLDevices(); for (CLDevice device : devices) { - if(device.isGLMemorySharingSupported()) { + if(glFilter.accept(device)) { return true; } } @@ -83,6 +85,21 @@ public class CLPlatformFilters { } /** + * Accepts all with the given OpenGL context compatible platforms containing at least one + * devices of which supports OpenGL-OpenCL interoparability. + */ + public static Filter<CLPlatform> glSharing(final GLContext context) { + return new Filter<CLPlatform>() { + private final Filter<CLPlatform> glFilter = glSharing(); + public boolean accept(CLPlatform item) { + String glVendor = context.getGL().glGetString(GL.GL_VENDOR); + String clVendor = item.getVendor(); + return clVendor.equals(glVendor) && glFilter.accept(item); + } + }; + } + + /** * Accepts all platforms supporting the given extensions. */ public static Filter<CLPlatform> extension(final String... extensions) { @@ -98,10 +115,10 @@ public class CLPlatformFilters { */ public static Filter<CLPlatform> queueMode(final Mode... modes) { return new Filter<CLPlatform>() { + private final Filter<CLDevice> queueModeFilter = CLDeviceFilters.queueMode(modes); public boolean accept(CLPlatform item) { - List<Mode> modesList = Arrays.asList(modes); for (CLDevice device : item.listCLDevices()) { - if(device.getQueueProperties().containsAll(modesList)) { + if(queueModeFilter.accept(device)) { return true; } } |