summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-03-16 22:55:32 +0100
committerMichael Bien <[email protected]>2010-03-16 22:55:32 +0100
commit36a289538cdb9373d8eb7700e616f019231ab591 (patch)
tree6310f16df3195b3d7553dde34ef52bca84270461
parent919d8e9f992c07ab18ddd6d192d6747e8d7aa40b (diff)
get(GL)Context() and getCL() getters.
fix in isGLMemorySharingSupported() on mac. javadoc fixes.
-rw-r--r--src/com/mbien/opencl/CLContext.java7
-rw-r--r--src/com/mbien/opencl/CLDevice.java14
-rw-r--r--src/com/mbien/opencl/gl/CLGLBuffer.java10
-rw-r--r--src/com/mbien/opencl/gl/CLGLContext.java27
-rw-r--r--src/com/mbien/opencl/gl/CLGLImage2d.java10
-rw-r--r--src/com/mbien/opencl/gl/CLGLObject.java11
-rw-r--r--src/com/mbien/opencl/gl/CLGLTexture.java2
-rw-r--r--src/com/mbien/opencl/gl/CLGLTexture2d.java1
-rw-r--r--src/com/mbien/opencl/gl/CLGLTexture3d.java14
9 files changed, 85 insertions, 11 deletions
diff --git a/src/com/mbien/opencl/CLContext.java b/src/com/mbien/opencl/CLContext.java
index 2698a934..bac542c0 100644
--- a/src/com/mbien/opencl/CLContext.java
+++ b/src/com/mbien/opencl/CLContext.java
@@ -447,6 +447,13 @@ public class CLContext extends CLObject implements CLResource {
return devices;
}
+ /**
+ * Return the low level OpenCL interface.
+ */
+ public CL getCL() {
+ return cl;
+ }
+
CLDevice getDevice(long dID) {
CLDevice[] deviceArray = getDevices();
for (int i = 0; i < deviceArray.length; i++) {
diff --git a/src/com/mbien/opencl/CLDevice.java b/src/com/mbien/opencl/CLDevice.java
index 01f9211f..d70f2afd 100644
--- a/src/com/mbien/opencl/CLDevice.java
+++ b/src/com/mbien/opencl/CLDevice.java
@@ -416,7 +416,7 @@ public final class CLDevice extends CLObject {
}
/**
- * Returns the command-queue properties properties supported by the device.
+ * Returns the command-queue properties supported by the device.
*/
public EnumSet<CLCommandQueue.Mode> getQueueProperties() {
return CLCommandQueue.Mode.valuesOf((int)deviceInfo.getLong(CL_DEVICE_QUEUE_PROPERTIES));
@@ -455,27 +455,27 @@ public final class CLDevice extends CLObject {
}
/**
- * Returns {@link #getExtensions()}.contains("cl_khr_fp16");
+ * Returns {@link #isExtensionAvailable("cl_khr_fp16");
* @see #getExtensions()
*/
public boolean isHalfFPAvailable() {
- return getExtensions().contains("cl_khr_fp16");
+ return isExtensionAvailable("cl_khr_fp16");
}
/**
- * Returns {@link #getExtensions()}.contains("cl_khr_fp64");
+ * Returns {@link #isExtensionAvailable("cl_khr_fp64");
* @see #getExtensions()
*/
public boolean isDoubleFPAvailable() {
- return getExtensions().contains("cl_khr_fp64");
+ return isExtensionAvailable("cl_khr_fp64");
}
/**
- * Returns {@link #getExtensions()}.contains("cl_khr_gl_sharing");
+ * Returns {@link #isExtensionAvailable("cl_khr_gl_sharing") || isExtensionAvailable("cl_apple_gl_sharing");
* @see #getExtensions()
*/
public boolean isGLMemorySharingSupported() {
- return getExtensions().contains("cl_khr_gl_sharing");
+ return isExtensionAvailable("cl_khr_gl_sharing") || isExtensionAvailable("cl_apple_gl_sharing");
}
/**
diff --git a/src/com/mbien/opencl/gl/CLGLBuffer.java b/src/com/mbien/opencl/gl/CLGLBuffer.java
index 1856e2ff..97a25626 100644
--- a/src/com/mbien/opencl/gl/CLGLBuffer.java
+++ b/src/com/mbien/opencl/gl/CLGLBuffer.java
@@ -5,6 +5,7 @@ import com.mbien.opencl.CLBuffer;
import com.mbien.opencl.CLContext;
import com.mbien.opencl.CLMemory.GLObjectType;
import java.nio.Buffer;
+import javax.media.opengl.GLContext;
/**
@@ -55,6 +56,15 @@ public final class CLGLBuffer<B extends Buffer> extends CLBuffer<B> implements C
}
@Override
+ public CLGLContext getContext() {
+ return (CLGLContext) super.getContext();
+ }
+
+ public GLContext getGLContext() {
+ return getContext().getGLContext();
+ }
+
+ @Override
public <T extends Buffer> CLGLBuffer<T> cloneWith(T directBuffer) {
return new CLGLBuffer<T>(context, directBuffer, ID, GLID, FLAGS);
}
diff --git a/src/com/mbien/opencl/gl/CLGLContext.java b/src/com/mbien/opencl/gl/CLGLContext.java
index 3c6711f5..ec0f909f 100644
--- a/src/com/mbien/opencl/gl/CLGLContext.java
+++ b/src/com/mbien/opencl/gl/CLGLContext.java
@@ -22,10 +22,12 @@ import static com.mbien.opencl.gl.CLGLI.*;
public final class CLGLContext extends CLContext {
final long glID;
+ private final GLContext glContext;
- private CLGLContext(CLPlatform platform, long clContextID, long glContextID) {
+ private CLGLContext(CLPlatform platform, GLContext glContext, long clContextID, long glContextID) {
super(platform, clContextID);
this.glID = glContextID;
+ this.glContext = glContext;
}
/**
@@ -72,7 +74,7 @@ public final class CLGLContext extends CLContext {
PointerBuffer properties = setupContextProperties(platform, glContext, glID);
long clID = createContextFromType(properties, toDeviceBitmap(deviceTypes));
- return new CLGLContext(platform, clID, glID[0]);
+ return new CLGLContext(platform, glContext, clID, glID[0]);
}
@@ -90,7 +92,7 @@ public final class CLGLContext extends CLContext {
PointerBuffer properties = setupContextProperties(platform, glContext, glID);
long clID = createContext(properties, devices);
- CLGLContext context = new CLGLContext(platform, clID, glID[0]);
+ CLGLContext context = new CLGLContext(platform, glContext, clID, glID[0]);
if(devices != null) {
for (int i = 0; i < devices.length; i++) {
context.overrideContext(devices[i]);
@@ -225,5 +227,24 @@ public final class CLGLContext extends CLContext {
return buffer;
}
+ /**
+ * Return the low level OpenCL interface with OpenGL interoperability.
+ */
+ @Override
+ public CLGLI getCL() {
+ return (CLGLI)super.getCL();
+ }
+
+ /**
+ * Returns the OpenGL context this context was shared with.
+ */
+ public GLContext getGLContext() {
+ return glContext;
+ }
+
+ @Override
+ public CLGLContext getContext() {
+ return this;
+ }
}
diff --git a/src/com/mbien/opencl/gl/CLGLImage2d.java b/src/com/mbien/opencl/gl/CLGLImage2d.java
index 0561e757..853c057e 100644
--- a/src/com/mbien/opencl/gl/CLGLImage2d.java
+++ b/src/com/mbien/opencl/gl/CLGLImage2d.java
@@ -7,6 +7,7 @@ import com.mbien.opencl.CLImageFormat;
import com.mbien.opencl.CLMemory.GLObjectType;
import com.mbien.opencl.impl.CLImageFormatImpl;
import java.nio.Buffer;
+import javax.media.opengl.GLContext;
import static com.mbien.opencl.CL.*;
@@ -61,4 +62,13 @@ public class CLGLImage2d<B extends Buffer> extends CLImage2d<B> implements CLGLO
return GLID;
}
+ @Override
+ public CLGLContext getContext() {
+ return (CLGLContext) super.getContext();
+ }
+
+ public GLContext getGLContext() {
+ return getContext().getGLContext();
+ }
+
}
diff --git a/src/com/mbien/opencl/gl/CLGLObject.java b/src/com/mbien/opencl/gl/CLGLObject.java
index 51a730ed..84c3ecef 100644
--- a/src/com/mbien/opencl/gl/CLGLObject.java
+++ b/src/com/mbien/opencl/gl/CLGLObject.java
@@ -4,6 +4,7 @@
package com.mbien.opencl.gl;
import com.mbien.opencl.CLMemory.GLObjectType;
+import javax.media.opengl.GLContext;
/**
*
@@ -20,5 +21,15 @@ interface CLGLObject {
* Returns the OpenGL buffer type of this shared object.
*/
public GLObjectType getGLObjectType();
+
+ /**
+ * Returns the OpenCL context of this shared object.
+ */
+ public CLGLContext getContext();
+
+ /**
+ * Returns the OpenGL context of this shared object.
+ */
+ public GLContext getGLContext();
}
diff --git a/src/com/mbien/opencl/gl/CLGLTexture.java b/src/com/mbien/opencl/gl/CLGLTexture.java
index 49fe4cb2..246f7d06 100644
--- a/src/com/mbien/opencl/gl/CLGLTexture.java
+++ b/src/com/mbien/opencl/gl/CLGLTexture.java
@@ -8,7 +8,7 @@ package com.mbien.opencl.gl;
*
* @author Michael Bien
*/
-interface CLGLTexture {
+interface CLGLTexture extends CLGLObject {
/**
* Returns the OpenGL texture target of this texture.
diff --git a/src/com/mbien/opencl/gl/CLGLTexture2d.java b/src/com/mbien/opencl/gl/CLGLTexture2d.java
index eec6127c..37c9a28a 100644
--- a/src/com/mbien/opencl/gl/CLGLTexture2d.java
+++ b/src/com/mbien/opencl/gl/CLGLTexture2d.java
@@ -6,6 +6,7 @@ import com.mbien.opencl.CLImageFormat;
import com.mbien.opencl.CLMemory.GLObjectType;
import com.mbien.opencl.impl.CLImageFormatImpl;
import java.nio.Buffer;
+import javax.media.opengl.GLContext;
import static com.mbien.opencl.CL.*;
diff --git a/src/com/mbien/opencl/gl/CLGLTexture3d.java b/src/com/mbien/opencl/gl/CLGLTexture3d.java
index e1fef3a9..0a25c890 100644
--- a/src/com/mbien/opencl/gl/CLGLTexture3d.java
+++ b/src/com/mbien/opencl/gl/CLGLTexture3d.java
@@ -7,6 +7,7 @@ import com.mbien.opencl.CLImageFormat;
import com.mbien.opencl.CLMemory.GLObjectType;
import com.mbien.opencl.impl.CLImageFormatImpl;
import java.nio.Buffer;
+import javax.media.opengl.GLContext;
import static com.mbien.opencl.CL.*;
@@ -70,4 +71,17 @@ public class CLGLTexture3d<B extends Buffer> extends CLImage3d<B> implements CLG
return GLObjectType.GL_OBJECT_TEXTURE3D;
}
+ /**
+ * Returns the shared CLGLContext.
+ */
+ @Override
+ public CLGLContext getContext() {
+ return (CLGLContext) super.getContext();
+ }
+
+ @Override
+ public GLContext getGLContext() {
+ return getContext().getGLContext();
+ }
+
}