From ed68a7b7495052fdb2e3489cc6567d74f2cb3472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wei=C3=9F?= Date: Sat, 27 Aug 2016 08:45:42 +0200 Subject: [PATCH] fixed formatting 2 --- .../com/jme3/opencl/lwjgl/info/CLUtil.java | 150 +-- .../java/com/jme3/opencl/lwjgl/info/Info.java | 1053 +++++++++++------ .../com/jme3/opencl/lwjgl/info/InfoQuery.java | 365 +++--- .../jme3/opencl/lwjgl/info/InfoQueryInt.java | 383 +++--- .../opencl/lwjgl/info/InfoQueryObject.java | 383 +++--- 5 files changed, 1342 insertions(+), 992 deletions(-) diff --git a/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/CLUtil.java b/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/CLUtil.java index 09378c5df..3e1e64598 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/CLUtil.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/CLUtil.java @@ -25,82 +25,90 @@ import static org.lwjgl.system.APIUtil.*; public final class CLUtil { - /** Maps OpenCL error token values to their String representations. */ - private static final Map CL_ERROR_TOKENS = apiClassTokens( - new BiPredicate() { - private final List EXCLUDE = Arrays.asList("CL_DEVICE_TYPE_ALL", "CL_BUILD_NONE", "CL_BUILD_ERROR", "CL_BUILD_IN_PROGRESS"); + /** + * Maps OpenCL error token values to their String representations. + */ + private static final Map CL_ERROR_TOKENS = apiClassTokens( + new BiPredicate() { + private final List EXCLUDE = Arrays.asList("CL_DEVICE_TYPE_ALL", "CL_BUILD_NONE", "CL_BUILD_ERROR", "CL_BUILD_IN_PROGRESS"); - @Override - public boolean test(Field field, Integer value) { - return value < 0 && !EXCLUDE.contains(field.getName()); // OpenCL errors have negative values. - } - }, - null, - CL10.class, - apiOptionalClass("org.lwjgl.opencl.CL10GL"), - CL11.class, - CL12.class, - CL20.class, - apiOptionalClass("org.lwjgl.opencl.APPLEGLSharing"), - INTELAccelerator.class, - apiOptionalClass("org.lwjgl.opencl.KHRGLSharing"), - apiOptionalClass("org.lwjgl.opencl.KHREGLEvent"), - apiOptionalClass("org.lwjgl.opencl.KHREGLImage"), - KHRICD.class - /*, EXTDeviceFission.class*/ - ); + @Override + public boolean test(Field field, Integer value) { + return value < 0 && !EXCLUDE.contains(field.getName()); // OpenCL errors have negative values. + } + }, + null, + CL10.class, + apiOptionalClass("org.lwjgl.opencl.CL10GL"), + CL11.class, + CL12.class, + CL20.class, + apiOptionalClass("org.lwjgl.opencl.APPLEGLSharing"), + INTELAccelerator.class, + apiOptionalClass("org.lwjgl.opencl.KHRGLSharing"), + apiOptionalClass("org.lwjgl.opencl.KHREGLEvent"), + apiOptionalClass("org.lwjgl.opencl.KHREGLImage"), + KHRICD.class + /*, EXTDeviceFission.class*/ + ); - private CLUtil() {} + private CLUtil() { + } - /** - * Checks the {@code errcode} present in the current position of the specified {@code errcode_ret} buffer and throws an {@link OpenCLException} if it's not - * equal to {@link CL10#CL_SUCCESS}. - * - * @param errcode_ret the {@code errcode} buffer - * - * @throws OpenCLException - */ - public static void checkCLError(ByteBuffer errcode_ret) { - checkCLError(errcode_ret.getInt(errcode_ret.position())); - } + /** + * Checks the {@code errcode} present in the current position of the + * specified {@code errcode_ret} buffer and throws an + * {@link OpenCLException} if it's not equal to {@link CL10#CL_SUCCESS}. + * + * @param errcode_ret the {@code errcode} buffer + * + * @throws OpenCLException + */ + public static void checkCLError(ByteBuffer errcode_ret) { + checkCLError(errcode_ret.getInt(errcode_ret.position())); + } - /** - * Checks the {@code errcode} present in the current position of the specified {@code errcode_ret} buffer and throws an {@link OpenCLException} if it's not - * equal to {@link CL10#CL_SUCCESS}. - * - * @param errcode_ret the {@code errcode} buffer - * - * @throws OpenCLException - */ - public static void checkCLError(IntBuffer errcode_ret) { - checkCLError(errcode_ret.get(errcode_ret.position())); - } + /** + * Checks the {@code errcode} present in the current position of the + * specified {@code errcode_ret} buffer and throws an + * {@link OpenCLException} if it's not equal to {@link CL10#CL_SUCCESS}. + * + * @param errcode_ret the {@code errcode} buffer + * + * @throws OpenCLException + */ + public static void checkCLError(IntBuffer errcode_ret) { + checkCLError(errcode_ret.get(errcode_ret.position())); + } - /** - * Checks the specified {@code errcode} and throws an {@link OpenCLException} if it's not equal to {@link CL10#CL_SUCCESS}. - * - * @param errcode the {@code errcode} to check - * - * @throws OpenCLException - */ - public static void checkCLError(int errcode) { - if ( errcode != CL_SUCCESS ) - throw new OpenCLException(getErrcodeName(errcode)); - } + /** + * Checks the specified {@code errcode} and throws an + * {@link OpenCLException} if it's not equal to {@link CL10#CL_SUCCESS}. + * + * @param errcode the {@code errcode} to check + * + * @throws OpenCLException + */ + public static void checkCLError(int errcode) { + if (errcode != CL_SUCCESS) { + throw new OpenCLException(getErrcodeName(errcode)); + } + } - /** - * Returns the token name of the specified {@code errcode}. - * - * @param errcode the {@code errcode} - * - * @return the {@code errcode} token name - */ - public static String getErrcodeName(int errcode) { - String errname = CL_ERROR_TOKENS.get(errcode); - if ( errname == null ) - errname = apiUnknownToken(errcode); + /** + * Returns the token name of the specified {@code errcode}. + * + * @param errcode the {@code errcode} + * + * @return the {@code errcode} token name + */ + public static String getErrcodeName(int errcode) { + String errname = CL_ERROR_TOKENS.get(errcode); + if (errname == null) { + errname = apiUnknownToken(errcode); + } - return errname; - } + return errname; + } -} \ No newline at end of file +} diff --git a/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/Info.java b/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/Info.java index e28061b28..fd48b21a5 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/Info.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/Info.java @@ -13,390 +13,675 @@ import static org.lwjgl.opencl.CL20.*; import static org.lwjgl.opencl.CL10GL.*; /** - * This class provides methods that can be used to query information about OpenCL objects. These methods are similar to the corresponding - * {@code clGet<Type>Info} function for each object type, except that only a single value is returned. Which one of these methods should be used - * depends on the type of the information being queried. + * This class provides methods that can be used to query information about + * OpenCL objects. These methods are similar to the corresponding + * {@code clGet<Type>Info} function for each object type, except that only + * a single value is returned. Which one of these methods should be used depends + * on the type of the information being queried. */ public final class Info { - private Info() { - } - - // ------------------------------------ - // Platform (CL10.clGetPlatformInfo) - // ------------------------------------ - - private static final InfoQuery PLATFORM = new InfoQuery() { - @Override - protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { - return nclGetPlatformInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); - } - }; - - /** String version of: {@link CL10#clGetPlatformInfo GetPlatformInfo} */ - public static String clGetPlatformInfoStringASCII(long platform, int param_name) { return PLATFORM.getStringASCII(platform, param_name); } - - /** String with explicit length version of: {@link CL10#clGetPlatformInfo GetPlatformInfo}*/ - public static String clGetPlatformInfoStringASCII(long platform, int param_name, int param_value_size) { return PLATFORM.getStringASCII(platform, param_name, param_value_size); } - - /** UTF-8 string version of: {@link CL10#clGetPlatformInfo GetPlatformInfo} */ - public static String clGetPlatformInfoStringUTF8(long platform, int param_name) { return PLATFORM.getStringUTF8(platform, param_name); } - - /** UTF-8 string with explicit length version of: {@link CL10#clGetPlatformInfo GetPlatformInfo} */ - public static String clGetPlatformInfoStringUTF8(long platform, int param_name, int param_value_size) { return PLATFORM.getStringUTF8(platform, param_name, param_value_size); } - - // ------------------------------------ - // Device (CL10.clGetDeviceInfo) - // ------------------------------------ - - private static final InfoQuery DEVICE = new InfoQuery() { - @Override - protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { - return nclGetDeviceInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); - } - }; - - /** Single boolean value version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} */ - public static boolean clGetDeviceInfoBoolean(long device, int param_name) { return DEVICE.getBoolean(device, param_name); } - - /** Single int value version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} */ - public static int clGetDeviceInfoInt(long device, int param_name) { return DEVICE.getInt(device, param_name); } - - /** Single long value version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} */ - public static long clGetDeviceInfoLong(long device, int param_name) { return DEVICE.getLong(device, param_name); } - - /** Single pointer value version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} */ - public static long clGetDeviceInfoPointer(long device, int param_name) { return DEVICE.getPointer(device, param_name); } - - /** PointBuffer version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} */ - public static int clGetDeviceInfoPointers(long device, int param_name, PointerBuffer target) { return DEVICE.getPointers(device, param_name, target); } - - /** String version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} */ - public static String clGetDeviceInfoStringASCII(long device, int param_name) { return DEVICE.getStringASCII(device, param_name); } - - /** String with explicit length version of: {@link CL10#clGetDeviceInfo GetDeviceInfo}*/ - public static String clGetDeviceInfoStringASCII(long device, int param_name, int param_value_size) { return DEVICE.getStringASCII(device, param_name, param_value_size); } - - /** UTF-8 string version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} */ - public static String clGetDeviceInfoStringUTF8(long device, int param_name) { return DEVICE.getStringUTF8(device, param_name); } - - /** UTF-8 string with explicit length version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} */ - public static String clGetDeviceInfoStringUTF8(long device, int param_name, int param_value_size) { return DEVICE.getStringUTF8(device, param_name, param_value_size); } - - // ------------------------------------ - // Context (CL10.clGetContextInfo) - // ------------------------------------ - - private static final InfoQuery CONTEXT = new InfoQuery() { - @Override - protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { - return nclGetContextInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); - } - }; - - /** Single int value version of: {@link CL10#clGetContextInfo GetContextInfo} */ - public static int clGetContextInfoInt(long context, int param_name) { return CONTEXT.getInt(context, param_name); } - - /** Single pointer value version of: {@link CL10#clGetContextInfo GetContextInfo} */ - public static long clGetContextInfoPointer(long context, int param_name) { return CONTEXT.getPointer(context, param_name); } - - /** PointBuffer version of: {@link CL10#clGetContextInfo GetContextInfo} */ - public static int clGetContextInfoPointers(long context, int param_name, PointerBuffer target) { return CONTEXT.getPointers(context, param_name, target); } - - // ------------------------------------ - // Command Queue (CL10.clGetCommandQueueInfo) - // ------------------------------------ - - private static final InfoQuery COMMAND_QUEUE = new InfoQuery() { - @Override - protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { - return nclGetCommandQueueInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); - } - }; - - /** Single int value version of: {@link CL10#clGetCommandQueueInfo GetCommandQueueInfo} */ - public static int clGetCommandQueueInfoInt(long command_queue, int param_name) { return COMMAND_QUEUE.getInt(command_queue, param_name); } - - /** Single pointer value version of: {@link CL10#clGetCommandQueueInfo GetCommandQueueInfo} */ - public static long clGetCommandQueueInfoPointer(long command_queue, int param_name) { return COMMAND_QUEUE.getPointer(command_queue, param_name); } - - /** PointBuffer version of: {@link CL10#clGetCommandQueueInfo GetCommandQueueInfo} */ - public static int clGetCommandQueueInfoPointers(long command_queue, int param_name, PointerBuffer target) { return COMMAND_QUEUE.getPointers(command_queue, param_name, target); } - - // ------------------------------------ - // Mem Object (CL10.clGetMemObjectInfo) - // ------------------------------------ - - private static final InfoQuery MEM_OBJECT = new InfoQuery() { - @Override - protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { - return nclGetMemObjectInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); - } - }; - - /** Single boolean value version of: {@link CL10#clGetMemObjectInfo GetMemObjectInfo} */ - public static boolean clGetMemObjectInfoBoolean(long memobj, int param_name) { return MEM_OBJECT.getBoolean(memobj, param_name); } - - /** Single int value version of: {@link CL10#clGetMemObjectInfo GetMemObjectInfo} */ - public static int clGetMemObjectInfoInt(long memobj, int param_name) { return MEM_OBJECT.getInt(memobj, param_name); } - - /** Single long value version of: {@link CL10#clGetMemObjectInfo GetMemObjectInfo} */ - public static long clGetMemObjectInfoLong(long memobj, int param_name) { return MEM_OBJECT.getLong(memobj, param_name); } - - /** Single pointer value version of: {@link CL10#clGetMemObjectInfo GetMemObjectInfo} */ - public static long clGetMemObjectInfoPointer(long memobj, int param_name) { return MEM_OBJECT.getPointer(memobj, param_name); } - - /** PointBuffer version of: {@link CL10#clGetMemObjectInfo GetMemObjectInfo} */ - public static int clGetMemObjectInfoPointers(long memobj, int param_name, PointerBuffer target) { return MEM_OBJECT.getPointers(memobj, param_name, target); } - - // ------------------------------------ - // Image (CL10.clGetImageInfo) - // ------------------------------------ - - private static final InfoQuery IMAGE = new InfoQuery() { - @Override - protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { - return nclGetImageInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); - } - }; - - /** Single int value version of: {@link CL10#clGetImageInfo GetImageInfo} */ - public static int clGetImageInfoInt(long image, int param_name) { return IMAGE.getInt(image, param_name); } - - /** Single pointer value version of: {@link CL10#clGetImageInfo GetImageInfo} */ - public static long clGetImageInfoPointer(long image, int param_name) { return IMAGE.getPointer(image, param_name); } - - /** PointBuffer version of: {@link CL10#clGetImageInfo GetImageInfo} */ - public static int clGetImageInfoPointers(long image, int param_name, PointerBuffer target) { return IMAGE.getPointers(image, param_name, target); } - - // ------------------------------------ - // Pipe (CL20.clGetPipeInfo) - // ------------------------------------ - - private static final InfoQuery PIPE = new InfoQuery() { - @Override - protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { - return nclGetPipeInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); - } - }; - - /** Single int value version of: {@link CL20#clGetPipeInfo GetPipeInfo} */ - public static int clGetPipeInfoInt(long pipe, int param_name) { return PIPE.getInt(pipe, param_name); } - - // ------------------------------------ - // Program (CL10.clGetProgramInfo) - // ------------------------------------ - - private static final InfoQuery PROGRAM = new InfoQuery() { - @Override - protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { - return nclGetProgramInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); - } - }; - - /** Single int value version of: {@link CL10#clGetProgramInfo GetProgramInfo} */ - public static int clGetProgramInfoInt(long program, int param_name) { return PROGRAM.getInt(program, param_name); } - - /** Single pointer value version of: {@link CL10#clGetProgramInfo GetProgramInfo} */ - public static long clGetProgramInfoPointer(long program, int param_name) { return PROGRAM.getPointer(program, param_name); } - - /** PointBuffer version of: {@link CL10#clGetProgramInfo GetProgramInfo} */ - public static int clGetProgramInfoPointers(long program, int param_name, PointerBuffer target) { return PROGRAM.getPointers(program, param_name, target); } - - /** String version of: {@link CL10#clGetProgramInfo GetProgramInfo} */ - public static String clGetProgramInfoStringASCII(long program, int param_name) { return PROGRAM.getStringASCII(program, param_name); } - - /** String with explicit length version of: {@link CL10#clGetProgramInfo GetProgramInfo}*/ - public static String clGetProgramInfoStringASCII(long program, int param_name, int param_value_size) { return PROGRAM.getStringASCII(program, param_name, param_value_size); } - - /** UTF-8 string version of: {@link CL10#clGetProgramInfo GetProgramInfo} */ - public static String clGetProgramInfoStringUTF8(long program, int param_name) { return PROGRAM.getStringUTF8(program, param_name); } - - /** UTF-8 string with explicit length version of: {@link CL10#clGetProgramInfo GetProgramInfo} */ - public static String clGetProgramInfoStringUTF8(long program, int param_name, int param_value_size) { return PROGRAM.getStringUTF8(program, param_name, param_value_size); } - - // ------------------------------------ - // Program Build (CL10.clGetProgramBuildInfo) - // ------------------------------------ - - private static final InfoQueryObject PROGRAM_BUILD = new InfoQueryObject() { - @Override - protected int get(long pointer, long arg, int param_name, long param_value_size, long param_value, long param_value_size_ret) { - return nclGetProgramBuildInfo(pointer, arg, param_name, param_value_size, param_value, param_value_size_ret); - } - }; - - /** Single int value version of: {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} */ - public static int clGetProgramBuildInfoInt(long program, long device, int param_name) { return PROGRAM_BUILD.getInt(program, device, param_name); } - - /** Single pointer value version of: {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} */ - public static long clGetProgramBuildInfoPointer(long program, long device, int param_name) { return PROGRAM_BUILD.getPointer(program, device, param_name); } - - /** PointBuffer version of: {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} */ - public static int clGetProgramBuildInfoPointers(long program, long device, int param_name, PointerBuffer target) { return PROGRAM_BUILD.getPointers(program, device, param_name, target); } - - /** String version of: {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} */ - public static String clGetProgramBuildInfoStringASCII(long program, long device, int param_name) { return PROGRAM_BUILD.getStringASCII(program, device, param_name); } - - /** String with explicit length version of: {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo}*/ - public static String clGetProgramBuildInfoStringASCII(long program, long device, int param_name, int param_value_size) { return PROGRAM_BUILD.getStringASCII(program, device, param_name, param_value_size); } - - /** UTF-8 string version of: {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} */ - public static String clGetProgramBuildInfoStringUTF8(long program, long device, int param_name) { return PROGRAM_BUILD.getStringUTF8(program, device, param_name); } - - /** UTF-8 string with explicit length version of: {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} */ - public static String clGetProgramBuildInfoStringUTF8(long program, long device, int param_name, int param_value_size) { return PROGRAM_BUILD.getStringUTF8(program, device, param_name, param_value_size); } - - // ------------------------------------ - // Kernel (CL10.clGetKernelInfo) - // ------------------------------------ - - private static final InfoQuery KERNEL = new InfoQuery() { - @Override - protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { - return nclGetKernelInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); - } - }; - - /** Single int value version of: {@link CL10#clGetKernelInfo GetKernelInfo} */ - public static int clGetKernelInfoInt(long kernel, int param_name) { return KERNEL.getInt(kernel, param_name); } - - /** Single pointer value version of: {@link CL10#clGetKernelInfo GetKernelInfo} */ - public static long clGetKernelInfoPointer(long kernel, int param_name) { return KERNEL.getPointer(kernel, param_name); } - - /** PointBuffer version of: {@link CL10#clGetKernelInfo GetKernelInfo} */ - public static int clGetKernelInfoPointers(long kernel, int param_name, PointerBuffer target) { return KERNEL.getPointers(kernel, param_name, target); } - - /** String version of: {@link CL10#clGetKernelInfo GetKernelInfo} */ - public static String clGetKernelInfoStringASCII(long kernel, int param_name) { return KERNEL.getStringASCII(kernel, param_name); } - - /** String with explicit length version of: {@link CL10#clGetKernelInfo GetKernelInfo}*/ - public static String clGetKernelInfoStringASCII(long kernel, int param_name, int param_value_size) { return KERNEL.getStringASCII(kernel, param_name, param_value_size); } - - /** UTF-8 string version of: {@link CL10#clGetKernelInfo GetKernelInfo} */ - public static String clGetKernelInfoStringUTF8(long kernel, int param_name) { return KERNEL.getStringUTF8(kernel, param_name); } - - /** UTF-8 string with explicit length version of: {@link CL10#clGetKernelInfo GetKernelInfo} */ - public static String clGetKernelInfoStringUTF8(long kernel, int param_name, int param_value_size) { return KERNEL.getStringUTF8(kernel, param_name, param_value_size); } - - // ------------------------------------ - // Kernel WorkGroup (CL10.clGetKernelWorkGroupInfo) - // ------------------------------------ - - private static final InfoQueryObject KERNEL_WORKGROUP = new InfoQueryObject() { - @Override - protected int get(long pointer, long arg, int param_name, long param_value_size, long param_value, long param_value_size_ret) { - return nclGetKernelWorkGroupInfo(pointer, arg, param_name, param_value_size, param_value, param_value_size_ret); - } - }; - - /** Single long value version of: {@link CL10#clGetKernelWorkGroupInfo GetKernelWorkGroupInfo} */ - public static long clGetKernelWorkGroupInfoLong(long kernel, long device, int param_name) { return KERNEL_WORKGROUP.getLong(kernel, device, param_name); } - - /** Single pointer value version of: {@link CL10#clGetKernelWorkGroupInfo GetKernelWorkGroupInfo} */ - public static long clGetKernelWorkGroupInfoPointer(long kernel, long device, int param_name) { return KERNEL_WORKGROUP.getPointer(kernel, device, param_name); } - - /** PointBuffer version of: {@link CL10#clGetKernelWorkGroupInfo GetKernelWorkGroupInfo} */ - public static int clGetKernelWorkGroupInfoPointers(long kernel, long device, int param_name, PointerBuffer target) { return KERNEL_WORKGROUP.getPointers(kernel, device, param_name, target); } - - // ------------------------------------ - // Kernel Arg (CL12.clGetKernelArgInfo) - // ------------------------------------ - - private static final InfoQueryInt KERNEL_ARG = new InfoQueryInt() { - @Override - protected int get(long pointer, int arg, int param_name, long param_value_size, long param_value, long param_value_size_ret) { - return nclGetKernelArgInfo(pointer, arg, param_name, param_value_size, param_value, param_value_size_ret); - } - }; - - /** Single int value version of: {@link CL12#clGetKernelArgInfo GetKernelArgInfo} */ - public static int clGetKernelArgInfoInt(long kernel, int arg_indx, int param_name) { return KERNEL_ARG.getInt(kernel, arg_indx, param_name); } - - /** Single long value version of: {@link CL12#clGetKernelArgInfo GetKernelArgInfo} */ - public static long clGetKernelArgInfoLong(long kernel, int arg_indx, int param_name) { return KERNEL_ARG.getLong(kernel, arg_indx, param_name); } - - /** String version of: {@link CL12#clGetKernelArgInfo GetKernelArgInfo} */ - public static String clGetKernelArgInfoStringASCII(long kernel, int arg_indx, int param_name) { return KERNEL_ARG.getStringASCII(kernel, arg_indx, param_name); } - - /** String with explicit length version of: {@link CL12#clGetKernelArgInfo GetKernelArgInfo}*/ - public static String clGetKernelArgInfoStringASCII(long kernel, int arg_indx, int param_name, int param_value_size) { return KERNEL_ARG.getStringASCII(kernel, arg_indx, param_name, param_value_size); } - - /** UTF-8 string version of: {@link CL12#clGetKernelArgInfo GetKernelArgInfo} */ - public static String clGetKernelArgInfoStringUTF8(long kernel, int arg_indx, int param_name) { return KERNEL_ARG.getStringUTF8(kernel, arg_indx, param_name); } - - /** UTF-8 string with explicit length version of: {@link CL12#clGetKernelArgInfo GetKernelArgInfo} */ - public static String clGetKernelArgInfoStringUTF8(long kernel, int arg_indx, int param_name, int param_value_size) { return KERNEL_ARG.getStringUTF8(kernel, arg_indx, param_name, param_value_size); } - - // ------------------------------------ - // Sampler (CL10.clGetSamplerInfo) - // ------------------------------------ - - private static final InfoQuery SAMPLER = new InfoQuery() { - @Override - protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { - return nclGetSamplerInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); - } - }; - - /** Single boolean value version of: {@link CL10#clGetSamplerInfo GetSamplerInfo} */ - public static boolean clGetSamplerInfoBoolean(long sampler, int param_name) { return SAMPLER.getBoolean(sampler, param_name); } - - /** Single int value version of: {@link CL10#clGetSamplerInfo GetSamplerInfo} */ - public static int clGetSamplerInfoInt(long sampler, int param_name) { return SAMPLER.getInt(sampler, param_name); } - - /** Single pointer value version of: {@link CL10#clGetSamplerInfo GetSamplerInfo} */ - public static long clGetSamplerInfoPointer(long sampler, int param_name) { return SAMPLER.getPointer(sampler, param_name); } - - /** PointBuffer version of: {@link CL10#clGetSamplerInfo GetSamplerInfo} */ - public static int clGetSamplerInfoPointers(long sampler, int param_name, PointerBuffer target) { return SAMPLER.getPointers(sampler, param_name, target); } - - // ------------------------------------ - // Event (CL10.clGetEventInfo) - // ------------------------------------ - - private static final InfoQuery EVENT = new InfoQuery() { - @Override - protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { - return nclGetEventInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); - } - }; - - /** Single int value version of: {@link CL10#clGetEventInfo GetEventInfo} */ - public static int clGetEventInfoInt(long event, int param_name) { return EVENT.getInt(event, param_name); } - - /** Single pointer value version of: {@link CL10#clGetEventInfo GetEventInfo} */ - public static long clGetEventInfoPointer(long event, int param_name) { return EVENT.getPointer(event, param_name); } - - /** PointBuffer version of: {@link CL10#clGetEventInfo GetEventInfo} */ - public static int clGetEventInfoPointers(long event, int param_name, PointerBuffer target) { return EVENT.getPointers(event, param_name, target); } - - // ------------------------------------ - // Event Profiling (CL10.clGetEventProfilingInfo) - // ------------------------------------ - - private static final InfoQuery EVENT_PROFILING = new InfoQuery() { - @Override - protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { - return nclGetEventProfilingInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); - } - }; - - /** Single long value version of: {@link CL10#clGetEventProfilingInfo GetEventProfilingInfo} */ - public static long clGetEventProfilingInfoLong(long event, int param_name) { return EVENT_PROFILING.getLong(event, param_name); } - - // ------------------------------------ - // GL Texture (CL10GL.clGetGLTextureInfo) - // ------------------------------------ - - private static final InfoQuery GL_TEXTURE = new InfoQuery() { - @Override - protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { - return nclGetGLTextureInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); - } - }; - - /** Single int value version of: {@link CL10GL#clGetGLTextureInfo GetGLTextureInfo} */ - public static int clGetGLTextureInfoInt(long memobj, int param_name) { return GL_TEXTURE.getInt(memobj, param_name); } - -} \ No newline at end of file + private Info() { + } + + // ------------------------------------ + // Platform (CL10.clGetPlatformInfo) + // ------------------------------------ + private static final InfoQuery PLATFORM = new InfoQuery() { + @Override + protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { + return nclGetPlatformInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); + } + }; + + /** + * String version of: {@link CL10#clGetPlatformInfo GetPlatformInfo} + */ + public static String clGetPlatformInfoStringASCII(long platform, int param_name) { + return PLATFORM.getStringASCII(platform, param_name); + } + + /** + * String with explicit length version of: {@link CL10#clGetPlatformInfo GetPlatformInfo} + */ + public static String clGetPlatformInfoStringASCII(long platform, int param_name, int param_value_size) { + return PLATFORM.getStringASCII(platform, param_name, param_value_size); + } + + /** + * UTF-8 string version of: {@link CL10#clGetPlatformInfo GetPlatformInfo} + */ + public static String clGetPlatformInfoStringUTF8(long platform, int param_name) { + return PLATFORM.getStringUTF8(platform, param_name); + } + + /** + * UTF-8 string with explicit length version of: + * {@link CL10#clGetPlatformInfo GetPlatformInfo} + */ + public static String clGetPlatformInfoStringUTF8(long platform, int param_name, int param_value_size) { + return PLATFORM.getStringUTF8(platform, param_name, param_value_size); + } + + // ------------------------------------ + // Device (CL10.clGetDeviceInfo) + // ------------------------------------ + private static final InfoQuery DEVICE = new InfoQuery() { + @Override + protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { + return nclGetDeviceInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); + } + }; + + /** + * Single boolean value version of: + * {@link CL10#clGetDeviceInfo GetDeviceInfo} + */ + public static boolean clGetDeviceInfoBoolean(long device, int param_name) { + return DEVICE.getBoolean(device, param_name); + } + + /** + * Single int value version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} + */ + public static int clGetDeviceInfoInt(long device, int param_name) { + return DEVICE.getInt(device, param_name); + } + + /** + * Single long value version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} + */ + public static long clGetDeviceInfoLong(long device, int param_name) { + return DEVICE.getLong(device, param_name); + } + + /** + * Single pointer value version of: + * {@link CL10#clGetDeviceInfo GetDeviceInfo} + */ + public static long clGetDeviceInfoPointer(long device, int param_name) { + return DEVICE.getPointer(device, param_name); + } + + /** + * PointBuffer version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} + */ + public static int clGetDeviceInfoPointers(long device, int param_name, PointerBuffer target) { + return DEVICE.getPointers(device, param_name, target); + } + + /** + * String version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} + */ + public static String clGetDeviceInfoStringASCII(long device, int param_name) { + return DEVICE.getStringASCII(device, param_name); + } + + /** + * String with explicit length version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} + */ + public static String clGetDeviceInfoStringASCII(long device, int param_name, int param_value_size) { + return DEVICE.getStringASCII(device, param_name, param_value_size); + } + + /** + * UTF-8 string version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} + */ + public static String clGetDeviceInfoStringUTF8(long device, int param_name) { + return DEVICE.getStringUTF8(device, param_name); + } + + /** + * UTF-8 string with explicit length version of: + * {@link CL10#clGetDeviceInfo GetDeviceInfo} + */ + public static String clGetDeviceInfoStringUTF8(long device, int param_name, int param_value_size) { + return DEVICE.getStringUTF8(device, param_name, param_value_size); + } + + // ------------------------------------ + // Context (CL10.clGetContextInfo) + // ------------------------------------ + private static final InfoQuery CONTEXT = new InfoQuery() { + @Override + protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { + return nclGetContextInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); + } + }; + + /** + * Single int value version of: {@link CL10#clGetContextInfo GetContextInfo} + */ + public static int clGetContextInfoInt(long context, int param_name) { + return CONTEXT.getInt(context, param_name); + } + + /** + * Single pointer value version of: + * {@link CL10#clGetContextInfo GetContextInfo} + */ + public static long clGetContextInfoPointer(long context, int param_name) { + return CONTEXT.getPointer(context, param_name); + } + + /** + * PointBuffer version of: {@link CL10#clGetContextInfo GetContextInfo} + */ + public static int clGetContextInfoPointers(long context, int param_name, PointerBuffer target) { + return CONTEXT.getPointers(context, param_name, target); + } + + // ------------------------------------ + // Command Queue (CL10.clGetCommandQueueInfo) + // ------------------------------------ + private static final InfoQuery COMMAND_QUEUE = new InfoQuery() { + @Override + protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { + return nclGetCommandQueueInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); + } + }; + + /** + * Single int value version of: + * {@link CL10#clGetCommandQueueInfo GetCommandQueueInfo} + */ + public static int clGetCommandQueueInfoInt(long command_queue, int param_name) { + return COMMAND_QUEUE.getInt(command_queue, param_name); + } + + /** + * Single pointer value version of: + * {@link CL10#clGetCommandQueueInfo GetCommandQueueInfo} + */ + public static long clGetCommandQueueInfoPointer(long command_queue, int param_name) { + return COMMAND_QUEUE.getPointer(command_queue, param_name); + } + + /** + * PointBuffer version of: + * {@link CL10#clGetCommandQueueInfo GetCommandQueueInfo} + */ + public static int clGetCommandQueueInfoPointers(long command_queue, int param_name, PointerBuffer target) { + return COMMAND_QUEUE.getPointers(command_queue, param_name, target); + } + + // ------------------------------------ + // Mem Object (CL10.clGetMemObjectInfo) + // ------------------------------------ + private static final InfoQuery MEM_OBJECT = new InfoQuery() { + @Override + protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { + return nclGetMemObjectInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); + } + }; + + /** + * Single boolean value version of: + * {@link CL10#clGetMemObjectInfo GetMemObjectInfo} + */ + public static boolean clGetMemObjectInfoBoolean(long memobj, int param_name) { + return MEM_OBJECT.getBoolean(memobj, param_name); + } + + /** + * Single int value version of: + * {@link CL10#clGetMemObjectInfo GetMemObjectInfo} + */ + public static int clGetMemObjectInfoInt(long memobj, int param_name) { + return MEM_OBJECT.getInt(memobj, param_name); + } + + /** + * Single long value version of: + * {@link CL10#clGetMemObjectInfo GetMemObjectInfo} + */ + public static long clGetMemObjectInfoLong(long memobj, int param_name) { + return MEM_OBJECT.getLong(memobj, param_name); + } + + /** + * Single pointer value version of: + * {@link CL10#clGetMemObjectInfo GetMemObjectInfo} + */ + public static long clGetMemObjectInfoPointer(long memobj, int param_name) { + return MEM_OBJECT.getPointer(memobj, param_name); + } + + /** + * PointBuffer version of: {@link CL10#clGetMemObjectInfo GetMemObjectInfo} + */ + public static int clGetMemObjectInfoPointers(long memobj, int param_name, PointerBuffer target) { + return MEM_OBJECT.getPointers(memobj, param_name, target); + } + + // ------------------------------------ + // Image (CL10.clGetImageInfo) + // ------------------------------------ + private static final InfoQuery IMAGE = new InfoQuery() { + @Override + protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { + return nclGetImageInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); + } + }; + + /** + * Single int value version of: {@link CL10#clGetImageInfo GetImageInfo} + */ + public static int clGetImageInfoInt(long image, int param_name) { + return IMAGE.getInt(image, param_name); + } + + /** + * Single pointer value version of: {@link CL10#clGetImageInfo GetImageInfo} + */ + public static long clGetImageInfoPointer(long image, int param_name) { + return IMAGE.getPointer(image, param_name); + } + + /** + * PointBuffer version of: {@link CL10#clGetImageInfo GetImageInfo} + */ + public static int clGetImageInfoPointers(long image, int param_name, PointerBuffer target) { + return IMAGE.getPointers(image, param_name, target); + } + + // ------------------------------------ + // Pipe (CL20.clGetPipeInfo) + // ------------------------------------ + private static final InfoQuery PIPE = new InfoQuery() { + @Override + protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { + return nclGetPipeInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); + } + }; + + /** + * Single int value version of: {@link CL20#clGetPipeInfo GetPipeInfo} + */ + public static int clGetPipeInfoInt(long pipe, int param_name) { + return PIPE.getInt(pipe, param_name); + } + + // ------------------------------------ + // Program (CL10.clGetProgramInfo) + // ------------------------------------ + private static final InfoQuery PROGRAM = new InfoQuery() { + @Override + protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { + return nclGetProgramInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); + } + }; + + /** + * Single int value version of: {@link CL10#clGetProgramInfo GetProgramInfo} + */ + public static int clGetProgramInfoInt(long program, int param_name) { + return PROGRAM.getInt(program, param_name); + } + + /** + * Single pointer value version of: + * {@link CL10#clGetProgramInfo GetProgramInfo} + */ + public static long clGetProgramInfoPointer(long program, int param_name) { + return PROGRAM.getPointer(program, param_name); + } + + /** + * PointBuffer version of: {@link CL10#clGetProgramInfo GetProgramInfo} + */ + public static int clGetProgramInfoPointers(long program, int param_name, PointerBuffer target) { + return PROGRAM.getPointers(program, param_name, target); + } + + /** + * String version of: {@link CL10#clGetProgramInfo GetProgramInfo} + */ + public static String clGetProgramInfoStringASCII(long program, int param_name) { + return PROGRAM.getStringASCII(program, param_name); + } + + /** + * String with explicit length version of: {@link CL10#clGetProgramInfo GetProgramInfo} + */ + public static String clGetProgramInfoStringASCII(long program, int param_name, int param_value_size) { + return PROGRAM.getStringASCII(program, param_name, param_value_size); + } + + /** + * UTF-8 string version of: {@link CL10#clGetProgramInfo GetProgramInfo} + */ + public static String clGetProgramInfoStringUTF8(long program, int param_name) { + return PROGRAM.getStringUTF8(program, param_name); + } + + /** + * UTF-8 string with explicit length version of: + * {@link CL10#clGetProgramInfo GetProgramInfo} + */ + public static String clGetProgramInfoStringUTF8(long program, int param_name, int param_value_size) { + return PROGRAM.getStringUTF8(program, param_name, param_value_size); + } + + // ------------------------------------ + // Program Build (CL10.clGetProgramBuildInfo) + // ------------------------------------ + private static final InfoQueryObject PROGRAM_BUILD = new InfoQueryObject() { + @Override + protected int get(long pointer, long arg, int param_name, long param_value_size, long param_value, long param_value_size_ret) { + return nclGetProgramBuildInfo(pointer, arg, param_name, param_value_size, param_value, param_value_size_ret); + } + }; + + /** + * Single int value version of: + * {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} + */ + public static int clGetProgramBuildInfoInt(long program, long device, int param_name) { + return PROGRAM_BUILD.getInt(program, device, param_name); + } + + /** + * Single pointer value version of: + * {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} + */ + public static long clGetProgramBuildInfoPointer(long program, long device, int param_name) { + return PROGRAM_BUILD.getPointer(program, device, param_name); + } + + /** + * PointBuffer version of: + * {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} + */ + public static int clGetProgramBuildInfoPointers(long program, long device, int param_name, PointerBuffer target) { + return PROGRAM_BUILD.getPointers(program, device, param_name, target); + } + + /** + * String version of: {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} + */ + public static String clGetProgramBuildInfoStringASCII(long program, long device, int param_name) { + return PROGRAM_BUILD.getStringASCII(program, device, param_name); + } + + /** + * String with explicit length version of: {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} + */ + public static String clGetProgramBuildInfoStringASCII(long program, long device, int param_name, int param_value_size) { + return PROGRAM_BUILD.getStringASCII(program, device, param_name, param_value_size); + } + + /** + * UTF-8 string version of: + * {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} + */ + public static String clGetProgramBuildInfoStringUTF8(long program, long device, int param_name) { + return PROGRAM_BUILD.getStringUTF8(program, device, param_name); + } + + /** + * UTF-8 string with explicit length version of: + * {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} + */ + public static String clGetProgramBuildInfoStringUTF8(long program, long device, int param_name, int param_value_size) { + return PROGRAM_BUILD.getStringUTF8(program, device, param_name, param_value_size); + } + + // ------------------------------------ + // Kernel (CL10.clGetKernelInfo) + // ------------------------------------ + private static final InfoQuery KERNEL = new InfoQuery() { + @Override + protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { + return nclGetKernelInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); + } + }; + + /** + * Single int value version of: {@link CL10#clGetKernelInfo GetKernelInfo} + */ + public static int clGetKernelInfoInt(long kernel, int param_name) { + return KERNEL.getInt(kernel, param_name); + } + + /** + * Single pointer value version of: + * {@link CL10#clGetKernelInfo GetKernelInfo} + */ + public static long clGetKernelInfoPointer(long kernel, int param_name) { + return KERNEL.getPointer(kernel, param_name); + } + + /** + * PointBuffer version of: {@link CL10#clGetKernelInfo GetKernelInfo} + */ + public static int clGetKernelInfoPointers(long kernel, int param_name, PointerBuffer target) { + return KERNEL.getPointers(kernel, param_name, target); + } + + /** + * String version of: {@link CL10#clGetKernelInfo GetKernelInfo} + */ + public static String clGetKernelInfoStringASCII(long kernel, int param_name) { + return KERNEL.getStringASCII(kernel, param_name); + } + + /** + * String with explicit length version of: {@link CL10#clGetKernelInfo GetKernelInfo} + */ + public static String clGetKernelInfoStringASCII(long kernel, int param_name, int param_value_size) { + return KERNEL.getStringASCII(kernel, param_name, param_value_size); + } + + /** + * UTF-8 string version of: {@link CL10#clGetKernelInfo GetKernelInfo} + */ + public static String clGetKernelInfoStringUTF8(long kernel, int param_name) { + return KERNEL.getStringUTF8(kernel, param_name); + } + + /** + * UTF-8 string with explicit length version of: + * {@link CL10#clGetKernelInfo GetKernelInfo} + */ + public static String clGetKernelInfoStringUTF8(long kernel, int param_name, int param_value_size) { + return KERNEL.getStringUTF8(kernel, param_name, param_value_size); + } + + // ------------------------------------ + // Kernel WorkGroup (CL10.clGetKernelWorkGroupInfo) + // ------------------------------------ + private static final InfoQueryObject KERNEL_WORKGROUP = new InfoQueryObject() { + @Override + protected int get(long pointer, long arg, int param_name, long param_value_size, long param_value, long param_value_size_ret) { + return nclGetKernelWorkGroupInfo(pointer, arg, param_name, param_value_size, param_value, param_value_size_ret); + } + }; + + /** + * Single long value version of: + * {@link CL10#clGetKernelWorkGroupInfo GetKernelWorkGroupInfo} + */ + public static long clGetKernelWorkGroupInfoLong(long kernel, long device, int param_name) { + return KERNEL_WORKGROUP.getLong(kernel, device, param_name); + } + + /** + * Single pointer value version of: + * {@link CL10#clGetKernelWorkGroupInfo GetKernelWorkGroupInfo} + */ + public static long clGetKernelWorkGroupInfoPointer(long kernel, long device, int param_name) { + return KERNEL_WORKGROUP.getPointer(kernel, device, param_name); + } + + /** + * PointBuffer version of: + * {@link CL10#clGetKernelWorkGroupInfo GetKernelWorkGroupInfo} + */ + public static int clGetKernelWorkGroupInfoPointers(long kernel, long device, int param_name, PointerBuffer target) { + return KERNEL_WORKGROUP.getPointers(kernel, device, param_name, target); + } + + // ------------------------------------ + // Kernel Arg (CL12.clGetKernelArgInfo) + // ------------------------------------ + private static final InfoQueryInt KERNEL_ARG = new InfoQueryInt() { + @Override + protected int get(long pointer, int arg, int param_name, long param_value_size, long param_value, long param_value_size_ret) { + return nclGetKernelArgInfo(pointer, arg, param_name, param_value_size, param_value, param_value_size_ret); + } + }; + + /** + * Single int value version of: + * {@link CL12#clGetKernelArgInfo GetKernelArgInfo} + */ + public static int clGetKernelArgInfoInt(long kernel, int arg_indx, int param_name) { + return KERNEL_ARG.getInt(kernel, arg_indx, param_name); + } + + /** + * Single long value version of: + * {@link CL12#clGetKernelArgInfo GetKernelArgInfo} + */ + public static long clGetKernelArgInfoLong(long kernel, int arg_indx, int param_name) { + return KERNEL_ARG.getLong(kernel, arg_indx, param_name); + } + + /** + * String version of: {@link CL12#clGetKernelArgInfo GetKernelArgInfo} + */ + public static String clGetKernelArgInfoStringASCII(long kernel, int arg_indx, int param_name) { + return KERNEL_ARG.getStringASCII(kernel, arg_indx, param_name); + } + + /** + * String with explicit length version of: {@link CL12#clGetKernelArgInfo GetKernelArgInfo} + */ + public static String clGetKernelArgInfoStringASCII(long kernel, int arg_indx, int param_name, int param_value_size) { + return KERNEL_ARG.getStringASCII(kernel, arg_indx, param_name, param_value_size); + } + + /** + * UTF-8 string version of: {@link CL12#clGetKernelArgInfo GetKernelArgInfo} + */ + public static String clGetKernelArgInfoStringUTF8(long kernel, int arg_indx, int param_name) { + return KERNEL_ARG.getStringUTF8(kernel, arg_indx, param_name); + } + + /** + * UTF-8 string with explicit length version of: + * {@link CL12#clGetKernelArgInfo GetKernelArgInfo} + */ + public static String clGetKernelArgInfoStringUTF8(long kernel, int arg_indx, int param_name, int param_value_size) { + return KERNEL_ARG.getStringUTF8(kernel, arg_indx, param_name, param_value_size); + } + + // ------------------------------------ + // Sampler (CL10.clGetSamplerInfo) + // ------------------------------------ + private static final InfoQuery SAMPLER = new InfoQuery() { + @Override + protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { + return nclGetSamplerInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); + } + }; + + /** + * Single boolean value version of: + * {@link CL10#clGetSamplerInfo GetSamplerInfo} + */ + public static boolean clGetSamplerInfoBoolean(long sampler, int param_name) { + return SAMPLER.getBoolean(sampler, param_name); + } + + /** + * Single int value version of: {@link CL10#clGetSamplerInfo GetSamplerInfo} + */ + public static int clGetSamplerInfoInt(long sampler, int param_name) { + return SAMPLER.getInt(sampler, param_name); + } + + /** + * Single pointer value version of: + * {@link CL10#clGetSamplerInfo GetSamplerInfo} + */ + public static long clGetSamplerInfoPointer(long sampler, int param_name) { + return SAMPLER.getPointer(sampler, param_name); + } + + /** + * PointBuffer version of: {@link CL10#clGetSamplerInfo GetSamplerInfo} + */ + public static int clGetSamplerInfoPointers(long sampler, int param_name, PointerBuffer target) { + return SAMPLER.getPointers(sampler, param_name, target); + } + + // ------------------------------------ + // Event (CL10.clGetEventInfo) + // ------------------------------------ + private static final InfoQuery EVENT = new InfoQuery() { + @Override + protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { + return nclGetEventInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); + } + }; + + /** + * Single int value version of: {@link CL10#clGetEventInfo GetEventInfo} + */ + public static int clGetEventInfoInt(long event, int param_name) { + return EVENT.getInt(event, param_name); + } + + /** + * Single pointer value version of: {@link CL10#clGetEventInfo GetEventInfo} + */ + public static long clGetEventInfoPointer(long event, int param_name) { + return EVENT.getPointer(event, param_name); + } + + /** + * PointBuffer version of: {@link CL10#clGetEventInfo GetEventInfo} + */ + public static int clGetEventInfoPointers(long event, int param_name, PointerBuffer target) { + return EVENT.getPointers(event, param_name, target); + } + + // ------------------------------------ + // Event Profiling (CL10.clGetEventProfilingInfo) + // ------------------------------------ + private static final InfoQuery EVENT_PROFILING = new InfoQuery() { + @Override + protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { + return nclGetEventProfilingInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); + } + }; + + /** + * Single long value version of: + * {@link CL10#clGetEventProfilingInfo GetEventProfilingInfo} + */ + public static long clGetEventProfilingInfoLong(long event, int param_name) { + return EVENT_PROFILING.getLong(event, param_name); + } + + // ------------------------------------ + // GL Texture (CL10GL.clGetGLTextureInfo) + // ------------------------------------ + private static final InfoQuery GL_TEXTURE = new InfoQuery() { + @Override + protected int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret) { + return nclGetGLTextureInfo(pointer, param_name, param_value_size, param_value, param_value_size_ret); + } + }; + + /** + * Single int value version of: + * {@link CL10GL#clGetGLTextureInfo GetGLTextureInfo} + */ + public static int clGetGLTextureInfoInt(long memobj, int param_name) { + return GL_TEXTURE.getInt(memobj, param_name); + } + +} diff --git a/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/InfoQuery.java b/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/InfoQuery.java index 2b64745f3..53411b385 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/InfoQuery.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/InfoQuery.java @@ -16,181 +16,200 @@ import static org.lwjgl.system.Pointer.*; /** * Base class for OpenCL object information queries. *

- * All methods require the object being queried (a pointer value) and the integer parameter name. + * All methods require the object being queried (a pointer value) and the + * integer parameter name. * * @see Info */ abstract class InfoQuery { - protected abstract int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret); - - InfoQuery() { - } - - /** - * Returns the integer value for the specified {@code param_name}, converted to a boolean. - * - * @param object the object to query - * @param param_name the parameter to query - * - * @return the parameter's boolean value - */ - boolean getBoolean(long object, int param_name) { - return getInt(object, param_name) != 0; - } - - /** - * Returns the integer value for the specified {@code param_name}. - *

- * For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}), {@link #getPointer} should be used instead. - * - * @param object the object to query - * @param param_name the parameter to query - * - * @return the parameter's int value - */ - int getInt(long object, int param_name) { - APIBuffer __buffer = apiBuffer(); - int errcode = get(object, param_name, 4L, __buffer.address(), NULL); - if ( DEBUG ) - checkCLError(errcode); - return __buffer.intValue(0); - } - - /** - * Returns the long value for the specified {@code param_name}. - *

- * For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}), {@link #getPointer} should be used instead. - * - * @param object the object to query - * @param param_name the parameter to query - * - * @return the parameter's long value - */ - long getLong(long object, int param_name) { - APIBuffer __buffer = apiBuffer(); - int errcode = get(object, param_name, 8L, __buffer.address(), NULL); - if ( DEBUG ) - checkCLError(errcode); - return __buffer.longValue(0); - } - - /** - * Returns the pointer value for the specified {@code param_name}. - *

- * This method should also be used for integer parameters that may be 32 or 64 bits (e.g. {@code size_t}). - * - * @param object the object to query - * @param param_name the parameter to query - * - * @return the parameter's pointer value - */ - long getPointer(long object, int param_name) { - APIBuffer __buffer = apiBuffer(); - int errcode = get(object, param_name, POINTER_SIZE, __buffer.address(), NULL); - if ( DEBUG ) - checkCLError(errcode); - return __buffer.pointerValue(0); - } - - /** - * Writes the pointer list for the specified {@code param_name} into {@code target}. - *

- * This method should also be used for integer parameters that may be 32 or 64 bits (e.g. {@code size_t}). - * - * @param object the object to query - * @param param_name the parameter to query - * @param target the buffer in which to put the returned pointer list - * - * @return how many pointers were actually returned - */ - int getPointers(long object, int param_name, PointerBuffer target) { - APIBuffer __buffer = apiBuffer(); - int errcode = get(object, param_name, target.remaining() * POINTER_SIZE, memAddress(target), __buffer.address()); - if ( DEBUG ) - checkCLError(errcode); - return (int)(__buffer.pointerValue(0) >> POINTER_SHIFT); - } - - /** - * Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be ASCII encoded. - * - * @param object the object to query - * @param param_name the parameter to query - * - * @return the parameter's string value - */ - String getStringASCII(long object, int param_name) { - APIBuffer __buffer = apiBuffer(); - int bytes = getString(object, param_name, __buffer); - return __buffer.stringValueASCII(0, bytes); - } - - /** - * Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be ASCII encoded and have length equal to {@code - * param_value_size}. - * - * @param object the object to query - * @param param_name the parameter to query - * @param param_value_size the explicit string length - * - * @return the parameter's string value - */ - String getStringASCII(long object, int param_name, int param_value_size) { - APIBuffer __buffer = apiBuffer(); - int errcode = get(object, param_name, param_value_size, __buffer.address(), NULL); - if ( DEBUG ) - checkCLError(errcode); - return __buffer.stringValueASCII(0, param_value_size); - } - - /** - * Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be UTF-8 encoded. - * - * @param object the object to query - * @param param_name the parameter to query - * - * @return the parameter's string value - */ - String getStringUTF8(long object, int param_name) { - APIBuffer __buffer = apiBuffer(); - int bytes = getString(object, param_name, __buffer); - return __buffer.stringValueUTF8(0, bytes); - } - - /** - * Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be UTF-8 encoded and have length equal to {@code - * param_value_size}. - * - * @param object the object to query - * @param param_name the parameter to query - * @param param_value_size the explicit string length - * - * @return the parameter's string value - */ - String getStringUTF8(long object, int param_name, int param_value_size) { - APIBuffer __buffer = apiBuffer(); - int errcode = get(object, param_name, param_value_size, __buffer.address(), NULL); - if ( DEBUG ) - checkCLError(errcode); - return __buffer.stringValueUTF8(0, param_value_size); - } - - private int getString(long object, int param_name, APIBuffer __buffer) { - // Get string length - int errcode = get(object, param_name, 0, NULL, __buffer.address()); - if ( DEBUG ) - checkCLError(errcode); - - int bytes = (int)__buffer.pointerValue(0); - __buffer.bufferParam(bytes); - - // Get string - errcode = get(object, param_name, bytes, __buffer.address(), NULL); - if ( DEBUG ) - checkCLError(errcode); - - return bytes - 1; // all OpenCL char[] parameters are null-terminated - } - -} \ No newline at end of file + protected abstract int get(long pointer, int param_name, long param_value_size, long param_value, long param_value_size_ret); + + InfoQuery() { + } + + /** + * Returns the integer value for the specified {@code param_name}, converted + * to a boolean. + * + * @param object the object to query + * @param param_name the parameter to query + * + * @return the parameter's boolean value + */ + boolean getBoolean(long object, int param_name) { + return getInt(object, param_name) != 0; + } + + /** + * Returns the integer value for the specified {@code param_name}. + *

+ * For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}), + * {@link #getPointer} should be used instead. + * + * @param object the object to query + * @param param_name the parameter to query + * + * @return the parameter's int value + */ + int getInt(long object, int param_name) { + APIBuffer __buffer = apiBuffer(); + int errcode = get(object, param_name, 4L, __buffer.address(), NULL); + if (DEBUG) { + checkCLError(errcode); + } + return __buffer.intValue(0); + } + + /** + * Returns the long value for the specified {@code param_name}. + *

+ * For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}), + * {@link #getPointer} should be used instead. + * + * @param object the object to query + * @param param_name the parameter to query + * + * @return the parameter's long value + */ + long getLong(long object, int param_name) { + APIBuffer __buffer = apiBuffer(); + int errcode = get(object, param_name, 8L, __buffer.address(), NULL); + if (DEBUG) { + checkCLError(errcode); + } + return __buffer.longValue(0); + } + + /** + * Returns the pointer value for the specified {@code param_name}. + *

+ * This method should also be used for integer parameters that may be 32 or + * 64 bits (e.g. {@code size_t}). + * + * @param object the object to query + * @param param_name the parameter to query + * + * @return the parameter's pointer value + */ + long getPointer(long object, int param_name) { + APIBuffer __buffer = apiBuffer(); + int errcode = get(object, param_name, POINTER_SIZE, __buffer.address(), NULL); + if (DEBUG) { + checkCLError(errcode); + } + return __buffer.pointerValue(0); + } + + /** + * Writes the pointer list for the specified {@code param_name} into + * {@code target}. + *

+ * This method should also be used for integer parameters that may be 32 or + * 64 bits (e.g. {@code size_t}). + * + * @param object the object to query + * @param param_name the parameter to query + * @param target the buffer in which to put the returned pointer list + * + * @return how many pointers were actually returned + */ + int getPointers(long object, int param_name, PointerBuffer target) { + APIBuffer __buffer = apiBuffer(); + int errcode = get(object, param_name, target.remaining() * POINTER_SIZE, memAddress(target), __buffer.address()); + if (DEBUG) { + checkCLError(errcode); + } + return (int) (__buffer.pointerValue(0) >> POINTER_SHIFT); + } + + /** + * Returns the string value for the specified {@code param_name}. The raw + * bytes returned are assumed to be ASCII encoded. + * + * @param object the object to query + * @param param_name the parameter to query + * + * @return the parameter's string value + */ + String getStringASCII(long object, int param_name) { + APIBuffer __buffer = apiBuffer(); + int bytes = getString(object, param_name, __buffer); + return __buffer.stringValueASCII(0, bytes); + } + + /** + * Returns the string value for the specified {@code param_name}. The raw + * bytes returned are assumed to be ASCII encoded and have length equal to {@code + * param_value_size}. + * + * @param object the object to query + * @param param_name the parameter to query + * @param param_value_size the explicit string length + * + * @return the parameter's string value + */ + String getStringASCII(long object, int param_name, int param_value_size) { + APIBuffer __buffer = apiBuffer(); + int errcode = get(object, param_name, param_value_size, __buffer.address(), NULL); + if (DEBUG) { + checkCLError(errcode); + } + return __buffer.stringValueASCII(0, param_value_size); + } + + /** + * Returns the string value for the specified {@code param_name}. The raw + * bytes returned are assumed to be UTF-8 encoded. + * + * @param object the object to query + * @param param_name the parameter to query + * + * @return the parameter's string value + */ + String getStringUTF8(long object, int param_name) { + APIBuffer __buffer = apiBuffer(); + int bytes = getString(object, param_name, __buffer); + return __buffer.stringValueUTF8(0, bytes); + } + + /** + * Returns the string value for the specified {@code param_name}. The raw + * bytes returned are assumed to be UTF-8 encoded and have length equal to {@code + * param_value_size}. + * + * @param object the object to query + * @param param_name the parameter to query + * @param param_value_size the explicit string length + * + * @return the parameter's string value + */ + String getStringUTF8(long object, int param_name, int param_value_size) { + APIBuffer __buffer = apiBuffer(); + int errcode = get(object, param_name, param_value_size, __buffer.address(), NULL); + if (DEBUG) { + checkCLError(errcode); + } + return __buffer.stringValueUTF8(0, param_value_size); + } + + private int getString(long object, int param_name, APIBuffer __buffer) { + // Get string length + int errcode = get(object, param_name, 0, NULL, __buffer.address()); + if (DEBUG) { + checkCLError(errcode); + } + + int bytes = (int) __buffer.pointerValue(0); + __buffer.bufferParam(bytes); + + // Get string + errcode = get(object, param_name, bytes, __buffer.address(), NULL); + if (DEBUG) { + checkCLError(errcode); + } + + return bytes - 1; // all OpenCL char[] parameters are null-terminated + } + +} diff --git a/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/InfoQueryInt.java b/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/InfoQueryInt.java index 9ec464f21..b900887d7 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/InfoQueryInt.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/InfoQueryInt.java @@ -16,190 +16,209 @@ import static org.lwjgl.system.Pointer.*; /** * Base class for OpenCL object information queries. *

- * All methods require the object being queried (a pointer value), a second integer argument and the integer parameter name. + * All methods require the object being queried (a pointer value), a second + * integer argument and the integer parameter name. * * @see Info */ abstract class InfoQueryInt { - protected abstract int get(long pointer, int arg, int param_name, long param_value_size, long param_value, long param_value_size_ret); - - InfoQueryInt() { - } - - /** - * Returns the integer value for the specified {@code param_name}, converted to a boolean. - * - * @param object the object to query - * @param arg an integer argument - * @param param_name the parameter to query - * - * @return the parameter's boolean value - */ - boolean getBoolean(long object, int arg, int param_name) { - return getInt(object, arg, param_name) != 0; - } - - /** - * Returns the integer value for the specified {@code param_name}. - *

- * For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}), {@link #getPointer} should be used instead. - * - * @param object the object to query - * @param arg an integer argument - * @param param_name the parameter to query - * - * @return the parameter's int value - */ - int getInt(long object, int arg, int param_name) { - APIBuffer __buffer = apiBuffer(); - int errcode = get(object, arg, param_name, 4L, __buffer.address(), NULL); - if ( DEBUG ) - checkCLError(errcode); - return __buffer.intValue(0); - } - - /** - * Returns the long value for the specified {@code param_name}. - *

- * For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}), {@link #getPointer} should be used instead. - * - * @param object the object to query - * @param arg an integer argument - * @param param_name the parameter to query - * - * @return the parameter's long value - */ - long getLong(long object, int arg, int param_name) { - APIBuffer __buffer = apiBuffer(); - int errcode = get(object, arg, param_name, 8L, __buffer.address(), NULL); - if ( DEBUG ) - checkCLError(errcode); - return __buffer.longValue(0); - } - - /** - * Returns the pointer value for the specified {@code param_name}. - *

- * This method should also be used for integer parameters that may be 32 or 64 bits (e.g. {@code size_t}). - * - * @param object the object to query - * @param arg an integer argument - * @param param_name the parameter to query - * - * @return the parameter's pointer value - */ - long getPointer(long object, int arg, int param_name) { - APIBuffer __buffer = apiBuffer(); - int errcode = get(object, arg, param_name, POINTER_SIZE, __buffer.address(), NULL); - if ( DEBUG ) - checkCLError(errcode); - return __buffer.pointerValue(0); - } - - /** - * Writes the pointer list for the specified {@code param_name} into {@code target}. - *

- * This method should also be used for integer parameters that may be 32 or 64 bits (e.g. {@code size_t}). - * - * @param object the object to query - * @param arg an integer argument - * @param param_name the parameter to query - * @param target the buffer in which to put the returned pointer list - * - * @return how many pointers were actually returned - */ - int getPointers(long object, int arg, int param_name, PointerBuffer target) { - APIBuffer __buffer = apiBuffer(); - int errcode = get(object, arg, param_name, target.remaining() * POINTER_SIZE, memAddress(target), __buffer.address()); - if ( DEBUG ) - checkCLError(errcode); - return (int)(__buffer.pointerValue(0) >> POINTER_SHIFT); - } - - /** - * Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be ASCII encoded. - * - * @param object the object to query - * @param arg an integer argument - * @param param_name the parameter to query - * - * @return the parameter's string value - */ - String getStringASCII(long object, int arg, int param_name) { - APIBuffer __buffer = apiBuffer(); - int bytes = getString(object, arg, param_name, __buffer); - return __buffer.stringValueASCII(0, bytes); - } - - /** - * Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be ASCII encoded and have length equal to {@code - * param_value_size}. - * - * @param object the object to query - * @param arg an integer argument - * @param param_name the parameter to query - * @param param_value_size the explicit string length - * - * @return the parameter's string value - */ - String getStringASCII(long object, int arg, int param_name, int param_value_size) { - APIBuffer __buffer = apiBuffer(); - int errcode = get(object, arg, param_name, param_value_size, __buffer.address(), NULL); - if ( DEBUG ) - checkCLError(errcode); - return __buffer.stringValueASCII(0, param_value_size); - } - - /** - * Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be UTF-8 encoded. - * - * @param object the object to query - * @param arg an integer argument - * @param param_name the parameter to query - * - * @return the parameter's string value - */ - String getStringUTF8(long object, int arg, int param_name) { - APIBuffer __buffer = apiBuffer(); - int bytes = getString(object, arg, param_name, __buffer); - return __buffer.stringValueUTF8(0, bytes); - } - - /** - * Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be UTF-8 encoded and have length equal to {@code - * param_value_size}. - * - * @param object the object to query - * @param arg an integer argument - * @param param_name the parameter to query - * @param param_value_size the explicit string length - * - * @return the parameter's string value - */ - String getStringUTF8(long object, int arg, int param_name, int param_value_size) { - APIBuffer __buffer = apiBuffer(); - int errcode = get(object, arg, param_name, param_value_size, __buffer.address(), NULL); - if ( DEBUG ) - checkCLError(errcode); - return __buffer.stringValueUTF8(0, param_value_size); - } - - private int getString(long object, int arg, int param_name, APIBuffer __buffer) { - // Get string length - int errcode = get(object, arg, param_name, 0, NULL, __buffer.address()); - if ( DEBUG ) - checkCLError(errcode); - - int bytes = (int)__buffer.pointerValue(0); - __buffer.bufferParam(bytes + POINTER_SIZE); - - // Get string - errcode = get(object, arg, param_name, bytes, __buffer.address(), NULL); - if ( DEBUG ) - checkCLError(errcode); - - return bytes - 1; // all OpenCL char[] parameters are null-terminated - } - -} \ No newline at end of file + protected abstract int get(long pointer, int arg, int param_name, long param_value_size, long param_value, long param_value_size_ret); + + InfoQueryInt() { + } + + /** + * Returns the integer value for the specified {@code param_name}, converted + * to a boolean. + * + * @param object the object to query + * @param arg an integer argument + * @param param_name the parameter to query + * + * @return the parameter's boolean value + */ + boolean getBoolean(long object, int arg, int param_name) { + return getInt(object, arg, param_name) != 0; + } + + /** + * Returns the integer value for the specified {@code param_name}. + *

+ * For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}), + * {@link #getPointer} should be used instead. + * + * @param object the object to query + * @param arg an integer argument + * @param param_name the parameter to query + * + * @return the parameter's int value + */ + int getInt(long object, int arg, int param_name) { + APIBuffer __buffer = apiBuffer(); + int errcode = get(object, arg, param_name, 4L, __buffer.address(), NULL); + if (DEBUG) { + checkCLError(errcode); + } + return __buffer.intValue(0); + } + + /** + * Returns the long value for the specified {@code param_name}. + *

+ * For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}), + * {@link #getPointer} should be used instead. + * + * @param object the object to query + * @param arg an integer argument + * @param param_name the parameter to query + * + * @return the parameter's long value + */ + long getLong(long object, int arg, int param_name) { + APIBuffer __buffer = apiBuffer(); + int errcode = get(object, arg, param_name, 8L, __buffer.address(), NULL); + if (DEBUG) { + checkCLError(errcode); + } + return __buffer.longValue(0); + } + + /** + * Returns the pointer value for the specified {@code param_name}. + *

+ * This method should also be used for integer parameters that may be 32 or + * 64 bits (e.g. {@code size_t}). + * + * @param object the object to query + * @param arg an integer argument + * @param param_name the parameter to query + * + * @return the parameter's pointer value + */ + long getPointer(long object, int arg, int param_name) { + APIBuffer __buffer = apiBuffer(); + int errcode = get(object, arg, param_name, POINTER_SIZE, __buffer.address(), NULL); + if (DEBUG) { + checkCLError(errcode); + } + return __buffer.pointerValue(0); + } + + /** + * Writes the pointer list for the specified {@code param_name} into + * {@code target}. + *

+ * This method should also be used for integer parameters that may be 32 or + * 64 bits (e.g. {@code size_t}). + * + * @param object the object to query + * @param arg an integer argument + * @param param_name the parameter to query + * @param target the buffer in which to put the returned pointer list + * + * @return how many pointers were actually returned + */ + int getPointers(long object, int arg, int param_name, PointerBuffer target) { + APIBuffer __buffer = apiBuffer(); + int errcode = get(object, arg, param_name, target.remaining() * POINTER_SIZE, memAddress(target), __buffer.address()); + if (DEBUG) { + checkCLError(errcode); + } + return (int) (__buffer.pointerValue(0) >> POINTER_SHIFT); + } + + /** + * Returns the string value for the specified {@code param_name}. The raw + * bytes returned are assumed to be ASCII encoded. + * + * @param object the object to query + * @param arg an integer argument + * @param param_name the parameter to query + * + * @return the parameter's string value + */ + String getStringASCII(long object, int arg, int param_name) { + APIBuffer __buffer = apiBuffer(); + int bytes = getString(object, arg, param_name, __buffer); + return __buffer.stringValueASCII(0, bytes); + } + + /** + * Returns the string value for the specified {@code param_name}. The raw + * bytes returned are assumed to be ASCII encoded and have length equal to {@code + * param_value_size}. + * + * @param object the object to query + * @param arg an integer argument + * @param param_name the parameter to query + * @param param_value_size the explicit string length + * + * @return the parameter's string value + */ + String getStringASCII(long object, int arg, int param_name, int param_value_size) { + APIBuffer __buffer = apiBuffer(); + int errcode = get(object, arg, param_name, param_value_size, __buffer.address(), NULL); + if (DEBUG) { + checkCLError(errcode); + } + return __buffer.stringValueASCII(0, param_value_size); + } + + /** + * Returns the string value for the specified {@code param_name}. The raw + * bytes returned are assumed to be UTF-8 encoded. + * + * @param object the object to query + * @param arg an integer argument + * @param param_name the parameter to query + * + * @return the parameter's string value + */ + String getStringUTF8(long object, int arg, int param_name) { + APIBuffer __buffer = apiBuffer(); + int bytes = getString(object, arg, param_name, __buffer); + return __buffer.stringValueUTF8(0, bytes); + } + + /** + * Returns the string value for the specified {@code param_name}. The raw + * bytes returned are assumed to be UTF-8 encoded and have length equal to {@code + * param_value_size}. + * + * @param object the object to query + * @param arg an integer argument + * @param param_name the parameter to query + * @param param_value_size the explicit string length + * + * @return the parameter's string value + */ + String getStringUTF8(long object, int arg, int param_name, int param_value_size) { + APIBuffer __buffer = apiBuffer(); + int errcode = get(object, arg, param_name, param_value_size, __buffer.address(), NULL); + if (DEBUG) { + checkCLError(errcode); + } + return __buffer.stringValueUTF8(0, param_value_size); + } + + private int getString(long object, int arg, int param_name, APIBuffer __buffer) { + // Get string length + int errcode = get(object, arg, param_name, 0, NULL, __buffer.address()); + if (DEBUG) { + checkCLError(errcode); + } + + int bytes = (int) __buffer.pointerValue(0); + __buffer.bufferParam(bytes + POINTER_SIZE); + + // Get string + errcode = get(object, arg, param_name, bytes, __buffer.address(), NULL); + if (DEBUG) { + checkCLError(errcode); + } + + return bytes - 1; // all OpenCL char[] parameters are null-terminated + } + +} diff --git a/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/InfoQueryObject.java b/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/InfoQueryObject.java index a3689cd44..da9dc846f 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/InfoQueryObject.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/InfoQueryObject.java @@ -16,190 +16,209 @@ import static org.lwjgl.system.Pointer.*; /** * Base class for OpenCL object information queries. *

- * All methods require the object being queried (a pointer value), a second object argument (another pointer value) and the integer parameter name. + * All methods require the object being queried (a pointer value), a second + * object argument (another pointer value) and the integer parameter name. * * @see org.lwjgl.opencl.Info */ abstract class InfoQueryObject { - protected abstract int get(long pointer, long arg, int param_name, long param_value_size, long param_value, long param_value_size_ret); - - InfoQueryObject() { - } - - /** - * Returns the integer value for the specified {@code param_name}, converted to a boolean. - * - * @param object the object to query - * @param arg an object argument - * @param param_name the parameter to query - * - * @return the parameter's boolean value - */ - boolean getBoolean(long object, long arg, int param_name) { - return getInt(object, arg, param_name) != 0; - } - - /** - * Returns the integer value for the specified {@code param_name}. - *

- * For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}), {@link #getPointer} should be used instead. - * - * @param object the object to query - * @param arg an object argument - * @param param_name the parameter to query - * - * @return the parameter's int value - */ - int getInt(long object, long arg, int param_name) { - APIBuffer __buffer = apiBuffer(); - int errcode = get(object, arg, param_name, 4L, __buffer.address(), NULL); - if ( DEBUG ) - checkCLError(errcode); - return __buffer.intValue(0); - } - - /** - * Returns the long value for the specified {@code param_name}. - *

- * For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}), {@link #getPointer} should be used instead. - * - * @param object the object to query - * @param arg an object argument - * @param param_name the parameter to query - * - * @return the parameter's long value - */ - long getLong(long object, long arg, int param_name) { - APIBuffer __buffer = apiBuffer(); - int errcode = get(object, arg, param_name, 8L, __buffer.address(), NULL); - if ( DEBUG ) - checkCLError(errcode); - return __buffer.longValue(0); - } - - /** - * Returns the pointer value for the specified {@code param_name}. - *

- * This method should also be used for integer parameters that may be 32 or 64 bits (e.g. {@code size_t}). - * - * @param object the object to query - * @param arg an object argument - * @param param_name the parameter to query - * - * @return the parameter's pointer value - */ - long getPointer(long object, long arg, int param_name) { - APIBuffer __buffer = apiBuffer(); - int errcode = get(object, arg, param_name, POINTER_SIZE, __buffer.address(), NULL); - if ( DEBUG ) - checkCLError(errcode); - return __buffer.pointerValue(0); - } - - /** - * Writes the pointer list for the specified {@code param_name} into {@code target}. - *

- * This method should also be used for integer parameters that may be 32 or 64 bits (e.g. {@code size_t}). - * - * @param object the object to query - * @param arg an object argument - * @param param_name the parameter to query - * @param target the buffer in which to put the returned pointer list - * - * @return how many pointers were actually returned - */ - int getPointers(long object, long arg, int param_name, PointerBuffer target) { - APIBuffer __buffer = apiBuffer(); - int errcode = get(object, arg, param_name, target.remaining() * POINTER_SIZE, memAddress(target), __buffer.address()); - if ( DEBUG ) - checkCLError(errcode); - return (int)(__buffer.pointerValue(0) >> POINTER_SHIFT); - } - - /** - * Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be ASCII encoded. - * - * @param object the object to query - * @param arg an object argument - * @param param_name the parameter to query - * - * @return the parameter's string value - */ - String getStringASCII(long object, long arg, int param_name) { - APIBuffer __buffer = apiBuffer(); - int bytes = getString(object, arg, param_name, __buffer); - return __buffer.stringValueASCII(0, bytes); - } - - /** - * Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be ASCII encoded and have length equal to {@code - * param_value_size}. - * - * @param object the object to query - * @param arg an object argument - * @param param_name the parameter to query - * @param param_value_size the explicit string length - * - * @return the parameter's string value - */ - String getStringASCII(long object, long arg, int param_name, int param_value_size) { - APIBuffer __buffer = apiBuffer(); - int errcode = get(object, arg, param_name, param_value_size, __buffer.address(), NULL); - if ( DEBUG ) - checkCLError(errcode); - return __buffer.stringValueASCII(0, param_value_size); - } - - /** - * Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be UTF-8 encoded. - * - * @param object the object to query - * @param arg an object argument - * @param param_name the parameter to query - * - * @return the parameter's string value - */ - String getStringUTF8(long object, long arg, int param_name) { - APIBuffer __buffer = apiBuffer(); - int bytes = getString(object, arg, param_name, __buffer); - return __buffer.stringValueUTF8(0, bytes); - } - - /** - * Returns the string value for the specified {@code param_name}. The raw bytes returned are assumed to be UTF-8 encoded and have length equal to {@code - * param_value_size}. - * - * @param object the object to query - * @param arg an object argument - * @param param_name the parameter to query - * @param param_value_size the explicit string length - * - * @return the parameter's string value - */ - String getStringUTF8(long object, long arg, int param_name, int param_value_size) { - APIBuffer __buffer = apiBuffer(); - int errcode = get(object, arg, param_name, param_value_size, __buffer.address(), NULL); - if ( DEBUG ) - checkCLError(errcode); - return __buffer.stringValueUTF8(0, param_value_size); - } - - private int getString(long object, long arg, int param_name, APIBuffer __buffer) { - // Get string length - int errcode = get(object, arg, param_name, 0, NULL, __buffer.address()); - if ( DEBUG ) - checkCLError(errcode); - - int bytes = (int)__buffer.pointerValue(0); - __buffer.bufferParam(bytes + POINTER_SIZE); - - // Get string - errcode = get(object, arg, param_name, bytes, __buffer.address(), NULL); - if ( DEBUG ) - checkCLError(errcode); - - return bytes - 1; // all OpenCL char[] parameters are null-terminated - } - -} \ No newline at end of file + protected abstract int get(long pointer, long arg, int param_name, long param_value_size, long param_value, long param_value_size_ret); + + InfoQueryObject() { + } + + /** + * Returns the integer value for the specified {@code param_name}, converted + * to a boolean. + * + * @param object the object to query + * @param arg an object argument + * @param param_name the parameter to query + * + * @return the parameter's boolean value + */ + boolean getBoolean(long object, long arg, int param_name) { + return getInt(object, arg, param_name) != 0; + } + + /** + * Returns the integer value for the specified {@code param_name}. + *

+ * For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}), + * {@link #getPointer} should be used instead. + * + * @param object the object to query + * @param arg an object argument + * @param param_name the parameter to query + * + * @return the parameter's int value + */ + int getInt(long object, long arg, int param_name) { + APIBuffer __buffer = apiBuffer(); + int errcode = get(object, arg, param_name, 4L, __buffer.address(), NULL); + if (DEBUG) { + checkCLError(errcode); + } + return __buffer.intValue(0); + } + + /** + * Returns the long value for the specified {@code param_name}. + *

+ * For integer parameters that may be 32 or 64 bits (e.g. {@code size_t}), + * {@link #getPointer} should be used instead. + * + * @param object the object to query + * @param arg an object argument + * @param param_name the parameter to query + * + * @return the parameter's long value + */ + long getLong(long object, long arg, int param_name) { + APIBuffer __buffer = apiBuffer(); + int errcode = get(object, arg, param_name, 8L, __buffer.address(), NULL); + if (DEBUG) { + checkCLError(errcode); + } + return __buffer.longValue(0); + } + + /** + * Returns the pointer value for the specified {@code param_name}. + *

+ * This method should also be used for integer parameters that may be 32 or + * 64 bits (e.g. {@code size_t}). + * + * @param object the object to query + * @param arg an object argument + * @param param_name the parameter to query + * + * @return the parameter's pointer value + */ + long getPointer(long object, long arg, int param_name) { + APIBuffer __buffer = apiBuffer(); + int errcode = get(object, arg, param_name, POINTER_SIZE, __buffer.address(), NULL); + if (DEBUG) { + checkCLError(errcode); + } + return __buffer.pointerValue(0); + } + + /** + * Writes the pointer list for the specified {@code param_name} into + * {@code target}. + *

+ * This method should also be used for integer parameters that may be 32 or + * 64 bits (e.g. {@code size_t}). + * + * @param object the object to query + * @param arg an object argument + * @param param_name the parameter to query + * @param target the buffer in which to put the returned pointer list + * + * @return how many pointers were actually returned + */ + int getPointers(long object, long arg, int param_name, PointerBuffer target) { + APIBuffer __buffer = apiBuffer(); + int errcode = get(object, arg, param_name, target.remaining() * POINTER_SIZE, memAddress(target), __buffer.address()); + if (DEBUG) { + checkCLError(errcode); + } + return (int) (__buffer.pointerValue(0) >> POINTER_SHIFT); + } + + /** + * Returns the string value for the specified {@code param_name}. The raw + * bytes returned are assumed to be ASCII encoded. + * + * @param object the object to query + * @param arg an object argument + * @param param_name the parameter to query + * + * @return the parameter's string value + */ + String getStringASCII(long object, long arg, int param_name) { + APIBuffer __buffer = apiBuffer(); + int bytes = getString(object, arg, param_name, __buffer); + return __buffer.stringValueASCII(0, bytes); + } + + /** + * Returns the string value for the specified {@code param_name}. The raw + * bytes returned are assumed to be ASCII encoded and have length equal to {@code + * param_value_size}. + * + * @param object the object to query + * @param arg an object argument + * @param param_name the parameter to query + * @param param_value_size the explicit string length + * + * @return the parameter's string value + */ + String getStringASCII(long object, long arg, int param_name, int param_value_size) { + APIBuffer __buffer = apiBuffer(); + int errcode = get(object, arg, param_name, param_value_size, __buffer.address(), NULL); + if (DEBUG) { + checkCLError(errcode); + } + return __buffer.stringValueASCII(0, param_value_size); + } + + /** + * Returns the string value for the specified {@code param_name}. The raw + * bytes returned are assumed to be UTF-8 encoded. + * + * @param object the object to query + * @param arg an object argument + * @param param_name the parameter to query + * + * @return the parameter's string value + */ + String getStringUTF8(long object, long arg, int param_name) { + APIBuffer __buffer = apiBuffer(); + int bytes = getString(object, arg, param_name, __buffer); + return __buffer.stringValueUTF8(0, bytes); + } + + /** + * Returns the string value for the specified {@code param_name}. The raw + * bytes returned are assumed to be UTF-8 encoded and have length equal to {@code + * param_value_size}. + * + * @param object the object to query + * @param arg an object argument + * @param param_name the parameter to query + * @param param_value_size the explicit string length + * + * @return the parameter's string value + */ + String getStringUTF8(long object, long arg, int param_name, int param_value_size) { + APIBuffer __buffer = apiBuffer(); + int errcode = get(object, arg, param_name, param_value_size, __buffer.address(), NULL); + if (DEBUG) { + checkCLError(errcode); + } + return __buffer.stringValueUTF8(0, param_value_size); + } + + private int getString(long object, long arg, int param_name, APIBuffer __buffer) { + // Get string length + int errcode = get(object, arg, param_name, 0, NULL, __buffer.address()); + if (DEBUG) { + checkCLError(errcode); + } + + int bytes = (int) __buffer.pointerValue(0); + __buffer.bufferParam(bytes + POINTER_SIZE); + + // Get string + errcode = get(object, arg, param_name, bytes, __buffer.address(), NULL); + if (DEBUG) { + checkCLError(errcode); + } + + return bytes - 1; // all OpenCL char[] parameters are null-terminated + } + +}