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

define_list_fix
shamanDevel 9 years ago
parent 250c871cab
commit 732e75fba6
  1. 12
      jme3-core/src/main/resources/Common/OpenCL/Random.clh
  2. 12
      jme3-examples/src/main/java/jme3test/opencl/TestOpenCLLibraries.java
  3. 1
      jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclBuffer.java
  4. 1
      jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclImage.java
  5. 1
      jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglBuffer.java
  6. 1
      jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglImage.java
  7. 2
      jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglKernel.java

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

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

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

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

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

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

@ -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.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.m10).put(m.m11).put(m.m12).put(m.m13);
buf.put(m.m20).put(m.m21).put(m.m22).put(m.m23); 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.put(m.m30).put(m.m31).put(m.m32).put(m.m33);
buf.position(0);
int ret = CL10.clSetKernelArg(kernel, index, buf); int ret = CL10.clSetKernelArg(kernel, index, buf);
Utils.checkError(ret, "clSetKernelArg"); Utils.checkError(ret, "clSetKernelArg");
} }

Loading…
Cancel
Save