summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/jogamp/opencl/CLContext.java34
-rw-r--r--src/com/jogamp/opencl/CLPlatform.java55
-rw-r--r--src/com/jogamp/opencl/gl/CLGLContext.java4
-rw-r--r--src/com/jogamp/opencl/gl/CLGLTexture2d.java4
4 files changed, 77 insertions, 20 deletions
diff --git a/src/com/jogamp/opencl/CLContext.java b/src/com/jogamp/opencl/CLContext.java
index 2beea3f8..c66b111a 100644
--- a/src/com/jogamp/opencl/CLContext.java
+++ b/src/com/jogamp/opencl/CLContext.java
@@ -34,6 +34,7 @@ import com.jogamp.opencl.CLDevice.Type;
import com.jogamp.opencl.CLSampler.AddressingMode;
import com.jogamp.opencl.CLSampler.FilteringMode;
import com.jogamp.common.nio.NativeSizeBuffer;
+import com.jogamp.opencl.llb.CLContextBinding;
import com.jogamp.opencl.llb.impl.CLImageFormatImpl;
import java.io.BufferedReader;
import java.io.IOException;
@@ -116,7 +117,7 @@ public class CLContext extends CLObject implements CLResource {
}
- private synchronized void initDevices() {
+ private synchronized void initDevices(CLContextBinding cl) {
if (devices == null) {
@@ -173,7 +174,7 @@ public class CLContext extends CLObject implements CLResource {
NativeSizeBuffer properties = setupContextProperties(platform);
ErrorDispatcher dispatcher = new ErrorDispatcher();
- return new CLContext(platform, createContextFromType(dispatcher, properties, type), dispatcher);
+ return new CLContext(platform, createContextFromType(platform, dispatcher, properties, type), dispatcher);
}
/**
@@ -191,7 +192,7 @@ public class CLContext extends CLObject implements CLResource {
NativeSizeBuffer properties = setupContextProperties(platform);
ErrorDispatcher dispatcher = new ErrorDispatcher();
- CLContext context = new CLContext(platform, createContext(dispatcher, properties, devices), dispatcher);
+ CLContext context = new CLContext(platform, createContext(platform, dispatcher, properties, devices), dispatcher);
if(devices != null) {
for (int i = 0; i < devices.length; i++) {
devices[i].setContext(context);
@@ -200,17 +201,18 @@ public class CLContext extends CLObject implements CLResource {
return context;
}
- protected static long createContextFromType(CLErrorHandler handler, NativeSizeBuffer properties, long deviceType) {
+ protected static long createContextFromType(CLPlatform platform, CLErrorHandler handler, NativeSizeBuffer properties, long deviceType) {
IntBuffer status = newDirectIntBuffer(1);
- long context = CLPlatform.getLowLevelCLInterface().clCreateContextFromType(properties, deviceType, handler, status);
+ CLContextBinding cl = platform.getContextBinding();
+ long context = cl.clCreateContextFromType(properties, deviceType, handler, status);
checkForError(status.get(), "can not create CL context");
return context;
}
- protected static long createContext(CLErrorHandler handler, NativeSizeBuffer properties, CLDevice... devices) {
+ protected static long createContext(CLPlatform platform, CLErrorHandler handler, NativeSizeBuffer properties, CLDevice... devices) {
IntBuffer status = newDirectIntBuffer(1);
NativeSizeBuffer pb = null;
@@ -224,7 +226,8 @@ public class CLContext extends CLObject implements CLResource {
pb.put(i, device.ID);
}
}
- long context = CLPlatform.getLowLevelCLInterface().clCreateContext(properties, pb, handler, status);
+ CLContextBinding cl = platform.getContextBinding();
+ long context = cl.clCreateContext(properties, pb, handler, status);
checkForError(status.get(), "can not create CL context");
@@ -505,15 +508,12 @@ public class CLContext extends CLObject implements CLResource {
release(memoryObjects);
release(samplers);
- for (CLDevice device : getDevices()) {
- Collection<CLCommandQueue> queues = queuesMap.get(device);
- if(queues != null) {
- release(queues);
- }
+ for (List<CLCommandQueue> queues : queuesMap.values()) {
+ release(queues);
}
}finally{
- int ret = cl.clReleaseContext(ID);
+ int ret = platform.getContextBinding().clReleaseContext(ID);
checkForError(ret, "error releasing context");
}
@@ -525,8 +525,10 @@ public class CLContext extends CLObject implements CLResource {
private CLImageFormat[] getSupportedImageFormats(int flags, int type) {
+ CLContextBinding binding = platform.getContextBinding();
+
int[] entries = new int[1];
- int ret = cl.clGetSupportedImageFormats(ID, flags, type, 0, null, entries, 0);
+ int ret = binding.clGetSupportedImageFormats(ID, flags, type, 0, null, entries, 0);
if(ret != CL_SUCCESS) {
throw newException(ret, "error calling clGetSupportedImageFormats");
}
@@ -538,7 +540,7 @@ public class CLContext extends CLObject implements CLResource {
CLImageFormat[] formats = new CLImageFormat[count];
CLImageFormatImpl impl = CLImageFormatImpl.create(newDirectByteBuffer(count * CLImageFormatImpl.size()));
- ret = cl.clGetSupportedImageFormats(ID, flags, type, count, impl, null, 0);
+ ret = binding.clGetSupportedImageFormats(ID, flags, type, count, impl, null, 0);
if(ret != CL_SUCCESS) {
throw newException(ret, "error calling clGetSupportedImageFormats");
}
@@ -630,7 +632,7 @@ public class CLContext extends CLObject implements CLResource {
* Returns all devices associated with this CLContext.
*/
public CLDevice[] getDevices() {
- initDevices();
+ initDevices(platform.getContextBinding());
return devices;
}
diff --git a/src/com/jogamp/opencl/CLPlatform.java b/src/com/jogamp/opencl/CLPlatform.java
index a494edcb..3b65b41f 100644
--- a/src/com/jogamp/opencl/CLPlatform.java
+++ b/src/com/jogamp/opencl/CLPlatform.java
@@ -28,6 +28,11 @@
package com.jogamp.opencl;
+import com.jogamp.opencl.llb.CLPlatformBinding;
+import com.jogamp.opencl.llb.CLProgramBinding;
+import com.jogamp.opencl.llb.CLSamplerBinding;
+import com.jogamp.opencl.llb.CLKernelBinding;
+import com.jogamp.opencl.llb.CLImageBinding;
import com.jogamp.opencl.llb.CL;
import com.jogamp.opencl.impl.CLTLAccessorFactory;
import com.jogamp.common.nio.Buffers;
@@ -36,6 +41,12 @@ import com.jogamp.common.JogampRuntimeException;
import com.jogamp.common.os.NativeLibrary;
import com.jogamp.common.nio.NativeSizeBuffer;
import com.jogamp.gluegen.runtime.FunctionAddressResolver;
+import com.jogamp.opencl.llb.CLBufferBinding;
+import com.jogamp.opencl.llb.CLCommandQueueBinding;
+import com.jogamp.opencl.llb.CLContextBinding;
+import com.jogamp.opencl.llb.CLDeviceBinding;
+import com.jogamp.opencl.llb.CLEventBinding;
+import com.jogamp.opencl.llb.CLMemObjBinding;
import com.jogamp.opencl.spi.CLPlatformInfoAccessor;
import com.jogamp.opencl.util.CLUtil;
import com.jogamp.opencl.llb.impl.CLImpl;
@@ -539,6 +550,50 @@ public class CLPlatform {
return info;
}
+ protected CLBufferBinding getBufferBinding() {
+ return cl;
+ }
+
+ protected CLCommandQueueBinding getCommandQueueBinding() {
+ return cl;
+ }
+
+ protected CLContextBinding getContextBinding() {
+ return cl;
+ }
+
+ protected CLDeviceBinding getDeviceBinding() {
+ return cl;
+ }
+
+ protected CLEventBinding getEventBinding() {
+ return cl;
+ }
+
+ protected CLImageBinding getImageBinding() {
+ return cl;
+ }
+
+ protected CLKernelBinding getKernelBinding() {
+ return cl;
+ }
+
+ protected CLMemObjBinding getMemObjectBinding() {
+ return cl;
+ }
+
+ protected CLPlatformBinding getPlatformBinding() {
+ return cl;
+ }
+
+ protected CLProgramBinding getProgramBinding() {
+ return cl;
+ }
+
+ protected CLSamplerBinding getSamplerBinding() {
+ return cl;
+ }
+
@Override
public String toString() {
return "CLPlatform [name: " + getName()
diff --git a/src/com/jogamp/opencl/gl/CLGLContext.java b/src/com/jogamp/opencl/gl/CLGLContext.java
index e688717f..f7214b6e 100644
--- a/src/com/jogamp/opencl/gl/CLGLContext.java
+++ b/src/com/jogamp/opencl/gl/CLGLContext.java
@@ -99,7 +99,7 @@ public final class CLGLContext extends CLContext {
long[] glID = new long[1];
NativeSizeBuffer properties = setupContextProperties(platform, glContext, glID);
ErrorDispatcher dispatcher = createErrorHandler();
- long clID = createContextFromType(dispatcher, properties, toDeviceBitmap(deviceTypes));
+ long clID = createContextFromType(platform, dispatcher, properties, toDeviceBitmap(deviceTypes));
return new CLGLContext(platform, glContext, clID, glID[0], dispatcher);
@@ -123,7 +123,7 @@ public final class CLGLContext extends CLContext {
long[] glID = new long[1];
NativeSizeBuffer properties = setupContextProperties(platform, glContext, glID);
ErrorDispatcher dispatcher = createErrorHandler();
- long clID = createContext(dispatcher, properties, devices);
+ long clID = createContext(platform, dispatcher, properties, devices);
CLGLContext context = new CLGLContext(platform, glContext, clID, glID[0], dispatcher);
if(devices != null) {
diff --git a/src/com/jogamp/opencl/gl/CLGLTexture2d.java b/src/com/jogamp/opencl/gl/CLGLTexture2d.java
index 484d00d2..7cbd95d5 100644
--- a/src/com/jogamp/opencl/gl/CLGLTexture2d.java
+++ b/src/com/jogamp/opencl/gl/CLGLTexture2d.java
@@ -70,8 +70,8 @@ public class CLGLTexture2d<B extends Buffer> extends CLGLImage2d<B> implements C
CLImageFormat format = createUninitializedImageFormat();
accessor.getInfo(CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null);
- int width = 640; //(int)accessor.getLong(CL_IMAGE_WIDTH);
- int height = 480; //(int)accessor.getLong(CL_IMAGE_HEIGHT);
+ int width = (int)accessor.getLong(CL_IMAGE_WIDTH);
+ int height = (int)accessor.getLong(CL_IMAGE_HEIGHT);
return new CLGLTexture2d<B>(context, directBuffer, format, accessor, target, mipLevel, width, height, id, texture, flags);