diff options
author | Michael Bien <[email protected]> | 2010-06-21 20:56:46 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2010-06-21 20:56:46 +0200 |
commit | 9d181f846f7c7a1ce4916f2009dab9348ec037f6 (patch) | |
tree | c3447c3da5614442281d6229cd499d2e9891ae75 /src/com/jogamp/opencl/CLPlatform.java | |
parent | 4b96c9539e7b31bbfd5b349d16b51dd5eb556707 (diff) |
switched to dynamic linking. All custom code functions must be called via funciton pointers since this point.
Diffstat (limited to 'src/com/jogamp/opencl/CLPlatform.java')
-rw-r--r-- | src/com/jogamp/opencl/CLPlatform.java | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/src/com/jogamp/opencl/CLPlatform.java b/src/com/jogamp/opencl/CLPlatform.java index 60eb2db0..46715feb 100644 --- a/src/com/jogamp/opencl/CLPlatform.java +++ b/src/com/jogamp/opencl/CLPlatform.java @@ -1,11 +1,11 @@ package com.jogamp.opencl; +import com.jogamp.common.os.DynamicLookupHelper; import java.security.PrivilegedAction; 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.common.os.UnixDynamicLinkerImpl; +import com.jogamp.gluegen.runtime.FunctionAddressResolver; import com.jogamp.opencl.util.CLUtil; import com.jogamp.opencl.impl.CLImpl; import com.jogamp.opencl.impl.CLProcAddressTable; @@ -45,21 +45,44 @@ public final class CLPlatform { static{ try { -// new UnixDynamicLinkerImpl().openLibraryGlobal("/usr/lib/jvm/java-6-sun/jre/lib/amd64/libjsig.so", true); - // run the whole static initialization privileged to speed up, - // since this skips checking further access - CLProcAddressTable table = doPrivileged(new PrivilegedAction<CLProcAddressTable>() { + final CLProcAddressTable table = new CLProcAddressTable(new FunctionAddressResolver() { + public long resolve(String name, DynamicLookupHelper lookup) { + + //FIXME workaround to fix a gluegen issue + if(name.endsWith("Impl")) { + name = name.substring(0, name.length() - "Impl".length()); + } + + if(name.endsWith("KHR") || name.endsWith("EXT")) { + long address = ((CLImpl) cl).clGetExtensionFunctionAddress(name); + if(address != 0) { + return address; + } + } + + return lookup.dynamicLookupFunction(name); + } + }); + + cl = new CLImpl(table); + + //load JOCL and init table + doPrivileged(new PrivilegedAction<CLProcAddressTable>() { public CLProcAddressTable run() { + NativeLibrary lib = JOCLJNILibLoader.loadJOCL(); - CLProcAddressTable table = new CLProcAddressTable(); + //eagerly init funciton to query extension addresses (used in reset()) + table.initEntry("clGetExtensionFunctionAddressImpl", lib); table.reset(lib); - return table; + return null; } }); - cl = new CLImpl(table); +// System.out.println("\n"+table); + System.out.println("unavailable functions: "+table.getNullPointerFunctions()); + }catch(Exception ex) { throw new JogampRuntimeException("JOCL initialization error.", ex); } |