summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-06-22 12:53:20 +0200
committerMichael Bien <[email protected]>2010-06-22 12:53:20 +0200
commitea713fc1514c072693856a325c8c6fa37390a02b (patch)
tree8d1fa452ea2f7ef71aa89134a03e38bcb26713b3
parent4340cf9a1005f645dc031c83358c8c36dc43015a (diff)
parent9d181f846f7c7a1ce4916f2009dab9348ec037f6 (diff)
Merge branch 'master' of github.com:mbien/jocl
-rw-r--r--src/com/jogamp/opencl/CLPlatform.java41
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);
}