From a444a384b808e423f2e8377ff14c69b0c4be043a Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Fri, 27 May 2011 03:00:12 +0200 Subject: LLB refactoring. - split up CL into multiple sub interfaces - seperation is now feature wise - introdused llb package for low level classes --- src/com/jogamp/opencl/CLBuffer.java | 1 + src/com/jogamp/opencl/CLCommandQueue.java | 8 +- src/com/jogamp/opencl/CLContext.java | 11 +- src/com/jogamp/opencl/CLDevice.java | 3 +- src/com/jogamp/opencl/CLEvent.java | 4 +- src/com/jogamp/opencl/CLEventList.java | 6 + src/com/jogamp/opencl/CLException.java | 2 +- src/com/jogamp/opencl/CLImage.java | 3 +- src/com/jogamp/opencl/CLImage2d.java | 1 + src/com/jogamp/opencl/CLImage3d.java | 3 +- src/com/jogamp/opencl/CLImageFormat.java | 4 +- src/com/jogamp/opencl/CLKernel.java | 5 +- src/com/jogamp/opencl/CLMemory.java | 11 +- src/com/jogamp/opencl/CLObject.java | 2 + src/com/jogamp/opencl/CLPlatform.java | 7 +- src/com/jogamp/opencl/CLProgram.java | 4 +- src/com/jogamp/opencl/CLSampler.java | 4 +- src/com/jogamp/opencl/CLUserEvent.java | 2 +- src/com/jogamp/opencl/gl/CLGLBuffer.java | 6 +- src/com/jogamp/opencl/gl/CLGLContext.java | 7 +- src/com/jogamp/opencl/gl/CLGLImage2d.java | 10 +- src/com/jogamp/opencl/gl/CLGLTexture2d.java | 17 +- src/com/jogamp/opencl/gl/CLGLTexture3d.java | 13 +- .../jogamp/opencl/impl/BuildProgramCallback.java | 47 ---- src/com/jogamp/opencl/impl/CLEventCallback.java | 43 --- src/com/jogamp/opencl/impl/CLImpl.java | 284 -------------------- .../opencl/impl/CLMemObjectDestructorCallback.java | 47 ---- .../jogamp/opencl/impl/CLTLAccessorFactory.java | 2 +- .../opencl/llb/impl/BuildProgramCallback.java | 47 ++++ .../jogamp/opencl/llb/impl/CLEventCallback.java | 43 +++ src/com/jogamp/opencl/llb/impl/CLImpl.java | 291 +++++++++++++++++++++ .../llb/impl/CLMemObjectDestructorCallback.java | 47 ++++ src/com/jogamp/opencl/spi/CLAccessorFactory.java | 2 +- src/com/jogamp/opencl/util/CLBuildListener.java | 4 +- src/com/jogamp/opencl/util/CLInfo.java | 2 +- src/com/jogamp/opencl/util/CLUtil.java | 2 +- src/com/jogamp/opencl/util/JOCLVersion.java | 6 +- 37 files changed, 521 insertions(+), 480 deletions(-) delete mode 100644 src/com/jogamp/opencl/impl/BuildProgramCallback.java delete mode 100644 src/com/jogamp/opencl/impl/CLEventCallback.java delete mode 100644 src/com/jogamp/opencl/impl/CLImpl.java delete mode 100644 src/com/jogamp/opencl/impl/CLMemObjectDestructorCallback.java create mode 100644 src/com/jogamp/opencl/llb/impl/BuildProgramCallback.java create mode 100644 src/com/jogamp/opencl/llb/impl/CLEventCallback.java create mode 100644 src/com/jogamp/opencl/llb/impl/CLImpl.java create mode 100644 src/com/jogamp/opencl/llb/impl/CLMemObjectDestructorCallback.java (limited to 'src') diff --git a/src/com/jogamp/opencl/CLBuffer.java b/src/com/jogamp/opencl/CLBuffer.java index 6f00247c..dfdfd2d0 100644 --- a/src/com/jogamp/opencl/CLBuffer.java +++ b/src/com/jogamp/opencl/CLBuffer.java @@ -32,6 +32,7 @@ import com.jogamp.common.nio.Buffers; import java.util.List; import com.jogamp.common.nio.NativeSizeBuffer; import com.jogamp.opencl.CLMemory.Mem; +import com.jogamp.opencl.llb.CL; import java.nio.Buffer; import java.util.ArrayList; import java.util.Collections; diff --git a/src/com/jogamp/opencl/CLCommandQueue.java b/src/com/jogamp/opencl/CLCommandQueue.java index d578738b..2f83464f 100644 --- a/src/com/jogamp/opencl/CLCommandQueue.java +++ b/src/com/jogamp/opencl/CLCommandQueue.java @@ -29,7 +29,7 @@ package com.jogamp.opencl; import com.jogamp.common.nio.CachedBufferFactory; -import com.jogamp.opencl.gl.CLGLI; +import com.jogamp.opencl.llb.gl.CLGL; import com.jogamp.common.nio.NativeSizeBuffer; import com.jogamp.opencl.gl.CLGLObject; import java.nio.Buffer; @@ -41,7 +41,7 @@ import java.util.EnumSet; import java.util.List; import static com.jogamp.opencl.CLException.*; -import static com.jogamp.opencl.CL.*; +import static com.jogamp.opencl.llb.CL.*; import static com.jogamp.opencl.util.CLUtil.*; /** @@ -1667,7 +1667,7 @@ public class CLCommandQueue extends CLObject implements CLResource { conditions = condition.size; } - CLGLI xl = (CLGLI) cl; + CLGL xl = (CLGL) cl; int ret = xl.clEnqueueAcquireGLObjects(ID, glObjectIDs.remaining(), glObjectIDs, conditions, conditionIDs, @@ -1736,7 +1736,7 @@ public class CLCommandQueue extends CLObject implements CLResource { conditions = condition.size; } - CLGLI xl = (CLGLI) cl; + CLGL xl = (CLGL) cl; int ret = xl.clEnqueueReleaseGLObjects(ID, glObjectIDs.remaining(), glObjectIDs, conditions, conditionIDs, diff --git a/src/com/jogamp/opencl/CLContext.java b/src/com/jogamp/opencl/CLContext.java index 147fc2ae..2beea3f8 100644 --- a/src/com/jogamp/opencl/CLContext.java +++ b/src/com/jogamp/opencl/CLContext.java @@ -28,12 +28,13 @@ package com.jogamp.opencl; +import com.jogamp.opencl.llb.CL; import com.jogamp.common.nio.Buffers; import com.jogamp.opencl.CLDevice.Type; import com.jogamp.opencl.CLSampler.AddressingMode; import com.jogamp.opencl.CLSampler.FilteringMode; import com.jogamp.common.nio.NativeSizeBuffer; -import com.jogamp.opencl.impl.CLImageFormatImpl; +import com.jogamp.opencl.llb.impl.CLImageFormatImpl; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -57,7 +58,7 @@ import static java.lang.System.*; import static com.jogamp.opencl.CLException.*; import static com.jogamp.common.nio.Buffers.*; import static com.jogamp.common.os.Platform.*; -import static com.jogamp.opencl.CL.*; +import static com.jogamp.opencl.llb.CL.*; import static com.jogamp.opencl.CLBuffer.*; import static java.util.Collections.*; @@ -121,11 +122,11 @@ public class CLContext extends CLObject implements CLResource { NativeSizeBuffer deviceCount = NativeSizeBuffer.allocateDirect(1); - int ret = cl.clGetContextInfo(ID, CL.CL_CONTEXT_DEVICES, 0, null, deviceCount); + int ret = cl.clGetContextInfo(ID, CL_CONTEXT_DEVICES, 0, null, deviceCount); checkForError(ret, "can not enumerate devices"); ByteBuffer deviceIDs = Buffers.newDirectByteBuffer((int)deviceCount.get()); - ret = cl.clGetContextInfo(ID, CL.CL_CONTEXT_DEVICES, deviceIDs.capacity(), deviceIDs, null); + ret = cl.clGetContextInfo(ID, CL_CONTEXT_DEVICES, deviceIDs.capacity(), deviceIDs, null); checkForError(ret, "can not enumerate devices"); devices = new CLDevice[deviceIDs.capacity() / (is32Bit() ? 4 : 8)]; @@ -236,7 +237,7 @@ public class CLContext extends CLObject implements CLResource { throw new RuntimeException("no OpenCL installation found"); } - return NativeSizeBuffer.allocateDirect(3).put(CL.CL_CONTEXT_PLATFORM) + return NativeSizeBuffer.allocateDirect(3).put(CL_CONTEXT_PLATFORM) .put(platform.ID).put(0) // 0 terminated array .rewind(); } diff --git a/src/com/jogamp/opencl/CLDevice.java b/src/com/jogamp/opencl/CLDevice.java index 6ca4cf38..abfb3a07 100644 --- a/src/com/jogamp/opencl/CLDevice.java +++ b/src/com/jogamp/opencl/CLDevice.java @@ -28,6 +28,7 @@ package com.jogamp.opencl; +import com.jogamp.opencl.llb.CL; import com.jogamp.opencl.util.CLUtil; import com.jogamp.opencl.spi.CLInfoAccessor; import java.nio.ByteOrder; @@ -40,7 +41,7 @@ import java.util.Map; import java.util.Scanner; import java.util.Set; -import static com.jogamp.opencl.CL.*; +import static com.jogamp.opencl.llb.CL.*; /** * This object represents an OpenCL device. diff --git a/src/com/jogamp/opencl/CLEvent.java b/src/com/jogamp/opencl/CLEvent.java index 52b316da..0b2c1eb7 100644 --- a/src/com/jogamp/opencl/CLEvent.java +++ b/src/com/jogamp/opencl/CLEvent.java @@ -29,11 +29,11 @@ package com.jogamp.opencl; import com.jogamp.opencl.impl.CLTLInfoAccessor; -import com.jogamp.opencl.impl.CLEventCallback; +import com.jogamp.opencl.llb.impl.CLEventCallback; import com.jogamp.common.nio.NativeSizeBuffer; import java.nio.Buffer; -import static com.jogamp.opencl.CL.*; +import static com.jogamp.opencl.llb.CL.*; import static com.jogamp.opencl.CLException.*; /** diff --git a/src/com/jogamp/opencl/CLEventList.java b/src/com/jogamp/opencl/CLEventList.java index 3642d915..8c09f60f 100644 --- a/src/com/jogamp/opencl/CLEventList.java +++ b/src/com/jogamp/opencl/CLEventList.java @@ -102,6 +102,7 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable iterator() { return new EventIterator(events, size); } @@ -167,10 +170,12 @@ public final class CLEventList implements CLResource, AutoCloseable, Iterable extends CLObject implements CL @Deprecated /*public*/ final GLObjectType _getGLObjectType() { int[] array = new int[1]; - int ret = ((CLGLI)cl).clGetGLObjectInfo(ID, array, 0, null, 0); + int ret = ((CLGL)cl).clGetGLObjectInfo(ID, array, 0, null, 0); CLException.checkForError(ret, "error while asking for gl object info"); return GLObjectType.valueOf(array[0]); } @@ -242,7 +243,7 @@ public abstract class CLMemory extends CLObject implements CL @Deprecated /*public*/ final int _getGLObjectID() { int[] array = new int[1]; - int ret = ((CLGLI)cl).clGetGLObjectInfo(ID, null, 0, array, 0); + int ret = ((CLGL)cl).clGetGLObjectInfo(ID, null, 0, array, 0); CLException.checkForError(ret, "error while asking for gl object info"); return array[0]; } diff --git a/src/com/jogamp/opencl/CLObject.java b/src/com/jogamp/opencl/CLObject.java index 54031884..eb1f0abf 100644 --- a/src/com/jogamp/opencl/CLObject.java +++ b/src/com/jogamp/opencl/CLObject.java @@ -29,6 +29,7 @@ package com.jogamp.opencl; import com.jogamp.common.AutoCloseable; +import com.jogamp.opencl.llb.CL; /** * Common superclass for all OpenCL objects. @@ -64,6 +65,7 @@ abstract class CLObject implements AutoCloseable { * @see java.lang.AutoCloseable */ @Deprecated + @Override public final void close() { if(this instanceof CLResource) { ((CLResource)this).release(); diff --git a/src/com/jogamp/opencl/CLPlatform.java b/src/com/jogamp/opencl/CLPlatform.java index 4a87b43d..a494edcb 100644 --- a/src/com/jogamp/opencl/CLPlatform.java +++ b/src/com/jogamp/opencl/CLPlatform.java @@ -28,6 +28,7 @@ package com.jogamp.opencl; +import com.jogamp.opencl.llb.CL; import com.jogamp.opencl.impl.CLTLAccessorFactory; import com.jogamp.common.nio.Buffers; import com.jogamp.common.os.DynamicLookupHelper; @@ -37,8 +38,8 @@ import com.jogamp.common.nio.NativeSizeBuffer; import com.jogamp.gluegen.runtime.FunctionAddressResolver; import com.jogamp.opencl.spi.CLPlatformInfoAccessor; import com.jogamp.opencl.util.CLUtil; -import com.jogamp.opencl.impl.CLImpl; -import com.jogamp.opencl.impl.CLProcAddressTable; +import com.jogamp.opencl.llb.impl.CLImpl; +import com.jogamp.opencl.llb.impl.CLProcAddressTable; import com.jogamp.opencl.spi.CLAccessorFactory; import com.jogamp.opencl.util.Filter; import com.jogamp.opencl.util.JOCLVersion; @@ -55,7 +56,7 @@ import java.security.PrivilegedAction; import static java.security.AccessController.*; import static com.jogamp.opencl.CLException.*; -import static com.jogamp.opencl.CL.*; +import static com.jogamp.opencl.llb.CL.*; /** * CLPlatfrorm representing a OpenCL implementation (e.g. graphics driver). diff --git a/src/com/jogamp/opencl/CLProgram.java b/src/com/jogamp/opencl/CLProgram.java index e8706a73..b991c1e9 100644 --- a/src/com/jogamp/opencl/CLProgram.java +++ b/src/com/jogamp/opencl/CLProgram.java @@ -34,7 +34,7 @@ import com.jogamp.opencl.util.CLUtil; import com.jogamp.common.os.Platform; import com.jogamp.common.nio.NativeSizeBuffer; import com.jogamp.common.nio.PointerBuffer; -import com.jogamp.opencl.impl.BuildProgramCallback; +import com.jogamp.opencl.llb.impl.BuildProgramCallback; import com.jogamp.opencl.util.CLBuildListener; import java.nio.ByteBuffer; import java.nio.IntBuffer; @@ -48,7 +48,7 @@ import java.util.Map; import java.util.concurrent.locks.ReentrantLock; import static com.jogamp.opencl.CLException.*; -import static com.jogamp.opencl.CL.*; +import static com.jogamp.opencl.llb.CL.*; import static com.jogamp.common.nio.Buffers.*; /** diff --git a/src/com/jogamp/opencl/CLSampler.java b/src/com/jogamp/opencl/CLSampler.java index 015445e3..04751be2 100644 --- a/src/com/jogamp/opencl/CLSampler.java +++ b/src/com/jogamp/opencl/CLSampler.java @@ -34,7 +34,7 @@ import com.jogamp.common.nio.NativeSizeBuffer; import java.nio.Buffer; import static com.jogamp.opencl.CLException.*; -import static com.jogamp.opencl.CL.*; +import static com.jogamp.opencl.llb.CL.*; import static com.jogamp.opencl.util.CLUtil.*; /** @@ -78,7 +78,7 @@ public class CLSampler extends CLObject implements CLResource { public void release() { int ret = cl.clReleaseSampler(ID); context.onSamplerReleased(this); - if(ret != CL.CL_SUCCESS) { + if(ret != CL_SUCCESS) { throw newException(ret, "can not release "+this); } } diff --git a/src/com/jogamp/opencl/CLUserEvent.java b/src/com/jogamp/opencl/CLUserEvent.java index 4bbbf3b8..22839b0a 100644 --- a/src/com/jogamp/opencl/CLUserEvent.java +++ b/src/com/jogamp/opencl/CLUserEvent.java @@ -33,7 +33,7 @@ package com.jogamp.opencl; import static com.jogamp.opencl.CLException.*; -import static com.jogamp.opencl.CL.*; +import static com.jogamp.opencl.llb.CL.*; /** * Custom, user controlled event. diff --git a/src/com/jogamp/opencl/gl/CLGLBuffer.java b/src/com/jogamp/opencl/gl/CLGLBuffer.java index 148aa83d..55cede88 100644 --- a/src/com/jogamp/opencl/gl/CLGLBuffer.java +++ b/src/com/jogamp/opencl/gl/CLGLBuffer.java @@ -32,6 +32,7 @@ import com.jogamp.opencl.CLBuffer; import com.jogamp.opencl.CLCommandQueue; import com.jogamp.opencl.CLContext; import com.jogamp.opencl.CLException; +import com.jogamp.opencl.llb.gl.CLGL; import java.nio.Buffer; import javax.media.opengl.GLContext; @@ -58,7 +59,7 @@ public final class CLGLBuffer extends CLBuffer implements C static CLGLBuffer create(CLContext context, B directBuffer, long size, int flags, int glObject) { checkBuffer(directBuffer, flags); - CLGLI clgli = (CLGLI)getCL(context); + CLGL clgli = (CLGL)getCL(context); int[] result = new int[1]; long id = clgli.clCreateFromGLBuffer(context.ID, flags, glObject, result, 0); @@ -86,10 +87,12 @@ public final class CLGLBuffer extends CLBuffer implements C initCLCapacity(); } + @Override public int getGLObjectID() { return GLID; } + @Override public GLObjectType getGLObjectType() { return GLObjectType.GL_OBJECT_BUFFER; } @@ -99,6 +102,7 @@ public final class CLGLBuffer extends CLBuffer implements C return (CLGLContext) super.getContext(); } + @Override public GLContext getGLContext() { return getContext().getGLContext(); } diff --git a/src/com/jogamp/opencl/gl/CLGLContext.java b/src/com/jogamp/opencl/gl/CLGLContext.java index ee6c2108..e688717f 100644 --- a/src/com/jogamp/opencl/gl/CLGLContext.java +++ b/src/com/jogamp/opencl/gl/CLGLContext.java @@ -28,6 +28,7 @@ package com.jogamp.opencl.gl; +import com.jogamp.opencl.llb.gl.CLGL; import com.jogamp.opencl.CLContext; import com.jogamp.opencl.CLDevice; import java.nio.Buffer; @@ -42,7 +43,7 @@ import jogamp.opengl.windows.wgl.WindowsWGLContext; import jogamp.opengl.x11.glx.X11GLXContext; import javax.media.opengl.GLContext; -import static com.jogamp.opencl.gl.CLGLI.*; +import static com.jogamp.opencl.llb.gl.CLGL.*; /** * OpenCL Context supporting JOGL-JOCL interoperablity. @@ -308,8 +309,8 @@ public final class CLGLContext extends CLContext { * Return the low level OpenCL interface with OpenGL interoperability. */ @Override - public CLGLI getCL() { - return (CLGLI)super.getCL(); + public CLGL getCL() { + return (CLGL)super.getCL(); } /** diff --git a/src/com/jogamp/opencl/gl/CLGLImage2d.java b/src/com/jogamp/opencl/gl/CLGLImage2d.java index 94ad7e84..dd6b9d5a 100644 --- a/src/com/jogamp/opencl/gl/CLGLImage2d.java +++ b/src/com/jogamp/opencl/gl/CLGLImage2d.java @@ -28,15 +28,16 @@ package com.jogamp.opencl.gl; -import com.jogamp.opencl.CL; +import com.jogamp.opencl.llb.CL; +import com.jogamp.opencl.llb.gl.CLGL; import com.jogamp.opencl.CLContext; import com.jogamp.opencl.CLImage2d; import com.jogamp.opencl.CLImageFormat; -import com.jogamp.opencl.impl.CLImageFormatImpl; +import com.jogamp.opencl.llb.impl.CLImageFormatImpl; import java.nio.Buffer; import javax.media.opengl.GLContext; -import static com.jogamp.opencl.CL.*; +import static com.jogamp.opencl.llb.CL.*; /** * 2D OpenCL image representing an OpenGL renderbuffer. @@ -60,7 +61,7 @@ public class CLGLImage2d extends CLImage2d implements CLGLO CL cl = getCL(context); int[] result = new int[1]; - CLGLI clgli = (CLGLI)cl; + CLGL clgli = (CLGL)cl; long id = clgli.clCreateFromGLRenderbuffer(context.ID, flags, glObject, result, 0); @@ -94,6 +95,7 @@ public class CLGLImage2d extends CLImage2d implements CLGLO return (CLGLContext) super.getContext(); } + @Override public GLContext getGLContext() { return getContext().getGLContext(); } diff --git a/src/com/jogamp/opencl/gl/CLGLTexture2d.java b/src/com/jogamp/opencl/gl/CLGLTexture2d.java index faf1bdc8..484d00d2 100644 --- a/src/com/jogamp/opencl/gl/CLGLTexture2d.java +++ b/src/com/jogamp/opencl/gl/CLGLTexture2d.java @@ -28,13 +28,15 @@ package com.jogamp.opencl.gl; -import com.jogamp.opencl.CL; +import com.jogamp.opencl.llb.CL; import com.jogamp.opencl.CLContext; import com.jogamp.opencl.CLImageFormat; -import com.jogamp.opencl.impl.CLImageFormatImpl; +import com.jogamp.opencl.llb.impl.CLImageFormatImpl; +import com.jogamp.opencl.llb.gl.CLGL; import java.nio.Buffer; -import static com.jogamp.opencl.CL.*; +import static com.jogamp.opencl.CLException.*; +import static com.jogamp.opencl.llb.CL.*; /** * 2D OpenCL image representing an 2D OpenGL texture. @@ -58,26 +60,29 @@ public class CLGLTexture2d extends CLGLImage2d implements C CL cl = getCL(context); int[] result = new int[1]; - CLGLI clgli = (CLGLI)cl; + CLGL clgli = (CLGL)cl; long id = clgli.clCreateFromGLTexture2D(context.ID, flags, target, mipLevel, texture, result, 0); + checkForError((int)id, "can not share memory with texture #"+texture+"."); CLImageInfoAccessor accessor = new CLImageInfoAccessor(cl, id); CLImageFormat format = createUninitializedImageFormat(); accessor.getInfo(CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null); - int width = (int)accessor.getLong(CL_IMAGE_WIDTH); - int height = (int)accessor.getLong(CL_IMAGE_HEIGHT); + int width = 640; //(int)accessor.getLong(CL_IMAGE_WIDTH); + int height = 480; //(int)accessor.getLong(CL_IMAGE_HEIGHT); return new CLGLTexture2d(context, directBuffer, format, accessor, target, mipLevel, width, height, id, texture, flags); } + @Override public int getTextureTarget() { return target; } + @Override public int getMipMapLevel() { return mipMapLevel; } diff --git a/src/com/jogamp/opencl/gl/CLGLTexture3d.java b/src/com/jogamp/opencl/gl/CLGLTexture3d.java index ace779d9..8dd2682c 100644 --- a/src/com/jogamp/opencl/gl/CLGLTexture3d.java +++ b/src/com/jogamp/opencl/gl/CLGLTexture3d.java @@ -28,15 +28,16 @@ package com.jogamp.opencl.gl; -import com.jogamp.opencl.CL; +import com.jogamp.opencl.llb.gl.CLGL; +import com.jogamp.opencl.llb.CL; import com.jogamp.opencl.CLContext; import com.jogamp.opencl.CLImage3d; import com.jogamp.opencl.CLImageFormat; -import com.jogamp.opencl.impl.CLImageFormatImpl; +import com.jogamp.opencl.llb.impl.CLImageFormatImpl; import java.nio.Buffer; import javax.media.opengl.GLContext; -import static com.jogamp.opencl.CL.*; +import static com.jogamp.opencl.llb.CL.*; /** * 3D OpenCL image representing an 3D OpenGL texture. @@ -66,7 +67,7 @@ public class CLGLTexture3d extends CLImage3d implements CLG CL cl = getCL(context); int[] result = new int[1]; - CLGLI clgli = (CLGLI)cl; + CLGL clgli = (CLGL)cl; long id = clgli.clCreateFromGLTexture3D(context.ID, flags, target, mipLevel, texture, result, 0); @@ -82,18 +83,22 @@ public class CLGLTexture3d extends CLImage3d implements CLG return new CLGLTexture3d(context, directBuffer, format, accessor, target, mipLevel, width, height, depth, id, texture, flags); } + @Override public int getGLObjectID() { return GLID; } + @Override public int getTextureTarget() { return target; } + @Override public int getMipMapLevel() { return mipMapLevel; } + @Override public GLObjectType getGLObjectType() { return GLObjectType.GL_OBJECT_TEXTURE3D; } diff --git a/src/com/jogamp/opencl/impl/BuildProgramCallback.java b/src/com/jogamp/opencl/impl/BuildProgramCallback.java deleted file mode 100644 index cb4b36d1..00000000 --- a/src/com/jogamp/opencl/impl/BuildProgramCallback.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2009 - 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opencl.impl; - -/** - * A callback an application can register to be called when the program executable - * has been built (successfully or unsuccessfully).
- * Note1: registering a build callback can make {@link com.jogamp.opencl.CL#clBuildProgram} non blocking (OpenCL implementation dependent).
- * Note2: the thread which calls this method is unspecified. The Application should ensure propper synchronization. - * @author Michael Bien - * @see com.jogamp.opencl.CL#clBuildProgram(long, int, com.jogamp.common.nio.PointerBuffer, java.lang.String, com.jogamp.opencl.impl.BuildProgramCallback) - */ -public interface BuildProgramCallback { - - /** - * Called when the program executable - * has been built (successfully or unsuccessfully). - */ - public void buildFinished(long cl_program); - -} diff --git a/src/com/jogamp/opencl/impl/CLEventCallback.java b/src/com/jogamp/opencl/impl/CLEventCallback.java deleted file mode 100644 index d1526a08..00000000 --- a/src/com/jogamp/opencl/impl/CLEventCallback.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2009 - 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -/* - * Created on Tuesday, July 06 2010 00:46 - */ - -package com.jogamp.opencl.impl; - -/** - * A callback for a specific command execution status. - * @author Michael Bien - */ -public interface CLEventCallback { - - public void eventStateChanged(long event, int status); - -} diff --git a/src/com/jogamp/opencl/impl/CLImpl.java b/src/com/jogamp/opencl/impl/CLImpl.java deleted file mode 100644 index 8ea44201..00000000 --- a/src/com/jogamp/opencl/impl/CLImpl.java +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright 2009 - 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -/* - * Created on Monday, June 07 2010 at 04:25 - */ -package com.jogamp.opencl.impl; - -import com.jogamp.common.nio.NativeSizeBuffer; -import com.jogamp.common.os.Platform; -import com.jogamp.common.util.LongLongHashMap; -import com.jogamp.opencl.CLErrorHandler; -import com.jogamp.opencl.CLException; -import java.nio.ByteBuffer; -import java.nio.IntBuffer; - -import static com.jogamp.common.nio.Buffers.*; - -/** - * Java bindings to OpenCL, the Open Computing Language. - * @author Michael Bien - */ -public class CLImpl extends CLAbstractImpl { - - //maps the context id to its error handler's global object pointer - private final LongLongHashMap contextCallbackMap; - - public CLImpl(CLProcAddressTable addressTable) { - super(addressTable); - this.contextCallbackMap = new LongLongHashMap(); - this.contextCallbackMap.setKeyNotFoundValue(0); - } - - public long clCreateContext(NativeSizeBuffer properties, NativeSizeBuffer devices, CLErrorHandler pfn_notify, IntBuffer errcode_ret) { - - if (properties != null && !properties.isDirect()) { - throw new RuntimeException("Argument \"properties\" was not a direct buffer"); - } - - if (errcode_ret != null && !errcode_ret.isDirect()) { - throw new RuntimeException("Argument \"errcode_ret\" was not a direct buffer"); - } - - final long address = addressTable._addressof_clCreateContext; - if (address == 0) { - throw new UnsupportedOperationException("Method not available"); - } - - long[] global = new long[1]; - long ctx = this.clCreateContext0( - properties != null ? properties.getBuffer() : null, getDirectBufferByteOffset(properties), - devices != null ? devices.remaining() : 0, devices != null ? devices.getBuffer() : null, getDirectBufferByteOffset(devices), - pfn_notify, global, errcode_ret, getDirectBufferByteOffset(errcode_ret), address); - - if (pfn_notify != null && global[0] != 0) { - synchronized (contextCallbackMap) { - contextCallbackMap.put(ctx, global[0]); - } - } - return ctx; - } - - private native long clCreateContext0(Object cl_context_properties, int props_offset, int numDevices, Object devices, int devices_offset, Object pfn_notify, long[] global, Object errcode_ret, int err_offset, long address); - - public long clCreateContextFromType(NativeSizeBuffer properties, long device_type, CLErrorHandler pfn_notify, IntBuffer errcode_ret) { - - if (properties != null && !properties.isDirect()) { - throw new RuntimeException("Argument \"properties\" was not a direct buffer"); - } - - if (errcode_ret != null && !errcode_ret.isDirect()) { - throw new RuntimeException("Argument \"errcode_ret\" was not a direct buffer"); - } - - final long address = addressTable._addressof_clCreateContextFromType; - if (address == 0) { - throw new UnsupportedOperationException("Method not available"); - } - - long[] global = new long[1]; - long ctx = this.clCreateContextFromType0( - properties != null ? properties.getBuffer() : null, getDirectBufferByteOffset(properties), - device_type, pfn_notify, global, errcode_ret, getDirectBufferByteOffset(errcode_ret), address); - - if (pfn_notify != null && global[0] != 0) { - synchronized (contextCallbackMap) { - contextCallbackMap.put(ctx, global[0]); - } - } - return ctx; - } - - private native long clCreateContextFromType0(Object properties, int props_offset, long device_type, Object pfn_notify, long[] global, Object errcode_ret, int err_offset, long address); - - public int clReleaseContext(long context) { - long global = 0; - synchronized (contextCallbackMap) { - global = contextCallbackMap.remove(context); - } - - final long address = addressTable._addressof_clReleaseContext; - if (address == 0) { - throw new UnsupportedOperationException("Method not available"); - } - return clReleaseContextImpl(context, global, address); - } - - /** Interface to C language function:
int32_t {@native clReleaseContext}(cl_context context); */ - public native int clReleaseContextImpl(long context, long global, long address); - - /** Interface to C language function:
int32_t clBuildProgram(cl_program, uint32_t, cl_device_id * , const char * , void * ); */ - public int clBuildProgram(long program, int deviceCount, NativeSizeBuffer deviceList, String options, BuildProgramCallback cb) { - - if (deviceList != null && !deviceList.isDirect()) { - throw new RuntimeException("Argument \"properties\" was not a direct buffer"); - } - - final long address = addressTable._addressof_clBuildProgram; - if (address == 0) { - throw new UnsupportedOperationException("Method not available"); - } - return clBuildProgram0(program, deviceCount, deviceList != null ? deviceList.getBuffer() : null, - getDirectBufferByteOffset(deviceList), options, cb, address); - } - - /** Entry point to C language function: int32_t clBuildProgram(cl_program, uint32_t, cl_device_id * , const char * , void * ); */ - private native int clBuildProgram0(long program, int deviceCount, Object deviceList, int deviceListOffset, String options, BuildProgramCallback cb, long address); - - - public int clSetEventCallback(long event, int trigger, CLEventCallback callback) { - final long address = addressTable._addressof_clSetEventCallback; - if (address == 0) { - throw new UnsupportedOperationException("Method not available"); - } - return clSetEventCallback0(event, trigger, callback, address); - } - - private native int clSetEventCallback0(long event, int type, CLEventCallback cb, long address); - - - public int clSetMemObjectDestructorCallback(long memObjID, CLMemObjectDestructorCallback cb) { - final long address = addressTable._addressof_clSetMemObjectDestructorCallback; - if (address == 0) { - throw new UnsupportedOperationException("Method not available"); - } - return clSetMemObjectDestructorCallback0(memObjID, cb, address); - } - - private native int clSetMemObjectDestructorCallback0(long memObjID, CLMemObjectDestructorCallback cb, long address); - - - /** Interface to C language function:
void * {@native clEnqueueMapImage}(cl_command_queue command_queue, cl_mem image, uint32_t blocking_map, uint64_t map_flags, const size_t * , const size_t * , size_t * image_row_pitch, size_t * image_slice_pitch, uint32_t num_events_in_wait_list, cl_event * event_wait_list, cl_event * event, int32_t * errcode_ret); - @param origin a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param range a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param image_row_pitch a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param image_slice_pitch a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param event_wait_list a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param event a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param errcode_ret a direct {@link java.nio.IntBuffer} */ - public ByteBuffer clEnqueueMapImage(long command_queue, long image, int blocking_map, long map_flags, - NativeSizeBuffer origin, NativeSizeBuffer range, - NativeSizeBuffer image_row_pitch, NativeSizeBuffer image_slice_pitch, - int num_events_in_wait_list, - NativeSizeBuffer event_wait_list, NativeSizeBuffer event, IntBuffer errcode_ret) { - - if (origin != null && !origin.isDirect()) { - throw new CLException("Argument \"origin\" was not a direct buffer"); - } - if (range != null && !range.isDirect()) { - throw new CLException("Argument \"range\" was not a direct buffer"); - } - if (image_row_pitch != null && !image_row_pitch.isDirect()) { - throw new CLException("Argument \"image_row_pitch\" was not a direct buffer"); - } - if (image_slice_pitch != null && !image_slice_pitch.isDirect()) { - throw new CLException("Argument \"image_slice_pitch\" was not a direct buffer"); - } - if (event_wait_list != null && !event_wait_list.isDirect()) { - throw new CLException("Argument \"event_wait_list\" was not a direct buffer"); - } - if (event != null && !event.isDirect()) { - throw new CLException("Argument \"event\" was not a direct buffer"); - } - if (errcode_ret != null && !errcode_ret.isDirect()) { - throw new CLException("Argument \"errcode_ret\" was not a direct buffer"); - } - - final long mapImageAddress = addressTable._addressof_clEnqueueMapImage; - if (mapImageAddress == 0) { - throw new UnsupportedOperationException("Method not available"); - } - final long getImageInfoAddress = addressTable._addressof_clGetImageInfo; - if (getImageInfoAddress == 0) { - throw new UnsupportedOperationException("Method not available"); - } - ByteBuffer _res; - _res = clEnqueueMapImage0(command_queue, image, blocking_map, map_flags, origin != null ? origin.getBuffer() : null, - getDirectBufferByteOffset(origin), range != null ? range.getBuffer() : null, - getDirectBufferByteOffset(range), image_row_pitch != null ? image_row_pitch.getBuffer() : null, - getDirectBufferByteOffset(image_row_pitch), image_slice_pitch != null ? image_slice_pitch.getBuffer() : null, - getDirectBufferByteOffset(image_slice_pitch), num_events_in_wait_list, - event_wait_list != null ? event_wait_list.getBuffer() : null, getDirectBufferByteOffset(event_wait_list), - event != null ? event.getBuffer() : null, getDirectBufferByteOffset(event), errcode_ret, - getDirectBufferByteOffset(errcode_ret)); - if (_res == null) { - return null; - } - nativeOrder(_res); - return _res; - } - - /** Entry point to C language function: void * {@native clEnqueueMapImage}(cl_command_queue command_queue, cl_mem image, uint32_t blocking_map, uint64_t map_flags, const size_t * , const size_t * , size_t * image_row_pitch, size_t * image_slice_pitch, uint32_t num_events_in_wait_list, cl_event * event_wait_list, cl_event * event, int32_t * errcode_ret); - @param origin a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param range a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param image_row_pitch a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param image_slice_pitch a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param event_wait_list a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param event a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} - @param errcode_ret a direct {@link java.nio.IntBuffer} */ - private native ByteBuffer clEnqueueMapImage0(long command_queue, long image, int blocking_map, long map_flags, - Object origin, int origin_byte_offset, Object range, int range_byte_offset, Object image_row_pitch, - int image_row_pitch_byte_offset, Object image_slice_pitch, int image_slice_pitch_byte_offset, - int num_events_in_wait_list, Object event_wait_list, int event_wait_list_byte_offset, Object event, - int event_byte_offset, Object errcode_ret, int errcode_ret_byte_offset); - - /** - * Returns the extension function address for the given function name. - */ - public long clGetExtensionFunctionAddress(String name) { - ByteBuffer res = super.clGetExtensionFunctionAddressImpl(name); - if(res == null) { - return 0; - }else if (Platform.is32Bit()) { - return res.getInt(); - } else { - return res.getLong(); - } - } - - public CLProcAddressTable getAddressTable() { - return addressTable; - } - - /* - private static void convert32To64(long[] values) { - if (values.length % 2 == 1) { - values[values.length - 1] = values[values.length / 2] >>> 32; - } - for (int i = values.length - 1 - values.length % 2; i >= 0; i -= 2) { - long temp = values[i / 2]; - values[i - 1] = temp >>> 32; - values[i] = temp & 0x00000000FFFFFFFFL; - } - } - */ - - - -} diff --git a/src/com/jogamp/opencl/impl/CLMemObjectDestructorCallback.java b/src/com/jogamp/opencl/impl/CLMemObjectDestructorCallback.java deleted file mode 100644 index c040d2ce..00000000 --- a/src/com/jogamp/opencl/impl/CLMemObjectDestructorCallback.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2009 - 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -/* - * Created on Thursday, September 02 2010 23:09 - */ - -package com.jogamp.opencl.impl; - -/** - * A callback which is invoked by the OpenCL implementation when the memory - * object is deleted and its resources freed. - * @author Michael Bien - */ -public interface CLMemObjectDestructorCallback { - - /** - * - */ - public void memoryDeallocated(long memObjID); - -} diff --git a/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java b/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java index 1c7f9526..b5ad1d8a 100644 --- a/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java +++ b/src/com/jogamp/opencl/impl/CLTLAccessorFactory.java @@ -5,7 +5,7 @@ package com.jogamp.opencl.impl; import java.nio.IntBuffer; import com.jogamp.common.nio.NativeSizeBuffer; -import com.jogamp.opencl.CL; +import com.jogamp.opencl.llb.CL; import com.jogamp.opencl.spi.CLAccessorFactory; import com.jogamp.opencl.spi.CLInfoAccessor; import com.jogamp.opencl.spi.CLPlatformInfoAccessor; diff --git a/src/com/jogamp/opencl/llb/impl/BuildProgramCallback.java b/src/com/jogamp/opencl/llb/impl/BuildProgramCallback.java new file mode 100644 index 00000000..51bde322 --- /dev/null +++ b/src/com/jogamp/opencl/llb/impl/BuildProgramCallback.java @@ -0,0 +1,47 @@ +/* + * Copyright 2009 - 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opencl.llb.impl; + +/** + * A callback an application can register to be called when the program executable + * has been built (successfully or unsuccessfully).
+ * Note1: registering a build callback can make {@link com.jogamp.opencl.llb.CL#clBuildProgram} non blocking (OpenCL implementation dependent).
+ * Note2: the thread which calls this method is unspecified. The Application should ensure proper synchronization. + * @author Michael Bien + * @see com.jogamp.opencl.llb.CL#clBuildProgram + */ +public interface BuildProgramCallback { + + /** + * Called when the program executable + * has been built (successfully or unsuccessfully). + */ + public void buildFinished(long cl_program); + +} diff --git a/src/com/jogamp/opencl/llb/impl/CLEventCallback.java b/src/com/jogamp/opencl/llb/impl/CLEventCallback.java new file mode 100644 index 00000000..1373995a --- /dev/null +++ b/src/com/jogamp/opencl/llb/impl/CLEventCallback.java @@ -0,0 +1,43 @@ +/* + * Copyright 2009 - 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +/* + * Created on Tuesday, July 06 2010 00:46 + */ + +package com.jogamp.opencl.llb.impl; + +/** + * A callback for a specific command execution status. + * @author Michael Bien + */ +public interface CLEventCallback { + + public void eventStateChanged(long event, int status); + +} diff --git a/src/com/jogamp/opencl/llb/impl/CLImpl.java b/src/com/jogamp/opencl/llb/impl/CLImpl.java new file mode 100644 index 00000000..5de3126d --- /dev/null +++ b/src/com/jogamp/opencl/llb/impl/CLImpl.java @@ -0,0 +1,291 @@ +/* + * Copyright 2009 - 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +/* + * Created on Monday, June 07 2010 at 04:25 + */ +package com.jogamp.opencl.llb.impl; + +import com.jogamp.common.nio.NativeSizeBuffer; +import com.jogamp.common.os.Platform; +import com.jogamp.common.util.LongLongHashMap; +import com.jogamp.opencl.CLErrorHandler; +import com.jogamp.opencl.CLException; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +import static com.jogamp.common.nio.Buffers.*; + +/** + * Java bindings to OpenCL, the Open Computing Language. + * @author Michael Bien + */ +public class CLImpl extends CLAbstractImpl { + + //maps the context id to its error handler's global object pointer + private final LongLongHashMap contextCallbackMap; + + public CLImpl(CLProcAddressTable addressTable) { + super(addressTable); + this.contextCallbackMap = new LongLongHashMap(); + this.contextCallbackMap.setKeyNotFoundValue(0); + } + + @Override + public long clCreateContext(NativeSizeBuffer properties, NativeSizeBuffer devices, CLErrorHandler pfn_notify, IntBuffer errcode_ret) { + + if (properties != null && !properties.isDirect()) { + throw new RuntimeException("Argument \"properties\" was not a direct buffer"); + } + + if (errcode_ret != null && !errcode_ret.isDirect()) { + throw new RuntimeException("Argument \"errcode_ret\" was not a direct buffer"); + } + + final long address = addressTable._addressof_clCreateContext; + if (address == 0) { + throw new UnsupportedOperationException("Method not available"); + } + + long[] global = new long[1]; + long ctx = this.clCreateContext0( + properties != null ? properties.getBuffer() : null, getDirectBufferByteOffset(properties), + devices != null ? devices.remaining() : 0, devices != null ? devices.getBuffer() : null, getDirectBufferByteOffset(devices), + pfn_notify, global, errcode_ret, getDirectBufferByteOffset(errcode_ret), address); + + if (pfn_notify != null && global[0] != 0) { + synchronized (contextCallbackMap) { + contextCallbackMap.put(ctx, global[0]); + } + } + return ctx; + } + + private native long clCreateContext0(Object cl_context_properties, int props_offset, int numDevices, Object devices, int devices_offset, Object pfn_notify, long[] global, Object errcode_ret, int err_offset, long address); + + @Override + public long clCreateContextFromType(NativeSizeBuffer properties, long device_type, CLErrorHandler pfn_notify, IntBuffer errcode_ret) { + + if (properties != null && !properties.isDirect()) { + throw new RuntimeException("Argument \"properties\" was not a direct buffer"); + } + + if (errcode_ret != null && !errcode_ret.isDirect()) { + throw new RuntimeException("Argument \"errcode_ret\" was not a direct buffer"); + } + + final long address = addressTable._addressof_clCreateContextFromType; + if (address == 0) { + throw new UnsupportedOperationException("Method not available"); + } + + long[] global = new long[1]; + long ctx = this.clCreateContextFromType0( + properties != null ? properties.getBuffer() : null, getDirectBufferByteOffset(properties), + device_type, pfn_notify, global, errcode_ret, getDirectBufferByteOffset(errcode_ret), address); + + if (pfn_notify != null && global[0] != 0) { + synchronized (contextCallbackMap) { + contextCallbackMap.put(ctx, global[0]); + } + } + return ctx; + } + + private native long clCreateContextFromType0(Object properties, int props_offset, long device_type, Object pfn_notify, long[] global, Object errcode_ret, int err_offset, long address); + + @Override + public int clReleaseContext(long context) { + long global = 0; + synchronized (contextCallbackMap) { + global = contextCallbackMap.remove(context); + } + + final long address = addressTable._addressof_clReleaseContext; + if (address == 0) { + throw new UnsupportedOperationException("Method not available"); + } + return clReleaseContextImpl(context, global, address); + } + + /** Interface to C language function:
int32_t {@native clReleaseContext}(cl_context context); */ + public native int clReleaseContextImpl(long context, long global, long address); + + /** Interface to C language function:
int32_t clBuildProgram(cl_program, uint32_t, cl_device_id * , const char * , void * ); */ + @Override + public int clBuildProgram(long program, int deviceCount, NativeSizeBuffer deviceList, String options, BuildProgramCallback cb) { + + if (deviceList != null && !deviceList.isDirect()) { + throw new RuntimeException("Argument \"properties\" was not a direct buffer"); + } + + final long address = addressTable._addressof_clBuildProgram; + if (address == 0) { + throw new UnsupportedOperationException("Method not available"); + } + return clBuildProgram0(program, deviceCount, deviceList != null ? deviceList.getBuffer() : null, + getDirectBufferByteOffset(deviceList), options, cb, address); + } + + /** Entry point to C language function: int32_t clBuildProgram(cl_program, uint32_t, cl_device_id * , const char * , void * ); */ + private native int clBuildProgram0(long program, int deviceCount, Object deviceList, int deviceListOffset, String options, BuildProgramCallback cb, long address); + + + @Override + public int clSetEventCallback(long event, int trigger, CLEventCallback callback) { + final long address = addressTable._addressof_clSetEventCallback; + if (address == 0) { + throw new UnsupportedOperationException("Method not available"); + } + return clSetEventCallback0(event, trigger, callback, address); + } + + private native int clSetEventCallback0(long event, int type, CLEventCallback cb, long address); + + + @Override + public int clSetMemObjectDestructorCallback(long memObjID, CLMemObjectDestructorCallback cb) { + final long address = addressTable._addressof_clSetMemObjectDestructorCallback; + if (address == 0) { + throw new UnsupportedOperationException("Method not available"); + } + return clSetMemObjectDestructorCallback0(memObjID, cb, address); + } + + private native int clSetMemObjectDestructorCallback0(long memObjID, CLMemObjectDestructorCallback cb, long address); + + + /** Interface to C language function:
void * {@native clEnqueueMapImage}(cl_command_queue command_queue, cl_mem image, uint32_t blocking_map, uint64_t map_flags, const size_t * , const size_t * , size_t * image_row_pitch, size_t * image_slice_pitch, uint32_t num_events_in_wait_list, cl_event * event_wait_list, cl_event * event, int32_t * errcode_ret); + @param origin a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} + @param range a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} + @param image_row_pitch a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} + @param image_slice_pitch a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} + @param event_wait_list a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} + @param event a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} + @param errcode_ret a direct {@link java.nio.IntBuffer} */ + @Override + public ByteBuffer clEnqueueMapImage(long command_queue, long image, int blocking_map, long map_flags, + NativeSizeBuffer origin, NativeSizeBuffer range, + NativeSizeBuffer image_row_pitch, NativeSizeBuffer image_slice_pitch, + int num_events_in_wait_list, + NativeSizeBuffer event_wait_list, NativeSizeBuffer event, IntBuffer errcode_ret) { + + if (origin != null && !origin.isDirect()) { + throw new CLException("Argument \"origin\" was not a direct buffer"); + } + if (range != null && !range.isDirect()) { + throw new CLException("Argument \"range\" was not a direct buffer"); + } + if (image_row_pitch != null && !image_row_pitch.isDirect()) { + throw new CLException("Argument \"image_row_pitch\" was not a direct buffer"); + } + if (image_slice_pitch != null && !image_slice_pitch.isDirect()) { + throw new CLException("Argument \"image_slice_pitch\" was not a direct buffer"); + } + if (event_wait_list != null && !event_wait_list.isDirect()) { + throw new CLException("Argument \"event_wait_list\" was not a direct buffer"); + } + if (event != null && !event.isDirect()) { + throw new CLException("Argument \"event\" was not a direct buffer"); + } + if (errcode_ret != null && !errcode_ret.isDirect()) { + throw new CLException("Argument \"errcode_ret\" was not a direct buffer"); + } + + final long mapImageAddress = addressTable._addressof_clEnqueueMapImage; + if (mapImageAddress == 0) { + throw new UnsupportedOperationException("Method not available"); + } + final long getImageInfoAddress = addressTable._addressof_clGetImageInfo; + if (getImageInfoAddress == 0) { + throw new UnsupportedOperationException("Method not available"); + } + ByteBuffer _res; + _res = clEnqueueMapImage0(command_queue, image, blocking_map, map_flags, origin != null ? origin.getBuffer() : null, + getDirectBufferByteOffset(origin), range != null ? range.getBuffer() : null, + getDirectBufferByteOffset(range), image_row_pitch != null ? image_row_pitch.getBuffer() : null, + getDirectBufferByteOffset(image_row_pitch), image_slice_pitch != null ? image_slice_pitch.getBuffer() : null, + getDirectBufferByteOffset(image_slice_pitch), num_events_in_wait_list, + event_wait_list != null ? event_wait_list.getBuffer() : null, getDirectBufferByteOffset(event_wait_list), + event != null ? event.getBuffer() : null, getDirectBufferByteOffset(event), errcode_ret, + getDirectBufferByteOffset(errcode_ret)); + if (_res == null) { + return null; + } + nativeOrder(_res); + return _res; + } + + /** Entry point to C language function: void * {@native clEnqueueMapImage}(cl_command_queue command_queue, cl_mem image, uint32_t blocking_map, uint64_t map_flags, const size_t * , const size_t * , size_t * image_row_pitch, size_t * image_slice_pitch, uint32_t num_events_in_wait_list, cl_event * event_wait_list, cl_event * event, int32_t * errcode_ret); + @param origin a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} + @param range a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} + @param image_row_pitch a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} + @param image_slice_pitch a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} + @param event_wait_list a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} + @param event a direct {@link com.jogamp.gluegen.common.nio.NativeSizeBuffer} + @param errcode_ret a direct {@link java.nio.IntBuffer} */ + private native ByteBuffer clEnqueueMapImage0(long command_queue, long image, int blocking_map, long map_flags, + Object origin, int origin_byte_offset, Object range, int range_byte_offset, Object image_row_pitch, + int image_row_pitch_byte_offset, Object image_slice_pitch, int image_slice_pitch_byte_offset, + int num_events_in_wait_list, Object event_wait_list, int event_wait_list_byte_offset, Object event, + int event_byte_offset, Object errcode_ret, int errcode_ret_byte_offset); + + /** + * Returns the extension function address for the given function name. + */ + public long clGetExtensionFunctionAddress(String name) { + ByteBuffer res = super.clGetExtensionFunctionAddressImpl(name); + if(res == null) { + return 0; + }else if (Platform.is32Bit()) { + return res.getInt(); + } else { + return res.getLong(); + } + } + + public CLProcAddressTable getAddressTable() { + return addressTable; + } + + /* + private static void convert32To64(long[] values) { + if (values.length % 2 == 1) { + values[values.length - 1] = values[values.length / 2] >>> 32; + } + for (int i = values.length - 1 - values.length % 2; i >= 0; i -= 2) { + long temp = values[i / 2]; + values[i - 1] = temp >>> 32; + values[i] = temp & 0x00000000FFFFFFFFL; + } + } + */ + + + +} diff --git a/src/com/jogamp/opencl/llb/impl/CLMemObjectDestructorCallback.java b/src/com/jogamp/opencl/llb/impl/CLMemObjectDestructorCallback.java new file mode 100644 index 00000000..5ed57cce --- /dev/null +++ b/src/com/jogamp/opencl/llb/impl/CLMemObjectDestructorCallback.java @@ -0,0 +1,47 @@ +/* + * Copyright 2009 - 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +/* + * Created on Thursday, September 02 2010 23:09 + */ + +package com.jogamp.opencl.llb.impl; + +/** + * A callback which is invoked by the OpenCL implementation when the memory + * object is deleted and its resources freed. + * @author Michael Bien + */ +public interface CLMemObjectDestructorCallback { + + /** + * + */ + public void memoryDeallocated(long memObjID); + +} diff --git a/src/com/jogamp/opencl/spi/CLAccessorFactory.java b/src/com/jogamp/opencl/spi/CLAccessorFactory.java index 6239bb37..752891b4 100644 --- a/src/com/jogamp/opencl/spi/CLAccessorFactory.java +++ b/src/com/jogamp/opencl/spi/CLAccessorFactory.java @@ -3,7 +3,7 @@ */ package com.jogamp.opencl.spi; -import com.jogamp.opencl.CL; +import com.jogamp.opencl.llb.CL; /** * Implementations of this interface are factories responsible for creating CLAccessors. diff --git a/src/com/jogamp/opencl/util/CLBuildListener.java b/src/com/jogamp/opencl/util/CLBuildListener.java index 9a520582..05517850 100644 --- a/src/com/jogamp/opencl/util/CLBuildListener.java +++ b/src/com/jogamp/opencl/util/CLBuildListener.java @@ -37,10 +37,10 @@ import com.jogamp.opencl.CLProgram; /** * A callback an application can register to be called when the program executable * has been built (successfully or unsuccessfully).
- * Note1: registering a build callback can make {@link com.jogamp.opencl.CL#clBuildProgram} non blocking (OpenCL implementation dependent).
+ * Note1: registering a build callback can make {@link com.jogamp.opencl.llb.CL#clBuildProgram} non blocking (OpenCL implementation dependent).
* Note2: the thread which calls this method is unspecified. The Application should ensure propper synchronization. * @author Michael Bien - * @see com.jogamp.opencl.CL#clBuildProgram(long, int, com.jogamp.common.nio.NativeSizeBuffer, java.lang.String, com.jogamp.opencl.impl.BuildProgramCallback) + * @see com.jogamp.opencl.llb.CL#clBuildProgram(long, int, com.jogamp.common.nio.NativeSizeBuffer, java.lang.String, com.jogamp.opencl.llb.impl.BuildProgramCallback) */ public interface CLBuildListener { diff --git a/src/com/jogamp/opencl/util/CLInfo.java b/src/com/jogamp/opencl/util/CLInfo.java index 3b483fc2..40c4f2ff 100644 --- a/src/com/jogamp/opencl/util/CLInfo.java +++ b/src/com/jogamp/opencl/util/CLInfo.java @@ -34,7 +34,7 @@ package com.jogamp.opencl.util; import com.jogamp.common.os.Platform; import com.jogamp.opencl.CLDevice; import com.jogamp.opencl.CLPlatform; -import com.jogamp.opencl.impl.CLImpl; +import com.jogamp.opencl.llb.impl.CLImpl; import java.util.Map; diff --git a/src/com/jogamp/opencl/util/CLUtil.java b/src/com/jogamp/opencl/util/CLUtil.java index 371c493c..98a6cd7e 100644 --- a/src/com/jogamp/opencl/util/CLUtil.java +++ b/src/com/jogamp/opencl/util/CLUtil.java @@ -29,7 +29,7 @@ package com.jogamp.opencl.util; import com.jogamp.common.JogampRuntimeException; -import com.jogamp.opencl.CL; +import com.jogamp.opencl.llb.CL; import com.jogamp.opencl.CLDevice; import com.jogamp.opencl.CLPlatform; import com.jogamp.opencl.CLProperty; diff --git a/src/com/jogamp/opencl/util/JOCLVersion.java b/src/com/jogamp/opencl/util/JOCLVersion.java index 265233a2..48dd2a9e 100644 --- a/src/com/jogamp/opencl/util/JOCLVersion.java +++ b/src/com/jogamp/opencl/util/JOCLVersion.java @@ -35,7 +35,7 @@ import com.jogamp.common.GlueGenVersion; import com.jogamp.common.os.Platform; import com.jogamp.common.util.JogampVersion; import com.jogamp.common.util.VersionUtil; -import com.jogamp.opencl.CL; +import com.jogamp.opencl.llb.CL; import java.security.PrivilegedAction; import java.util.jar.Manifest; @@ -56,7 +56,7 @@ public class JOCLVersion extends JogampVersion { private static JOCLVersion createInstance() { return doPrivileged(new PrivilegedAction() { - public JOCLVersion run() { + @Override public JOCLVersion run() { Manifest manifest = VersionUtil.getManifest(CL.class.getClassLoader(), PACKAGE); if(manifest == null) { manifest = new Manifest(); @@ -92,7 +92,7 @@ public class JOCLVersion extends JogampVersion { try{ doPrivileged(new PrivilegedAction() { - public Object run() { + @Override public Object run() { sb.append(GlueGenVersion.getInstance().toString()); return null; } -- cgit v1.2.3