|
From: <sp...@us...> - 2010-10-01 22:20:21
|
Revision: 3426
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3426&view=rev
Author: spasi
Date: 2010-10-01 22:20:14 +0000 (Fri, 01 Oct 2010)
Log Message:
-----------
OpenCL bug fixes on MacOS.
Improved 64bit pointer detection.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/DefaultSysImplementation.java
trunk/LWJGL/src/java/org/lwjgl/Sys.java
trunk/LWJGL/src/java/org/lwjgl/SysImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opencl/APIUtil.java
trunk/LWJGL/src/java/org/lwjgl/opencl/CallbackUtil.java
trunk/LWJGL/src/java/org/lwjgl/test/opencl/HelloOpenCL.java
trunk/LWJGL/src/native/common/common_tools.c
Modified: trunk/LWJGL/src/java/org/lwjgl/DefaultSysImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/DefaultSysImplementation.java 2010-10-01 17:00:17 UTC (rev 3425)
+++ trunk/LWJGL/src/java/org/lwjgl/DefaultSysImplementation.java 2010-10-01 22:20:14 UTC (rev 3426)
@@ -40,6 +40,7 @@
*/
abstract class DefaultSysImplementation implements SysImplementation {
public native int getJNIVersion();
+ public native int getPointerSize();
public native void setDebug(boolean debug);
public long getTimerResolution() {
Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2010-10-01 17:00:17 UTC (rev 3425)
+++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2010-10-01 22:20:14 UTC (rev 3426)
@@ -77,15 +77,13 @@
});
}
- private static boolean loadLibrary(final String lib_name) {
+ private static void loadLibrary(final String lib_name) {
try {
doLoadLibrary(lib_name);
- return false;
} catch (UnsatisfiedLinkError e) {
if (implementation.has64Bit()) {
try {
doLoadLibrary(lib_name + POSTFIX64BIT);
- return true;
} catch (UnsatisfiedLinkError e2) {
LWJGLUtil.log("Failed to load 64 bit library: " + e2.getMessage());
}
@@ -97,13 +95,14 @@
static {
implementation = createImplementation();
- is64Bit = loadLibrary(JNI_LIBRARY_NAME);
+ loadLibrary(JNI_LIBRARY_NAME);
+ is64Bit = implementation.getPointerSize() == 8;
int native_jni_version = implementation.getJNIVersion();
int required_version = implementation.getRequiredJNIVersion();
if (native_jni_version != required_version)
throw new LinkageError("Version mismatch: jar version is '" + required_version +
- "', native libary version is '" + native_jni_version + "'");
+ "', native library version is '" + native_jni_version + "'");
implementation.setDebug(LWJGLUtil.DEBUG);
}
Modified: trunk/LWJGL/src/java/org/lwjgl/SysImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/SysImplementation.java 2010-10-01 17:00:17 UTC (rev 3425)
+++ trunk/LWJGL/src/java/org/lwjgl/SysImplementation.java 2010-10-01 22:20:14 UTC (rev 3426)
@@ -51,6 +51,11 @@
*/
int getJNIVersion();
+ /**
+ * Returns the platform's pointer size in bytes
+ */
+ int getPointerSize();
+
void setDebug(boolean debug);
/**
Modified: trunk/LWJGL/src/java/org/lwjgl/opencl/APIUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opencl/APIUtil.java 2010-10-01 17:00:17 UTC (rev 3425)
+++ trunk/LWJGL/src/java/org/lwjgl/opencl/APIUtil.java 2010-10-01 22:20:14 UTC (rev 3426)
@@ -430,9 +430,11 @@
static Set<String> getExtensions(final String extensionList) {
final Set<String> extensions = new HashSet<String>();
- final StringTokenizer tokenizer = new StringTokenizer(extensionList);
- while ( tokenizer.hasMoreTokens() )
- extensions.add(tokenizer.nextToken());
+ if ( extensionList != null ) {
+ final StringTokenizer tokenizer = new StringTokenizer(extensionList);
+ while ( tokenizer.hasMoreTokens() )
+ extensions.add(tokenizer.nextToken());
+ }
return extensions;
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opencl/CallbackUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opencl/CallbackUtil.java 2010-10-01 17:00:17 UTC (rev 3425)
+++ trunk/LWJGL/src/java/org/lwjgl/opencl/CallbackUtil.java 2010-10-01 22:20:14 UTC (rev 3426)
@@ -34,6 +34,8 @@
import java.util.HashMap;
import java.util.Map;
+import static org.lwjgl.opencl.CL10.*;
+
/**
* Utility class that handles OpenCL API callbacks.
*
@@ -79,7 +81,7 @@
* @param user_data the GlobalRef memory address
*/
static void checkCallback(final int errcode, final long user_data) {
- if ( errcode != 0x0 && user_data != 0 )
+ if ( errcode != CL_SUCCESS && user_data != 0 )
deleteGlobalRef(user_data);
}
@@ -107,7 +109,7 @@
* @param user_data the global reference pointer
*/
static void registerCallback(final CLContext context, final long user_data) {
- if ( context.getPointer() == 0 ) {
+ if ( context.getPointerUnsafe() == 0 ) {
if ( user_data != 0 )
deleteGlobalRef(user_data);
return;
Modified: trunk/LWJGL/src/java/org/lwjgl/test/opencl/HelloOpenCL.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/opencl/HelloOpenCL.java 2010-10-01 17:00:17 UTC (rev 3425)
+++ trunk/LWJGL/src/java/org/lwjgl/test/opencl/HelloOpenCL.java 2010-10-01 22:20:14 UTC (rev 3426)
@@ -33,6 +33,7 @@
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
+import org.lwjgl.LWJGLUtil;
import org.lwjgl.PointerBuffer;
import org.lwjgl.opencl.*;
import org.lwjgl.opencl.api.CLBufferRegion;
@@ -49,7 +50,7 @@
public HelloOpenCL() {
}
- protected void execute() {
+ protected static void execute() {
try {
CL.create();
@@ -135,28 +136,31 @@
clRetainMemObject(buffer);
- final long exec_caps = device.getInfoLong(CL_DEVICE_EXECUTION_CAPABILITIES);
- if ( (exec_caps & CL_EXEC_NATIVE_KERNEL) == CL_EXEC_NATIVE_KERNEL ) {
- System.out.println("-TRYING TO EXEC NATIVE KERNEL-");
- final CLCommandQueue queue = clCreateCommandQueue(context, device, 0, null);
+ if ( LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_MACOSX ) {
+ // TODO: Native kernels crash on MacOSX, disable this until we can debug properly.
+ final long exec_caps = device.getInfoLong(CL_DEVICE_EXECUTION_CAPABILITIES);
+ if ( (exec_caps & CL_EXEC_NATIVE_KERNEL) == CL_EXEC_NATIVE_KERNEL ) {
+ System.out.println("-TRYING TO EXEC NATIVE KERNEL-");
+ final CLCommandQueue queue = clCreateCommandQueue(context, device, 0, null);
- clEnqueueNativeKernel(queue, new CLNativeKernel() {
- protected void execute(final ByteBuffer[] memobjs) {
- if ( memobjs == null )
- System.out.println("OK, it's null");
- else {
- System.out.println("memobjs = " + memobjs.length);
- for ( int k = 0; k < memobjs.length; k++ ) {
- System.out.println("memobjs[" + k + "].remaining() = " + memobjs[k].remaining());
- for ( int l = memobjs[k].position(); l < memobjs[k].limit(); l++ ) {
- memobjs[k].put(l, (byte)l);
+ clEnqueueNativeKernel(queue, new CLNativeKernel() {
+ protected void execute(final ByteBuffer[] memobjs) {
+ if ( memobjs == null )
+ System.out.println("OK, it's null");
+ else {
+ System.out.println("memobjs = " + memobjs.length);
+ for ( int k = 0; k < memobjs.length; k++ ) {
+ System.out.println("memobjs[" + k + "].remaining() = " + memobjs[k].remaining());
+ for ( int l = memobjs[k].position(); l < memobjs[k].limit(); l++ ) {
+ memobjs[k].put(l, (byte)l);
+ }
}
}
}
- }
- }, new CLMem[] { buffer }, new long[] { 128 }, null, null);
+ }, new CLMem[] { buffer }, new long[] { 128 }, null, null);
- clFinish(queue);
+ clFinish(queue);
+ }
}
clReleaseMemObject(buffer);
Modified: trunk/LWJGL/src/native/common/common_tools.c
===================================================================
--- trunk/LWJGL/src/native/common/common_tools.c 2010-10-01 17:00:17 UTC (rev 3425)
+++ trunk/LWJGL/src/native/common/common_tools.c 2010-10-01 22:20:14 UTC (rev 3426)
@@ -61,6 +61,10 @@
list->current_index++;
}
+JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getPointerSize(JNIEnv *env, jclass clazz) {
+ return (jint)sizeof(void *);
+}
+
JNIEXPORT void JNICALL Java_org_lwjgl_DefaultSysImplementation_setDebug
(JNIEnv *env, jobject ignored, jboolean enable) {
debug = enable == JNI_TRUE ? true : false;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|