aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-03-08 17:08:03 +0100
committerMichael Bien <[email protected]>2010-03-08 17:08:03 +0100
commite081f13ca50353a7a9c34438a2f81d38e03e88a7 (patch)
tree7948e78a8e73fb4de5340a80075d35a8a1499c1f /src/com/mbien/opencl
parent5ad19147a76f80635dcae18693929edbf1da2cbf (diff)
introduced gl package and moved all interoperability functionality into it.
Diffstat (limited to 'src/com/mbien/opencl')
-rw-r--r--src/com/mbien/opencl/CLContext.java4
-rw-r--r--src/com/mbien/opencl/CLImage.java6
-rw-r--r--src/com/mbien/opencl/CLInfoAccessor.java4
-rw-r--r--src/com/mbien/opencl/CLMemory.java6
-rw-r--r--src/com/mbien/opencl/gl/CLGLBuffer.java (renamed from src/com/mbien/opencl/CLGLBuffer.java)8
-rw-r--r--src/com/mbien/opencl/gl/CLGLContext.java (renamed from src/com/mbien/opencl/CLGLContext.java)7
-rw-r--r--src/com/mbien/opencl/gl/CLGLImage2d.java (renamed from src/com/mbien/opencl/CLGLImage2d.java)13
-rw-r--r--src/com/mbien/opencl/gl/CLGLObject.java (renamed from src/com/mbien/opencl/CLGLObject.java)2
-rw-r--r--src/com/mbien/opencl/gl/CLGLTexture.java (renamed from src/com/mbien/opencl/CLGLTexture.java)2
-rw-r--r--src/com/mbien/opencl/gl/CLGLTexture2d.java (renamed from src/com/mbien/opencl/CLGLTexture2d.java)11
-rw-r--r--src/com/mbien/opencl/gl/CLGLTexture3d.java (renamed from src/com/mbien/opencl/CLGLTexture3d.java)11
-rw-r--r--src/com/mbien/opencl/util/CLBuildConfiguration.java8
12 files changed, 57 insertions, 25 deletions
diff --git a/src/com/mbien/opencl/CLContext.java b/src/com/mbien/opencl/CLContext.java
index 6b09cc3..2698a93 100644
--- a/src/com/mbien/opencl/CLContext.java
+++ b/src/com/mbien/opencl/CLContext.java
@@ -382,6 +382,10 @@ public class CLContext extends CLObject implements CLResource {
release();
}
+ protected void overrideContext(CLDevice device) {
+ device.setContext(this);
+ }
+
/**
* Returns the CLPlatform this context is running on.
*/
diff --git a/src/com/mbien/opencl/CLImage.java b/src/com/mbien/opencl/CLImage.java
index 1da1cc6..449ec70 100644
--- a/src/com/mbien/opencl/CLImage.java
+++ b/src/com/mbien/opencl/CLImage.java
@@ -30,6 +30,10 @@ public abstract class CLImage<B extends Buffer> extends CLMemory<B> {
this.height = height;
}
+ protected static CLImageFormat createUninitializedImageFormat() {
+ return new CLImageFormat();
+ }
+
/**
* Returns the image format descriptor specified when image was created.
*/
@@ -77,7 +81,7 @@ public abstract class CLImage<B extends Buffer> extends CLMemory<B> {
this.id = id;
}
@Override
- protected int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet) {
+ public int getInfo(int name, long valueSize, Buffer value, PointerBuffer valueSizeRet) {
return cl.clGetImageInfo(id, name, valueSize, value, valueSizeRet);
}
}
diff --git a/src/com/mbien/opencl/CLInfoAccessor.java b/src/com/mbien/opencl/CLInfoAccessor.java
index 316c125..554545b 100644
--- a/src/com/mbien/opencl/CLInfoAccessor.java
+++ b/src/com/mbien/opencl/CLInfoAccessor.java
@@ -32,7 +32,7 @@ abstract class CLInfoAccessor {
};
- final long getLong(int key) {
+ public final long getLong(int key) {
ByteBuffer buffer = localBB.get();
int ret = getInfo(key, 8, buffer, null);
@@ -41,7 +41,7 @@ abstract class CLInfoAccessor {
return buffer.getLong(0);
}
- final String getString(int key) {
+ public final String getString(int key) {
ByteBuffer buffer = localBB.get();
PointerBuffer pbuffer = localPB.get();
diff --git a/src/com/mbien/opencl/CLMemory.java b/src/com/mbien/opencl/CLMemory.java
index 275f39f..8bebea4 100644
--- a/src/com/mbien/opencl/CLMemory.java
+++ b/src/com/mbien/opencl/CLMemory.java
@@ -52,6 +52,10 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL
throw new RuntimeException("Unexpected buffer type " + buffer.getClass().getName());
}
+ protected static CL getCL(CLContext context) {
+ return context.cl;
+ }
+
/**
* Returns a new instance of CLMemory pointing to the same CLResource but using a different Buffer.
*/
@@ -250,7 +254,7 @@ public abstract class CLMemory <B extends Buffer> extends CLObject implements CL
return null;
}
- static int flagsToInt(Mem[] flags) {
+ public static int flagsToInt(Mem[] flags) {
int clFlags = 0;
if (flags != null) {
for (int i = 0; i < flags.length; i++) {
diff --git a/src/com/mbien/opencl/CLGLBuffer.java b/src/com/mbien/opencl/gl/CLGLBuffer.java
index 8b4e5f5..54e849f 100644
--- a/src/com/mbien/opencl/CLGLBuffer.java
+++ b/src/com/mbien/opencl/gl/CLGLBuffer.java
@@ -1,5 +1,9 @@
-package com.mbien.opencl;
+package com.mbien.opencl.gl;
+import com.mbien.opencl.CL;
+import com.mbien.opencl.CLBuffer;
+import com.mbien.opencl.CLContext;
+import com.mbien.opencl.CLGLI;
import com.mbien.opencl.CLMemory.GLObjectType;
import java.nio.Buffer;
@@ -25,7 +29,7 @@ public final class CLGLBuffer<B extends Buffer> extends CLBuffer<B> implements C
static <B extends Buffer> CLGLBuffer<B> create(CLContext context, B directBuffer, int flags, int glObject) {
checkBuffer(directBuffer, flags);
- CL cl = context.cl;
+ CL cl = getCL(context);
int[] result = new int[1];
CLGLI clgli = (CLGLI)cl;
diff --git a/src/com/mbien/opencl/CLGLContext.java b/src/com/mbien/opencl/gl/CLGLContext.java
index 5c7226c..2353904 100644
--- a/src/com/mbien/opencl/CLGLContext.java
+++ b/src/com/mbien/opencl/gl/CLGLContext.java
@@ -1,7 +1,10 @@
-package com.mbien.opencl;
+package com.mbien.opencl.gl;
+import com.mbien.opencl.CLContext;
+import com.mbien.opencl.CLDevice;
import java.nio.Buffer;
import com.mbien.opencl.CLMemory.Mem;
+import com.mbien.opencl.CLPlatform;
import com.sun.gluegen.runtime.PointerBuffer;
import com.sun.opengl.impl.GLContextImpl;
import com.sun.opengl.impl.macosx.cgl.MacOSXCGLContext;
@@ -90,7 +93,7 @@ public final class CLGLContext extends CLContext {
CLGLContext context = new CLGLContext(platform, clID, glID[0]);
if(devices != null) {
for (int i = 0; i < devices.length; i++) {
- devices[i].setContext(context);
+ context.overrideContext(devices[i]);
}
}
return context;
diff --git a/src/com/mbien/opencl/CLGLImage2d.java b/src/com/mbien/opencl/gl/CLGLImage2d.java
index dc64fc5..ab5f1c9 100644
--- a/src/com/mbien/opencl/CLGLImage2d.java
+++ b/src/com/mbien/opencl/gl/CLGLImage2d.java
@@ -1,5 +1,10 @@
-package com.mbien.opencl;
+package com.mbien.opencl.gl;
+import com.mbien.opencl.CL;
+import com.mbien.opencl.CLContext;
+import com.mbien.opencl.CLGLI;
+import com.mbien.opencl.CLImage2d;
+import com.mbien.opencl.CLImageFormat;
import com.mbien.opencl.CLMemory.GLObjectType;
import com.mbien.opencl.impl.CLImageFormatImpl;
import java.nio.Buffer;
@@ -26,7 +31,7 @@ public class CLGLImage2d<B extends Buffer> extends CLImage2d<B> implements CLGLO
CLGLBuffer.checkBuffer(directBuffer, flags);
- CL cl = context.cl;
+ CL cl = getCL(context);
int[] result = new int[1];
CLGLI clgli = (CLGLI)cl;
@@ -36,9 +41,9 @@ public class CLGLImage2d<B extends Buffer> extends CLImage2d<B> implements CLGLO
}
static <B extends Buffer> CLGLImage2d<B> createImage(CLContext context, long id, B directBuffer, int glObject) {
- CLImageInfoAccessor accessor = new CLImageInfoAccessor(context.cl, id);
+ CLImageInfoAccessor accessor = new CLImageInfoAccessor(getCL(context), id);
- CLImageFormat format = new CLImageFormat();
+ CLImageFormat format = createUninitializedImageFormat();
accessor.getInfo(CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null);
int width = (int)accessor.getLong(CL_IMAGE_WIDTH);
diff --git a/src/com/mbien/opencl/CLGLObject.java b/src/com/mbien/opencl/gl/CLGLObject.java
index 044f227..51a730e 100644
--- a/src/com/mbien/opencl/CLGLObject.java
+++ b/src/com/mbien/opencl/gl/CLGLObject.java
@@ -1,7 +1,7 @@
/*
* Created on Friday, February 26 2010
*/
-package com.mbien.opencl;
+package com.mbien.opencl.gl;
import com.mbien.opencl.CLMemory.GLObjectType;
diff --git a/src/com/mbien/opencl/CLGLTexture.java b/src/com/mbien/opencl/gl/CLGLTexture.java
index 9290dc6..49fe4cb 100644
--- a/src/com/mbien/opencl/CLGLTexture.java
+++ b/src/com/mbien/opencl/gl/CLGLTexture.java
@@ -2,7 +2,7 @@
* Created on Friday, February 26 2010
*/
-package com.mbien.opencl;
+package com.mbien.opencl.gl;
/**
*
diff --git a/src/com/mbien/opencl/CLGLTexture2d.java b/src/com/mbien/opencl/gl/CLGLTexture2d.java
index d23d7e3..2dbb09d 100644
--- a/src/com/mbien/opencl/CLGLTexture2d.java
+++ b/src/com/mbien/opencl/gl/CLGLTexture2d.java
@@ -1,6 +1,9 @@
-package com.mbien.opencl;
+package com.mbien.opencl.gl;
-import com.mbien.opencl.CLImage.CLImageInfoAccessor;
+import com.mbien.opencl.CL;
+import com.mbien.opencl.CLContext;
+import com.mbien.opencl.CLGLI;
+import com.mbien.opencl.CLImageFormat;
import com.mbien.opencl.CLMemory.GLObjectType;
import com.mbien.opencl.impl.CLImageFormatImpl;
import java.nio.Buffer;
@@ -27,7 +30,7 @@ public class CLGLTexture2d<B extends Buffer> extends CLGLImage2d<B> implements C
CLGLBuffer.checkBuffer(directBuffer, flags);
- CL cl = context.cl;
+ CL cl = getCL(context);
int[] result = new int[1];
CLGLI clgli = (CLGLI)cl;
@@ -35,7 +38,7 @@ public class CLGLTexture2d<B extends Buffer> extends CLGLImage2d<B> implements C
CLImageInfoAccessor accessor = new CLImageInfoAccessor(cl, id);
- CLImageFormat format = new CLImageFormat();
+ CLImageFormat format = createUninitializedImageFormat();
accessor.getInfo(CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null);
int width = (int)accessor.getLong(CL_IMAGE_WIDTH);
diff --git a/src/com/mbien/opencl/CLGLTexture3d.java b/src/com/mbien/opencl/gl/CLGLTexture3d.java
index 7bc0805..6c68b92 100644
--- a/src/com/mbien/opencl/CLGLTexture3d.java
+++ b/src/com/mbien/opencl/gl/CLGLTexture3d.java
@@ -1,5 +1,10 @@
-package com.mbien.opencl;
+package com.mbien.opencl.gl;
+import com.mbien.opencl.CL;
+import com.mbien.opencl.CLContext;
+import com.mbien.opencl.CLGLI;
+import com.mbien.opencl.CLImage3d;
+import com.mbien.opencl.CLImageFormat;
import com.mbien.opencl.CLMemory.GLObjectType;
import com.mbien.opencl.impl.CLImageFormatImpl;
import java.nio.Buffer;
@@ -32,7 +37,7 @@ public class CLGLTexture3d<B extends Buffer> extends CLImage3d<B> implements CLG
CLGLBuffer.checkBuffer(directBuffer, flags);
- CL cl = context.cl;
+ CL cl = getCL(context);
int[] result = new int[1];
CLGLI clgli = (CLGLI)cl;
@@ -40,7 +45,7 @@ public class CLGLTexture3d<B extends Buffer> extends CLImage3d<B> implements CLG
CLImageInfoAccessor accessor = new CLImageInfoAccessor(cl, id);
- CLImageFormat format = new CLImageFormat();
+ CLImageFormat format = createUninitializedImageFormat();
accessor.getInfo(CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null);
int width = (int)accessor.getLong(CL_IMAGE_WIDTH);
diff --git a/src/com/mbien/opencl/util/CLBuildConfiguration.java b/src/com/mbien/opencl/util/CLBuildConfiguration.java
index e65a9f9..a4d85b6 100644
--- a/src/com/mbien/opencl/util/CLBuildConfiguration.java
+++ b/src/com/mbien/opencl/util/CLBuildConfiguration.java
@@ -69,25 +69,25 @@ public interface CLBuildConfiguration extends Cloneable {
/**
* Adds the definitions to the build configuration.
- * @see CLProgram#define(java.lang.String)
+ * @see com.mbien.opencl.CLProgram#define(java.lang.String)
*/
public CLBuildConfiguration withDefines(String... names);
/**
* Adds the definitions to the build configuration.
- * @see CLProgram#define(java.lang.String, java.lang.Object)
+ * @see com.mbien.opencl.CLProgram#define(java.lang.String, java.lang.Object)
*/
public CLBuildConfiguration withDefines(Map<String, ? extends Object> defines);
/**
* Adds the compiler option to the build configuration.
- * @see CLProgram.CompilerOptions
+ * @see com.mbien.opencl.CLProgram.CompilerOptions
*/
public CLBuildConfiguration withOption(String option);
/**
* Adds the compiler options to the build configuration.
- * @see CLProgram.CompilerOptions
+ * @see com.mbien.opencl.CLProgram.CompilerOptions
*/
public CLBuildConfiguration withOptions(String... options);