From ad7769f9c90b5834b8d8fbf623f1c9cf098cc096 Mon Sep 17 00:00:00 2001 From: Ioannis Tsakpinis Date: Wed, 16 Nov 2011 14:36:28 +0000 Subject: [PATCH] Added support for OpenCL 1.2 [UNTESTED] --- platform_build/build-generator.xml | 5 +- .../lwjgl/opencl/CLBuildProgramCallback.java | 37 +- src/java/org/lwjgl/opencl/CLChecks.java | 12 +- .../opencl/CLCompileProgramCallback.java | 43 ++ src/java/org/lwjgl/opencl/CLContext.java | 58 ++- .../lwjgl/opencl/CLLinkProgramCallback.java | 43 ++ .../org/lwjgl/opencl/CLPrintfCallback.java | 51 ++ .../org/lwjgl/opencl/CLProgramCallback.java | 74 +++ src/java/org/lwjgl/opencl/CallbackUtil.java | 45 +- .../org/lwjgl/opencl/InfoUtilFactory.java | 2 +- src/java/org/lwjgl/util/generator/Utils.java | 8 +- .../opencl/CLPDCapabilitiesGenerator.java | 2 +- src/native/common/extcl.h | 3 +- src/native/common/extcl_types.h | 24 +- .../common/org_lwjgl_opencl_CallbackUtil.c | 47 +- src/templates/org/lwjgl/opencl/CL10.java | 24 +- src/templates/org/lwjgl/opencl/CL11.java | 12 +- src/templates/org/lwjgl/opencl/CL12.java | 445 ++++++++++++++++++ src/templates/org/lwjgl/opencl/CL12GL.java | 60 +++ .../org/lwjgl/opencl/EXT_device_fission.java | 1 - .../opengl/ARB_separate_shader_objects.java | 33 +- src/templates/org/lwjgl/opengl/GL41.java | 80 ++-- 22 files changed, 943 insertions(+), 166 deletions(-) create mode 100644 src/java/org/lwjgl/opencl/CLCompileProgramCallback.java create mode 100644 src/java/org/lwjgl/opencl/CLLinkProgramCallback.java create mode 100644 src/java/org/lwjgl/opencl/CLPrintfCallback.java create mode 100644 src/java/org/lwjgl/opencl/CLProgramCallback.java create mode 100644 src/templates/org/lwjgl/opencl/CL12.java create mode 100644 src/templates/org/lwjgl/opencl/CL12GL.java diff --git a/platform_build/build-generator.xml b/platform_build/build-generator.xml index c6f8c089..cf347c6c 100644 --- a/platform_build/build-generator.xml +++ b/platform_build/build-generator.xml @@ -36,13 +36,10 @@ - - - + - diff --git a/src/java/org/lwjgl/opencl/CLBuildProgramCallback.java b/src/java/org/lwjgl/opencl/CLBuildProgramCallback.java index 1d5c9b44..aef91295 100644 --- a/src/java/org/lwjgl/opencl/CLBuildProgramCallback.java +++ b/src/java/org/lwjgl/opencl/CLBuildProgramCallback.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2010 LWJGL Project + * Copyright (c) 2002-2011 LWJGL Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,8 +31,6 @@ */ package org.lwjgl.opencl; -import org.lwjgl.PointerWrapperAbstract; - /** * Instances of this class can be used to receive OpenCL program build notifications. * A single CLBuildProgramCallback instance should only be used with programs created @@ -40,37 +38,6 @@ import org.lwjgl.PointerWrapperAbstract; * * @author Spasi */ -public abstract class CLBuildProgramCallback extends PointerWrapperAbstract { - - private CLContext context; - - protected CLBuildProgramCallback() { - super(CallbackUtil.getBuildProgramCallback()); - } - - /** - * Sets the context that contains the CLPrograms to which we're registered. - * - * @param context the CLContext object - */ - void setContext(final CLContext context) { - this.context = context; - } - - /** - * Called from native code. - * - * @param program_address the CLProgram object pointer - */ - private void handleMessage(long program_address) { - handleMessage(context.getCLProgram(program_address)); - } - - /** - * The callback method. - * - * @param program the CLProgram object that was built - */ - protected abstract void handleMessage(CLProgram program); +public abstract class CLBuildProgramCallback extends CLProgramCallback { } \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLChecks.java b/src/java/org/lwjgl/opencl/CLChecks.java index bb608366..090ad436 100644 --- a/src/java/org/lwjgl/opencl/CLChecks.java +++ b/src/java/org/lwjgl/opencl/CLChecks.java @@ -53,23 +53,23 @@ final class CLChecks { /** * Calculates the number of bytes in the specified cl_mem buffer rectangle region. * - * @param origin the host origin + * @param offset the host offset * @param region the rectangle region * @param row_pitch the host row pitch * @param slice_pitch the host slice pitch * * @return the region size in bytes */ - static int calculateBufferRectSize(final PointerBuffer origin, final PointerBuffer region, long row_pitch, long slice_pitch) { + static int calculateBufferRectSize(final PointerBuffer offset, final PointerBuffer region, long row_pitch, long slice_pitch) { if ( !LWJGLUtil.CHECKS ) return 0; - final long x = origin.get(0); - final long y = origin.get(1); - final long z = origin.get(2); + final long x = offset.get(0); + final long y = offset.get(1); + final long z = offset.get(2); if ( LWJGLUtil.DEBUG && (x < 0 || y < 0 || z < 0) ) - throw new IllegalArgumentException("Invalid cl_mem host origin: " + x + ", " + y + ", " + z); + throw new IllegalArgumentException("Invalid cl_mem host offset: " + x + ", " + y + ", " + z); final long w = region.get(0); final long h = region.get(1); diff --git a/src/java/org/lwjgl/opencl/CLCompileProgramCallback.java b/src/java/org/lwjgl/opencl/CLCompileProgramCallback.java new file mode 100644 index 00000000..8b0c4939 --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLCompileProgramCallback.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * 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. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT OWNER 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. + */ +package org.lwjgl.opencl; + +/** + * Instances of this class can be used to receive OpenCL program compilation notifications. + * A single CLCompileProgramCallback instance should only be used with programs created + * in the same CLContext. + * + * @author Spasi + */ +public abstract class CLCompileProgramCallback extends CLProgramCallback { + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLContext.java b/src/java/org/lwjgl/opencl/CLContext.java index 7d798beb..f2828b31 100644 --- a/src/java/org/lwjgl/opencl/CLContext.java +++ b/src/java/org/lwjgl/opencl/CLContext.java @@ -49,10 +49,14 @@ public final class CLContext extends CLObjectChild { private static final CLContextUtil util = (CLContextUtil)CLPlatform.getInfoUtilInstance(CLContext.class, "CL_CONTEXT_UTIL"); private final CLObjectRegistry clCommandQueues; - private final CLObjectRegistry clMems; - private final CLObjectRegistry clSamplers; - private final CLObjectRegistry clPrograms; - private final CLObjectRegistry clEvents; + private final CLObjectRegistry clMems; + private final CLObjectRegistry clSamplers; + private final CLObjectRegistry clPrograms; + private final CLObjectRegistry clEvents; + + private long + contextCallback, + printfCallback; CLContext(final long pointer, final CLPlatform platform) { super(pointer, platform); @@ -269,4 +273,50 @@ public final class CLContext extends CLObjectChild { CLObjectRegistry getCLEventRegistry() { return clEvents; } + private boolean checkCallback(final long callback, final int result) { + if ( result == 0 && (callback == 0 || isValid()) ) + return true; + + if ( callback != 0 ) + CallbackUtil.deleteGlobalRef(callback); + return false; + } + + /** + * Associates this context with the specified context callback reference. If the context + * is invalid, the callback reference is deleted. NO-OP if user_data is 0. + * + * @param callback the context callback pointer + */ + void setContextCallback(final long callback) { + if ( checkCallback(callback, 0) ) + this.contextCallback = callback; + } + + /** + * Associates this context with the specified printf callback reference. If the context + * is invalid, the callback reference is deleted. NO-OP if user_data is 0. + * + * @param callback the printf callback pointer + */ + void setPrintfCallback(final long callback, final int result) { + if ( checkCallback(callback, result) ) + this.printfCallback = callback; + } + + /** + * Decrements the context's reference count. If the reference + * count hits zero, it also deletes + * any callback objects associated with it. + */ + void releaseImpl() { + if ( release() > 0 ) + return; + + if ( contextCallback != 0 ) + CallbackUtil.deleteGlobalRef(contextCallback); + if ( printfCallback != 0 ) + CallbackUtil.deleteGlobalRef(printfCallback); + } + } \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLLinkProgramCallback.java b/src/java/org/lwjgl/opencl/CLLinkProgramCallback.java new file mode 100644 index 00000000..d0e4f94f --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLLinkProgramCallback.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * 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. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT OWNER 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. + */ +package org.lwjgl.opencl; + +/** + * Instances of this class can be used to receive OpenCL program linkage notifications. + * A single CLLinkProgramCallback instance should only be used with programs created + * in the same CLContext. + * + * @author Spasi + */ +public abstract class CLLinkProgramCallback extends CLProgramCallback { + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLPrintfCallback.java b/src/java/org/lwjgl/opencl/CLPrintfCallback.java new file mode 100644 index 00000000..00dab6eb --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLPrintfCallback.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * 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. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT OWNER 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. + */ +package org.lwjgl.opencl; + +import org.lwjgl.PointerWrapperAbstract; + +/** + * Instances of this class can be used to receive OpenCL printf messages. + * Different CLContexts should use different CLPrintfCallback instances. + * + * @author Spasi + */ +public abstract class CLPrintfCallback extends PointerWrapperAbstract { + + protected CLPrintfCallback() { + super(CallbackUtil.getPrintfCallback()); + } + + /** The callback method. */ + protected abstract void handleMessage(String data); + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CLProgramCallback.java b/src/java/org/lwjgl/opencl/CLProgramCallback.java new file mode 100644 index 00000000..5071916c --- /dev/null +++ b/src/java/org/lwjgl/opencl/CLProgramCallback.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2002-2011 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * 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. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT OWNER 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. + */ +package org.lwjgl.opencl; + +import org.lwjgl.PointerWrapperAbstract; + +/** + * Base class for OpenCL program action notifications. + * + * @author Spasi + */ +abstract class CLProgramCallback extends PointerWrapperAbstract { + + private CLContext context; + + protected CLProgramCallback() { + super(CallbackUtil.getProgramCallback()); + } + + /** + * Sets the context that contains the CLPrograms to which we're registered. + * + * @param context the CLContext object + */ + final void setContext(final CLContext context) { + this.context = context; + } + + /** + * Called from native code. + * + * @param program_address the CLProgram object pointer + */ + private void handleMessage(long program_address) { + handleMessage(context.getCLProgram(program_address)); + } + + /** + * The callback method. + * + * @param program the CLProgram object affected + */ + protected abstract void handleMessage(CLProgram program); + +} \ No newline at end of file diff --git a/src/java/org/lwjgl/opencl/CallbackUtil.java b/src/java/org/lwjgl/opencl/CallbackUtil.java index 98f9a4f5..d70164ac 100644 --- a/src/java/org/lwjgl/opencl/CallbackUtil.java +++ b/src/java/org/lwjgl/opencl/CallbackUtil.java @@ -70,7 +70,7 @@ final class CallbackUtil { * * @param ref the GlobalRef memory address. */ - private static native void deleteGlobalRef(long ref); + static native void deleteGlobalRef(long ref); /** * Deletes the global reference represented by user_data if an OpenCL error occured. @@ -99,40 +99,6 @@ final class CallbackUtil { */ static native long getContextCallback(); - /** - * Associates the specified CLContext with the specified global reference. If the context - * is invalid, the global reference is deleted. NO-OP if user_data is 0. - * - * @param context the CLContext to register - * @param user_data the global reference pointer - */ - static void registerCallback(final CLContext context, final long user_data) { - if ( user_data == 0 ) - return; - - if ( context.isValid() ) - contextUserData.put(context, user_data); - else - deleteGlobalRef(user_data); - } - - /** - * Decrements the specified context's reference count, clears its association - * with a CLContextCallback object if it exists and deletes the corresponding - * global reference. - * - * @param context the CLContext to unregister - */ - static void unregisterCallback(final CLContext context) { - if ( context.release() > 0 ) - return; - - final Long user_data = contextUserData.remove(context); - - if ( user_data != null ) - deleteGlobalRef(user_data); - } - /* [ Other callback functionality ] The other callbacks are simpler. We create the GlobalRef before passing the callback, we delete it when we receive the callback call. @@ -150,7 +116,7 @@ final class CallbackUtil { * * @return the callback function address */ - static native long getBuildProgramCallback(); + static native long getProgramCallback(); /** * Returns the memory address of the native function we pass to clEnqueueNativeKernel. @@ -166,6 +132,13 @@ final class CallbackUtil { */ static native long getEventCallback(); + /** + * Returns the memory address of the native function we pass to clSetPrintfCallback. + * + * @return the callback function address + */ + static native long getPrintfCallback(); + /** * Returns the memory address of the native function we pass to clCreateContext(FromType), * when APPLEContextLoggingUtil.SYSTEM_LOG_CALLBACK is used. diff --git a/src/java/org/lwjgl/opencl/InfoUtilFactory.java b/src/java/org/lwjgl/opencl/InfoUtilFactory.java index c7872900..c45077b8 100644 --- a/src/java/org/lwjgl/opencl/InfoUtilFactory.java +++ b/src/java/org/lwjgl/opencl/InfoUtilFactory.java @@ -123,7 +123,7 @@ final class InfoUtilFactory { Util.checkCLError(errcode_ret.get(0)); return __result; } finally { - CallbackUtil.registerCallback(__result, user_data); + if ( __result != null ) __result.setContextCallback(user_data); } } diff --git a/src/java/org/lwjgl/util/generator/Utils.java b/src/java/org/lwjgl/util/generator/Utils.java index c3934333..36b2347f 100644 --- a/src/java/org/lwjgl/util/generator/Utils.java +++ b/src/java/org/lwjgl/util/generator/Utils.java @@ -373,20 +373,22 @@ public class Utils { if ( param != null && p.getSimpleName().equals(param.getSimpleName()) ) break; + if ( p.getAnnotation(NullTerminated.class) != null ) + continue; + final Class type = Utils.getJavaType(p.getType()); if ( type.equals(CharSequence.class) ) { if ( offset == null ) offset = p.getSimpleName() + ".length()"; else offset += " + " + p.getSimpleName() + ".length()"; - if ( p.getAnnotation(NullTerminated.class) != null ) offset += " + 1"; - + //if ( p.getAnnotation(NullTerminated.class) != null ) offset += " + 1"; } else if ( type.equals(CharSequence[].class) ) { if ( offset == null ) offset = "APIUtil.getTotalLength(" + p.getSimpleName() + ")"; else offset += " + APIUtil.getTotalLength(" + p.getSimpleName() + ")"; - if ( p.getAnnotation(NullTerminated.class) != null ) offset += " + " + p.getSimpleName() + ".length"; + //if ( p.getAnnotation(NullTerminated.class) != null ) offset += " + " + p.getSimpleName() + ".length"; } } diff --git a/src/java/org/lwjgl/util/generator/opencl/CLPDCapabilitiesGenerator.java b/src/java/org/lwjgl/util/generator/opencl/CLPDCapabilitiesGenerator.java index 0c298660..9d7f10e3 100644 --- a/src/java/org/lwjgl/util/generator/opencl/CLPDCapabilitiesGenerator.java +++ b/src/java/org/lwjgl/util/generator/opencl/CLPDCapabilitiesGenerator.java @@ -51,7 +51,7 @@ public class CLPDCapabilitiesGenerator { // TODO: Add future versions here private static final int[][] CL_VERSIONS = { - { 1 }, // OpenCL 1 + { 1, 2 }, // OpenCL 1 }; static void generateClassPrologue(final PrintWriter writer, final String name) { diff --git a/src/native/common/extcl.h b/src/native/common/extcl.h index 053df19d..e6e6bc98 100644 --- a/src/native/common/extcl.h +++ b/src/native/common/extcl.h @@ -61,9 +61,10 @@ typedef GLsync cl_GLsync; typedef void (CL_CALLBACK * cl_create_context_callback)(const char *errinfo, const void *private_info, size_t cb, void *user_data); typedef void (CL_CALLBACK * cl_mem_object_destructor_callback)(cl_mem memobj, void *user_data); -typedef void (CL_CALLBACK * cl_build_program_callback)(cl_program program, void *user_data); +typedef void (CL_CALLBACK * cl_program_callback)(cl_program program, void *user_data); typedef void (CL_CALLBACK * cl_event_callback)(cl_event event, cl_int event_command_exec_status, void *user_data); typedef void (CL_CALLBACK * cl_native_kernel_func)(void *args); +typedef void (CL_CALLBACK * cl_printf_callback)(cl_context context, cl_uint printf_data_len, char *printf_data_ptr, void *user_data); // -----------------[ Cross-platform functions ]----------------- diff --git a/src/native/common/extcl_types.h b/src/native/common/extcl_types.h index 042307c4..0e0f935a 100644 --- a/src/native/common/extcl_types.h +++ b/src/native/common/extcl_types.h @@ -20,8 +20,10 @@ typedef cl_uint cl_device_mem_cache_type; typedef cl_uint cl_device_local_mem_type; typedef cl_bitfield cl_device_exec_capabilities; typedef cl_bitfield cl_command_queue_properties; +typedef intptr_t cl_device_partition_property; +typedef cl_bitfield cl_device_affinity_domain; -typedef intptr_t cl_context_properties; +typedef intptr_t cl_context_properties; typedef cl_uint cl_context_info; typedef cl_uint cl_command_queue_info; typedef cl_uint cl_channel_order; @@ -29,6 +31,7 @@ typedef cl_uint cl_channel_type; typedef cl_bitfield cl_mem_flags; typedef cl_uint cl_mem_object_type; typedef cl_uint cl_mem_info; +typedef cl_bitfield cl_mem_migration_flags; typedef cl_uint cl_image_info; typedef cl_uint cl_buffer_create_type; typedef cl_uint cl_addressing_mode; @@ -37,8 +40,12 @@ typedef cl_uint cl_sampler_info; typedef cl_bitfield cl_map_flags; typedef cl_uint cl_program_info; typedef cl_uint cl_program_build_info; +typedef cl_uint cl_program_binary_type; typedef cl_int cl_build_status; typedef cl_uint cl_kernel_info; +typedef cl_uint cl_kernel_arg_info; +typedef cl_uint cl_kernel_arg_address_qualifier; +typedef cl_uint cl_kernel_arg_access_qualifier; typedef cl_uint cl_kernel_work_group_info; typedef cl_uint cl_event_info; typedef cl_uint cl_command_type; @@ -49,6 +56,19 @@ typedef struct _cl_image_format { cl_channel_type image_channel_data_type; } cl_image_format; +typedef struct _cl_image_desc { + cl_mem_object_type image_type; + size_t image_width; + size_t image_height; + size_t image_depth; + size_t image_array_size; + size_t image_row_pitch; + size_t image_slice_pitch; + cl_uint num_mip_levels; + cl_uint num_samples; + cl_mem buffer; +} cl_image_desc; + typedef struct _cl_buffer_region { size_t origin; size_t size; @@ -63,7 +83,7 @@ typedef cl_uint cl_gl_texture_info; // -----------------[ Extension typedefs ]----------------- // EXT_device_fission -typedef cl_bitfield cl_device_partition_property_ext; +typedef cl_ulong cl_device_partition_property_ext; // EXT_migrate_memobject typedef cl_bitfield cl_mem_migration_flags_ext; diff --git a/src/native/common/org_lwjgl_opencl_CallbackUtil.c b/src/native/common/org_lwjgl_opencl_CallbackUtil.c index c721a9c2..0641d45f 100644 --- a/src/native/common/org_lwjgl_opencl_CallbackUtil.c +++ b/src/native/common/org_lwjgl_opencl_CallbackUtil.c @@ -43,9 +43,10 @@ static jmethodID contextCallbackJ; static jmethodID memObjectDestructorCallbackJ; -static jmethodID buildProgramCallbackJ; +static jmethodID programCallbackJ; static jmethodID nativeKernelCallbackJ; static jmethodID eventCallbackJ; +static jmethodID printfCallbackJ; JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_ncreateGlobalRef(JNIEnv *env, jclass clazz, jobject obj) { return (intptr_t)(*env)->NewGlobalRef(env, obj); @@ -113,13 +114,13 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getMemObjectDestructo return (jlong)(intptr_t)&memObjectDestructorCallback; } -// ----------------- [ MEM OBJECT DESTRUCTOR CALLBACK ] ----------------- +// ----------------- [ PROGRAM CALLBACK ] ----------------- -static void CL_CALLBACK buildProgramCallback(cl_program program, void *user_data) { +static void CL_CALLBACK programCallback(cl_program program, void *user_data) { JNIEnv *env = attachCurrentThread(); - if ( env != NULL && !(*env)->ExceptionOccurred(env) && buildProgramCallbackJ != NULL ) { - (*env)->CallVoidMethod(env, (jobject)user_data, buildProgramCallbackJ, + if ( env != NULL && !(*env)->ExceptionOccurred(env) && programCallbackJ != NULL ) { + (*env)->CallVoidMethod(env, (jobject)user_data, programCallbackJ, (jlong)(intptr_t)program ); (*env)->DeleteGlobalRef(env, (jobject)user_data); @@ -128,16 +129,16 @@ static void CL_CALLBACK buildProgramCallback(cl_program program, void *user_data detachCurrentThread(); } -JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getBuildProgramCallback(JNIEnv *env, jclass clazz) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getProgramCallback(JNIEnv *env, jclass clazz) { // Cache the callback methodID jclass callbackClass; - if ( buildProgramCallbackJ == NULL ) { - callbackClass = (*env)->FindClass(env, "org/lwjgl/opencl/CLBuildProgramCallback"); + if ( programCallbackJ == NULL ) { + callbackClass = (*env)->FindClass(env, "org/lwjgl/opencl/CLProgramCallback"); if ( callbackClass != NULL ) - buildProgramCallbackJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(J)V"); + programCallbackJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(J)V"); } - return (jlong)(intptr_t)&buildProgramCallback; + return (jlong)(intptr_t)&programCallback; } // ----------------- [ NATIVE KERNEL CALLBACK ] ----------------- @@ -214,6 +215,32 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getEventCallback(JNIE return (jlong)(intptr_t)&eventCallback; } +// ----------------- [ PRINTF CALLBACK ] ----------------- + +static void CL_CALLBACK printfCallback(cl_context context, cl_uint printf_data_len, char *printf_data_ptr, void *user_data) { + JNIEnv *env = attachCurrentThread(); + + if ( env != NULL && !(*env)->ExceptionOccurred(env) && printfCallbackJ != NULL ) { + (*env)->CallVoidMethod(env, (jobject)user_data, printfCallbackJ, + NewStringNativeWithLength(env, printf_data_ptr, printf_data_len) + ); + } + + detachCurrentThread(); +} + +JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getPrintfCallback(JNIEnv *env, jclass clazz) { + // Cache the callback methodID + jclass callbackClass; + if ( printfCallbackJ == NULL ) { + callbackClass = (*env)->FindClass(env, "org/lwjgl/opencl/CLPrintfCallback"); + if ( callbackClass != NULL ) + printfCallbackJ = (*env)->GetMethodID(env, callbackClass, "handleMessage", "(Ljava/lang/String;)V"); + } + + return (jlong)(intptr_t)&printfCallback; +} + // ----------------- [ APPLE_ContextLoggingFunctions CALLBACKS ] ----------------- JNIEXPORT jlong JNICALL Java_org_lwjgl_opencl_CallbackUtil_getLogMessageToSystemLogAPPLE(JNIEnv *env, jclass clazz) { diff --git a/src/templates/org/lwjgl/opencl/CL10.java b/src/templates/org/lwjgl/opencl/CL10.java index 458cf246..b50a0d3e 100644 --- a/src/templates/org/lwjgl/opencl/CL10.java +++ b/src/templates/org/lwjgl/opencl/CL10.java @@ -399,7 +399,7 @@ public interface CL10 { // Create a GlobalRef to the callback object. javaBeforeNative = "\t\tlong user_data = pfn_notify == null || pfn_notify.isCustom() ? 0 : CallbackUtil.createGlobalRef(pfn_notify);", // Associate context with the GlobalRef, so we can delete it later. - javaFinally = "\t\t\tCallbackUtil.registerCallback(__result, user_data);" + javaFinally = "\t\t\tif ( __result != null ) __result.setContextCallback(user_data);" ) @Check(value = "errcode_ret", canBeNull = true) @PointerWrapper(value = "cl_context", params = "APIUtil.getCLPlatform(properties)") @@ -417,7 +417,7 @@ public interface CL10 { // Create a GlobalRef to the callback object. javaBeforeNative = "\t\tlong user_data = pfn_notify == null || pfn_notify.isCustom() ? 0 : CallbackUtil.createGlobalRef(pfn_notify);", // Associate context with the GlobalRef, so we can delete it later. - javaFinally = "\t\t\tCallbackUtil.registerCallback(__result, user_data);" + javaFinally = "\t\t\tif ( __result != null ) __result.setContextCallback(user_data);" ) @Check(value = "errcode_ret", canBeNull = true) @PointerWrapper(value = "cl_context", params = "APIUtil.getCLPlatform(properties)") @@ -434,7 +434,7 @@ public interface CL10 { // Create a GlobalRef to the callback object. javaBeforeNative = "\t\tlong user_data = pfn_notify == null || pfn_notify.isCustom() ? 0 : CallbackUtil.createGlobalRef(pfn_notify);", // Associate context with the GlobalRef, so we can delete it later. - javaFinally = "\t\t\tCallbackUtil.registerCallback(__result, user_data);" + javaFinally = "\t\t\tif ( __result != null ) __result.setContextCallback(user_data);" ) @Check(value = "errcode_ret", canBeNull = true) @PointerWrapper(value = "cl_context", params = "APIUtil.getCLPlatform(properties)") @@ -450,7 +450,7 @@ public interface CL10 { @Code( javaBeforeNative = "\t\tAPIUtil.releaseObjects(context);", - javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) CallbackUtil.unregisterCallback(context);" + javaAfterNative = "\t\tif ( __result == CL_SUCCESS ) context.releaseImpl();" ) @cl_int int clReleaseContext(@PointerWrapper("cl_context") CLContext context); @@ -511,7 +511,7 @@ public interface CL10 { @PointerWrapper("cl_mem") CLMem buffer, @cl_bool int blocking_read, @size_t long offset, - @AutoSize("ptr") @size_t long cb, + @AutoSize("ptr") @size_t long size, @OutParameter @cl_byte @cl_short @@ -529,7 +529,7 @@ public interface CL10 { @PointerWrapper("cl_mem") CLMem buffer, @cl_bool int blocking_write, @size_t long offset, - @AutoSize("ptr") @size_t long cb, + @AutoSize("ptr") @size_t long size, @Const @cl_byte @cl_short @@ -548,7 +548,7 @@ public interface CL10 { @PointerWrapper("cl_mem") CLMem dst_buffer, @size_t long src_offset, @size_t long dst_offset, - @size_t long cb, + @size_t long size, @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); @@ -556,13 +556,13 @@ public interface CL10 { @Code(javaAfterNative = "\t\tif ( __result != null ) command_queue.registerCLEvent(event);") @Check(value = "errcode_ret", canBeNull = true) @cl_void - @AutoSize("cb") + @AutoSize("size") ByteBuffer clEnqueueMapBuffer(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, @PointerWrapper("cl_mem") CLMem buffer, @cl_bool int blocking_map, @NativeType("cl_map_flags") long map_flags, @size_t long offset, - @size_t long cb, + @size_t long size, @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event, @@ -855,7 +855,7 @@ public interface CL10 { @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices, @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list, @Check @NullTerminated @Const @cl_char ByteBuffer options, - @PointerWrapper(value = "cl_build_program_callback", canBeNull = true) CLBuildProgramCallback pfn_notify, + @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLBuildProgramCallback pfn_notify, @Constant("user_data") @PointerWrapper("void *") long user_data); @Alternate("clBuildProgram") @@ -872,7 +872,7 @@ public interface CL10 { @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices, @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list, @NullTerminated @Const CharSequence options, - @PointerWrapper(value = "cl_build_program_callback", canBeNull = true) CLBuildProgramCallback pfn_notify, + @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLBuildProgramCallback pfn_notify, @Constant("user_data") @PointerWrapper("void *") long user_data); @Alternate("clBuildProgram") @@ -889,7 +889,7 @@ public interface CL10 { @Constant("1") @cl_uint int num_devices, @Constant(value = "APIUtil.getPointer(device)", keepParam = true) CLDevice device, @NullTerminated @Const CharSequence options, - @PointerWrapper(value = "cl_build_program_callback", canBeNull = true) CLBuildProgramCallback pfn_notify, + @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLBuildProgramCallback pfn_notify, @Constant("user_data") @PointerWrapper("void *") long user_data); @cl_int diff --git a/src/templates/org/lwjgl/opencl/CL11.java b/src/templates/org/lwjgl/opencl/CL11.java index dc7e0f0a..82c0a408 100644 --- a/src/templates/org/lwjgl/opencl/CL11.java +++ b/src/templates/org/lwjgl/opencl/CL11.java @@ -121,14 +121,14 @@ public interface CL11 { int clEnqueueReadBufferRect(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, @PointerWrapper("cl_mem") CLMem buffer, @cl_bool int blocking_read, - @Const @Check("3") @NativeType("size_t") PointerBuffer buffer_origin, - @Const @Check("3") @NativeType("size_t") PointerBuffer host_origin, + @Const @Check("3") @NativeType("size_t") PointerBuffer buffer_offset, + @Const @Check("3") @NativeType("size_t") PointerBuffer host_offset, @Const @Check("3") @NativeType("size_t") PointerBuffer region, @size_t long buffer_row_pitch, @size_t long buffer_slice_pitch, @size_t long host_row_pitch, @size_t long host_slice_pitch, - @OutParameter @Check("CLChecks.calculateBufferRectSize(host_origin, region, host_row_pitch, host_slice_pitch)") + @OutParameter @Check("CLChecks.calculateBufferRectSize(host_offset, region, host_row_pitch, host_slice_pitch)") @cl_byte @cl_short @cl_int @@ -144,14 +144,14 @@ public interface CL11 { int clEnqueueWriteBufferRect(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, @PointerWrapper("cl_mem") CLMem buffer, @cl_bool int blocking_write, - @Const @Check("3") @NativeType("size_t") PointerBuffer buffer_origin, - @Const @Check("3") @NativeType("size_t") PointerBuffer host_origin, + @Const @Check("3") @NativeType("size_t") PointerBuffer buffer_offset, + @Const @Check("3") @NativeType("size_t") PointerBuffer host_offset, @Const @Check("3") @NativeType("size_t") PointerBuffer region, @size_t long buffer_row_pitch, @size_t long buffer_slice_pitch, @size_t long host_row_pitch, @size_t long host_slice_pitch, - @Const @Check("CLChecks.calculateBufferRectSize(host_origin, region, host_row_pitch, host_slice_pitch)") + @Const @Check("CLChecks.calculateBufferRectSize(host_offset, region, host_row_pitch, host_slice_pitch)") @cl_byte @cl_short @cl_int diff --git a/src/templates/org/lwjgl/opencl/CL12.java b/src/templates/org/lwjgl/opencl/CL12.java new file mode 100644 index 00000000..f4263645 --- /dev/null +++ b/src/templates/org/lwjgl/opencl/CL12.java @@ -0,0 +1,445 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * 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. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT OWNER 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. + */ +package org.lwjgl.opencl; + +import org.lwjgl.PointerBuffer; +import org.lwjgl.util.generator.*; +import org.lwjgl.util.generator.opencl.*; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.nio.LongBuffer; + +/** The core OpenCL 1.1 API */ +public interface CL12 { + + /** Error Codes */ + int CL_COMPILE_PROGRAM_FAILURE = -15, + CL_LINKER_NOT_AVAILABLE = -16, + CL_LINK_PROGRAM_FAILURE = -17, + CL_DEVICE_PARTITION_FAILED = -18, + CL_KERNEL_ARG_INFO_NOT_AVAILABLE = -19, + CL_INVALID_IMAGE_DESCRIPTOR = -65, + CL_INVALID_COMPILER_OPTIONS = -66, + CL_INVALID_LINKER_OPTIONS = -67, + CL_INVALID_DEVICE_PARTITION_COUNT = -68; + + /** OpenCL Version */ + int CL_VERSION_1_2 = 1; + + /** cl_bool */ + int CL_BLOCKING = CL10.CL_TRUE, + CL_NON_BLOCKING = CL10.CL_FALSE; + + /** cl_device_type - bitfield */ + int CL_DEVICE_TYPE_CUSTOM = (1 << 4); + + /* cl_device_info */ + int CL_DEVICE_DOUBLE_FP_CONFIG = 0x1032, + CL_DEVICE_LINKER_AVAILABLE = 0x103E, + CL_DEVICE_BUILT_IN_KERNELS = 0x103F, + CL_DEVICE_IMAGE_MAX_BUFFER_SIZE = 0x1040, + CL_DEVICE_IMAGE_MAX_ARRAY_SIZE = 0x1041, + CL_DEVICE_PARENT_DEVICE = 0x1042, + CL_DEVICE_PARTITION_MAX_SUB_DEVICES = 0x1043, + CL_DEVICE_PARTITION_PROPERTIES = 0x1044, + CL_DEVICE_PARTITION_AFFINITY_DOMAIN = 0x1045, + CL_DEVICE_PARTITION_TYPE = 0x1046, + CL_DEVICE_REFERENCE_COUNT = 0x1047, + CL_DEVICE_PREFERRED_INTEROP_USER_SYNC = 0x1048, + CL_DEVICE_PRINTF_BUFFER_SIZE = 0x1049; + + /* cl_device_fp_config - bitfield */ + int CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT = (1 << 7); + + /* cl_context_properties */ + int CL_CONTEXT_INTEROP_USER_SYNC = 0x1085; + + /* cl_device_partition_property */ + int CL_DEVICE_PARTITION_EQUALLY = 0x1086, + CL_DEVICE_PARTITION_BY_COUNTS = 0x1087, + CL_DEVICE_PARTITION_BY_COUNTS_LIST_END = 0x0, + CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN = 0x1088; + + /* cl_device_affinity_domain */ + int CL_DEVICE_AFFINITY_DOMAIN_NUMA = (1 << 0), + CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE = (1 << 1), + CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE = (1 << 2), + CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE = (1 << 3), + CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE = (1 << 4), + CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE = (1 << 5); + + /* cl_mem_flags - bitfield */ + int CL_MEM_HOST_WRITE_ONLY = (1 << 7), + CL_MEM_HOST_READ_ONLY = (1 << 8), + CL_MEM_HOST_NO_ACCESS = (1 << 9); + + /* cl_mem_migration_flags - bitfield */ + int CL_MIGRATE_MEM_OBJECT_HOST = (1 << 0), + CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED = (1 << 1); + + /* cl_mem_object_type */ + int CL_MEM_OBJECT_IMAGE2D_ARRAY = 0x10F3, + CL_MEM_OBJECT_IMAGE1D = 0x10F4, + CL_MEM_OBJECT_IMAGE1D_ARRAY = 0x10F5, + CL_MEM_OBJECT_IMAGE1D_BUFFER = 0x10F6; + + /* cl_image_info */ + int CL_IMAGE_ARRAY_SIZE = 0x1117, + CL_IMAGE_BUFFER = 0x1118, + CL_IMAGE_NUM_MIP_LEVELS = 0x1119, + CL_IMAGE_NUM_SAMPLES = 0x111A; + + /* cl_map_flags - bitfield */ + int CL_MAP_WRITE_INVALIDATE_REGION = (1 << 2); + + /* cl_program_info */ + int CL_PROGRAM_NUM_KERNELS = 0x1167, + CL_PROGRAM_KERNEL_NAMES = 0x1168; + + /* cl_program_build_info */ + int CL_PROGRAM_BINARY_TYPE = 0x1184; + + /* cl_program_binary_type */ + int CL_PROGRAM_BINARY_TYPE_NONE = 0x0, + CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT = 0x1, + CL_PROGRAM_BINARY_TYPE_LIBRARY = 0x2, + CL_PROGRAM_BINARY_TYPE_EXECUTABLE = 0x4; + + /* cl_kernel_info */ + int CL_KERNEL_ATTRIBUTES = 0x1195; + + /* cl_kernel_arg_info */ + int CL_KERNEL_ARG_ADDRESS_QUALIFIER = 0x1196, + CL_KERNEL_ARG_ACCESS_QUALIFIER = 0x1197, + CL_KERNEL_ARG_TYPE_NAME = 0x1198, + CL_KERNEL_ARG_NAME = 0x1199; + + /* cl_kernel_arg_address_qualifier */ + int CL_KERNEL_ARG_ADDRESS_GLOBAL = 0x119A, + CL_KERNEL_ARG_ADDRESS_LOCAL = 0x119B, + CL_KERNEL_ARG_ADDRESS_CONSTANT = 0x119C, + CL_KERNEL_ARG_ADDRESS_PRIVATE = 0x119D; + + /* cl_kernel_arg_access_qualifier */ + int CL_KERNEL_ARG_ACCESS_READ_ONLY = 0x11A0, + CL_KERNEL_ARG_ACCESS_WRITE_ONLY = 0x11A1, + CL_KERNEL_ARG_ACCESS_READ_WRITE = 0x11A2, + CL_KERNEL_ARG_ACCESS_NONE = 0x11A3; + + /* cl_kernel_work_group_info */ + int CL_KERNEL_GLOBAL_WORK_SIZE = 0x11B5; + + /* cl_command_type */ + int CL_COMMAND_BARRIER = 0x1205, + CL_COMMAND_MIGRATE_MEM_OBJECTS = 0x1206, + CL_COMMAND_FILL_BUFFER = 0x1207, + CL_COMMAND_FILL_IMAGE = 0x1208; + + @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) device.retain();") + @cl_int + int clRetainDevice(@PointerWrapper("cl_device_id") CLDevice device); + + /** + * Warning: LWJGL will not automatically release any objects associated with sub-devices. + * The user is responsible for tracking and releasing everything prior to calling this method. + * + * @param device the parent CLDevice + * + * @return the error code + */ + @Code( + javaBeforeNative = "\t\tAPIUtil.releaseObjects(device);", + javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS ) device.release();" + ) + @cl_int + int clReleaseDevice(@PointerWrapper("cl_device_id") CLDevice device); + + @Code(javaAfterNative = "\t\tif ( __result == CL10.CL_SUCCESS && out_devices != null ) in_device.registerSubCLDevices(out_devices);") + @cl_int + int clCreateSubDevices( + @PointerWrapper("cl_device_id") CLDevice in_device, + @NullTerminated @Const @NativeType("cl_device_partition_property") LongBuffer properties, + @AutoSize(value = "out_devices", canBeNull = true) @cl_uint int num_devices, + @OutParameter @Check(canBeNull = true) @NativeType("cl_device_id") PointerBuffer out_devices, + @OutParameter @Check(value = "1", canBeNull = true) @cl_uint IntBuffer num_devices_ret); + + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_mem", params = "context") + CLMem clCreateImage(@PointerWrapper("cl_context") CLContext context, + @NativeType("cl_mem_flags") long flags, + @Check("2 * 4") @Const @NativeType("cl_image_format") ByteBuffer image_format, + @Check("3 * 4 + 7 * PointerBuffer.getPointerSize()") @Const @NativeType("cl_image_desc") ByteBuffer image_desc, + @Check + @cl_byte + @cl_short + @cl_int + @cl_float Buffer host_ptr, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_program", params = "context") + CLProgram clCreateProgramWithBuiltInKernels(@PointerWrapper("cl_context") CLContext context, + @AutoSize("device_list") @cl_uint int num_devices, + @Check("1") @Const @NativeType("cl_device_id") PointerBuffer device_list, + @Check @Const @cl_char ByteBuffer kernel_names, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + @Alternate("clCreateProgramWithBuiltInKernels") + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_program", params = "context") + CLProgram clCreateProgramWithBuiltInKernels(@PointerWrapper("cl_context") CLContext context, + @AutoSize("device_list") @cl_uint int num_devices, + @Check("1") @Const @NativeType("cl_device_id") PointerBuffer device_list, + CharSequence kernel_names, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + + /** Single null-terminated header include name. */ + @Code( + tryBlock = true, + // Create a GlobalRef to the callback object. + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" + + "\t\tif ( pfn_notify != null ) pfn_notify.setContext(program.getParent());", + // Check if we need to delete the GlobalRef. + javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);" + ) + @cl_int + int clCompileProgram(@PointerWrapper("cl_program") CLProgram program, + @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices, + @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list, + @Check @NullTerminated @Const @cl_char ByteBuffer options, + @Constant("1") @cl_uint int num_input_headers, + @Check("1") @Const @NativeType("cl_program") PointerBuffer input_header, + @NullTerminated @Check @Const @cl_char @Indirect ByteBuffer header_include_name, + @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLCompileProgramCallback pfn_notify, + @Constant("user_data") @PointerWrapper("void *") long user_data); + + /** Multiple null-terminated header include names, one after the other. */ + @Alternate(value = "clCompileProgram", nativeAlt = true, javaAlt = true) + @Code( + tryBlock = true, + // Create a GlobalRef to the callback object. + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" + + "\t\tif ( pfn_notify != null ) pfn_notify.setContext(program.getParent());", + // Check if we need to delete the GlobalRef. + javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);" + ) + @cl_int + int clCompileProgramMulti(@PointerWrapper("cl_program") CLProgram program, + @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices, + @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list, + @Check @NullTerminated @Const @cl_char ByteBuffer options, + @AutoSize("input_headers") @cl_uint int num_input_headers, + @Check("1") @Const @NativeType("cl_program") PointerBuffer input_headers, + @NullTerminated("input_headers.remaining()") @Check @Const @Indirect @cl_char @PointerArray("num_input_headers") ByteBuffer header_include_names, + @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLCompileProgramCallback pfn_notify, + @Constant("user_data") @PointerWrapper("void *") long user_data); + + @Alternate(value = "clCompileProgram", nativeAlt = true) + @Code( + tryBlock = true, + // Create a GlobalRef to the callback object. + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" + + "\t\tif ( pfn_notify != null ) pfn_notify.setContext(program.getParent());", + // Check if we need to delete the GlobalRef. + javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);" + ) + @cl_int + int clCompileProgram3(@PointerWrapper("cl_program") CLProgram program, + @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices, + @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list, + @Check @NullTerminated @Const @cl_char ByteBuffer options, + @Constant("header_include_names.length") @cl_uint int num_input_headers, + @Check("header_include_names.length") @Const @NativeType("cl_program") PointerBuffer input_headers, + @NullTerminated @Check("1") @PointerArray(value = "num_input_headers") @Const @NativeType("cl_char") ByteBuffer[] header_include_names, + @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLCompileProgramCallback pfn_notify, + @Constant("user_data") @PointerWrapper("void *") long user_data); + + @Alternate("clCompileProgram") + @Code( + tryBlock = true, + // Create a GlobalRef to the callback object. + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" + + "\t\tif ( pfn_notify != null ) pfn_notify.setContext(program.getParent());", + // Check if we need to delete the GlobalRef. + javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);" + ) + @cl_int + int clCompileProgram(@PointerWrapper("cl_program") CLProgram program, + @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices, + @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list, + @NullTerminated CharSequence options, + @Constant("1") @cl_uint int num_input_headers, + @Check("1") @Const @NativeType("cl_program") PointerBuffer input_header, + @NullTerminated @Const CharSequence header_include_name, + @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLCompileProgramCallback pfn_notify, + @Constant("user_data") @PointerWrapper("void *") long user_data); + + @Alternate(value = "clCompileProgram", nativeAlt = true, skipNative = true) + @Code( + tryBlock = true, + // Create a GlobalRef to the callback object. + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" + + "\t\tif ( pfn_notify != null ) pfn_notify.setContext(program.getParent());", + // Check if we need to delete the GlobalRef. + javaFinally = "\t\t\tCallbackUtil.checkCallback(__result, user_data);" + ) + @cl_int + int clCompileProgramMulti(@PointerWrapper("cl_program") CLProgram program, + @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices, + @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list, + @NullTerminated CharSequence options, + @AutoSize("input_header") @cl_uint int num_input_headers, + @Check("1") @Const @NativeType("cl_program") PointerBuffer input_header, + @NullTerminated @PointerArray(value = "num_input_headers") @Const CharSequence[] header_include_name, + @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLCompileProgramCallback pfn_notify, + @Constant("user_data") @PointerWrapper("void *") long user_data); + + @Code( + tryBlock = true, + // Create a GlobalRef to the callback object. + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" + + "\t\tif ( pfn_notify != null ) pfn_notify.setContext(context);", + // Check if we need to delete the GlobalRef. + javaFinally = "\t\t\tCallbackUtil.checkCallback(errcode_ret.get(errcode_ret.position()), user_data);" + ) + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_program", params = "context") + CLProgram clLinkProgram(@PointerWrapper("cl_context") CLContext context, + @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices, + @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list, + @NullTerminated @Check @Const @cl_char ByteBuffer options, + @AutoSize("input_programs") @cl_uint int num_input_programs, + @Check @Const @NativeType("cl_program") PointerBuffer input_programs, + @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLLinkProgramCallback pfn_notify, + @Constant("user_data") @PointerWrapper("void *") long user_data, + @OutParameter @Check("1") @cl_int IntBuffer errcode_ret); + + @Alternate("clLinkProgram") + @Code( + tryBlock = true, + // Create a GlobalRef to the callback object. + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);\n" + + "\t\tif ( pfn_notify != null ) pfn_notify.setContext(context);", + // Check if we need to delete the GlobalRef. + javaFinally = "\t\t\tCallbackUtil.checkCallback(errcode_ret.get(errcode_ret.position()), user_data);" + ) + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_program", params = "context") + CLProgram clLinkProgram(@PointerWrapper("cl_context") CLContext context, + @AutoSize(value = "device_list", canBeNull = true) @cl_uint int num_devices, + @Check(canBeNull = true) @Const @NativeType("cl_device_id") PointerBuffer device_list, + @NullTerminated CharSequence options, + @AutoSize("input_programs") @cl_uint int num_input_programs, + @Check @Const @NativeType("cl_program") PointerBuffer input_programs, + @PointerWrapper(value = "cl_program_callback", canBeNull = true) CLLinkProgramCallback pfn_notify, + @Constant("user_data") @PointerWrapper("void *") long user_data, + @OutParameter @Check("1") @cl_int IntBuffer errcode_ret); + + @cl_int + int clUnloadPlatformCompiler(@PointerWrapper("cl_platform_id") CLPlatform platform); + + @cl_int + int clGetKernelArgInfo(@PointerWrapper("cl_kernel") CLKernel kernel, + @cl_uint int arg_indx, + @NativeType("cl_kernel_arg_info") int param_name, + @AutoSize(value = "param_value", canBeNull = true) @size_t long param_value_size, + @OutParameter @Check(canBeNull = true) @cl_void ByteBuffer param_value, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("size_t") PointerBuffer param_value_size_ret); + + @cl_int + int clEnqueueFillBuffer(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_mem") CLMem buffer, + @Check @Const @cl_void ByteBuffer pattern, + @AutoSize("pattern") @size_t long pattern_size, + @size_t long offset, + @size_t long size, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @cl_int + int clEnqueueFillImage(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @PointerWrapper("cl_mem") CLMem image, + @Check("4 * 4") @Const @cl_void ByteBuffer fill_color, + @Check("3") @Const @NativeType("size_t") PointerBuffer origin, + @Check("3") @Const @NativeType("size_t") PointerBuffer region, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @cl_int + int clEnqueueMigrateMemObjects(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @AutoSize("mem_objects") @cl_uint int num_mem_objects, + @Check @Const @NativeType("cl_mem") PointerBuffer mem_objects, + @NativeType("cl_mem_migration_flags") long flags, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @cl_int + int clEnqueueMarkerWithWaitList(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @cl_int + int clEnqueueBarrierWithWaitList(@PointerWrapper("cl_command_queue") CLCommandQueue command_queue, + @AutoSize(value = "event_wait_list", canBeNull = true) @cl_uint int num_events_in_wait_list, + @Check(canBeNull = true) @Const @NativeType("cl_event") PointerBuffer event_wait_list, + @OutParameter @Check(value = "1", canBeNull = true) @NativeType("cl_event") PointerBuffer event); + + @Code( + tryBlock = true, + // Create a GlobalRef to the callback object. + javaBeforeNative = "\t\tlong user_data = CallbackUtil.createGlobalRef(pfn_notify);", + // Check if we need to delete the GlobalRef. + javaFinally = "\t\t\tcontext.setPrintfCallback(user_data, __result);" + ) + @cl_int + int clSetPrintfCallback(@PointerWrapper("cl_context") CLContext context, + @PointerWrapper("cl_printf_callback") CLPrintfCallback pfn_notify, + @Constant("user_data") @PointerWrapper("void *") long user_data); + + @Private + @PointerWrapper("void *") + CLFunctionAddress clGetExtensionFunctionAddressForPlatform(@PointerWrapper("cl_platform_id") CLPlatform platform, + @Check("1") @Const @cl_char ByteBuffer func_name); + + @Alternate("clGetExtensionFunctionAddressForPlatform") + @Private + @PointerWrapper("void *") + CLFunctionAddress clGetExtensionFunctionAddressForPlatform(@PointerWrapper("cl_platform_id") CLPlatform platform, + CharSequence func_name); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/CL12GL.java b/src/templates/org/lwjgl/opencl/CL12GL.java new file mode 100644 index 00000000..f655e990 --- /dev/null +++ b/src/templates/org/lwjgl/opencl/CL12GL.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2002-2008 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * 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. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 THE COPYRIGHT OWNER 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. + */ +package org.lwjgl.opencl; + +import org.lwjgl.util.generator.Check; +import org.lwjgl.util.generator.NativeType; +import org.lwjgl.util.generator.OutParameter; +import org.lwjgl.util.generator.PointerWrapper; +import org.lwjgl.util.generator.opencl.cl_int; + +import java.nio.IntBuffer; + +/** The core OpenCL 1.2 OpenGL interrop functionality. */ +public interface CL12GL { + + /* cl_gl_object_type */ + int CL_GL_OBJECT_TEXTURE2D_ARRAY = 0x200E, + CL_GL_OBJECT_TEXTURE1D = 0x200F, + CL_GL_OBJECT_TEXTURE1D_ARRAY = 0x2010, + CL_GL_OBJECT_TEXTURE_BUFFER = 0x2011; + + @Check(value = "errcode_ret", canBeNull = true) + @PointerWrapper(value = "cl_mem", params = "context") + CLMem clCreateFromGLTexture(@PointerWrapper("cl_context") CLContext context, + @NativeType("cl_mem_flags") long flags, + @NativeType("GLenum") int target, + @NativeType("GLint") int miplevel, + @NativeType("GLuint") int texture, + @OutParameter @Check(value = "1", canBeNull = true) @cl_int IntBuffer errcode_ret); + +} \ No newline at end of file diff --git a/src/templates/org/lwjgl/opencl/EXT_device_fission.java b/src/templates/org/lwjgl/opencl/EXT_device_fission.java index 23ecd9be..a7ff519f 100644 --- a/src/templates/org/lwjgl/opencl/EXT_device_fission.java +++ b/src/templates/org/lwjgl/opencl/EXT_device_fission.java @@ -135,7 +135,6 @@ public interface EXT_device_fission { @cl_int int clCreateSubDevicesEXT( @PointerWrapper("cl_device_id") CLDevice in_device, - // TODO: cl_device_partition_property_ext is a cl_bitfield (ulong), but the spec says properties is a {property-value, cl_int[]} list... @NullTerminated @Const @NativeType("cl_device_partition_property_ext") LongBuffer properties, @AutoSize(value = "out_devices", canBeNull = true) @cl_uint int num_entries, @OutParameter @Check(canBeNull = true) @NativeType("cl_device_id") PointerBuffer out_devices, diff --git a/src/templates/org/lwjgl/opengl/ARB_separate_shader_objects.java b/src/templates/org/lwjgl/opengl/ARB_separate_shader_objects.java index cecb4d9f..f0a84954 100644 --- a/src/templates/org/lwjgl/opengl/ARB_separate_shader_objects.java +++ b/src/templates/org/lwjgl/opengl/ARB_separate_shader_objects.java @@ -32,7 +32,6 @@ package org.lwjgl.opengl; import org.lwjgl.util.generator.*; -import org.lwjgl.util.generator.Alternate; import org.lwjgl.util.generator.opengl.*; import java.nio.ByteBuffer; @@ -44,12 +43,12 @@ import java.nio.IntBuffer; public interface ARB_separate_shader_objects { /** Accepted by <stages> parameter to UseProgramStages: */ - int GL_VERTEX_SHADER_BIT = 0x00000001, - GL_FRAGMENT_SHADER_BIT = 0x00000002, - GL_GEOMETRY_SHADER_BIT = 0x00000004, - GL_TESS_CONTROL_SHADER_BIT = 0x00000008, + int GL_VERTEX_SHADER_BIT = 0x00000001, + GL_FRAGMENT_SHADER_BIT = 0x00000002, + GL_GEOMETRY_SHADER_BIT = 0x00000004, + GL_TESS_CONTROL_SHADER_BIT = 0x00000008, GL_TESS_EVALUATION_SHADER_BIT = 0x00000010, - GL_ALL_SHADER_BITS = 0xFFFFFFFF; + GL_ALL_SHADER_BITS = 0xFFFFFFFF; /** * Accepted by the <pname> parameter of ProgramParameteri and @@ -72,10 +71,24 @@ public interface ARB_separate_shader_objects { @Reuse("GL41") void glActiveShaderProgram(@GLuint int pipeline, @GLuint int program); + /** Single null-terminated source code string. */ @Reuse("GL41") + @StripPostfix(value = "string", postfix = "v") + @GLuint + int glCreateShaderProgramv(@GLenum int type, @Constant("1") @GLsizei int count, @NullTerminated @Check @Const @Indirect @GLchar ByteBuffer string); + + /** Multiple null-terminated source code strings, one after the other. */ + @Reuse("GL41") + @Alternate(value = "glCreateShaderProgramv", nativeAlt = true) @StripPostfix(value = "strings", postfix = "v") @GLuint - int glCreateShaderProgramv(@GLenum int type, @GLsizei int count, @Check @Const @Indirect @GLchar ByteBuffer strings); + int glCreateShaderProgramv2(@GLenum int type, @GLsizei int count, @NullTerminated("count") @Check @Const @Indirect @GLchar @PointerArray("count") ByteBuffer strings); + + @Reuse("GL41") + @Alternate(value = "glCreateShaderProgramv", nativeAlt = true) + @StripPostfix(value = "strings", postfix = "v") + @GLuint + int glCreateShaderProgramv3(@GLenum int type, @Constant("strings.length") @GLsizei int count, @NullTerminated @Check("1") @PointerArray(value = "count") @Const @NativeType("GLchar") ByteBuffer[] strings); @Reuse("GL41") @Alternate("glCreateShaderProgramv") @@ -84,11 +97,11 @@ public interface ARB_separate_shader_objects { int glCreateShaderProgramv(@GLenum int type, @Constant("1") @GLsizei int count, @NullTerminated CharSequence string); @Reuse("GL41") - @Alternate("glCreateShaderProgramv") + @Alternate(value = "glCreateShaderProgramv", nativeAlt = true, skipNative = true) @StripPostfix(value = "strings", postfix = "v") @GLuint - int glCreateShaderProgramv(@GLenum int type, @Constant("strings.length") @GLsizei int count, - @Const @NullTerminated @PointerArray(value = "count") CharSequence[] strings); + int glCreateShaderProgramv2(@GLenum int type, @Constant("strings.length") @GLsizei int count, + @Const @NullTerminated @PointerArray(value = "count") CharSequence[] strings); @Reuse("GL41") void glBindProgramPipeline(@GLuint int pipeline); diff --git a/src/templates/org/lwjgl/opengl/GL41.java b/src/templates/org/lwjgl/opengl/GL41.java index 5bed704a..557c210e 100644 --- a/src/templates/org/lwjgl/opengl/GL41.java +++ b/src/templates/org/lwjgl/opengl/GL41.java @@ -46,12 +46,12 @@ public interface GL41 { * Accepted by the <value> parameter of GetBooleanv, GetIntegerv, * GetInteger64v, GetFloatv, and GetDoublev: */ - int GL_SHADER_COMPILER = 0x8DFA, - GL_NUM_SHADER_BINARY_FORMATS = 0x8DF9, - GL_MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB, - GL_MAX_VARYING_VECTORS = 0x8DFC, - GL_MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD, - GL_IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A, + int GL_SHADER_COMPILER = 0x8DFA, + GL_NUM_SHADER_BINARY_FORMATS = 0x8DF9, + GL_MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB, + GL_MAX_VARYING_VECTORS = 0x8DFC, + GL_MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD, + GL_IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A, GL_IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B; /** Accepted by the <type> parameter of VertexAttribPointer: */ @@ -61,12 +61,12 @@ public interface GL41 { * Accepted by the <precisiontype> parameter of * GetShaderPrecisionFormat: */ - int GL_LOW_FLOAT = 0x8DF0, + int GL_LOW_FLOAT = 0x8DF0, GL_MEDIUM_FLOAT = 0x8DF1, - GL_HIGH_FLOAT = 0x8DF2, - GL_LOW_INT = 0x8DF3, - GL_MEDIUM_INT = 0x8DF4, - GL_HIGH_INT = 0x8DF5; + GL_HIGH_FLOAT = 0x8DF2, + GL_LOW_INT = 0x8DF3, + GL_MEDIUM_INT = 0x8DF4, + GL_HIGH_INT = 0x8DF5; void glReleaseShaderCompiler(); @@ -99,7 +99,7 @@ public interface GL41 { * GetInteger64v, GetFloatv and GetDoublev: */ int GL_NUM_PROGRAM_BINARY_FORMATS = 0x87FE, - GL_PROGRAM_BINARY_FORMATS = 0x87FF; + GL_PROGRAM_BINARY_FORMATS = 0x87FF; void glGetProgramBinary(@GLuint int program, @AutoSize("binary") @GLsizei int bufSize, @Check(value = "1", canBeNull = true) @GLsizei IntBuffer length, @@ -115,12 +115,12 @@ public interface GL41 { // --------------------------------------------------------------------------- /** Accepted by <stages> parameter to UseProgramStages: */ - int GL_VERTEX_SHADER_BIT = 0x00000001, - GL_FRAGMENT_SHADER_BIT = 0x00000002, - GL_GEOMETRY_SHADER_BIT = 0x00000004, - GL_TESS_CONTROL_SHADER_BIT = 0x00000008, + int GL_VERTEX_SHADER_BIT = 0x00000001, + GL_FRAGMENT_SHADER_BIT = 0x00000002, + GL_GEOMETRY_SHADER_BIT = 0x00000004, + GL_TESS_CONTROL_SHADER_BIT = 0x00000008, GL_TESS_EVALUATION_SHADER_BIT = 0x00000010, - GL_ALL_SHADER_BITS = 0xFFFFFFFF; + GL_ALL_SHADER_BITS = 0xFFFFFFFF; /** * Accepted by the <pname> parameter of ProgramParameteri and @@ -141,20 +141,32 @@ public interface GL41 { void glActiveShaderProgram(@GLuint int pipeline, @GLuint int program); + /** Single null-terminated source code string. */ + @StripPostfix(value = "string", postfix = "v") + @GLuint + int glCreateShaderProgramv(@GLenum int type, @Constant("1") @GLsizei int count, @NullTerminated @Check @Const @Indirect @GLchar ByteBuffer string); + + /** Multiple null-terminated source code strings, one after the other. */ + @Alternate(value = "glCreateShaderProgramv", nativeAlt = true) @StripPostfix(value = "strings", postfix = "v") @GLuint - int glCreateShaderProgramv(@GLenum int type, @GLsizei int count, @Check @Const @Indirect @GLchar ByteBuffer strings); + int glCreateShaderProgramv2(@GLenum int type, @GLsizei int count, @NullTerminated("count") @Check @Const @Indirect @GLchar @PointerArray("count") ByteBuffer strings); + + @Alternate(value = "glCreateShaderProgramv", nativeAlt = true) + @StripPostfix(value = "strings", postfix = "v") + @GLuint + int glCreateShaderProgramv3(@GLenum int type, @Constant("strings.length") @GLsizei int count, @NullTerminated @Check("1") @PointerArray(value = "count") @Const @NativeType("GLchar") ByteBuffer[] strings); @Alternate("glCreateShaderProgramv") @StripPostfix(value = "string", postfix = "v") @GLuint int glCreateShaderProgramv(@GLenum int type, @Constant("1") @GLsizei int count, @NullTerminated CharSequence string); - @Alternate("glCreateShaderProgramv") + @Alternate(value = "glCreateShaderProgramv", nativeAlt = true, skipNative = true) @StripPostfix(value = "strings", postfix = "v") @GLuint - int glCreateShaderProgramv(@GLenum int type, @Constant("strings.length") @GLsizei int count, - @Const @NullTerminated @PointerArray(value = "count") CharSequence[] strings); + int glCreateShaderProgramv2(@GLenum int type, @Constant("strings.length") @GLsizei int count, + @Const @NullTerminated @PointerArray(value = "count") CharSequence[] strings); void glBindProgramPipeline(@GLuint int pipeline); @@ -342,12 +354,12 @@ public interface GL41 { // ----------------------------------------------------------------------- /** Returned in the <type> parameter of GetActiveAttrib: */ - int GL_DOUBLE_VEC2 = 0x8FFC; - int GL_DOUBLE_VEC3 = 0x8FFD; - int GL_DOUBLE_VEC4 = 0x8FFE; - int GL_DOUBLE_MAT2 = 0x8F46; - int GL_DOUBLE_MAT3 = 0x8F47; - int GL_DOUBLE_MAT4 = 0x8F48; + int GL_DOUBLE_VEC2 = 0x8FFC; + int GL_DOUBLE_VEC3 = 0x8FFD; + int GL_DOUBLE_VEC4 = 0x8FFE; + int GL_DOUBLE_MAT2 = 0x8F46; + int GL_DOUBLE_MAT3 = 0x8F47; + int GL_DOUBLE_MAT4 = 0x8F48; int GL_DOUBLE_MAT2x3 = 0x8F49; int GL_DOUBLE_MAT2x4 = 0x8F4A; int GL_DOUBLE_MAT3x2 = 0x8F4B; @@ -391,10 +403,10 @@ public interface GL41 { * Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, * GetDoublev and GetInteger64v: */ - int GL_MAX_VIEWPORTS = 0x825B, - GL_VIEWPORT_SUBPIXEL_BITS = 0x825C, - GL_VIEWPORT_BOUNDS_RANGE = 0x825D, - GL_LAYER_PROVOKING_VERTEX = 0x825E, + int GL_MAX_VIEWPORTS = 0x825B, + GL_VIEWPORT_SUBPIXEL_BITS = 0x825C, + GL_VIEWPORT_BOUNDS_RANGE = 0x825D, + GL_LAYER_PROVOKING_VERTEX = 0x825E, GL_VIEWPORT_INDEX_PROVOKING_VERTEX = 0x825F; /** Accepted by the <pname> parameter of GetIntegeri_v: */ @@ -414,9 +426,9 @@ public interface GL41 { * LAYER_PROVOKING_VERTEX or VIEWPORT_INDEX_PROVOKING_VERTEX: */ int GL_FIRST_VERTEX_CONVENTION = 0x8E4D, - GL_LAST_VERTEX_CONVENTION = 0x8E4E, - GL_PROVOKING_VERTEX = 0x8E4F, - GL_UNDEFINED_VERTEX = 0x8260; + GL_LAST_VERTEX_CONVENTION = 0x8E4E, + GL_PROVOKING_VERTEX = 0x8E4F, + GL_UNDEFINED_VERTEX = 0x8260; @StripPostfix("v") void glViewportArrayv(@GLuint int first, @AutoSize(value = "v", expression = " >> 2") @GLsizei int count, @Const FloatBuffer v);