diff options
-rw-r--r-- | resources/cl-impl.cfg | 11 | ||||
-rw-r--r-- | resources/clImplCustomCode.java | 8 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLContext.java | 2 | ||||
-rw-r--r-- | src/com/jogamp/opencl/CLPlatform.java | 21 | ||||
-rw-r--r-- | src/com/jogamp/opencl/NativeLibLoader.java | 18 | ||||
-rw-r--r-- | src/com/jogamp/opencl/gl/CLGLContext.java | 1 |
6 files changed, 44 insertions, 17 deletions
diff --git a/resources/cl-impl.cfg b/resources/cl-impl.cfg index 93dab2ba..a404398f 100644 --- a/resources/cl-impl.cfg +++ b/resources/cl-impl.cfg @@ -18,7 +18,18 @@ EmitProcAddressTable true ProcAddressTableClassName CLProcAddressTable GetProcAddressTableExpr addressTable ProcAddressNameExpr $UpperCase(arg) + +#dynamic binding for OpenGL specific functions ForceProcAddressGen clGetGLContextInfoKHR +ForceProcAddressGen clCreateFromGLBuffer +ForceProcAddressGen clCreateFromGLRenderbuffer +ForceProcAddressGen clCreateFromGLTexture2D +ForceProcAddressGen clCreateFromGLTexture3D +ForceProcAddressGen clEnqueueAcquireGLObjects +ForceProcAddressGen clEnqueueReleaseGLObjects +ForceProcAddressGen clGetGLObjectInfo +ForceProcAddressGen clGetGLTextureInfo +ForceProcAddressGen clIcdGetPlatformIDsKHR Unignore clGetExtensionFunctionAddress #AccessControl clGetExtensionFunctionAddress PACKAGE_PRIVATE diff --git a/resources/clImplCustomCode.java b/resources/clImplCustomCode.java index 3048a6ad..fab3a724 100644 --- a/resources/clImplCustomCode.java +++ b/resources/clImplCustomCode.java @@ -1,9 +1,9 @@ - final static CLProcAddressTable addressTable = new CLProcAddressTable(); + private final CLProcAddressTable addressTable; -// static{ -// ProcAddressHelper.resetProcAddressTable(addressTable, ); -// } + public CLImpl(CLProcAddressTable addressTable) { + this.addressTable = addressTable; + } public long clCreateContext(PointerBuffer properties, PointerBuffer devices, CreateContextCallback pfn_notify, Object userData, IntBuffer errcode_ret) { diff --git a/src/com/jogamp/opencl/CLContext.java b/src/com/jogamp/opencl/CLContext.java index 07b59d9e..01159a01 100644 --- a/src/com/jogamp/opencl/CLContext.java +++ b/src/com/jogamp/opencl/CLContext.java @@ -162,7 +162,7 @@ public class CLContext extends CLObject implements CLResource { for (int i = 0; i < devices.length; i++) { CLDevice device = devices[i]; if(device == null) { - throw new IllegalArgumentException("device at index"+i+" was null."); + throw new IllegalArgumentException("device at index "+i+" was null."); } pb.put(i, device.ID); } diff --git a/src/com/jogamp/opencl/CLPlatform.java b/src/com/jogamp/opencl/CLPlatform.java index f3c00926..aa162d0c 100644 --- a/src/com/jogamp/opencl/CLPlatform.java +++ b/src/com/jogamp/opencl/CLPlatform.java @@ -1,9 +1,14 @@ package com.jogamp.opencl; +import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.nio.Int64Buffer; +import com.jogamp.common.os.NativeLibrary; +import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.util.CLUtil; import com.jogamp.opencl.impl.CLImpl; -import com.jogamp.common.nio.PointerBuffer; +import com.jogamp.opencl.impl.CLProcAddressTable; +import com.jogamp.gluegen.runtime.ProcAddressHelper; + import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.IntBuffer; @@ -34,10 +39,16 @@ public final class CLPlatform { private Set<String> extensions; static{ - NativeLibLoader.loadJOCL(); -// System.loadLibrary("gluegen-rt"); -// ProcAddressHelper.resetProcAddressTable(table, null); - cl = new CLImpl(); + try { + NativeLibrary lib = NativeLibLoader.loadJOCL(); + + CLProcAddressTable table = new CLProcAddressTable(); + ProcAddressHelper.resetProcAddressTable(table, lib); + + cl = new CLImpl(table); + }catch(Exception ex) { + throw new JogampRuntimeException("JOCL initialization error.", ex); + } } private CLPlatform(long id) { diff --git a/src/com/jogamp/opencl/NativeLibLoader.java b/src/com/jogamp/opencl/NativeLibLoader.java index 2761cb3c..5cce1a36 100644 --- a/src/com/jogamp/opencl/NativeLibLoader.java +++ b/src/com/jogamp/opencl/NativeLibLoader.java @@ -1,20 +1,26 @@ package com.jogamp.opencl; -import java.security.AccessController; import java.security.PrivilegedAction; import com.jogamp.common.jvm.JNILibLoaderBase; +import com.jogamp.common.os.NativeLibrary; + +import static java.security.AccessController.*; /** - * + * Responsible for JOCL lib loading. * @author Michael Bien */ class NativeLibLoader extends JNILibLoaderBase { - public static void loadJOCL() { - AccessController.doPrivileged(new PrivilegedAction<Object>() { - public Object run() { + /** + * Loads the native binding and returns the OpenCL library for dynamic linking. + */ + static NativeLibrary loadJOCL() { + + return doPrivileged(new PrivilegedAction<NativeLibrary>() { + public NativeLibrary run() { loadLibrary("jocl", null, true); - return null; + return NativeLibrary.open("OpenCL", NativeLibLoader.class.getClassLoader()); } }); } diff --git a/src/com/jogamp/opencl/gl/CLGLContext.java b/src/com/jogamp/opencl/gl/CLGLContext.java index 5fd669b8..f8ca92f3 100644 --- a/src/com/jogamp/opencl/gl/CLGLContext.java +++ b/src/com/jogamp/opencl/gl/CLGLContext.java @@ -10,7 +10,6 @@ import com.jogamp.opengl.impl.GLContextImpl; import com.jogamp.opengl.impl.macosx.cgl.MacOSXCGLContext; import com.jogamp.opengl.impl.windows.wgl.WindowsWGLContext; import com.jogamp.opengl.impl.x11.glx.X11GLXContext; -import javax.media.nativewindow.DefaultGraphicsConfiguration; import javax.media.opengl.GLContext; import static com.jogamp.opencl.gl.CLGLI.*; |