Pārlūkot izejas kodu

fixed unmapping of buffer objects and an error in setArg in Lwjgl3's Kernel

shamanDevel 9 gadi atpakaļ
vecāks
revīzija
732e75fba6

+ 6 - 6
jme3-core/src/main/resources/Common/OpenCL/Random.clh

@@ -5,13 +5,13 @@
 //#define RANDOM_DOUBLES
 
 #ifdef RANDOM_DOUBLES
-#ifdef cl_khr_fp64
+//#ifdef cl_khr_fp64
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
-#elif defined(cl_amd_fp64)
-#pragma OPENCL EXTENSION cl_amd_fp64 : enable
-#else
-#error "Double precision floating point not supported by OpenCL implementation."
-#endif
+//#elif defined(cl_amd_fp64)
+//#pragma OPENCL EXTENSION cl_amd_fp64 : enable
+//#else
+//#error "Double precision floating point not supported by OpenCL implementation."
+//#endif
 #endif
 
 inline int randNext(int bits, __global ulong* seed)

+ 6 - 6
jme3-examples/src/main/java/jme3test/opencl/TestOpenCLLibraries.java

@@ -250,10 +250,10 @@ public class TestOpenCLLibraries extends SimpleApplication {
             program.release();
 
         } catch (AssertionError ex) {
-            LOG.log(Level.SEVERE, "kernel test failed with an assertion error");
+            LOG.log(Level.SEVERE, "random test failed with an assertion error");
             return false;
         } catch (Exception ex) {
-            LOG.log(Level.SEVERE, "kernel test failed with:", ex);
+            LOG.log(Level.SEVERE, "random test failed with:", ex);
             return false;
         }
         return true;
@@ -310,10 +310,10 @@ public class TestOpenCLLibraries extends SimpleApplication {
             buffer.release();
             
         } catch (AssertionError ex) {
-            LOG.log(Level.SEVERE, "kernel test failed with an assertion error");
+            LOG.log(Level.SEVERE, "matrix3f test failed with an assertion error");
             return false;
         } catch (Exception ex) {
-            LOG.log(Level.SEVERE, "kernel test failed with:", ex);
+            LOG.log(Level.SEVERE, "matrix3f test failed with:", ex);
             return false;
         }
         return true;
@@ -392,10 +392,10 @@ public class TestOpenCLLibraries extends SimpleApplication {
             buffer.release();
             
         } catch (AssertionError ex) {
-            LOG.log(Level.SEVERE, "kernel test failed with an assertion error");
+            LOG.log(Level.SEVERE, "matrix4f test failed with an assertion error");
             return false;
         } catch (Exception ex) {
-            LOG.log(Level.SEVERE, "kernel test failed with:", ex);
+            LOG.log(Level.SEVERE, "matrix4f test failed with:", ex);
             return false;
         }
         return true;

+ 1 - 0
jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclBuffer.java

@@ -140,6 +140,7 @@ public class JoclBuffer extends Buffer {
     public void unmap(CommandQueue queue, ByteBuffer ptr) {
         long q = ((JoclCommandQueue)queue).id;
         Utils.pointers[0].rewind();
+        ptr.position(0);
         int ret = cl.clEnqueueUnmapMemObject(q, id, ptr, 0, null, Utils.pointers[0]);
         Utils.checkError(ret, "clEnqueueUnmapMemObject");
         ret = cl.clWaitForEvents(1, Utils.pointers[0]);

+ 1 - 0
jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclImage.java

@@ -448,6 +448,7 @@ public class JoclImage extends Image {
     public void unmap(CommandQueue queue, ImageMapping mapping) {
         long q = ((JoclCommandQueue)queue).id;
         Utils.pointers[0].rewind();
+        mapping.buffer.position(0);
         int ret = cl.clEnqueueUnmapMemObject(q, id, mapping.buffer, 0, null, Utils.pointers[0]);
         Utils.checkError(ret, "clEnqueueUnmapMemObject");
         ret = cl.clWaitForEvents(1, Utils.pointers[0]);

+ 1 - 0
jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglBuffer.java

@@ -136,6 +136,7 @@ public class LwjglBuffer extends Buffer {
 
     @Override
     public void unmap(CommandQueue queue, ByteBuffer ptr) {
+        ptr.position(0);
         long q = ((LwjglCommandQueue) queue).getQueue();
         Utils.pointerBuffers[0].rewind();
         int ret = CL10.clEnqueueUnmapMemObject(q, buffer, ptr, null, Utils.pointerBuffers[0]);

+ 1 - 0
jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglImage.java

@@ -449,6 +449,7 @@ public class LwjglImage extends Image {
 
     @Override
     public void unmap(CommandQueue queue, ImageMapping mapping) {
+        mapping.buffer.position(0);
         long q = ((LwjglCommandQueue) queue).getQueue();
         Utils.pointerBuffers[0].rewind();
         int ret = CL10.clEnqueueUnmapMemObject(q, image, mapping.buffer, null, Utils.pointerBuffers[0]);

+ 1 - 1
jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglKernel.java

@@ -162,8 +162,8 @@ public class LwjglKernel extends Kernel {
         buf.put(m.m00).put(m.m01).put(m.m02).put(m.m03);
         buf.put(m.m10).put(m.m11).put(m.m12).put(m.m13);
         buf.put(m.m20).put(m.m21).put(m.m22).put(m.m23);
-        buf.position(0);
         buf.put(m.m30).put(m.m31).put(m.m32).put(m.m33);
+        buf.position(0);
         int ret = CL10.clSetKernelArg(kernel, index, buf);
         Utils.checkError(ret, "clSetKernelArg");
     }